babylon.module.d.ts 6.2 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896
  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. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  410. * @param num the number to convert and pad
  411. * @param length the expected length of the string
  412. * @returns the padded string
  413. */
  414. static PadNumber(num: number, length: number): string;
  415. }
  416. }
  417. declare module "babylonjs/Misc/deepCopier" {
  418. /**
  419. * Class containing a set of static utilities functions for deep copy.
  420. */
  421. export class DeepCopier {
  422. /**
  423. * Tries to copy an object by duplicating every property
  424. * @param source defines the source object
  425. * @param destination defines the target object
  426. * @param doNotCopyList defines a list of properties to avoid
  427. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  428. */
  429. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  430. }
  431. }
  432. declare module "babylonjs/Misc/precisionDate" {
  433. /**
  434. * Class containing a set of static utilities functions for precision date
  435. */
  436. export class PrecisionDate {
  437. /**
  438. * Gets either window.performance.now() if supported or Date.now() else
  439. */
  440. static get Now(): number;
  441. }
  442. }
  443. declare module "babylonjs/Misc/devTools" {
  444. /** @hidden */
  445. export class _DevTools {
  446. static WarnImport(name: string): string;
  447. }
  448. }
  449. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  450. /**
  451. * Interface used to define the mechanism to get data from the network
  452. */
  453. export interface IWebRequest {
  454. /**
  455. * Returns client's response url
  456. */
  457. responseURL: string;
  458. /**
  459. * Returns client's status
  460. */
  461. status: number;
  462. /**
  463. * Returns client's status as a text
  464. */
  465. statusText: string;
  466. }
  467. }
  468. declare module "babylonjs/Misc/webRequest" {
  469. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  470. import { Nullable } from "babylonjs/types";
  471. /**
  472. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  473. */
  474. export class WebRequest implements IWebRequest {
  475. private _xhr;
  476. /**
  477. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  478. * i.e. when loading files, where the server/service expects an Authorization header
  479. */
  480. static CustomRequestHeaders: {
  481. [key: string]: string;
  482. };
  483. /**
  484. * Add callback functions in this array to update all the requests before they get sent to the network
  485. */
  486. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  487. private _injectCustomRequestHeaders;
  488. /**
  489. * Gets or sets a function to be called when loading progress changes
  490. */
  491. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  492. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  493. /**
  494. * Returns client's state
  495. */
  496. get readyState(): number;
  497. /**
  498. * Returns client's status
  499. */
  500. get status(): number;
  501. /**
  502. * Returns client's status as a text
  503. */
  504. get statusText(): string;
  505. /**
  506. * Returns client's response
  507. */
  508. get response(): any;
  509. /**
  510. * Returns client's response url
  511. */
  512. get responseURL(): string;
  513. /**
  514. * Returns client's response as text
  515. */
  516. get responseText(): string;
  517. /**
  518. * Gets or sets the expected response type
  519. */
  520. get responseType(): XMLHttpRequestResponseType;
  521. set responseType(value: XMLHttpRequestResponseType);
  522. /** @hidden */
  523. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  524. /** @hidden */
  525. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  526. /**
  527. * Cancels any network activity
  528. */
  529. abort(): void;
  530. /**
  531. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  532. * @param body defines an optional request body
  533. */
  534. send(body?: Document | BodyInit | null): void;
  535. /**
  536. * Sets the request method, request URL
  537. * @param method defines the method to use (GET, POST, etc..)
  538. * @param url defines the url to connect with
  539. */
  540. open(method: string, url: string): void;
  541. /**
  542. * Sets the value of a request header.
  543. * @param name The name of the header whose value is to be set
  544. * @param value The value to set as the body of the header
  545. */
  546. setRequestHeader(name: string, value: string): void;
  547. /**
  548. * Get the string containing the text of a particular header's value.
  549. * @param name The name of the header
  550. * @returns The string containing the text of the given header name
  551. */
  552. getResponseHeader(name: string): Nullable<string>;
  553. }
  554. }
  555. declare module "babylonjs/Misc/fileRequest" {
  556. import { Observable } from "babylonjs/Misc/observable";
  557. /**
  558. * File request interface
  559. */
  560. export interface IFileRequest {
  561. /**
  562. * Raised when the request is complete (success or error).
  563. */
  564. onCompleteObservable: Observable<IFileRequest>;
  565. /**
  566. * Aborts the request for a file.
  567. */
  568. abort: () => void;
  569. }
  570. }
  571. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  572. /**
  573. * Define options used to create a render target texture
  574. */
  575. export class RenderTargetCreationOptions {
  576. /**
  577. * Specifies is mipmaps must be generated
  578. */
  579. generateMipMaps?: boolean;
  580. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  581. generateDepthBuffer?: boolean;
  582. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  583. generateStencilBuffer?: boolean;
  584. /** Defines texture type (int by default) */
  585. type?: number;
  586. /** Defines sampling mode (trilinear by default) */
  587. samplingMode?: number;
  588. /** Defines format (RGBA by default) */
  589. format?: number;
  590. }
  591. }
  592. declare module "babylonjs/Engines/constants" {
  593. /** Defines the cross module used constants to avoid circular dependncies */
  594. export class Constants {
  595. /** Defines that alpha blending is disabled */
  596. static readonly ALPHA_DISABLE: number;
  597. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  598. static readonly ALPHA_ADD: number;
  599. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  600. static readonly ALPHA_COMBINE: number;
  601. /** Defines that alpha blending is DEST - SRC * DEST */
  602. static readonly ALPHA_SUBTRACT: number;
  603. /** Defines that alpha blending is SRC * DEST */
  604. static readonly ALPHA_MULTIPLY: number;
  605. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  606. static readonly ALPHA_MAXIMIZED: number;
  607. /** Defines that alpha blending is SRC + DEST */
  608. static readonly ALPHA_ONEONE: number;
  609. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  610. static readonly ALPHA_PREMULTIPLIED: number;
  611. /**
  612. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  613. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  614. */
  615. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  616. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  617. static readonly ALPHA_INTERPOLATE: number;
  618. /**
  619. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  620. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  621. */
  622. static readonly ALPHA_SCREENMODE: number;
  623. /**
  624. * Defines that alpha blending is SRC + DST
  625. * Alpha will be set to SRC ALPHA + DST ALPHA
  626. */
  627. static readonly ALPHA_ONEONE_ONEONE: number;
  628. /**
  629. * Defines that alpha blending is SRC * DST ALPHA + DST
  630. * Alpha will be set to 0
  631. */
  632. static readonly ALPHA_ALPHATOCOLOR: number;
  633. /**
  634. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  635. */
  636. static readonly ALPHA_REVERSEONEMINUS: number;
  637. /**
  638. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  639. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  640. */
  641. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST
  644. * Alpha will be set to SRC ALPHA
  645. */
  646. static readonly ALPHA_ONEONE_ONEZERO: number;
  647. /**
  648. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  649. * Alpha will be set to DST ALPHA
  650. */
  651. static readonly ALPHA_EXCLUSION: number;
  652. /** Defines that alpha blending equation a SUM */
  653. static readonly ALPHA_EQUATION_ADD: number;
  654. /** Defines that alpha blending equation a SUBSTRACTION */
  655. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  656. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  657. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  658. /** Defines that alpha blending equation a MAX operation */
  659. static readonly ALPHA_EQUATION_MAX: number;
  660. /** Defines that alpha blending equation a MIN operation */
  661. static readonly ALPHA_EQUATION_MIN: number;
  662. /**
  663. * Defines that alpha blending equation a DARKEN operation:
  664. * It takes the min of the src and sums the alpha channels.
  665. */
  666. static readonly ALPHA_EQUATION_DARKEN: number;
  667. /** Defines that the ressource is not delayed*/
  668. static readonly DELAYLOADSTATE_NONE: number;
  669. /** Defines that the ressource was successfully delay loaded */
  670. static readonly DELAYLOADSTATE_LOADED: number;
  671. /** Defines that the ressource is currently delay loading */
  672. static readonly DELAYLOADSTATE_LOADING: number;
  673. /** Defines that the ressource is delayed and has not started loading */
  674. static readonly DELAYLOADSTATE_NOTLOADED: number;
  675. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  676. static readonly NEVER: number;
  677. /** 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 */
  678. static readonly ALWAYS: number;
  679. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  680. static readonly LESS: number;
  681. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  682. static readonly EQUAL: number;
  683. /** 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 */
  684. static readonly LEQUAL: number;
  685. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  686. static readonly GREATER: number;
  687. /** 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 */
  688. static readonly GEQUAL: number;
  689. /** 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 */
  690. static readonly NOTEQUAL: number;
  691. /** Passed to stencilOperation to specify that stencil value must be kept */
  692. static readonly KEEP: number;
  693. /** Passed to stencilOperation to specify that stencil value must be replaced */
  694. static readonly REPLACE: number;
  695. /** Passed to stencilOperation to specify that stencil value must be incremented */
  696. static readonly INCR: number;
  697. /** Passed to stencilOperation to specify that stencil value must be decremented */
  698. static readonly DECR: number;
  699. /** Passed to stencilOperation to specify that stencil value must be inverted */
  700. static readonly INVERT: number;
  701. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  702. static readonly INCR_WRAP: number;
  703. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  704. static readonly DECR_WRAP: number;
  705. /** Texture is not repeating outside of 0..1 UVs */
  706. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  707. /** Texture is repeating outside of 0..1 UVs */
  708. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  709. /** Texture is repeating and mirrored */
  710. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  711. /** ALPHA */
  712. static readonly TEXTUREFORMAT_ALPHA: number;
  713. /** LUMINANCE */
  714. static readonly TEXTUREFORMAT_LUMINANCE: number;
  715. /** LUMINANCE_ALPHA */
  716. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  717. /** RGB */
  718. static readonly TEXTUREFORMAT_RGB: number;
  719. /** RGBA */
  720. static readonly TEXTUREFORMAT_RGBA: number;
  721. /** RED */
  722. static readonly TEXTUREFORMAT_RED: number;
  723. /** RED (2nd reference) */
  724. static readonly TEXTUREFORMAT_R: number;
  725. /** RG */
  726. static readonly TEXTUREFORMAT_RG: number;
  727. /** RED_INTEGER */
  728. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  729. /** RED_INTEGER (2nd reference) */
  730. static readonly TEXTUREFORMAT_R_INTEGER: number;
  731. /** RG_INTEGER */
  732. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  733. /** RGB_INTEGER */
  734. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  735. /** RGBA_INTEGER */
  736. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  737. /** UNSIGNED_BYTE */
  738. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  739. /** UNSIGNED_BYTE (2nd reference) */
  740. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  741. /** FLOAT */
  742. static readonly TEXTURETYPE_FLOAT: number;
  743. /** HALF_FLOAT */
  744. static readonly TEXTURETYPE_HALF_FLOAT: number;
  745. /** BYTE */
  746. static readonly TEXTURETYPE_BYTE: number;
  747. /** SHORT */
  748. static readonly TEXTURETYPE_SHORT: number;
  749. /** UNSIGNED_SHORT */
  750. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  751. /** INT */
  752. static readonly TEXTURETYPE_INT: number;
  753. /** UNSIGNED_INT */
  754. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  755. /** UNSIGNED_SHORT_4_4_4_4 */
  756. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  757. /** UNSIGNED_SHORT_5_5_5_1 */
  758. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  759. /** UNSIGNED_SHORT_5_6_5 */
  760. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  761. /** UNSIGNED_INT_2_10_10_10_REV */
  762. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  763. /** UNSIGNED_INT_24_8 */
  764. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  765. /** UNSIGNED_INT_10F_11F_11F_REV */
  766. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  767. /** UNSIGNED_INT_5_9_9_9_REV */
  768. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  769. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  770. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  771. /** nearest is mag = nearest and min = nearest and no mip */
  772. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  773. /** mag = nearest and min = nearest and mip = none */
  774. static readonly TEXTURE_NEAREST_NEAREST: number;
  775. /** Bilinear is mag = linear and min = linear and no mip */
  776. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  777. /** mag = linear and min = linear and mip = none */
  778. static readonly TEXTURE_LINEAR_LINEAR: number;
  779. /** Trilinear is mag = linear and min = linear and mip = linear */
  780. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  781. /** Trilinear is mag = linear and min = linear and mip = linear */
  782. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  783. /** mag = nearest and min = nearest and mip = nearest */
  784. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  785. /** mag = nearest and min = linear and mip = nearest */
  786. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  787. /** mag = nearest and min = linear and mip = linear */
  788. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  789. /** mag = nearest and min = linear and mip = none */
  790. static readonly TEXTURE_NEAREST_LINEAR: number;
  791. /** nearest is mag = nearest and min = nearest and mip = linear */
  792. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  793. /** mag = linear and min = nearest and mip = nearest */
  794. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  795. /** mag = linear and min = nearest and mip = linear */
  796. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  797. /** Bilinear is mag = linear and min = linear and mip = nearest */
  798. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  799. /** mag = linear and min = nearest and mip = none */
  800. static readonly TEXTURE_LINEAR_NEAREST: number;
  801. /** Explicit coordinates mode */
  802. static readonly TEXTURE_EXPLICIT_MODE: number;
  803. /** Spherical coordinates mode */
  804. static readonly TEXTURE_SPHERICAL_MODE: number;
  805. /** Planar coordinates mode */
  806. static readonly TEXTURE_PLANAR_MODE: number;
  807. /** Cubic coordinates mode */
  808. static readonly TEXTURE_CUBIC_MODE: number;
  809. /** Projection coordinates mode */
  810. static readonly TEXTURE_PROJECTION_MODE: number;
  811. /** Skybox coordinates mode */
  812. static readonly TEXTURE_SKYBOX_MODE: number;
  813. /** Inverse Cubic coordinates mode */
  814. static readonly TEXTURE_INVCUBIC_MODE: number;
  815. /** Equirectangular coordinates mode */
  816. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  817. /** Equirectangular Fixed coordinates mode */
  818. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  819. /** Equirectangular Fixed Mirrored coordinates mode */
  820. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  821. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  822. static readonly SCALEMODE_FLOOR: number;
  823. /** Defines that texture rescaling will look for the nearest power of 2 size */
  824. static readonly SCALEMODE_NEAREST: number;
  825. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  826. static readonly SCALEMODE_CEILING: number;
  827. /**
  828. * The dirty texture flag value
  829. */
  830. static readonly MATERIAL_TextureDirtyFlag: number;
  831. /**
  832. * The dirty light flag value
  833. */
  834. static readonly MATERIAL_LightDirtyFlag: number;
  835. /**
  836. * The dirty fresnel flag value
  837. */
  838. static readonly MATERIAL_FresnelDirtyFlag: number;
  839. /**
  840. * The dirty attribute flag value
  841. */
  842. static readonly MATERIAL_AttributesDirtyFlag: number;
  843. /**
  844. * The dirty misc flag value
  845. */
  846. static readonly MATERIAL_MiscDirtyFlag: number;
  847. /**
  848. * The all dirty flag value
  849. */
  850. static readonly MATERIAL_AllDirtyFlag: number;
  851. /**
  852. * Returns the triangle fill mode
  853. */
  854. static readonly MATERIAL_TriangleFillMode: number;
  855. /**
  856. * Returns the wireframe mode
  857. */
  858. static readonly MATERIAL_WireFrameFillMode: number;
  859. /**
  860. * Returns the point fill mode
  861. */
  862. static readonly MATERIAL_PointFillMode: number;
  863. /**
  864. * Returns the point list draw mode
  865. */
  866. static readonly MATERIAL_PointListDrawMode: number;
  867. /**
  868. * Returns the line list draw mode
  869. */
  870. static readonly MATERIAL_LineListDrawMode: number;
  871. /**
  872. * Returns the line loop draw mode
  873. */
  874. static readonly MATERIAL_LineLoopDrawMode: number;
  875. /**
  876. * Returns the line strip draw mode
  877. */
  878. static readonly MATERIAL_LineStripDrawMode: number;
  879. /**
  880. * Returns the triangle strip draw mode
  881. */
  882. static readonly MATERIAL_TriangleStripDrawMode: number;
  883. /**
  884. * Returns the triangle fan draw mode
  885. */
  886. static readonly MATERIAL_TriangleFanDrawMode: number;
  887. /**
  888. * Stores the clock-wise side orientation
  889. */
  890. static readonly MATERIAL_ClockWiseSideOrientation: number;
  891. /**
  892. * Stores the counter clock-wise side orientation
  893. */
  894. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  895. /**
  896. * Nothing
  897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  898. */
  899. static readonly ACTION_NothingTrigger: number;
  900. /**
  901. * On pick
  902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  903. */
  904. static readonly ACTION_OnPickTrigger: number;
  905. /**
  906. * On left pick
  907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  908. */
  909. static readonly ACTION_OnLeftPickTrigger: number;
  910. /**
  911. * On right pick
  912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  913. */
  914. static readonly ACTION_OnRightPickTrigger: number;
  915. /**
  916. * On center pick
  917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  918. */
  919. static readonly ACTION_OnCenterPickTrigger: number;
  920. /**
  921. * On pick down
  922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  923. */
  924. static readonly ACTION_OnPickDownTrigger: number;
  925. /**
  926. * On double pick
  927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  928. */
  929. static readonly ACTION_OnDoublePickTrigger: number;
  930. /**
  931. * On pick up
  932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  933. */
  934. static readonly ACTION_OnPickUpTrigger: number;
  935. /**
  936. * On pick out.
  937. * This trigger will only be raised if you also declared a OnPickDown
  938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  939. */
  940. static readonly ACTION_OnPickOutTrigger: number;
  941. /**
  942. * On long press
  943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  944. */
  945. static readonly ACTION_OnLongPressTrigger: number;
  946. /**
  947. * On pointer over
  948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  949. */
  950. static readonly ACTION_OnPointerOverTrigger: number;
  951. /**
  952. * On pointer out
  953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  954. */
  955. static readonly ACTION_OnPointerOutTrigger: number;
  956. /**
  957. * On every frame
  958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  959. */
  960. static readonly ACTION_OnEveryFrameTrigger: number;
  961. /**
  962. * On intersection enter
  963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  964. */
  965. static readonly ACTION_OnIntersectionEnterTrigger: number;
  966. /**
  967. * On intersection exit
  968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  969. */
  970. static readonly ACTION_OnIntersectionExitTrigger: number;
  971. /**
  972. * On key down
  973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  974. */
  975. static readonly ACTION_OnKeyDownTrigger: number;
  976. /**
  977. * On key up
  978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  979. */
  980. static readonly ACTION_OnKeyUpTrigger: number;
  981. /**
  982. * Billboard mode will only apply to Y axis
  983. */
  984. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  985. /**
  986. * Billboard mode will apply to all axes
  987. */
  988. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  989. /**
  990. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  991. */
  992. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  993. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  994. * Test order :
  995. * Is the bounding sphere outside the frustum ?
  996. * If not, are the bounding box vertices outside the frustum ?
  997. * It not, then the cullable object is in the frustum.
  998. */
  999. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1000. /** Culling strategy : Bounding Sphere Only.
  1001. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1002. * It's also less accurate than the standard because some not visible objects can still be selected.
  1003. * Test : is the bounding sphere outside the frustum ?
  1004. * If not, then the cullable object is in the frustum.
  1005. */
  1006. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1007. /** Culling strategy : Optimistic Inclusion.
  1008. * This in an inclusion test first, then the standard exclusion test.
  1009. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1010. * 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.
  1011. * Anyway, it's as accurate as the standard strategy.
  1012. * Test :
  1013. * Is the cullable object bounding sphere center in the frustum ?
  1014. * If not, apply the default culling strategy.
  1015. */
  1016. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1017. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1018. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1019. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1020. * 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.
  1021. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1022. * Test :
  1023. * Is the cullable object bounding sphere center in the frustum ?
  1024. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1025. */
  1026. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1027. /**
  1028. * No logging while loading
  1029. */
  1030. static readonly SCENELOADER_NO_LOGGING: number;
  1031. /**
  1032. * Minimal logging while loading
  1033. */
  1034. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1035. /**
  1036. * Summary logging while loading
  1037. */
  1038. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1039. /**
  1040. * Detailled logging while loading
  1041. */
  1042. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1043. }
  1044. }
  1045. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1046. import { Nullable } from "babylonjs/types";
  1047. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1048. /**
  1049. * This represents the required contract to create a new type of texture loader.
  1050. */
  1051. export interface IInternalTextureLoader {
  1052. /**
  1053. * Defines wether the loader supports cascade loading the different faces.
  1054. */
  1055. supportCascades: boolean;
  1056. /**
  1057. * This returns if the loader support the current file information.
  1058. * @param extension defines the file extension of the file being loaded
  1059. * @returns true if the loader can load the specified file
  1060. */
  1061. canLoad(extension: string): boolean;
  1062. /**
  1063. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1064. * @param data contains the texture data
  1065. * @param texture defines the BabylonJS internal texture
  1066. * @param createPolynomials will be true if polynomials have been requested
  1067. * @param onLoad defines the callback to trigger once the texture is ready
  1068. * @param onError defines the callback to trigger in case of error
  1069. */
  1070. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1071. /**
  1072. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1073. * @param data contains the texture data
  1074. * @param texture defines the BabylonJS internal texture
  1075. * @param callback defines the method to call once ready to upload
  1076. */
  1077. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1078. }
  1079. }
  1080. declare module "babylonjs/Engines/IPipelineContext" {
  1081. /**
  1082. * Class used to store and describe the pipeline context associated with an effect
  1083. */
  1084. export interface IPipelineContext {
  1085. /**
  1086. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1087. */
  1088. isAsync: boolean;
  1089. /**
  1090. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1091. */
  1092. isReady: boolean;
  1093. /** @hidden */
  1094. _getVertexShaderCode(): string | null;
  1095. /** @hidden */
  1096. _getFragmentShaderCode(): string | null;
  1097. /** @hidden */
  1098. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1099. }
  1100. }
  1101. declare module "babylonjs/Meshes/dataBuffer" {
  1102. /**
  1103. * Class used to store gfx data (like WebGLBuffer)
  1104. */
  1105. export class DataBuffer {
  1106. /**
  1107. * Gets or sets the number of objects referencing this buffer
  1108. */
  1109. references: number;
  1110. /** Gets or sets the size of the underlying buffer */
  1111. capacity: number;
  1112. /**
  1113. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1114. */
  1115. is32Bits: boolean;
  1116. /**
  1117. * Gets the underlying buffer
  1118. */
  1119. get underlyingResource(): any;
  1120. }
  1121. }
  1122. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1123. /** @hidden */
  1124. export interface IShaderProcessor {
  1125. attributeProcessor?: (attribute: string) => string;
  1126. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1127. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1128. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1129. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1130. lineProcessor?: (line: string, isFragment: boolean) => string;
  1131. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1132. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1133. }
  1134. }
  1135. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1136. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1137. /** @hidden */
  1138. export interface ProcessingOptions {
  1139. defines: string[];
  1140. indexParameters: any;
  1141. isFragment: boolean;
  1142. shouldUseHighPrecisionShader: boolean;
  1143. supportsUniformBuffers: boolean;
  1144. shadersRepository: string;
  1145. includesShadersStore: {
  1146. [key: string]: string;
  1147. };
  1148. processor?: IShaderProcessor;
  1149. version: string;
  1150. platformName: string;
  1151. lookForClosingBracketForUniformBuffer?: boolean;
  1152. }
  1153. }
  1154. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1155. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1156. /** @hidden */
  1157. export class ShaderCodeNode {
  1158. line: string;
  1159. children: ShaderCodeNode[];
  1160. additionalDefineKey?: string;
  1161. additionalDefineValue?: string;
  1162. isValid(preprocessors: {
  1163. [key: string]: string;
  1164. }): boolean;
  1165. process(preprocessors: {
  1166. [key: string]: string;
  1167. }, options: ProcessingOptions): string;
  1168. }
  1169. }
  1170. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1171. /** @hidden */
  1172. export class ShaderCodeCursor {
  1173. private _lines;
  1174. lineIndex: number;
  1175. get currentLine(): string;
  1176. get canRead(): boolean;
  1177. set lines(value: string[]);
  1178. }
  1179. }
  1180. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1181. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1182. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1183. /** @hidden */
  1184. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1185. process(preprocessors: {
  1186. [key: string]: string;
  1187. }, options: ProcessingOptions): string;
  1188. }
  1189. }
  1190. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1191. /** @hidden */
  1192. export class ShaderDefineExpression {
  1193. isTrue(preprocessors: {
  1194. [key: string]: string;
  1195. }): boolean;
  1196. }
  1197. }
  1198. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1199. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1200. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1201. /** @hidden */
  1202. export class ShaderCodeTestNode extends ShaderCodeNode {
  1203. testExpression: ShaderDefineExpression;
  1204. isValid(preprocessors: {
  1205. [key: string]: string;
  1206. }): boolean;
  1207. }
  1208. }
  1209. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1210. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1211. /** @hidden */
  1212. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1213. define: string;
  1214. not: boolean;
  1215. constructor(define: string, not?: boolean);
  1216. isTrue(preprocessors: {
  1217. [key: string]: string;
  1218. }): boolean;
  1219. }
  1220. }
  1221. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1222. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1223. /** @hidden */
  1224. export class ShaderDefineOrOperator 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/shaderDefineAndOperator" {
  1233. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1234. /** @hidden */
  1235. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1236. leftOperand: ShaderDefineExpression;
  1237. rightOperand: ShaderDefineExpression;
  1238. isTrue(preprocessors: {
  1239. [key: string]: string;
  1240. }): boolean;
  1241. }
  1242. }
  1243. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1244. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1245. /** @hidden */
  1246. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1247. define: string;
  1248. operand: string;
  1249. testValue: string;
  1250. constructor(define: string, operand: string, testValue: string);
  1251. isTrue(preprocessors: {
  1252. [key: string]: string;
  1253. }): boolean;
  1254. }
  1255. }
  1256. declare module "babylonjs/Offline/IOfflineProvider" {
  1257. /**
  1258. * Class used to enable access to offline support
  1259. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1260. */
  1261. export interface IOfflineProvider {
  1262. /**
  1263. * Gets a boolean indicating if scene must be saved in the database
  1264. */
  1265. enableSceneOffline: boolean;
  1266. /**
  1267. * Gets a boolean indicating if textures must be saved in the database
  1268. */
  1269. enableTexturesOffline: boolean;
  1270. /**
  1271. * Open the offline support and make it available
  1272. * @param successCallback defines the callback to call on success
  1273. * @param errorCallback defines the callback to call on error
  1274. */
  1275. open(successCallback: () => void, errorCallback: () => void): void;
  1276. /**
  1277. * Loads an image from the offline support
  1278. * @param url defines the url to load from
  1279. * @param image defines the target DOM image
  1280. */
  1281. loadImage(url: string, image: HTMLImageElement): void;
  1282. /**
  1283. * Loads a file from offline support
  1284. * @param url defines the URL to load from
  1285. * @param sceneLoaded defines a callback to call on success
  1286. * @param progressCallBack defines a callback to call when progress changed
  1287. * @param errorCallback defines a callback to call on error
  1288. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1289. */
  1290. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1291. }
  1292. }
  1293. declare module "babylonjs/Misc/filesInputStore" {
  1294. /**
  1295. * Class used to help managing file picking and drag'n'drop
  1296. * File Storage
  1297. */
  1298. export class FilesInputStore {
  1299. /**
  1300. * List of files ready to be loaded
  1301. */
  1302. static FilesToLoad: {
  1303. [key: string]: File;
  1304. };
  1305. }
  1306. }
  1307. declare module "babylonjs/Misc/retryStrategy" {
  1308. import { WebRequest } from "babylonjs/Misc/webRequest";
  1309. /**
  1310. * Class used to define a retry strategy when error happens while loading assets
  1311. */
  1312. export class RetryStrategy {
  1313. /**
  1314. * Function used to defines an exponential back off strategy
  1315. * @param maxRetries defines the maximum number of retries (3 by default)
  1316. * @param baseInterval defines the interval between retries
  1317. * @returns the strategy function to use
  1318. */
  1319. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1320. }
  1321. }
  1322. declare module "babylonjs/Misc/baseError" {
  1323. /**
  1324. * @ignore
  1325. * Application error to support additional information when loading a file
  1326. */
  1327. export abstract class BaseError extends Error {
  1328. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1329. }
  1330. }
  1331. declare module "babylonjs/Misc/fileTools" {
  1332. import { WebRequest } from "babylonjs/Misc/webRequest";
  1333. import { Nullable } from "babylonjs/types";
  1334. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1335. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1336. import { BaseError } from "babylonjs/Misc/baseError";
  1337. /** @ignore */
  1338. export class LoadFileError extends BaseError {
  1339. request?: WebRequest;
  1340. file?: File;
  1341. /**
  1342. * Creates a new LoadFileError
  1343. * @param message defines the message of the error
  1344. * @param request defines the optional web request
  1345. * @param file defines the optional file
  1346. */
  1347. constructor(message: string, object?: WebRequest | File);
  1348. }
  1349. /** @ignore */
  1350. export class RequestFileError extends BaseError {
  1351. request: WebRequest;
  1352. /**
  1353. * Creates a new LoadFileError
  1354. * @param message defines the message of the error
  1355. * @param request defines the optional web request
  1356. */
  1357. constructor(message: string, request: WebRequest);
  1358. }
  1359. /** @ignore */
  1360. export class ReadFileError extends BaseError {
  1361. file: File;
  1362. /**
  1363. * Creates a new ReadFileError
  1364. * @param message defines the message of the error
  1365. * @param file defines the optional file
  1366. */
  1367. constructor(message: string, file: File);
  1368. }
  1369. /**
  1370. * @hidden
  1371. */
  1372. export class FileTools {
  1373. /**
  1374. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1375. */
  1376. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1377. /**
  1378. * Gets or sets the base URL to use to load assets
  1379. */
  1380. static BaseUrl: string;
  1381. /**
  1382. * Default behaviour for cors in the application.
  1383. * It can be a string if the expected behavior is identical in the entire app.
  1384. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1385. */
  1386. static CorsBehavior: string | ((url: string | string[]) => string);
  1387. /**
  1388. * Gets or sets a function used to pre-process url before using them to load assets
  1389. */
  1390. static PreprocessUrl: (url: string) => string;
  1391. /**
  1392. * Removes unwanted characters from an url
  1393. * @param url defines the url to clean
  1394. * @returns the cleaned url
  1395. */
  1396. private static _CleanUrl;
  1397. /**
  1398. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1399. * @param url define the url we are trying
  1400. * @param element define the dom element where to configure the cors policy
  1401. */
  1402. static SetCorsBehavior(url: string | string[], element: {
  1403. crossOrigin: string | null;
  1404. }): void;
  1405. /**
  1406. * Loads an image as an HTMLImageElement.
  1407. * @param input url string, ArrayBuffer, or Blob to load
  1408. * @param onLoad callback called when the image successfully loads
  1409. * @param onError callback called when the image fails to load
  1410. * @param offlineProvider offline provider for caching
  1411. * @param mimeType optional mime type
  1412. * @returns the HTMLImageElement of the loaded image
  1413. */
  1414. 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>;
  1415. /**
  1416. * Reads a file from a File object
  1417. * @param file defines the file to load
  1418. * @param onSuccess defines the callback to call when data is loaded
  1419. * @param onProgress defines the callback to call during loading process
  1420. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1421. * @param onError defines the callback to call when an error occurs
  1422. * @returns a file request object
  1423. */
  1424. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1425. /**
  1426. * Loads a file from a url
  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 offlineProvider defines the offline provider for caching
  1431. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1432. * @param onError callback called when the file fails to load
  1433. * @returns a file request object
  1434. */
  1435. 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;
  1436. /**
  1437. * Loads a file
  1438. * @param url url to load
  1439. * @param onSuccess callback called when the file successfully loads
  1440. * @param onProgress callback called while file is loading (if the server supports this mode)
  1441. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1442. * @param onError callback called when the file fails to load
  1443. * @param onOpened callback called when the web request is opened
  1444. * @returns a file request object
  1445. */
  1446. 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;
  1447. /**
  1448. * Checks if the loaded document was accessed via `file:`-Protocol.
  1449. * @returns boolean
  1450. */
  1451. static IsFileURL(): boolean;
  1452. }
  1453. }
  1454. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1455. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1456. import { WebRequest } from "babylonjs/Misc/webRequest";
  1457. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1458. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1459. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1460. /** @hidden */
  1461. export class ShaderProcessor {
  1462. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1463. private static _ProcessPrecision;
  1464. private static _ExtractOperation;
  1465. private static _BuildSubExpression;
  1466. private static _BuildExpression;
  1467. private static _MoveCursorWithinIf;
  1468. private static _MoveCursor;
  1469. private static _EvaluatePreProcessors;
  1470. private static _PreparePreProcessors;
  1471. private static _ProcessShaderConversion;
  1472. private static _ProcessIncludes;
  1473. /**
  1474. * Loads a file from a url
  1475. * @param url url to load
  1476. * @param onSuccess callback called when the file successfully loads
  1477. * @param onProgress callback called while file is loading (if the server supports this mode)
  1478. * @param offlineProvider defines the offline provider for caching
  1479. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1480. * @param onError callback called when the file fails to load
  1481. * @returns a file request object
  1482. * @hidden
  1483. */
  1484. 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;
  1485. }
  1486. }
  1487. declare module "babylonjs/Maths/math.like" {
  1488. import { float, int, DeepImmutable } from "babylonjs/types";
  1489. /**
  1490. * @hidden
  1491. */
  1492. export interface IColor4Like {
  1493. r: float;
  1494. g: float;
  1495. b: float;
  1496. a: float;
  1497. }
  1498. /**
  1499. * @hidden
  1500. */
  1501. export interface IColor3Like {
  1502. r: float;
  1503. g: float;
  1504. b: float;
  1505. }
  1506. /**
  1507. * @hidden
  1508. */
  1509. export interface IVector4Like {
  1510. x: float;
  1511. y: float;
  1512. z: float;
  1513. w: float;
  1514. }
  1515. /**
  1516. * @hidden
  1517. */
  1518. export interface IVector3Like {
  1519. x: float;
  1520. y: float;
  1521. z: float;
  1522. }
  1523. /**
  1524. * @hidden
  1525. */
  1526. export interface IVector2Like {
  1527. x: float;
  1528. y: float;
  1529. }
  1530. /**
  1531. * @hidden
  1532. */
  1533. export interface IMatrixLike {
  1534. toArray(): DeepImmutable<Float32Array>;
  1535. updateFlag: int;
  1536. }
  1537. /**
  1538. * @hidden
  1539. */
  1540. export interface IViewportLike {
  1541. x: float;
  1542. y: float;
  1543. width: float;
  1544. height: float;
  1545. }
  1546. /**
  1547. * @hidden
  1548. */
  1549. export interface IPlaneLike {
  1550. normal: IVector3Like;
  1551. d: float;
  1552. normalize(): void;
  1553. }
  1554. }
  1555. declare module "babylonjs/Materials/iEffectFallbacks" {
  1556. import { Effect } from "babylonjs/Materials/effect";
  1557. /**
  1558. * Interface used to define common properties for effect fallbacks
  1559. */
  1560. export interface IEffectFallbacks {
  1561. /**
  1562. * Removes the defines that should be removed when falling back.
  1563. * @param currentDefines defines the current define statements for the shader.
  1564. * @param effect defines the current effect we try to compile
  1565. * @returns The resulting defines with defines of the current rank removed.
  1566. */
  1567. reduce(currentDefines: string, effect: Effect): string;
  1568. /**
  1569. * Removes the fallback from the bound mesh.
  1570. */
  1571. unBindMesh(): void;
  1572. /**
  1573. * Checks to see if more fallbacks are still availible.
  1574. */
  1575. hasMoreFallbacks: boolean;
  1576. }
  1577. }
  1578. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1579. /**
  1580. * Class used to evalaute queries containing `and` and `or` operators
  1581. */
  1582. export class AndOrNotEvaluator {
  1583. /**
  1584. * Evaluate a query
  1585. * @param query defines the query to evaluate
  1586. * @param evaluateCallback defines the callback used to filter result
  1587. * @returns true if the query matches
  1588. */
  1589. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1590. private static _HandleParenthesisContent;
  1591. private static _SimplifyNegation;
  1592. }
  1593. }
  1594. declare module "babylonjs/Misc/tags" {
  1595. /**
  1596. * Class used to store custom tags
  1597. */
  1598. export class Tags {
  1599. /**
  1600. * Adds support for tags on the given object
  1601. * @param obj defines the object to use
  1602. */
  1603. static EnableFor(obj: any): void;
  1604. /**
  1605. * Removes tags support
  1606. * @param obj defines the object to use
  1607. */
  1608. static DisableFor(obj: any): void;
  1609. /**
  1610. * Gets a boolean indicating if the given object has tags
  1611. * @param obj defines the object to use
  1612. * @returns a boolean
  1613. */
  1614. static HasTags(obj: any): boolean;
  1615. /**
  1616. * Gets the tags available on a given object
  1617. * @param obj defines the object to use
  1618. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1619. * @returns the tags
  1620. */
  1621. static GetTags(obj: any, asString?: boolean): any;
  1622. /**
  1623. * Adds tags to an object
  1624. * @param obj defines the object to use
  1625. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1626. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1627. */
  1628. static AddTagsTo(obj: any, tagsString: string): void;
  1629. /**
  1630. * @hidden
  1631. */
  1632. static _AddTagTo(obj: any, tag: string): void;
  1633. /**
  1634. * Removes specific tags from a specific object
  1635. * @param obj defines the object to use
  1636. * @param tagsString defines the tags to remove
  1637. */
  1638. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1639. /**
  1640. * @hidden
  1641. */
  1642. static _RemoveTagFrom(obj: any, tag: string): void;
  1643. /**
  1644. * Defines if tags hosted on an object match a given query
  1645. * @param obj defines the object to use
  1646. * @param tagsQuery defines the tag query
  1647. * @returns a boolean
  1648. */
  1649. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1650. }
  1651. }
  1652. declare module "babylonjs/Maths/math.scalar" {
  1653. /**
  1654. * Scalar computation library
  1655. */
  1656. export class Scalar {
  1657. /**
  1658. * Two pi constants convenient for computation.
  1659. */
  1660. static TwoPi: number;
  1661. /**
  1662. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1663. * @param a number
  1664. * @param b number
  1665. * @param epsilon (default = 1.401298E-45)
  1666. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1667. */
  1668. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1669. /**
  1670. * Returns a string : the upper case translation of the number i to hexadecimal.
  1671. * @param i number
  1672. * @returns the upper case translation of the number i to hexadecimal.
  1673. */
  1674. static ToHex(i: number): string;
  1675. /**
  1676. * Returns -1 if value is negative and +1 is value is positive.
  1677. * @param value the value
  1678. * @returns the value itself if it's equal to zero.
  1679. */
  1680. static Sign(value: number): number;
  1681. /**
  1682. * Returns the value itself if it's between min and max.
  1683. * Returns min if the value is lower than min.
  1684. * Returns max if the value is greater than max.
  1685. * @param value the value to clmap
  1686. * @param min the min value to clamp to (default: 0)
  1687. * @param max the max value to clamp to (default: 1)
  1688. * @returns the clamped value
  1689. */
  1690. static Clamp(value: number, min?: number, max?: number): number;
  1691. /**
  1692. * the log2 of value.
  1693. * @param value the value to compute log2 of
  1694. * @returns the log2 of value.
  1695. */
  1696. static Log2(value: number): number;
  1697. /**
  1698. * Loops the value, so that it is never larger than length and never smaller than 0.
  1699. *
  1700. * This is similar to the modulo operator but it works with floating point numbers.
  1701. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1702. * With t = 5 and length = 2.5, the result would be 0.0.
  1703. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1704. * @param value the value
  1705. * @param length the length
  1706. * @returns the looped value
  1707. */
  1708. static Repeat(value: number, length: number): number;
  1709. /**
  1710. * Normalize the value between 0.0 and 1.0 using min and max values
  1711. * @param value value to normalize
  1712. * @param min max to normalize between
  1713. * @param max min to normalize between
  1714. * @returns the normalized value
  1715. */
  1716. static Normalize(value: number, min: number, max: number): number;
  1717. /**
  1718. * Denormalize the value from 0.0 and 1.0 using min and max values
  1719. * @param normalized value to denormalize
  1720. * @param min max to denormalize between
  1721. * @param max min to denormalize between
  1722. * @returns the denormalized value
  1723. */
  1724. static Denormalize(normalized: number, min: number, max: number): number;
  1725. /**
  1726. * Calculates the shortest difference between two given angles given in degrees.
  1727. * @param current current angle in degrees
  1728. * @param target target angle in degrees
  1729. * @returns the delta
  1730. */
  1731. static DeltaAngle(current: number, target: number): number;
  1732. /**
  1733. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1734. * @param tx value
  1735. * @param length length
  1736. * @returns The returned value will move back and forth between 0 and length
  1737. */
  1738. static PingPong(tx: number, length: number): number;
  1739. /**
  1740. * Interpolates between min and max with smoothing at the limits.
  1741. *
  1742. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1743. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1744. * @param from from
  1745. * @param to to
  1746. * @param tx value
  1747. * @returns the smooth stepped value
  1748. */
  1749. static SmoothStep(from: number, to: number, tx: number): number;
  1750. /**
  1751. * Moves a value current towards target.
  1752. *
  1753. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1754. * Negative values of maxDelta pushes the value away from target.
  1755. * @param current current value
  1756. * @param target target value
  1757. * @param maxDelta max distance to move
  1758. * @returns resulting value
  1759. */
  1760. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1761. /**
  1762. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1763. *
  1764. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1765. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1766. * @param current current value
  1767. * @param target target value
  1768. * @param maxDelta max distance to move
  1769. * @returns resulting angle
  1770. */
  1771. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1772. /**
  1773. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1774. * @param start start value
  1775. * @param end target value
  1776. * @param amount amount to lerp between
  1777. * @returns the lerped value
  1778. */
  1779. static Lerp(start: number, end: number, amount: number): number;
  1780. /**
  1781. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1782. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1783. * @param start start value
  1784. * @param end target value
  1785. * @param amount amount to lerp between
  1786. * @returns the lerped value
  1787. */
  1788. static LerpAngle(start: number, end: number, amount: number): number;
  1789. /**
  1790. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1791. * @param a start value
  1792. * @param b target value
  1793. * @param value value between a and b
  1794. * @returns the inverseLerp value
  1795. */
  1796. static InverseLerp(a: number, b: number, value: number): number;
  1797. /**
  1798. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1799. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1800. * @param value1 spline value
  1801. * @param tangent1 spline value
  1802. * @param value2 spline value
  1803. * @param tangent2 spline value
  1804. * @param amount input value
  1805. * @returns hermite result
  1806. */
  1807. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1808. /**
  1809. * Returns a random float number between and min and max values
  1810. * @param min min value of random
  1811. * @param max max value of random
  1812. * @returns random value
  1813. */
  1814. static RandomRange(min: number, max: number): number;
  1815. /**
  1816. * This function returns percentage of a number in a given range.
  1817. *
  1818. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1819. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1820. * @param number to convert to percentage
  1821. * @param min min range
  1822. * @param max max range
  1823. * @returns the percentage
  1824. */
  1825. static RangeToPercent(number: number, min: number, max: number): number;
  1826. /**
  1827. * This function returns number that corresponds to the percentage in a given range.
  1828. *
  1829. * PercentToRange(0.34,0,100) will return 34.
  1830. * @param percent to convert to number
  1831. * @param min min range
  1832. * @param max max range
  1833. * @returns the number
  1834. */
  1835. static PercentToRange(percent: number, min: number, max: number): number;
  1836. /**
  1837. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1838. * @param angle The angle to normalize in radian.
  1839. * @return The converted angle.
  1840. */
  1841. static NormalizeRadians(angle: number): number;
  1842. }
  1843. }
  1844. declare module "babylonjs/Maths/math.constants" {
  1845. /**
  1846. * Constant used to convert a value to gamma space
  1847. * @ignorenaming
  1848. */
  1849. export const ToGammaSpace: number;
  1850. /**
  1851. * Constant used to convert a value to linear space
  1852. * @ignorenaming
  1853. */
  1854. export const ToLinearSpace = 2.2;
  1855. /**
  1856. * Constant used to define the minimal number value in Babylon.js
  1857. * @ignorenaming
  1858. */
  1859. let Epsilon: number;
  1860. export { Epsilon };
  1861. }
  1862. declare module "babylonjs/Maths/math.viewport" {
  1863. /**
  1864. * Class used to represent a viewport on screen
  1865. */
  1866. export class Viewport {
  1867. /** viewport left coordinate */
  1868. x: number;
  1869. /** viewport top coordinate */
  1870. y: number;
  1871. /**viewport width */
  1872. width: number;
  1873. /** viewport height */
  1874. height: number;
  1875. /**
  1876. * Creates a Viewport object located at (x, y) and sized (width, height)
  1877. * @param x defines viewport left coordinate
  1878. * @param y defines viewport top coordinate
  1879. * @param width defines the viewport width
  1880. * @param height defines the viewport height
  1881. */
  1882. constructor(
  1883. /** viewport left coordinate */
  1884. x: number,
  1885. /** viewport top coordinate */
  1886. y: number,
  1887. /**viewport width */
  1888. width: number,
  1889. /** viewport height */
  1890. height: number);
  1891. /**
  1892. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1893. * @param renderWidth defines the rendering width
  1894. * @param renderHeight defines the rendering height
  1895. * @returns a new Viewport
  1896. */
  1897. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1898. /**
  1899. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1900. * @param renderWidth defines the rendering width
  1901. * @param renderHeight defines the rendering height
  1902. * @param ref defines the target viewport
  1903. * @returns the current viewport
  1904. */
  1905. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1906. /**
  1907. * Returns a new Viewport copied from the current one
  1908. * @returns a new Viewport
  1909. */
  1910. clone(): Viewport;
  1911. }
  1912. }
  1913. declare module "babylonjs/Misc/arrayTools" {
  1914. /**
  1915. * Class containing a set of static utilities functions for arrays.
  1916. */
  1917. export class ArrayTools {
  1918. /**
  1919. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1920. * @param size the number of element to construct and put in the array
  1921. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1922. * @returns a new array filled with new objects
  1923. */
  1924. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1925. }
  1926. }
  1927. declare module "babylonjs/Maths/math.vector" {
  1928. import { Viewport } from "babylonjs/Maths/math.viewport";
  1929. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1930. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1931. /**
  1932. * Class representing a vector containing 2 coordinates
  1933. */
  1934. export class Vector2 {
  1935. /** defines the first coordinate */
  1936. x: number;
  1937. /** defines the second coordinate */
  1938. y: number;
  1939. /**
  1940. * Creates a new Vector2 from the given x and y coordinates
  1941. * @param x defines the first coordinate
  1942. * @param y defines the second coordinate
  1943. */
  1944. constructor(
  1945. /** defines the first coordinate */
  1946. x?: number,
  1947. /** defines the second coordinate */
  1948. y?: number);
  1949. /**
  1950. * Gets a string with the Vector2 coordinates
  1951. * @returns a string with the Vector2 coordinates
  1952. */
  1953. toString(): string;
  1954. /**
  1955. * Gets class name
  1956. * @returns the string "Vector2"
  1957. */
  1958. getClassName(): string;
  1959. /**
  1960. * Gets current vector hash code
  1961. * @returns the Vector2 hash code as a number
  1962. */
  1963. getHashCode(): number;
  1964. /**
  1965. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1966. * @param array defines the source array
  1967. * @param index defines the offset in source array
  1968. * @returns the current Vector2
  1969. */
  1970. toArray(array: FloatArray, index?: number): Vector2;
  1971. /**
  1972. * Copy the current vector to an array
  1973. * @returns a new array with 2 elements: the Vector2 coordinates.
  1974. */
  1975. asArray(): number[];
  1976. /**
  1977. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1978. * @param source defines the source Vector2
  1979. * @returns the current updated Vector2
  1980. */
  1981. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1982. /**
  1983. * Sets the Vector2 coordinates with the given floats
  1984. * @param x defines the first coordinate
  1985. * @param y defines the second coordinate
  1986. * @returns the current updated Vector2
  1987. */
  1988. copyFromFloats(x: number, y: number): Vector2;
  1989. /**
  1990. * Sets the Vector2 coordinates with the given floats
  1991. * @param x defines the first coordinate
  1992. * @param y defines the second coordinate
  1993. * @returns the current updated Vector2
  1994. */
  1995. set(x: number, y: number): Vector2;
  1996. /**
  1997. * Add another vector with the current one
  1998. * @param otherVector defines the other vector
  1999. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2000. */
  2001. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2002. /**
  2003. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2004. * @param otherVector defines the other vector
  2005. * @param result defines the target vector
  2006. * @returns the unmodified current Vector2
  2007. */
  2008. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2009. /**
  2010. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2011. * @param otherVector defines the other vector
  2012. * @returns the current updated Vector2
  2013. */
  2014. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2015. /**
  2016. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2017. * @param otherVector defines the other vector
  2018. * @returns a new Vector2
  2019. */
  2020. addVector3(otherVector: Vector3): Vector2;
  2021. /**
  2022. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2023. * @param otherVector defines the other vector
  2024. * @returns a new Vector2
  2025. */
  2026. subtract(otherVector: Vector2): Vector2;
  2027. /**
  2028. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2029. * @param otherVector defines the other vector
  2030. * @param result defines the target vector
  2031. * @returns the unmodified current Vector2
  2032. */
  2033. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2034. /**
  2035. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2036. * @param otherVector defines the other vector
  2037. * @returns the current updated Vector2
  2038. */
  2039. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2040. /**
  2041. * Multiplies in place the current Vector2 coordinates by the given ones
  2042. * @param otherVector defines the other vector
  2043. * @returns the current updated Vector2
  2044. */
  2045. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2046. /**
  2047. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2048. * @param otherVector defines the other vector
  2049. * @returns a new Vector2
  2050. */
  2051. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2052. /**
  2053. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2054. * @param otherVector defines the other vector
  2055. * @param result defines the target vector
  2056. * @returns the unmodified current Vector2
  2057. */
  2058. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2059. /**
  2060. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2061. * @param x defines the first coordinate
  2062. * @param y defines the second coordinate
  2063. * @returns a new Vector2
  2064. */
  2065. multiplyByFloats(x: number, y: number): Vector2;
  2066. /**
  2067. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2068. * @param otherVector defines the other vector
  2069. * @returns a new Vector2
  2070. */
  2071. divide(otherVector: Vector2): Vector2;
  2072. /**
  2073. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2074. * @param otherVector defines the other vector
  2075. * @param result defines the target vector
  2076. * @returns the unmodified current Vector2
  2077. */
  2078. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2079. /**
  2080. * Divides the current Vector2 coordinates by the given ones
  2081. * @param otherVector defines the other vector
  2082. * @returns the current updated Vector2
  2083. */
  2084. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2085. /**
  2086. * Gets a new Vector2 with current Vector2 negated coordinates
  2087. * @returns a new Vector2
  2088. */
  2089. negate(): Vector2;
  2090. /**
  2091. * Negate this vector in place
  2092. * @returns this
  2093. */
  2094. negateInPlace(): Vector2;
  2095. /**
  2096. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2097. * @param result defines the Vector3 object where to store the result
  2098. * @returns the current Vector2
  2099. */
  2100. negateToRef(result: Vector2): Vector2;
  2101. /**
  2102. * Multiply the Vector2 coordinates by scale
  2103. * @param scale defines the scaling factor
  2104. * @returns the current updated Vector2
  2105. */
  2106. scaleInPlace(scale: number): Vector2;
  2107. /**
  2108. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2109. * @param scale defines the scaling factor
  2110. * @returns a new Vector2
  2111. */
  2112. scale(scale: number): Vector2;
  2113. /**
  2114. * Scale the current Vector2 values by a factor to a given Vector2
  2115. * @param scale defines the scale factor
  2116. * @param result defines the Vector2 object where to store the result
  2117. * @returns the unmodified current Vector2
  2118. */
  2119. scaleToRef(scale: number, result: Vector2): Vector2;
  2120. /**
  2121. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2122. * @param scale defines the scale factor
  2123. * @param result defines the Vector2 object where to store the result
  2124. * @returns the unmodified current Vector2
  2125. */
  2126. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2127. /**
  2128. * Gets a boolean if two vectors are equals
  2129. * @param otherVector defines the other vector
  2130. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2131. */
  2132. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2133. /**
  2134. * Gets a boolean if two vectors are equals (using an epsilon value)
  2135. * @param otherVector defines the other vector
  2136. * @param epsilon defines the minimal distance to consider equality
  2137. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2138. */
  2139. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2140. /**
  2141. * Gets a new Vector2 from current Vector2 floored values
  2142. * @returns a new Vector2
  2143. */
  2144. floor(): Vector2;
  2145. /**
  2146. * Gets a new Vector2 from current Vector2 floored values
  2147. * @returns a new Vector2
  2148. */
  2149. fract(): Vector2;
  2150. /**
  2151. * Gets the length of the vector
  2152. * @returns the vector length (float)
  2153. */
  2154. length(): number;
  2155. /**
  2156. * Gets the vector squared length
  2157. * @returns the vector squared length (float)
  2158. */
  2159. lengthSquared(): number;
  2160. /**
  2161. * Normalize the vector
  2162. * @returns the current updated Vector2
  2163. */
  2164. normalize(): Vector2;
  2165. /**
  2166. * Gets a new Vector2 copied from the Vector2
  2167. * @returns a new Vector2
  2168. */
  2169. clone(): Vector2;
  2170. /**
  2171. * Gets a new Vector2(0, 0)
  2172. * @returns a new Vector2
  2173. */
  2174. static Zero(): Vector2;
  2175. /**
  2176. * Gets a new Vector2(1, 1)
  2177. * @returns a new Vector2
  2178. */
  2179. static One(): Vector2;
  2180. /**
  2181. * Gets a new Vector2 set from the given index element of the given array
  2182. * @param array defines the data source
  2183. * @param offset defines the offset in the data source
  2184. * @returns a new Vector2
  2185. */
  2186. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2187. /**
  2188. * Sets "result" from the given index element of the given array
  2189. * @param array defines the data source
  2190. * @param offset defines the offset in the data source
  2191. * @param result defines the target vector
  2192. */
  2193. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2194. /**
  2195. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2196. * @param value1 defines 1st point of control
  2197. * @param value2 defines 2nd point of control
  2198. * @param value3 defines 3rd point of control
  2199. * @param value4 defines 4th point of control
  2200. * @param amount defines the interpolation factor
  2201. * @returns a new Vector2
  2202. */
  2203. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2204. /**
  2205. * 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".
  2206. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2207. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2208. * @param value defines the value to clamp
  2209. * @param min defines the lower limit
  2210. * @param max defines the upper limit
  2211. * @returns a new Vector2
  2212. */
  2213. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2214. /**
  2215. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2216. * @param value1 defines the 1st control point
  2217. * @param tangent1 defines the outgoing tangent
  2218. * @param value2 defines the 2nd control point
  2219. * @param tangent2 defines the incoming tangent
  2220. * @param amount defines the interpolation factor
  2221. * @returns a new Vector2
  2222. */
  2223. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2224. /**
  2225. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2226. * @param start defines the start vector
  2227. * @param end defines the end vector
  2228. * @param amount defines the interpolation factor
  2229. * @returns a new Vector2
  2230. */
  2231. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2232. /**
  2233. * Gets the dot product of the vector "left" and the vector "right"
  2234. * @param left defines first vector
  2235. * @param right defines second vector
  2236. * @returns the dot product (float)
  2237. */
  2238. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2239. /**
  2240. * Returns a new Vector2 equal to the normalized given vector
  2241. * @param vector defines the vector to normalize
  2242. * @returns a new Vector2
  2243. */
  2244. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2245. /**
  2246. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2247. * @param left defines 1st vector
  2248. * @param right defines 2nd vector
  2249. * @returns a new Vector2
  2250. */
  2251. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2252. /**
  2253. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2254. * @param left defines 1st vector
  2255. * @param right defines 2nd vector
  2256. * @returns a new Vector2
  2257. */
  2258. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2259. /**
  2260. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2261. * @param vector defines the vector to transform
  2262. * @param transformation defines the matrix to apply
  2263. * @returns a new Vector2
  2264. */
  2265. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2266. /**
  2267. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2268. * @param vector defines the vector to transform
  2269. * @param transformation defines the matrix to apply
  2270. * @param result defines the target vector
  2271. */
  2272. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2273. /**
  2274. * Determines if a given vector is included in a triangle
  2275. * @param p defines the vector to test
  2276. * @param p0 defines 1st triangle point
  2277. * @param p1 defines 2nd triangle point
  2278. * @param p2 defines 3rd triangle point
  2279. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2280. */
  2281. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2282. /**
  2283. * Gets the distance between the vectors "value1" and "value2"
  2284. * @param value1 defines first vector
  2285. * @param value2 defines second vector
  2286. * @returns the distance between vectors
  2287. */
  2288. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2289. /**
  2290. * Returns the squared distance between the vectors "value1" and "value2"
  2291. * @param value1 defines first vector
  2292. * @param value2 defines second vector
  2293. * @returns the squared distance between vectors
  2294. */
  2295. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2296. /**
  2297. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2298. * @param value1 defines first vector
  2299. * @param value2 defines second vector
  2300. * @returns a new Vector2
  2301. */
  2302. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2303. /**
  2304. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2305. * @param p defines the middle point
  2306. * @param segA defines one point of the segment
  2307. * @param segB defines the other point of the segment
  2308. * @returns the shortest distance
  2309. */
  2310. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2311. }
  2312. /**
  2313. * Class used to store (x,y,z) vector representation
  2314. * A Vector3 is the main object used in 3D geometry
  2315. * It can represent etiher the coordinates of a point the space, either a direction
  2316. * Reminder: js uses a left handed forward facing system
  2317. */
  2318. export class Vector3 {
  2319. /**
  2320. * Defines the first coordinates (on X axis)
  2321. */
  2322. x: number;
  2323. /**
  2324. * Defines the second coordinates (on Y axis)
  2325. */
  2326. y: number;
  2327. /**
  2328. * Defines the third coordinates (on Z axis)
  2329. */
  2330. z: number;
  2331. private static _UpReadOnly;
  2332. private static _ZeroReadOnly;
  2333. /**
  2334. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2335. * @param x defines the first coordinates (on X axis)
  2336. * @param y defines the second coordinates (on Y axis)
  2337. * @param z defines the third coordinates (on Z axis)
  2338. */
  2339. constructor(
  2340. /**
  2341. * Defines the first coordinates (on X axis)
  2342. */
  2343. x?: number,
  2344. /**
  2345. * Defines the second coordinates (on Y axis)
  2346. */
  2347. y?: number,
  2348. /**
  2349. * Defines the third coordinates (on Z axis)
  2350. */
  2351. z?: number);
  2352. /**
  2353. * Creates a string representation of the Vector3
  2354. * @returns a string with the Vector3 coordinates.
  2355. */
  2356. toString(): string;
  2357. /**
  2358. * Gets the class name
  2359. * @returns the string "Vector3"
  2360. */
  2361. getClassName(): string;
  2362. /**
  2363. * Creates the Vector3 hash code
  2364. * @returns a number which tends to be unique between Vector3 instances
  2365. */
  2366. getHashCode(): number;
  2367. /**
  2368. * Creates an array containing three elements : the coordinates of the Vector3
  2369. * @returns a new array of numbers
  2370. */
  2371. asArray(): number[];
  2372. /**
  2373. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2374. * @param array defines the destination array
  2375. * @param index defines the offset in the destination array
  2376. * @returns the current Vector3
  2377. */
  2378. toArray(array: FloatArray, index?: number): Vector3;
  2379. /**
  2380. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2381. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2382. */
  2383. toQuaternion(): Quaternion;
  2384. /**
  2385. * Adds the given vector to the current Vector3
  2386. * @param otherVector defines the second operand
  2387. * @returns the current updated Vector3
  2388. */
  2389. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2390. /**
  2391. * Adds the given coordinates to the current Vector3
  2392. * @param x defines the x coordinate of the operand
  2393. * @param y defines the y coordinate of the operand
  2394. * @param z defines the z coordinate of the operand
  2395. * @returns the current updated Vector3
  2396. */
  2397. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2398. /**
  2399. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2400. * @param otherVector defines the second operand
  2401. * @returns the resulting Vector3
  2402. */
  2403. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2404. /**
  2405. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2406. * @param otherVector defines the second operand
  2407. * @param result defines the Vector3 object where to store the result
  2408. * @returns the current Vector3
  2409. */
  2410. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2411. /**
  2412. * Subtract the given vector from the current Vector3
  2413. * @param otherVector defines the second operand
  2414. * @returns the current updated Vector3
  2415. */
  2416. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2417. /**
  2418. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2419. * @param otherVector defines the second operand
  2420. * @returns the resulting Vector3
  2421. */
  2422. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2423. /**
  2424. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2425. * @param otherVector defines the second operand
  2426. * @param result defines the Vector3 object where to store the result
  2427. * @returns the current Vector3
  2428. */
  2429. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2430. /**
  2431. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2432. * @param x defines the x coordinate of the operand
  2433. * @param y defines the y coordinate of the operand
  2434. * @param z defines the z coordinate of the operand
  2435. * @returns the resulting Vector3
  2436. */
  2437. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2438. /**
  2439. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2440. * @param x defines the x coordinate of the operand
  2441. * @param y defines the y coordinate of the operand
  2442. * @param z defines the z coordinate of the operand
  2443. * @param result defines the Vector3 object where to store the result
  2444. * @returns the current Vector3
  2445. */
  2446. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2447. /**
  2448. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2449. * @returns a new Vector3
  2450. */
  2451. negate(): Vector3;
  2452. /**
  2453. * Negate this vector in place
  2454. * @returns this
  2455. */
  2456. negateInPlace(): Vector3;
  2457. /**
  2458. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2459. * @param result defines the Vector3 object where to store the result
  2460. * @returns the current Vector3
  2461. */
  2462. negateToRef(result: Vector3): Vector3;
  2463. /**
  2464. * Multiplies the Vector3 coordinates by the float "scale"
  2465. * @param scale defines the multiplier factor
  2466. * @returns the current updated Vector3
  2467. */
  2468. scaleInPlace(scale: number): Vector3;
  2469. /**
  2470. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2471. * @param scale defines the multiplier factor
  2472. * @returns a new Vector3
  2473. */
  2474. scale(scale: number): Vector3;
  2475. /**
  2476. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2477. * @param scale defines the multiplier factor
  2478. * @param result defines the Vector3 object where to store the result
  2479. * @returns the current Vector3
  2480. */
  2481. scaleToRef(scale: number, result: Vector3): Vector3;
  2482. /**
  2483. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2484. * @param scale defines the scale factor
  2485. * @param result defines the Vector3 object where to store the result
  2486. * @returns the unmodified current Vector3
  2487. */
  2488. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2489. /**
  2490. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2491. * @param otherVector defines the second operand
  2492. * @returns true if both vectors are equals
  2493. */
  2494. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2495. /**
  2496. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2497. * @param otherVector defines the second operand
  2498. * @param epsilon defines the minimal distance to define values as equals
  2499. * @returns true if both vectors are distant less than epsilon
  2500. */
  2501. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2502. /**
  2503. * Returns true if the current Vector3 coordinates equals the given floats
  2504. * @param x defines the x coordinate of the operand
  2505. * @param y defines the y coordinate of the operand
  2506. * @param z defines the z coordinate of the operand
  2507. * @returns true if both vectors are equals
  2508. */
  2509. equalsToFloats(x: number, y: number, z: number): boolean;
  2510. /**
  2511. * Multiplies the current Vector3 coordinates by the given ones
  2512. * @param otherVector defines the second operand
  2513. * @returns the current updated Vector3
  2514. */
  2515. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2516. /**
  2517. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2518. * @param otherVector defines the second operand
  2519. * @returns the new Vector3
  2520. */
  2521. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2522. /**
  2523. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2524. * @param otherVector defines the second operand
  2525. * @param result defines the Vector3 object where to store the result
  2526. * @returns the current Vector3
  2527. */
  2528. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2529. /**
  2530. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2531. * @param x defines the x coordinate of the operand
  2532. * @param y defines the y coordinate of the operand
  2533. * @param z defines the z coordinate of the operand
  2534. * @returns the new Vector3
  2535. */
  2536. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2537. /**
  2538. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2539. * @param otherVector defines the second operand
  2540. * @returns the new Vector3
  2541. */
  2542. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2543. /**
  2544. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2545. * @param otherVector defines the second operand
  2546. * @param result defines the Vector3 object where to store the result
  2547. * @returns the current Vector3
  2548. */
  2549. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2550. /**
  2551. * Divides the current Vector3 coordinates by the given ones.
  2552. * @param otherVector defines the second operand
  2553. * @returns the current updated Vector3
  2554. */
  2555. divideInPlace(otherVector: Vector3): Vector3;
  2556. /**
  2557. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2558. * @param other defines the second operand
  2559. * @returns the current updated Vector3
  2560. */
  2561. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2562. /**
  2563. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2564. * @param other defines the second operand
  2565. * @returns the current updated Vector3
  2566. */
  2567. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2568. /**
  2569. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2570. * @param x defines the x coordinate of the operand
  2571. * @param y defines the y coordinate of the operand
  2572. * @param z defines the z coordinate of the operand
  2573. * @returns the current updated Vector3
  2574. */
  2575. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2576. /**
  2577. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2578. * @param x defines the x coordinate of the operand
  2579. * @param y defines the y coordinate of the operand
  2580. * @param z defines the z coordinate of the operand
  2581. * @returns the current updated Vector3
  2582. */
  2583. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2584. /**
  2585. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2586. * Check if is non uniform within a certain amount of decimal places to account for this
  2587. * @param epsilon the amount the values can differ
  2588. * @returns if the the vector is non uniform to a certain number of decimal places
  2589. */
  2590. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2591. /**
  2592. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2593. */
  2594. get isNonUniform(): boolean;
  2595. /**
  2596. * Gets a new Vector3 from current Vector3 floored values
  2597. * @returns a new Vector3
  2598. */
  2599. floor(): Vector3;
  2600. /**
  2601. * Gets a new Vector3 from current Vector3 floored values
  2602. * @returns a new Vector3
  2603. */
  2604. fract(): Vector3;
  2605. /**
  2606. * Gets the length of the Vector3
  2607. * @returns the length of the Vector3
  2608. */
  2609. length(): number;
  2610. /**
  2611. * Gets the squared length of the Vector3
  2612. * @returns squared length of the Vector3
  2613. */
  2614. lengthSquared(): number;
  2615. /**
  2616. * Normalize the current Vector3.
  2617. * Please note that this is an in place operation.
  2618. * @returns the current updated Vector3
  2619. */
  2620. normalize(): Vector3;
  2621. /**
  2622. * Reorders the x y z properties of the vector in place
  2623. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2624. * @returns the current updated vector
  2625. */
  2626. reorderInPlace(order: string): this;
  2627. /**
  2628. * Rotates the vector around 0,0,0 by a quaternion
  2629. * @param quaternion the rotation quaternion
  2630. * @param result vector to store the result
  2631. * @returns the resulting vector
  2632. */
  2633. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2634. /**
  2635. * Rotates a vector around a given point
  2636. * @param quaternion the rotation quaternion
  2637. * @param point the point to rotate around
  2638. * @param result vector to store the result
  2639. * @returns the resulting vector
  2640. */
  2641. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2642. /**
  2643. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2644. * The cross product is then orthogonal to both current and "other"
  2645. * @param other defines the right operand
  2646. * @returns the cross product
  2647. */
  2648. cross(other: Vector3): Vector3;
  2649. /**
  2650. * Normalize the current Vector3 with the given input length.
  2651. * Please note that this is an in place operation.
  2652. * @param len the length of the vector
  2653. * @returns the current updated Vector3
  2654. */
  2655. normalizeFromLength(len: number): Vector3;
  2656. /**
  2657. * Normalize the current Vector3 to a new vector
  2658. * @returns the new Vector3
  2659. */
  2660. normalizeToNew(): Vector3;
  2661. /**
  2662. * Normalize the current Vector3 to the reference
  2663. * @param reference define the Vector3 to update
  2664. * @returns the updated Vector3
  2665. */
  2666. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2667. /**
  2668. * Creates a new Vector3 copied from the current Vector3
  2669. * @returns the new Vector3
  2670. */
  2671. clone(): Vector3;
  2672. /**
  2673. * Copies the given vector coordinates to the current Vector3 ones
  2674. * @param source defines the source Vector3
  2675. * @returns the current updated Vector3
  2676. */
  2677. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2678. /**
  2679. * Copies the given floats to the current Vector3 coordinates
  2680. * @param x defines the x coordinate of the operand
  2681. * @param y defines the y coordinate of the operand
  2682. * @param z defines the z coordinate of the operand
  2683. * @returns the current updated Vector3
  2684. */
  2685. copyFromFloats(x: number, y: number, z: number): Vector3;
  2686. /**
  2687. * Copies the given floats to the current Vector3 coordinates
  2688. * @param x defines the x coordinate of the operand
  2689. * @param y defines the y coordinate of the operand
  2690. * @param z defines the z coordinate of the operand
  2691. * @returns the current updated Vector3
  2692. */
  2693. set(x: number, y: number, z: number): Vector3;
  2694. /**
  2695. * Copies the given float to the current Vector3 coordinates
  2696. * @param v defines the x, y and z coordinates of the operand
  2697. * @returns the current updated Vector3
  2698. */
  2699. setAll(v: number): Vector3;
  2700. /**
  2701. * Get the clip factor between two vectors
  2702. * @param vector0 defines the first operand
  2703. * @param vector1 defines the second operand
  2704. * @param axis defines the axis to use
  2705. * @param size defines the size along the axis
  2706. * @returns the clip factor
  2707. */
  2708. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2709. /**
  2710. * Get angle between two vectors
  2711. * @param vector0 angle between vector0 and vector1
  2712. * @param vector1 angle between vector0 and vector1
  2713. * @param normal direction of the normal
  2714. * @return the angle between vector0 and vector1
  2715. */
  2716. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2717. /**
  2718. * Returns a new Vector3 set from the index "offset" of the given array
  2719. * @param array defines the source array
  2720. * @param offset defines the offset in the source array
  2721. * @returns the new Vector3
  2722. */
  2723. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2724. /**
  2725. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2726. * @param array defines the source array
  2727. * @param offset defines the offset in the source array
  2728. * @returns the new Vector3
  2729. * @deprecated Please use FromArray instead.
  2730. */
  2731. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2732. /**
  2733. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2734. * @param array defines the source array
  2735. * @param offset defines the offset in the source array
  2736. * @param result defines the Vector3 where to store the result
  2737. */
  2738. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2739. /**
  2740. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2741. * @param array defines the source array
  2742. * @param offset defines the offset in the source array
  2743. * @param result defines the Vector3 where to store the result
  2744. * @deprecated Please use FromArrayToRef instead.
  2745. */
  2746. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2747. /**
  2748. * Sets the given vector "result" with the given floats.
  2749. * @param x defines the x coordinate of the source
  2750. * @param y defines the y coordinate of the source
  2751. * @param z defines the z coordinate of the source
  2752. * @param result defines the Vector3 where to store the result
  2753. */
  2754. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2755. /**
  2756. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2757. * @returns a new empty Vector3
  2758. */
  2759. static Zero(): Vector3;
  2760. /**
  2761. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2762. * @returns a new unit Vector3
  2763. */
  2764. static One(): Vector3;
  2765. /**
  2766. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2767. * @returns a new up Vector3
  2768. */
  2769. static Up(): Vector3;
  2770. /**
  2771. * Gets a up Vector3 that must not be updated
  2772. */
  2773. static get UpReadOnly(): DeepImmutable<Vector3>;
  2774. /**
  2775. * Gets a zero Vector3 that must not be updated
  2776. */
  2777. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2778. /**
  2779. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2780. * @returns a new down Vector3
  2781. */
  2782. static Down(): Vector3;
  2783. /**
  2784. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2785. * @returns a new forward Vector3
  2786. */
  2787. static Forward(): Vector3;
  2788. /**
  2789. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2790. * @returns a new forward Vector3
  2791. */
  2792. static Backward(): Vector3;
  2793. /**
  2794. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2795. * @returns a new right Vector3
  2796. */
  2797. static Right(): Vector3;
  2798. /**
  2799. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2800. * @returns a new left Vector3
  2801. */
  2802. static Left(): Vector3;
  2803. /**
  2804. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2805. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2806. * @param vector defines the Vector3 to transform
  2807. * @param transformation defines the transformation matrix
  2808. * @returns the transformed Vector3
  2809. */
  2810. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2811. /**
  2812. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2813. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2814. * @param vector defines the Vector3 to transform
  2815. * @param transformation defines the transformation matrix
  2816. * @param result defines the Vector3 where to store the result
  2817. */
  2818. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2819. /**
  2820. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2821. * This method computes tranformed coordinates only, not transformed direction vectors
  2822. * @param x define the x coordinate of the source vector
  2823. * @param y define the y coordinate of the source vector
  2824. * @param z define the z coordinate of the source vector
  2825. * @param transformation defines the transformation matrix
  2826. * @param result defines the Vector3 where to store the result
  2827. */
  2828. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2829. /**
  2830. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2831. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2832. * @param vector defines the Vector3 to transform
  2833. * @param transformation defines the transformation matrix
  2834. * @returns the new Vector3
  2835. */
  2836. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2837. /**
  2838. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2839. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2840. * @param vector defines the Vector3 to transform
  2841. * @param transformation defines the transformation matrix
  2842. * @param result defines the Vector3 where to store the result
  2843. */
  2844. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2845. /**
  2846. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2847. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2848. * @param x define the x coordinate of the source vector
  2849. * @param y define the y coordinate of the source vector
  2850. * @param z define the z coordinate of the source vector
  2851. * @param transformation defines the transformation matrix
  2852. * @param result defines the Vector3 where to store the result
  2853. */
  2854. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2855. /**
  2856. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2857. * @param value1 defines the first control point
  2858. * @param value2 defines the second control point
  2859. * @param value3 defines the third control point
  2860. * @param value4 defines the fourth control point
  2861. * @param amount defines the amount on the spline to use
  2862. * @returns the new Vector3
  2863. */
  2864. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2865. /**
  2866. * 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"
  2867. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2868. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2869. * @param value defines the current value
  2870. * @param min defines the lower range value
  2871. * @param max defines the upper range value
  2872. * @returns the new Vector3
  2873. */
  2874. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2875. /**
  2876. * 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"
  2877. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2878. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2879. * @param value defines the current value
  2880. * @param min defines the lower range value
  2881. * @param max defines the upper range value
  2882. * @param result defines the Vector3 where to store the result
  2883. */
  2884. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2885. /**
  2886. * Checks if a given vector is inside a specific range
  2887. * @param v defines the vector to test
  2888. * @param min defines the minimum range
  2889. * @param max defines the maximum range
  2890. */
  2891. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2892. /**
  2893. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2894. * @param value1 defines the first control point
  2895. * @param tangent1 defines the first tangent vector
  2896. * @param value2 defines the second control point
  2897. * @param tangent2 defines the second tangent vector
  2898. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2899. * @returns the new Vector3
  2900. */
  2901. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2902. /**
  2903. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2904. * @param start defines the start value
  2905. * @param end defines the end value
  2906. * @param amount max defines amount between both (between 0 and 1)
  2907. * @returns the new Vector3
  2908. */
  2909. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2910. /**
  2911. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2912. * @param start defines the start value
  2913. * @param end defines the end value
  2914. * @param amount max defines amount between both (between 0 and 1)
  2915. * @param result defines the Vector3 where to store the result
  2916. */
  2917. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2918. /**
  2919. * Returns the dot product (float) between the vectors "left" and "right"
  2920. * @param left defines the left operand
  2921. * @param right defines the right operand
  2922. * @returns the dot product
  2923. */
  2924. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2925. /**
  2926. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2927. * The cross product is then orthogonal to both "left" and "right"
  2928. * @param left defines the left operand
  2929. * @param right defines the right operand
  2930. * @returns the cross product
  2931. */
  2932. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2933. /**
  2934. * Sets the given vector "result" with the cross product of "left" and "right"
  2935. * The cross product is then orthogonal to both "left" and "right"
  2936. * @param left defines the left operand
  2937. * @param right defines the right operand
  2938. * @param result defines the Vector3 where to store the result
  2939. */
  2940. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2941. /**
  2942. * Returns a new Vector3 as the normalization of the given vector
  2943. * @param vector defines the Vector3 to normalize
  2944. * @returns the new Vector3
  2945. */
  2946. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2947. /**
  2948. * Sets the given vector "result" with the normalization of the given first vector
  2949. * @param vector defines the Vector3 to normalize
  2950. * @param result defines the Vector3 where to store the result
  2951. */
  2952. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2953. /**
  2954. * Project a Vector3 onto screen space
  2955. * @param vector defines the Vector3 to project
  2956. * @param world defines the world matrix to use
  2957. * @param transform defines the transform (view x projection) matrix to use
  2958. * @param viewport defines the screen viewport to use
  2959. * @returns the new Vector3
  2960. */
  2961. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2962. /** @hidden */
  2963. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2964. /**
  2965. * Unproject from screen space to object space
  2966. * @param source defines the screen space Vector3 to use
  2967. * @param viewportWidth defines the current width of the viewport
  2968. * @param viewportHeight defines the current height of the viewport
  2969. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2970. * @param transform defines the transform (view x projection) matrix to use
  2971. * @returns the new Vector3
  2972. */
  2973. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: 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. * @returns the new Vector3
  2983. */
  2984. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2985. /**
  2986. * Unproject from screen space to object space
  2987. * @param source defines the screen space Vector3 to use
  2988. * @param viewportWidth defines the current width of the viewport
  2989. * @param viewportHeight defines the current height of the viewport
  2990. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2991. * @param view defines the view matrix to use
  2992. * @param projection defines the projection matrix to use
  2993. * @param result defines the Vector3 where to store the result
  2994. */
  2995. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2996. /**
  2997. * Unproject from screen space to object space
  2998. * @param sourceX defines the screen space x coordinate to use
  2999. * @param sourceY defines the screen space y coordinate to use
  3000. * @param sourceZ defines the screen space z coordinate to use
  3001. * @param viewportWidth defines the current width of the viewport
  3002. * @param viewportHeight defines the current height of the viewport
  3003. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3004. * @param view defines the view matrix to use
  3005. * @param projection defines the projection matrix to use
  3006. * @param result defines the Vector3 where to store the result
  3007. */
  3008. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3009. /**
  3010. * Gets the minimal coordinate values between two Vector3
  3011. * @param left defines the first operand
  3012. * @param right defines the second operand
  3013. * @returns the new Vector3
  3014. */
  3015. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3016. /**
  3017. * Gets the maximal coordinate values between two Vector3
  3018. * @param left defines the first operand
  3019. * @param right defines the second operand
  3020. * @returns the new Vector3
  3021. */
  3022. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3023. /**
  3024. * Returns the distance between the vectors "value1" and "value2"
  3025. * @param value1 defines the first operand
  3026. * @param value2 defines the second operand
  3027. * @returns the distance
  3028. */
  3029. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3030. /**
  3031. * Returns the squared distance between the vectors "value1" and "value2"
  3032. * @param value1 defines the first operand
  3033. * @param value2 defines the second operand
  3034. * @returns the squared distance
  3035. */
  3036. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3037. /**
  3038. * Returns a new Vector3 located at the center between "value1" and "value2"
  3039. * @param value1 defines the first operand
  3040. * @param value2 defines the second operand
  3041. * @returns the new Vector3
  3042. */
  3043. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3044. /**
  3045. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3046. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3047. * to something in order to rotate it from its local system to the given target system
  3048. * Note: axis1, axis2 and axis3 are normalized during this operation
  3049. * @param axis1 defines the first axis
  3050. * @param axis2 defines the second axis
  3051. * @param axis3 defines the third axis
  3052. * @returns a new Vector3
  3053. */
  3054. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3055. /**
  3056. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3057. * @param axis1 defines the first axis
  3058. * @param axis2 defines the second axis
  3059. * @param axis3 defines the third axis
  3060. * @param ref defines the Vector3 where to store the result
  3061. */
  3062. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3063. }
  3064. /**
  3065. * Vector4 class created for EulerAngle class conversion to Quaternion
  3066. */
  3067. export class Vector4 {
  3068. /** x value of the vector */
  3069. x: number;
  3070. /** y value of the vector */
  3071. y: number;
  3072. /** z value of the vector */
  3073. z: number;
  3074. /** w value of the vector */
  3075. w: number;
  3076. /**
  3077. * Creates a Vector4 object from the given floats.
  3078. * @param x x value of the vector
  3079. * @param y y value of the vector
  3080. * @param z z value of the vector
  3081. * @param w w value of the vector
  3082. */
  3083. constructor(
  3084. /** x value of the vector */
  3085. x: number,
  3086. /** y value of the vector */
  3087. y: number,
  3088. /** z value of the vector */
  3089. z: number,
  3090. /** w value of the vector */
  3091. w: number);
  3092. /**
  3093. * Returns the string with the Vector4 coordinates.
  3094. * @returns a string containing all the vector values
  3095. */
  3096. toString(): string;
  3097. /**
  3098. * Returns the string "Vector4".
  3099. * @returns "Vector4"
  3100. */
  3101. getClassName(): string;
  3102. /**
  3103. * Returns the Vector4 hash code.
  3104. * @returns a unique hash code
  3105. */
  3106. getHashCode(): number;
  3107. /**
  3108. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3109. * @returns the resulting array
  3110. */
  3111. asArray(): number[];
  3112. /**
  3113. * Populates the given array from the given index with the Vector4 coordinates.
  3114. * @param array array to populate
  3115. * @param index index of the array to start at (default: 0)
  3116. * @returns the Vector4.
  3117. */
  3118. toArray(array: FloatArray, index?: number): Vector4;
  3119. /**
  3120. * Adds the given vector to the current Vector4.
  3121. * @param otherVector the vector to add
  3122. * @returns the updated Vector4.
  3123. */
  3124. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3125. /**
  3126. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3127. * @param otherVector the vector to add
  3128. * @returns the resulting vector
  3129. */
  3130. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3131. /**
  3132. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3133. * @param otherVector the vector to add
  3134. * @param result the vector to store the result
  3135. * @returns the current Vector4.
  3136. */
  3137. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3138. /**
  3139. * Subtract in place the given vector from the current Vector4.
  3140. * @param otherVector the vector to subtract
  3141. * @returns the updated Vector4.
  3142. */
  3143. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3144. /**
  3145. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3146. * @param otherVector the vector to add
  3147. * @returns the new vector with the result
  3148. */
  3149. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3150. /**
  3151. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3152. * @param otherVector the vector to subtract
  3153. * @param result the vector to store the result
  3154. * @returns the current Vector4.
  3155. */
  3156. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3157. /**
  3158. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3159. */
  3160. /**
  3161. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3162. * @param x value to subtract
  3163. * @param y value to subtract
  3164. * @param z value to subtract
  3165. * @param w value to subtract
  3166. * @returns new vector containing the result
  3167. */
  3168. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3169. /**
  3170. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3171. * @param x value to subtract
  3172. * @param y value to subtract
  3173. * @param z value to subtract
  3174. * @param w value to subtract
  3175. * @param result the vector to store the result in
  3176. * @returns the current Vector4.
  3177. */
  3178. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3179. /**
  3180. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3181. * @returns a new vector with the negated values
  3182. */
  3183. negate(): Vector4;
  3184. /**
  3185. * Negate this vector in place
  3186. * @returns this
  3187. */
  3188. negateInPlace(): Vector4;
  3189. /**
  3190. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3191. * @param result defines the Vector3 object where to store the result
  3192. * @returns the current Vector4
  3193. */
  3194. negateToRef(result: Vector4): Vector4;
  3195. /**
  3196. * Multiplies the current Vector4 coordinates by scale (float).
  3197. * @param scale the number to scale with
  3198. * @returns the updated Vector4.
  3199. */
  3200. scaleInPlace(scale: number): Vector4;
  3201. /**
  3202. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3203. * @param scale the number to scale with
  3204. * @returns a new vector with the result
  3205. */
  3206. scale(scale: number): Vector4;
  3207. /**
  3208. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3209. * @param scale the number to scale with
  3210. * @param result a vector to store the result in
  3211. * @returns the current Vector4.
  3212. */
  3213. scaleToRef(scale: number, result: Vector4): Vector4;
  3214. /**
  3215. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3216. * @param scale defines the scale factor
  3217. * @param result defines the Vector4 object where to store the result
  3218. * @returns the unmodified current Vector4
  3219. */
  3220. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3221. /**
  3222. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3223. * @param otherVector the vector to compare against
  3224. * @returns true if they are equal
  3225. */
  3226. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3227. /**
  3228. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3229. * @param otherVector vector to compare against
  3230. * @param epsilon (Default: very small number)
  3231. * @returns true if they are equal
  3232. */
  3233. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3234. /**
  3235. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3236. * @param x x value to compare against
  3237. * @param y y value to compare against
  3238. * @param z z value to compare against
  3239. * @param w w value to compare against
  3240. * @returns true if equal
  3241. */
  3242. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3243. /**
  3244. * Multiplies in place the current Vector4 by the given one.
  3245. * @param otherVector vector to multiple with
  3246. * @returns the updated Vector4.
  3247. */
  3248. multiplyInPlace(otherVector: Vector4): Vector4;
  3249. /**
  3250. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3251. * @param otherVector vector to multiple with
  3252. * @returns resulting new vector
  3253. */
  3254. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3255. /**
  3256. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3257. * @param otherVector vector to multiple with
  3258. * @param result vector to store the result
  3259. * @returns the current Vector4.
  3260. */
  3261. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3262. /**
  3263. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3264. * @param x x value multiply with
  3265. * @param y y value multiply with
  3266. * @param z z value multiply with
  3267. * @param w w value multiply with
  3268. * @returns resulting new vector
  3269. */
  3270. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3271. /**
  3272. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3273. * @param otherVector vector to devide with
  3274. * @returns resulting new vector
  3275. */
  3276. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3277. /**
  3278. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3279. * @param otherVector vector to devide with
  3280. * @param result vector to store the result
  3281. * @returns the current Vector4.
  3282. */
  3283. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3284. /**
  3285. * Divides the current Vector3 coordinates by the given ones.
  3286. * @param otherVector vector to devide with
  3287. * @returns the updated Vector3.
  3288. */
  3289. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3290. /**
  3291. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3292. * @param other defines the second operand
  3293. * @returns the current updated Vector4
  3294. */
  3295. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3296. /**
  3297. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3298. * @param other defines the second operand
  3299. * @returns the current updated Vector4
  3300. */
  3301. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3302. /**
  3303. * Gets a new Vector4 from current Vector4 floored values
  3304. * @returns a new Vector4
  3305. */
  3306. floor(): Vector4;
  3307. /**
  3308. * Gets a new Vector4 from current Vector3 floored values
  3309. * @returns a new Vector4
  3310. */
  3311. fract(): Vector4;
  3312. /**
  3313. * Returns the Vector4 length (float).
  3314. * @returns the length
  3315. */
  3316. length(): number;
  3317. /**
  3318. * Returns the Vector4 squared length (float).
  3319. * @returns the length squared
  3320. */
  3321. lengthSquared(): number;
  3322. /**
  3323. * Normalizes in place the Vector4.
  3324. * @returns the updated Vector4.
  3325. */
  3326. normalize(): Vector4;
  3327. /**
  3328. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3329. * @returns this converted to a new vector3
  3330. */
  3331. toVector3(): Vector3;
  3332. /**
  3333. * Returns a new Vector4 copied from the current one.
  3334. * @returns the new cloned vector
  3335. */
  3336. clone(): Vector4;
  3337. /**
  3338. * Updates the current Vector4 with the given one coordinates.
  3339. * @param source the source vector to copy from
  3340. * @returns the updated Vector4.
  3341. */
  3342. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3343. /**
  3344. * Updates the current Vector4 coordinates with the given floats.
  3345. * @param x float to copy from
  3346. * @param y float to copy from
  3347. * @param z float to copy from
  3348. * @param w float to copy from
  3349. * @returns the updated Vector4.
  3350. */
  3351. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3352. /**
  3353. * Updates the current Vector4 coordinates with the given floats.
  3354. * @param x float to set from
  3355. * @param y float to set from
  3356. * @param z float to set from
  3357. * @param w float to set from
  3358. * @returns the updated Vector4.
  3359. */
  3360. set(x: number, y: number, z: number, w: number): Vector4;
  3361. /**
  3362. * Copies the given float to the current Vector3 coordinates
  3363. * @param v defines the x, y, z and w coordinates of the operand
  3364. * @returns the current updated Vector3
  3365. */
  3366. setAll(v: number): Vector4;
  3367. /**
  3368. * Returns a new Vector4 set from the starting index of the given array.
  3369. * @param array the array to pull values from
  3370. * @param offset the offset into the array to start at
  3371. * @returns the new vector
  3372. */
  3373. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3374. /**
  3375. * Updates the given vector "result" from the starting index of the given array.
  3376. * @param array the array to pull values from
  3377. * @param offset the offset into the array to start at
  3378. * @param result the vector to store the result in
  3379. */
  3380. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3381. /**
  3382. * Updates the given vector "result" from the starting index of the given Float32Array.
  3383. * @param array the array to pull values from
  3384. * @param offset the offset into the array to start at
  3385. * @param result the vector to store the result in
  3386. */
  3387. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3388. /**
  3389. * Updates the given vector "result" coordinates from the given floats.
  3390. * @param x float to set from
  3391. * @param y float to set from
  3392. * @param z float to set from
  3393. * @param w float to set from
  3394. * @param result the vector to the floats in
  3395. */
  3396. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3397. /**
  3398. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3399. * @returns the new vector
  3400. */
  3401. static Zero(): Vector4;
  3402. /**
  3403. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3404. * @returns the new vector
  3405. */
  3406. static One(): Vector4;
  3407. /**
  3408. * Returns a new normalized Vector4 from the given one.
  3409. * @param vector the vector to normalize
  3410. * @returns the vector
  3411. */
  3412. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3413. /**
  3414. * Updates the given vector "result" from the normalization of the given one.
  3415. * @param vector the vector to normalize
  3416. * @param result the vector to store the result in
  3417. */
  3418. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3419. /**
  3420. * Returns a vector with the minimum values from the left and right vectors
  3421. * @param left left vector to minimize
  3422. * @param right right vector to minimize
  3423. * @returns a new vector with the minimum of the left and right vector values
  3424. */
  3425. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3426. /**
  3427. * Returns a vector with the maximum values from the left and right vectors
  3428. * @param left left vector to maximize
  3429. * @param right right vector to maximize
  3430. * @returns a new vector with the maximum of the left and right vector values
  3431. */
  3432. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3433. /**
  3434. * Returns the distance (float) between the vectors "value1" and "value2".
  3435. * @param value1 value to calulate the distance between
  3436. * @param value2 value to calulate the distance between
  3437. * @return the distance between the two vectors
  3438. */
  3439. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3440. /**
  3441. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3442. * @param value1 value to calulate the distance between
  3443. * @param value2 value to calulate the distance between
  3444. * @return the distance between the two vectors squared
  3445. */
  3446. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3447. /**
  3448. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3449. * @param value1 value to calulate the center between
  3450. * @param value2 value to calulate the center between
  3451. * @return the center between the two vectors
  3452. */
  3453. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3454. /**
  3455. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3456. * This methods computes transformed normalized direction vectors only.
  3457. * @param vector the vector to transform
  3458. * @param transformation the transformation matrix to apply
  3459. * @returns the new vector
  3460. */
  3461. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3462. /**
  3463. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3464. * This methods computes transformed normalized direction vectors only.
  3465. * @param vector the vector to transform
  3466. * @param transformation the transformation matrix to apply
  3467. * @param result the vector to store the result in
  3468. */
  3469. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3470. /**
  3471. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3472. * This methods computes transformed normalized direction vectors only.
  3473. * @param x value to transform
  3474. * @param y value to transform
  3475. * @param z value to transform
  3476. * @param w value to transform
  3477. * @param transformation the transformation matrix to apply
  3478. * @param result the vector to store the results in
  3479. */
  3480. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3481. /**
  3482. * Creates a new Vector4 from a Vector3
  3483. * @param source defines the source data
  3484. * @param w defines the 4th component (default is 0)
  3485. * @returns a new Vector4
  3486. */
  3487. static FromVector3(source: Vector3, w?: number): Vector4;
  3488. }
  3489. /**
  3490. * Class used to store quaternion data
  3491. * @see https://en.wikipedia.org/wiki/Quaternion
  3492. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3493. */
  3494. export class Quaternion {
  3495. /** defines the first component (0 by default) */
  3496. x: number;
  3497. /** defines the second component (0 by default) */
  3498. y: number;
  3499. /** defines the third component (0 by default) */
  3500. z: number;
  3501. /** defines the fourth component (1.0 by default) */
  3502. w: number;
  3503. /**
  3504. * Creates a new Quaternion from the given floats
  3505. * @param x defines the first component (0 by default)
  3506. * @param y defines the second component (0 by default)
  3507. * @param z defines the third component (0 by default)
  3508. * @param w defines the fourth component (1.0 by default)
  3509. */
  3510. constructor(
  3511. /** defines the first component (0 by default) */
  3512. x?: number,
  3513. /** defines the second component (0 by default) */
  3514. y?: number,
  3515. /** defines the third component (0 by default) */
  3516. z?: number,
  3517. /** defines the fourth component (1.0 by default) */
  3518. w?: number);
  3519. /**
  3520. * Gets a string representation for the current quaternion
  3521. * @returns a string with the Quaternion coordinates
  3522. */
  3523. toString(): string;
  3524. /**
  3525. * Gets the class name of the quaternion
  3526. * @returns the string "Quaternion"
  3527. */
  3528. getClassName(): string;
  3529. /**
  3530. * Gets a hash code for this quaternion
  3531. * @returns the quaternion hash code
  3532. */
  3533. getHashCode(): number;
  3534. /**
  3535. * Copy the quaternion to an array
  3536. * @returns a new array populated with 4 elements from the quaternion coordinates
  3537. */
  3538. asArray(): number[];
  3539. /**
  3540. * Check if two quaternions are equals
  3541. * @param otherQuaternion defines the second operand
  3542. * @return true if the current quaternion and the given one coordinates are strictly equals
  3543. */
  3544. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3545. /**
  3546. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3547. * @param otherQuaternion defines the other quaternion
  3548. * @param epsilon defines the minimal distance to consider equality
  3549. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3550. */
  3551. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3552. /**
  3553. * Clone the current quaternion
  3554. * @returns a new quaternion copied from the current one
  3555. */
  3556. clone(): Quaternion;
  3557. /**
  3558. * Copy a quaternion to the current one
  3559. * @param other defines the other quaternion
  3560. * @returns the updated current quaternion
  3561. */
  3562. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3563. /**
  3564. * Updates the current quaternion with the given float coordinates
  3565. * @param x defines the x coordinate
  3566. * @param y defines the y coordinate
  3567. * @param z defines the z coordinate
  3568. * @param w defines the w coordinate
  3569. * @returns the updated current quaternion
  3570. */
  3571. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3572. /**
  3573. * Updates the current quaternion from the given float coordinates
  3574. * @param x defines the x coordinate
  3575. * @param y defines the y coordinate
  3576. * @param z defines the z coordinate
  3577. * @param w defines the w coordinate
  3578. * @returns the updated current quaternion
  3579. */
  3580. set(x: number, y: number, z: number, w: number): Quaternion;
  3581. /**
  3582. * Adds two quaternions
  3583. * @param other defines the second operand
  3584. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3585. */
  3586. add(other: DeepImmutable<Quaternion>): Quaternion;
  3587. /**
  3588. * Add a quaternion to the current one
  3589. * @param other defines the quaternion to add
  3590. * @returns the current quaternion
  3591. */
  3592. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3593. /**
  3594. * Subtract two quaternions
  3595. * @param other defines the second operand
  3596. * @returns a new quaternion as the subtraction result of the given one from the current one
  3597. */
  3598. subtract(other: Quaternion): Quaternion;
  3599. /**
  3600. * Multiplies the current quaternion by a scale factor
  3601. * @param value defines the scale factor
  3602. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3603. */
  3604. scale(value: number): Quaternion;
  3605. /**
  3606. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3607. * @param scale defines the scale factor
  3608. * @param result defines the Quaternion object where to store the result
  3609. * @returns the unmodified current quaternion
  3610. */
  3611. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3612. /**
  3613. * Multiplies in place the current quaternion by a scale factor
  3614. * @param value defines the scale factor
  3615. * @returns the current modified quaternion
  3616. */
  3617. scaleInPlace(value: number): Quaternion;
  3618. /**
  3619. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3620. * @param scale defines the scale factor
  3621. * @param result defines the Quaternion object where to store the result
  3622. * @returns the unmodified current quaternion
  3623. */
  3624. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3625. /**
  3626. * Multiplies two quaternions
  3627. * @param q1 defines the second operand
  3628. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3629. */
  3630. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3631. /**
  3632. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3633. * @param q1 defines the second operand
  3634. * @param result defines the target quaternion
  3635. * @returns the current quaternion
  3636. */
  3637. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3638. /**
  3639. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3640. * @param q1 defines the second operand
  3641. * @returns the currentupdated quaternion
  3642. */
  3643. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3644. /**
  3645. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3646. * @param ref defines the target quaternion
  3647. * @returns the current quaternion
  3648. */
  3649. conjugateToRef(ref: Quaternion): Quaternion;
  3650. /**
  3651. * Conjugates in place (1-q) the current quaternion
  3652. * @returns the current updated quaternion
  3653. */
  3654. conjugateInPlace(): Quaternion;
  3655. /**
  3656. * Conjugates in place (1-q) the current quaternion
  3657. * @returns a new quaternion
  3658. */
  3659. conjugate(): Quaternion;
  3660. /**
  3661. * Gets length of current quaternion
  3662. * @returns the quaternion length (float)
  3663. */
  3664. length(): number;
  3665. /**
  3666. * Normalize in place the current quaternion
  3667. * @returns the current updated quaternion
  3668. */
  3669. normalize(): Quaternion;
  3670. /**
  3671. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3672. * @param order is a reserved parameter and is ignore for now
  3673. * @returns a new Vector3 containing the Euler angles
  3674. */
  3675. toEulerAngles(order?: string): Vector3;
  3676. /**
  3677. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3678. * @param result defines the vector which will be filled with the Euler angles
  3679. * @param order is a reserved parameter and is ignore for now
  3680. * @returns the current unchanged quaternion
  3681. */
  3682. toEulerAnglesToRef(result: Vector3): Quaternion;
  3683. /**
  3684. * Updates the given rotation matrix with the current quaternion values
  3685. * @param result defines the target matrix
  3686. * @returns the current unchanged quaternion
  3687. */
  3688. toRotationMatrix(result: Matrix): Quaternion;
  3689. /**
  3690. * Updates the current quaternion from the given rotation matrix values
  3691. * @param matrix defines the source matrix
  3692. * @returns the current updated quaternion
  3693. */
  3694. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3695. /**
  3696. * Creates a new quaternion from a rotation matrix
  3697. * @param matrix defines the source matrix
  3698. * @returns a new quaternion created from the given rotation matrix values
  3699. */
  3700. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3701. /**
  3702. * Updates the given quaternion with the given rotation matrix values
  3703. * @param matrix defines the source matrix
  3704. * @param result defines the target quaternion
  3705. */
  3706. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3707. /**
  3708. * Returns the dot product (float) between the quaternions "left" and "right"
  3709. * @param left defines the left operand
  3710. * @param right defines the right operand
  3711. * @returns the dot product
  3712. */
  3713. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3714. /**
  3715. * Checks if the two quaternions are close to each other
  3716. * @param quat0 defines the first quaternion to check
  3717. * @param quat1 defines the second quaternion to check
  3718. * @returns true if the two quaternions are close to each other
  3719. */
  3720. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3721. /**
  3722. * Creates an empty quaternion
  3723. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3724. */
  3725. static Zero(): Quaternion;
  3726. /**
  3727. * Inverse a given quaternion
  3728. * @param q defines the source quaternion
  3729. * @returns a new quaternion as the inverted current quaternion
  3730. */
  3731. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3732. /**
  3733. * Inverse a given quaternion
  3734. * @param q defines the source quaternion
  3735. * @param result the quaternion the result will be stored in
  3736. * @returns the result quaternion
  3737. */
  3738. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3739. /**
  3740. * Creates an identity quaternion
  3741. * @returns the identity quaternion
  3742. */
  3743. static Identity(): Quaternion;
  3744. /**
  3745. * Gets a boolean indicating if the given quaternion is identity
  3746. * @param quaternion defines the quaternion to check
  3747. * @returns true if the quaternion is identity
  3748. */
  3749. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3750. /**
  3751. * Creates a quaternion from a rotation around an axis
  3752. * @param axis defines the axis to use
  3753. * @param angle defines the angle to use
  3754. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3755. */
  3756. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3757. /**
  3758. * Creates a rotation around an axis and stores it into the given quaternion
  3759. * @param axis defines the axis to use
  3760. * @param angle defines the angle to use
  3761. * @param result defines the target quaternion
  3762. * @returns the target quaternion
  3763. */
  3764. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3765. /**
  3766. * Creates a new quaternion from data stored into an array
  3767. * @param array defines the data source
  3768. * @param offset defines the offset in the source array where the data starts
  3769. * @returns a new quaternion
  3770. */
  3771. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3772. /**
  3773. * Updates the given quaternion "result" from the starting index of the given array.
  3774. * @param array the array to pull values from
  3775. * @param offset the offset into the array to start at
  3776. * @param result the quaternion to store the result in
  3777. */
  3778. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3779. /**
  3780. * Create a quaternion from Euler rotation angles
  3781. * @param x Pitch
  3782. * @param y Yaw
  3783. * @param z Roll
  3784. * @returns the new Quaternion
  3785. */
  3786. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3787. /**
  3788. * Updates a quaternion from Euler rotation angles
  3789. * @param x Pitch
  3790. * @param y Yaw
  3791. * @param z Roll
  3792. * @param result the quaternion to store the result
  3793. * @returns the updated quaternion
  3794. */
  3795. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3796. /**
  3797. * Create a quaternion from Euler rotation vector
  3798. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3799. * @returns the new Quaternion
  3800. */
  3801. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3802. /**
  3803. * Updates a quaternion from Euler rotation vector
  3804. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3805. * @param result the quaternion to store the result
  3806. * @returns the updated quaternion
  3807. */
  3808. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3809. /**
  3810. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3811. * @param yaw defines the rotation around Y axis
  3812. * @param pitch defines the rotation around X axis
  3813. * @param roll defines the rotation around Z axis
  3814. * @returns the new quaternion
  3815. */
  3816. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3817. /**
  3818. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3819. * @param yaw defines the rotation around Y axis
  3820. * @param pitch defines the rotation around X axis
  3821. * @param roll defines the rotation around Z axis
  3822. * @param result defines the target quaternion
  3823. */
  3824. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3825. /**
  3826. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3827. * @param alpha defines the rotation around first axis
  3828. * @param beta defines the rotation around second axis
  3829. * @param gamma defines the rotation around third axis
  3830. * @returns the new quaternion
  3831. */
  3832. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3833. /**
  3834. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3835. * @param alpha defines the rotation around first axis
  3836. * @param beta defines the rotation around second axis
  3837. * @param gamma defines the rotation around third axis
  3838. * @param result defines the target quaternion
  3839. */
  3840. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3841. /**
  3842. * 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)
  3843. * @param axis1 defines the first axis
  3844. * @param axis2 defines the second axis
  3845. * @param axis3 defines the third axis
  3846. * @returns the new quaternion
  3847. */
  3848. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3849. /**
  3850. * 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
  3851. * @param axis1 defines the first axis
  3852. * @param axis2 defines the second axis
  3853. * @param axis3 defines the third axis
  3854. * @param ref defines the target quaternion
  3855. */
  3856. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3857. /**
  3858. * Interpolates between two quaternions
  3859. * @param left defines first quaternion
  3860. * @param right defines second quaternion
  3861. * @param amount defines the gradient to use
  3862. * @returns the new interpolated quaternion
  3863. */
  3864. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3865. /**
  3866. * Interpolates between two quaternions and stores it into a target quaternion
  3867. * @param left defines first quaternion
  3868. * @param right defines second quaternion
  3869. * @param amount defines the gradient to use
  3870. * @param result defines the target quaternion
  3871. */
  3872. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3873. /**
  3874. * Interpolate between two quaternions using Hermite interpolation
  3875. * @param value1 defines first quaternion
  3876. * @param tangent1 defines the incoming tangent
  3877. * @param value2 defines second quaternion
  3878. * @param tangent2 defines the outgoing tangent
  3879. * @param amount defines the target quaternion
  3880. * @returns the new interpolated quaternion
  3881. */
  3882. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3883. }
  3884. /**
  3885. * Class used to store matrix data (4x4)
  3886. */
  3887. export class Matrix {
  3888. private static _updateFlagSeed;
  3889. private static _identityReadOnly;
  3890. private _isIdentity;
  3891. private _isIdentityDirty;
  3892. private _isIdentity3x2;
  3893. private _isIdentity3x2Dirty;
  3894. /**
  3895. * Gets the update flag of the matrix which is an unique number for the matrix.
  3896. * It will be incremented every time the matrix data change.
  3897. * You can use it to speed the comparison between two versions of the same matrix.
  3898. */
  3899. updateFlag: number;
  3900. private readonly _m;
  3901. /**
  3902. * Gets the internal data of the matrix
  3903. */
  3904. get m(): DeepImmutable<Float32Array>;
  3905. /** @hidden */
  3906. _markAsUpdated(): void;
  3907. /** @hidden */
  3908. private _updateIdentityStatus;
  3909. /**
  3910. * Creates an empty matrix (filled with zeros)
  3911. */
  3912. constructor();
  3913. /**
  3914. * Check if the current matrix is identity
  3915. * @returns true is the matrix is the identity matrix
  3916. */
  3917. isIdentity(): boolean;
  3918. /**
  3919. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3920. * @returns true is the matrix is the identity matrix
  3921. */
  3922. isIdentityAs3x2(): boolean;
  3923. /**
  3924. * Gets the determinant of the matrix
  3925. * @returns the matrix determinant
  3926. */
  3927. determinant(): number;
  3928. /**
  3929. * Returns the matrix as a Float32Array
  3930. * @returns the matrix underlying array
  3931. */
  3932. toArray(): DeepImmutable<Float32Array>;
  3933. /**
  3934. * Returns the matrix as a Float32Array
  3935. * @returns the matrix underlying array.
  3936. */
  3937. asArray(): DeepImmutable<Float32Array>;
  3938. /**
  3939. * Inverts the current matrix in place
  3940. * @returns the current inverted matrix
  3941. */
  3942. invert(): Matrix;
  3943. /**
  3944. * Sets all the matrix elements to zero
  3945. * @returns the current matrix
  3946. */
  3947. reset(): Matrix;
  3948. /**
  3949. * Adds the current matrix with a second one
  3950. * @param other defines the matrix to add
  3951. * @returns a new matrix as the addition of the current matrix and the given one
  3952. */
  3953. add(other: DeepImmutable<Matrix>): Matrix;
  3954. /**
  3955. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3956. * @param other defines the matrix to add
  3957. * @param result defines the target matrix
  3958. * @returns the current matrix
  3959. */
  3960. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3961. /**
  3962. * Adds in place the given matrix to the current matrix
  3963. * @param other defines the second operand
  3964. * @returns the current updated matrix
  3965. */
  3966. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3967. /**
  3968. * Sets the given matrix to the current inverted Matrix
  3969. * @param other defines the target matrix
  3970. * @returns the unmodified current matrix
  3971. */
  3972. invertToRef(other: Matrix): Matrix;
  3973. /**
  3974. * add a value at the specified position in the current Matrix
  3975. * @param index the index of the value within the matrix. between 0 and 15.
  3976. * @param value the value to be added
  3977. * @returns the current updated matrix
  3978. */
  3979. addAtIndex(index: number, value: number): Matrix;
  3980. /**
  3981. * mutiply the specified position in the current Matrix by a value
  3982. * @param index the index of the value within the matrix. between 0 and 15.
  3983. * @param value the value to be added
  3984. * @returns the current updated matrix
  3985. */
  3986. multiplyAtIndex(index: number, value: number): Matrix;
  3987. /**
  3988. * Inserts the translation vector (using 3 floats) in the current matrix
  3989. * @param x defines the 1st component of the translation
  3990. * @param y defines the 2nd component of the translation
  3991. * @param z defines the 3rd component of the translation
  3992. * @returns the current updated matrix
  3993. */
  3994. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3995. /**
  3996. * Adds the translation vector (using 3 floats) in the current matrix
  3997. * @param x defines the 1st component of the translation
  3998. * @param y defines the 2nd component of the translation
  3999. * @param z defines the 3rd component of the translation
  4000. * @returns the current updated matrix
  4001. */
  4002. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4003. /**
  4004. * Inserts the translation vector in the current matrix
  4005. * @param vector3 defines the translation to insert
  4006. * @returns the current updated matrix
  4007. */
  4008. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4009. /**
  4010. * Gets the translation value of the current matrix
  4011. * @returns a new Vector3 as the extracted translation from the matrix
  4012. */
  4013. getTranslation(): Vector3;
  4014. /**
  4015. * Fill a Vector3 with the extracted translation from the matrix
  4016. * @param result defines the Vector3 where to store the translation
  4017. * @returns the current matrix
  4018. */
  4019. getTranslationToRef(result: Vector3): Matrix;
  4020. /**
  4021. * Remove rotation and scaling part from the matrix
  4022. * @returns the updated matrix
  4023. */
  4024. removeRotationAndScaling(): Matrix;
  4025. /**
  4026. * Multiply two matrices
  4027. * @param other defines the second operand
  4028. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4029. */
  4030. multiply(other: DeepImmutable<Matrix>): Matrix;
  4031. /**
  4032. * Copy the current matrix from the given one
  4033. * @param other defines the source matrix
  4034. * @returns the current updated matrix
  4035. */
  4036. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4037. /**
  4038. * Populates the given array from the starting index with the current matrix values
  4039. * @param array defines the target array
  4040. * @param offset defines the offset in the target array where to start storing values
  4041. * @returns the current matrix
  4042. */
  4043. copyToArray(array: Float32Array, offset?: number): Matrix;
  4044. /**
  4045. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4046. * @param other defines the second operand
  4047. * @param result defines the matrix where to store the multiplication
  4048. * @returns the current matrix
  4049. */
  4050. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4051. /**
  4052. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4053. * @param other defines the second operand
  4054. * @param result defines the array where to store the multiplication
  4055. * @param offset defines the offset in the target array where to start storing values
  4056. * @returns the current matrix
  4057. */
  4058. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4059. /**
  4060. * Check equality between this matrix and a second one
  4061. * @param value defines the second matrix to compare
  4062. * @returns true is the current matrix and the given one values are strictly equal
  4063. */
  4064. equals(value: DeepImmutable<Matrix>): boolean;
  4065. /**
  4066. * Clone the current matrix
  4067. * @returns a new matrix from the current matrix
  4068. */
  4069. clone(): Matrix;
  4070. /**
  4071. * Returns the name of the current matrix class
  4072. * @returns the string "Matrix"
  4073. */
  4074. getClassName(): string;
  4075. /**
  4076. * Gets the hash code of the current matrix
  4077. * @returns the hash code
  4078. */
  4079. getHashCode(): number;
  4080. /**
  4081. * Decomposes the current Matrix into a translation, rotation and scaling components
  4082. * @param scale defines the scale vector3 given as a reference to update
  4083. * @param rotation defines the rotation quaternion given as a reference to update
  4084. * @param translation defines the translation vector3 given as a reference to update
  4085. * @returns true if operation was successful
  4086. */
  4087. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4088. /**
  4089. * Gets specific row of the matrix
  4090. * @param index defines the number of the row to get
  4091. * @returns the index-th row of the current matrix as a new Vector4
  4092. */
  4093. getRow(index: number): Nullable<Vector4>;
  4094. /**
  4095. * Sets the index-th row of the current matrix to the vector4 values
  4096. * @param index defines the number of the row to set
  4097. * @param row defines the target vector4
  4098. * @returns the updated current matrix
  4099. */
  4100. setRow(index: number, row: Vector4): Matrix;
  4101. /**
  4102. * Compute the transpose of the matrix
  4103. * @returns the new transposed matrix
  4104. */
  4105. transpose(): Matrix;
  4106. /**
  4107. * Compute the transpose of the matrix and store it in a given matrix
  4108. * @param result defines the target matrix
  4109. * @returns the current matrix
  4110. */
  4111. transposeToRef(result: Matrix): Matrix;
  4112. /**
  4113. * Sets the index-th row of the current matrix with the given 4 x float values
  4114. * @param index defines the row index
  4115. * @param x defines the x component to set
  4116. * @param y defines the y component to set
  4117. * @param z defines the z component to set
  4118. * @param w defines the w component to set
  4119. * @returns the updated current matrix
  4120. */
  4121. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4122. /**
  4123. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4124. * @param scale defines the scale factor
  4125. * @returns a new matrix
  4126. */
  4127. scale(scale: number): Matrix;
  4128. /**
  4129. * Scale the current matrix values by a factor to a given result matrix
  4130. * @param scale defines the scale factor
  4131. * @param result defines the matrix to store the result
  4132. * @returns the current matrix
  4133. */
  4134. scaleToRef(scale: number, result: Matrix): Matrix;
  4135. /**
  4136. * Scale the current matrix values by a factor and add the result to a given matrix
  4137. * @param scale defines the scale factor
  4138. * @param result defines the Matrix to store the result
  4139. * @returns the current matrix
  4140. */
  4141. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4142. /**
  4143. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4144. * @param ref matrix to store the result
  4145. */
  4146. toNormalMatrix(ref: Matrix): void;
  4147. /**
  4148. * Gets only rotation part of the current matrix
  4149. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4150. */
  4151. getRotationMatrix(): Matrix;
  4152. /**
  4153. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4154. * @param result defines the target matrix to store data to
  4155. * @returns the current matrix
  4156. */
  4157. getRotationMatrixToRef(result: Matrix): Matrix;
  4158. /**
  4159. * Toggles model matrix from being right handed to left handed in place and vice versa
  4160. */
  4161. toggleModelMatrixHandInPlace(): void;
  4162. /**
  4163. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4164. */
  4165. toggleProjectionMatrixHandInPlace(): void;
  4166. /**
  4167. * Creates a matrix from an array
  4168. * @param array defines the source array
  4169. * @param offset defines an offset in the source array
  4170. * @returns a new Matrix set from the starting index of the given array
  4171. */
  4172. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4173. /**
  4174. * Copy the content of an array into a given matrix
  4175. * @param array defines the source array
  4176. * @param offset defines an offset in the source array
  4177. * @param result defines the target matrix
  4178. */
  4179. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4180. /**
  4181. * Stores an array into a matrix after having multiplied each component by a given factor
  4182. * @param array defines the source array
  4183. * @param offset defines the offset in the source array
  4184. * @param scale defines the scaling factor
  4185. * @param result defines the target matrix
  4186. */
  4187. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4188. /**
  4189. * Gets an identity matrix that must not be updated
  4190. */
  4191. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4192. /**
  4193. * Stores a list of values (16) inside a given matrix
  4194. * @param initialM11 defines 1st value of 1st row
  4195. * @param initialM12 defines 2nd value of 1st row
  4196. * @param initialM13 defines 3rd value of 1st row
  4197. * @param initialM14 defines 4th value of 1st row
  4198. * @param initialM21 defines 1st value of 2nd row
  4199. * @param initialM22 defines 2nd value of 2nd row
  4200. * @param initialM23 defines 3rd value of 2nd row
  4201. * @param initialM24 defines 4th value of 2nd row
  4202. * @param initialM31 defines 1st value of 3rd row
  4203. * @param initialM32 defines 2nd value of 3rd row
  4204. * @param initialM33 defines 3rd value of 3rd row
  4205. * @param initialM34 defines 4th value of 3rd row
  4206. * @param initialM41 defines 1st value of 4th row
  4207. * @param initialM42 defines 2nd value of 4th row
  4208. * @param initialM43 defines 3rd value of 4th row
  4209. * @param initialM44 defines 4th value of 4th row
  4210. * @param result defines the target matrix
  4211. */
  4212. 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;
  4213. /**
  4214. * Creates new matrix from a list of values (16)
  4215. * @param initialM11 defines 1st value of 1st row
  4216. * @param initialM12 defines 2nd value of 1st row
  4217. * @param initialM13 defines 3rd value of 1st row
  4218. * @param initialM14 defines 4th value of 1st row
  4219. * @param initialM21 defines 1st value of 2nd row
  4220. * @param initialM22 defines 2nd value of 2nd row
  4221. * @param initialM23 defines 3rd value of 2nd row
  4222. * @param initialM24 defines 4th value of 2nd row
  4223. * @param initialM31 defines 1st value of 3rd row
  4224. * @param initialM32 defines 2nd value of 3rd row
  4225. * @param initialM33 defines 3rd value of 3rd row
  4226. * @param initialM34 defines 4th value of 3rd row
  4227. * @param initialM41 defines 1st value of 4th row
  4228. * @param initialM42 defines 2nd value of 4th row
  4229. * @param initialM43 defines 3rd value of 4th row
  4230. * @param initialM44 defines 4th value of 4th row
  4231. * @returns the new matrix
  4232. */
  4233. 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;
  4234. /**
  4235. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4236. * @param scale defines the scale vector3
  4237. * @param rotation defines the rotation quaternion
  4238. * @param translation defines the translation vector3
  4239. * @returns a new matrix
  4240. */
  4241. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4242. /**
  4243. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4244. * @param scale defines the scale vector3
  4245. * @param rotation defines the rotation quaternion
  4246. * @param translation defines the translation vector3
  4247. * @param result defines the target matrix
  4248. */
  4249. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4250. /**
  4251. * Creates a new identity matrix
  4252. * @returns a new identity matrix
  4253. */
  4254. static Identity(): Matrix;
  4255. /**
  4256. * Creates a new identity matrix and stores the result in a given matrix
  4257. * @param result defines the target matrix
  4258. */
  4259. static IdentityToRef(result: Matrix): void;
  4260. /**
  4261. * Creates a new zero matrix
  4262. * @returns a new zero matrix
  4263. */
  4264. static Zero(): Matrix;
  4265. /**
  4266. * Creates a new rotation matrix for "angle" radians around the X axis
  4267. * @param angle defines the angle (in radians) to use
  4268. * @return the new matrix
  4269. */
  4270. static RotationX(angle: number): Matrix;
  4271. /**
  4272. * Creates a new matrix as the invert of a given matrix
  4273. * @param source defines the source matrix
  4274. * @returns the new matrix
  4275. */
  4276. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4277. /**
  4278. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4279. * @param angle defines the angle (in radians) to use
  4280. * @param result defines the target matrix
  4281. */
  4282. static RotationXToRef(angle: number, result: Matrix): void;
  4283. /**
  4284. * Creates a new rotation matrix for "angle" radians around the Y axis
  4285. * @param angle defines the angle (in radians) to use
  4286. * @return the new matrix
  4287. */
  4288. static RotationY(angle: number): Matrix;
  4289. /**
  4290. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4291. * @param angle defines the angle (in radians) to use
  4292. * @param result defines the target matrix
  4293. */
  4294. static RotationYToRef(angle: number, result: Matrix): void;
  4295. /**
  4296. * Creates a new rotation matrix for "angle" radians around the Z axis
  4297. * @param angle defines the angle (in radians) to use
  4298. * @return the new matrix
  4299. */
  4300. static RotationZ(angle: number): Matrix;
  4301. /**
  4302. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4303. * @param angle defines the angle (in radians) to use
  4304. * @param result defines the target matrix
  4305. */
  4306. static RotationZToRef(angle: number, result: Matrix): void;
  4307. /**
  4308. * Creates a new rotation matrix for "angle" radians around the given axis
  4309. * @param axis defines the axis to use
  4310. * @param angle defines the angle (in radians) to use
  4311. * @return the new matrix
  4312. */
  4313. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4314. /**
  4315. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4316. * @param axis defines the axis to use
  4317. * @param angle defines the angle (in radians) to use
  4318. * @param result defines the target matrix
  4319. */
  4320. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4321. /**
  4322. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4323. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4324. * @param from defines the vector to align
  4325. * @param to defines the vector to align to
  4326. * @param result defines the target matrix
  4327. */
  4328. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4329. /**
  4330. * Creates a rotation matrix
  4331. * @param yaw defines the yaw angle in radians (Y axis)
  4332. * @param pitch defines the pitch angle in radians (X axis)
  4333. * @param roll defines the roll angle in radians (X axis)
  4334. * @returns the new rotation matrix
  4335. */
  4336. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4337. /**
  4338. * Creates a rotation matrix and stores it in a given matrix
  4339. * @param yaw defines the yaw angle in radians (Y axis)
  4340. * @param pitch defines the pitch angle in radians (X axis)
  4341. * @param roll defines the roll angle in radians (X axis)
  4342. * @param result defines the target matrix
  4343. */
  4344. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4345. /**
  4346. * Creates a scaling matrix
  4347. * @param x defines the scale factor on X axis
  4348. * @param y defines the scale factor on Y axis
  4349. * @param z defines the scale factor on Z axis
  4350. * @returns the new matrix
  4351. */
  4352. static Scaling(x: number, y: number, z: number): Matrix;
  4353. /**
  4354. * Creates a scaling matrix and stores it in a given matrix
  4355. * @param x defines the scale factor on X axis
  4356. * @param y defines the scale factor on Y axis
  4357. * @param z defines the scale factor on Z axis
  4358. * @param result defines the target matrix
  4359. */
  4360. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4361. /**
  4362. * Creates a translation matrix
  4363. * @param x defines the translation on X axis
  4364. * @param y defines the translation on Y axis
  4365. * @param z defines the translationon Z axis
  4366. * @returns the new matrix
  4367. */
  4368. static Translation(x: number, y: number, z: number): Matrix;
  4369. /**
  4370. * Creates a translation matrix and stores it in a given matrix
  4371. * @param x defines the translation on X axis
  4372. * @param y defines the translation on Y axis
  4373. * @param z defines the translationon Z axis
  4374. * @param result defines the target matrix
  4375. */
  4376. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4377. /**
  4378. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4379. * @param startValue defines the start value
  4380. * @param endValue defines the end value
  4381. * @param gradient defines the gradient factor
  4382. * @returns the new matrix
  4383. */
  4384. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4385. /**
  4386. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4387. * @param startValue defines the start value
  4388. * @param endValue defines the end value
  4389. * @param gradient defines the gradient factor
  4390. * @param result defines the Matrix object where to store data
  4391. */
  4392. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4393. /**
  4394. * Builds a new matrix whose values are computed by:
  4395. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4396. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4397. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4398. * @param startValue defines the first matrix
  4399. * @param endValue defines the second matrix
  4400. * @param gradient defines the gradient between the two matrices
  4401. * @returns the new matrix
  4402. */
  4403. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4404. /**
  4405. * Update a matrix to values which are computed by:
  4406. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4407. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4408. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4409. * @param startValue defines the first matrix
  4410. * @param endValue defines the second matrix
  4411. * @param gradient defines the gradient between the two matrices
  4412. * @param result defines the target matrix
  4413. */
  4414. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, 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 left 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 LookAtLH(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 left 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 LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4433. /**
  4434. * 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"
  4435. * This function works in right handed mode
  4436. * @param eye defines the final position of the entity
  4437. * @param target defines where the entity should look at
  4438. * @param up defines the up vector for the entity
  4439. * @returns the new matrix
  4440. */
  4441. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4442. /**
  4443. * 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".
  4444. * This function works in right handed mode
  4445. * @param eye defines the final position of the entity
  4446. * @param target defines where the entity should look at
  4447. * @param up defines the up vector for the entity
  4448. * @param result defines the target matrix
  4449. */
  4450. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4451. /**
  4452. * Create a left-handed orthographic projection matrix
  4453. * @param width defines the viewport width
  4454. * @param height defines the viewport height
  4455. * @param znear defines the near clip plane
  4456. * @param zfar defines the far clip plane
  4457. * @returns a new matrix as a left-handed orthographic projection matrix
  4458. */
  4459. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4460. /**
  4461. * Store a left-handed orthographic projection to a given matrix
  4462. * @param width defines the viewport width
  4463. * @param height defines the viewport height
  4464. * @param znear defines the near clip plane
  4465. * @param zfar defines the far clip plane
  4466. * @param result defines the target matrix
  4467. */
  4468. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4469. /**
  4470. * Create a left-handed orthographic projection matrix
  4471. * @param left defines the viewport left coordinate
  4472. * @param right defines the viewport right coordinate
  4473. * @param bottom defines the viewport bottom coordinate
  4474. * @param top defines the viewport top coordinate
  4475. * @param znear defines the near clip plane
  4476. * @param zfar defines the far clip plane
  4477. * @returns a new matrix as a left-handed orthographic projection matrix
  4478. */
  4479. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4480. /**
  4481. * Stores a left-handed orthographic projection into a given matrix
  4482. * @param left defines the viewport left coordinate
  4483. * @param right defines the viewport right coordinate
  4484. * @param bottom defines the viewport bottom coordinate
  4485. * @param top defines the viewport top coordinate
  4486. * @param znear defines the near clip plane
  4487. * @param zfar defines the far clip plane
  4488. * @param result defines the target matrix
  4489. */
  4490. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4491. /**
  4492. * Creates a right-handed orthographic projection matrix
  4493. * @param left defines the viewport left coordinate
  4494. * @param right defines the viewport right coordinate
  4495. * @param bottom defines the viewport bottom coordinate
  4496. * @param top defines the viewport top coordinate
  4497. * @param znear defines the near clip plane
  4498. * @param zfar defines the far clip plane
  4499. * @returns a new matrix as a right-handed orthographic projection matrix
  4500. */
  4501. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4502. /**
  4503. * Stores a right-handed orthographic projection into a given matrix
  4504. * @param left defines the viewport left coordinate
  4505. * @param right defines the viewport right coordinate
  4506. * @param bottom defines the viewport bottom coordinate
  4507. * @param top defines the viewport top coordinate
  4508. * @param znear defines the near clip plane
  4509. * @param zfar defines the far clip plane
  4510. * @param result defines the target matrix
  4511. */
  4512. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4513. /**
  4514. * Creates a left-handed perspective projection matrix
  4515. * @param width defines the viewport width
  4516. * @param height defines the viewport height
  4517. * @param znear defines the near clip plane
  4518. * @param zfar defines the far clip plane
  4519. * @returns a new matrix as a left-handed perspective projection matrix
  4520. */
  4521. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4522. /**
  4523. * Creates a left-handed perspective projection matrix
  4524. * @param fov defines the horizontal field of view
  4525. * @param aspect defines the aspect ratio
  4526. * @param znear defines the near clip plane
  4527. * @param zfar defines the far clip plane
  4528. * @returns a new matrix as a left-handed perspective projection matrix
  4529. */
  4530. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4531. /**
  4532. * Stores a left-handed perspective projection into a given matrix
  4533. * @param fov defines the horizontal field of view
  4534. * @param aspect defines the aspect ratio
  4535. * @param znear defines the near clip plane
  4536. * @param zfar defines the far clip plane
  4537. * @param result defines the target matrix
  4538. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4539. */
  4540. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4541. /**
  4542. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4543. * @param fov defines the horizontal field of view
  4544. * @param aspect defines the aspect ratio
  4545. * @param znear defines the near clip plane
  4546. * @param zfar not used as infinity is used as far clip
  4547. * @param result defines the target matrix
  4548. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4549. */
  4550. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4551. /**
  4552. * Creates a right-handed perspective projection matrix
  4553. * @param fov defines the horizontal field of view
  4554. * @param aspect defines the aspect ratio
  4555. * @param znear defines the near clip plane
  4556. * @param zfar defines the far clip plane
  4557. * @returns a new matrix as a right-handed perspective projection matrix
  4558. */
  4559. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4560. /**
  4561. * Stores a right-handed perspective projection into a given matrix
  4562. * @param fov defines the horizontal field of view
  4563. * @param aspect defines the aspect ratio
  4564. * @param znear defines the near clip plane
  4565. * @param zfar defines the far clip plane
  4566. * @param result defines the target matrix
  4567. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4568. */
  4569. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4570. /**
  4571. * Stores a right-handed perspective projection into a given matrix
  4572. * @param fov defines the horizontal field of view
  4573. * @param aspect defines the aspect ratio
  4574. * @param znear defines the near clip plane
  4575. * @param zfar not used as infinity is used as far clip
  4576. * @param result defines the target matrix
  4577. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4578. */
  4579. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4580. /**
  4581. * Stores a perspective projection for WebVR info a given matrix
  4582. * @param fov defines the field of view
  4583. * @param znear defines the near clip plane
  4584. * @param zfar defines the far clip plane
  4585. * @param result defines the target matrix
  4586. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4587. */
  4588. static PerspectiveFovWebVRToRef(fov: {
  4589. upDegrees: number;
  4590. downDegrees: number;
  4591. leftDegrees: number;
  4592. rightDegrees: number;
  4593. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4594. /**
  4595. * Computes a complete transformation matrix
  4596. * @param viewport defines the viewport to use
  4597. * @param world defines the world matrix
  4598. * @param view defines the view matrix
  4599. * @param projection defines the projection matrix
  4600. * @param zmin defines the near clip plane
  4601. * @param zmax defines the far clip plane
  4602. * @returns the transformation matrix
  4603. */
  4604. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4605. /**
  4606. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4607. * @param matrix defines the matrix to use
  4608. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4609. */
  4610. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4611. /**
  4612. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4613. * @param matrix defines the matrix to use
  4614. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4615. */
  4616. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4617. /**
  4618. * Compute the transpose of a given matrix
  4619. * @param matrix defines the matrix to transpose
  4620. * @returns the new matrix
  4621. */
  4622. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4623. /**
  4624. * Compute the transpose of a matrix and store it in a target matrix
  4625. * @param matrix defines the matrix to transpose
  4626. * @param result defines the target matrix
  4627. */
  4628. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4629. /**
  4630. * Computes a reflection matrix from a plane
  4631. * @param plane defines the reflection plane
  4632. * @returns a new matrix
  4633. */
  4634. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4635. /**
  4636. * Computes a reflection matrix from a plane
  4637. * @param plane defines the reflection plane
  4638. * @param result defines the target matrix
  4639. */
  4640. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4641. /**
  4642. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4643. * @param xaxis defines the value of the 1st axis
  4644. * @param yaxis defines the value of the 2nd axis
  4645. * @param zaxis defines the value of the 3rd axis
  4646. * @param result defines the target matrix
  4647. */
  4648. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4649. /**
  4650. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4651. * @param quat defines the quaternion to use
  4652. * @param result defines the target matrix
  4653. */
  4654. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4655. }
  4656. /**
  4657. * @hidden
  4658. */
  4659. export class TmpVectors {
  4660. static Vector2: Vector2[];
  4661. static Vector3: Vector3[];
  4662. static Vector4: Vector4[];
  4663. static Quaternion: Quaternion[];
  4664. static Matrix: Matrix[];
  4665. }
  4666. }
  4667. declare module "babylonjs/Maths/math.path" {
  4668. import { DeepImmutable, Nullable } from "babylonjs/types";
  4669. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4670. /**
  4671. * Defines potential orientation for back face culling
  4672. */
  4673. export enum Orientation {
  4674. /**
  4675. * Clockwise
  4676. */
  4677. CW = 0,
  4678. /** Counter clockwise */
  4679. CCW = 1
  4680. }
  4681. /** Class used to represent a Bezier curve */
  4682. export class BezierCurve {
  4683. /**
  4684. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4685. * @param t defines the time
  4686. * @param x1 defines the left coordinate on X axis
  4687. * @param y1 defines the left coordinate on Y axis
  4688. * @param x2 defines the right coordinate on X axis
  4689. * @param y2 defines the right coordinate on Y axis
  4690. * @returns the interpolated value
  4691. */
  4692. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4693. }
  4694. /**
  4695. * Defines angle representation
  4696. */
  4697. export class Angle {
  4698. private _radians;
  4699. /**
  4700. * Creates an Angle object of "radians" radians (float).
  4701. * @param radians the angle in radians
  4702. */
  4703. constructor(radians: number);
  4704. /**
  4705. * Get value in degrees
  4706. * @returns the Angle value in degrees (float)
  4707. */
  4708. degrees(): number;
  4709. /**
  4710. * Get value in radians
  4711. * @returns the Angle value in radians (float)
  4712. */
  4713. radians(): number;
  4714. /**
  4715. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4716. * @param a defines first vector
  4717. * @param b defines second vector
  4718. * @returns a new Angle
  4719. */
  4720. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4721. /**
  4722. * Gets a new Angle object from the given float in radians
  4723. * @param radians defines the angle value in radians
  4724. * @returns a new Angle
  4725. */
  4726. static FromRadians(radians: number): Angle;
  4727. /**
  4728. * Gets a new Angle object from the given float in degrees
  4729. * @param degrees defines the angle value in degrees
  4730. * @returns a new Angle
  4731. */
  4732. static FromDegrees(degrees: number): Angle;
  4733. }
  4734. /**
  4735. * This represents an arc in a 2d space.
  4736. */
  4737. export class Arc2 {
  4738. /** Defines the start point of the arc */
  4739. startPoint: Vector2;
  4740. /** Defines the mid point of the arc */
  4741. midPoint: Vector2;
  4742. /** Defines the end point of the arc */
  4743. endPoint: Vector2;
  4744. /**
  4745. * Defines the center point of the arc.
  4746. */
  4747. centerPoint: Vector2;
  4748. /**
  4749. * Defines the radius of the arc.
  4750. */
  4751. radius: number;
  4752. /**
  4753. * Defines the angle of the arc (from mid point to end point).
  4754. */
  4755. angle: Angle;
  4756. /**
  4757. * Defines the start angle of the arc (from start point to middle point).
  4758. */
  4759. startAngle: Angle;
  4760. /**
  4761. * Defines the orientation of the arc (clock wise/counter clock wise).
  4762. */
  4763. orientation: Orientation;
  4764. /**
  4765. * Creates an Arc object from the three given points : start, middle and end.
  4766. * @param startPoint Defines the start point of the arc
  4767. * @param midPoint Defines the midlle point of the arc
  4768. * @param endPoint Defines the end point of the arc
  4769. */
  4770. constructor(
  4771. /** Defines the start point of the arc */
  4772. startPoint: Vector2,
  4773. /** Defines the mid point of the arc */
  4774. midPoint: Vector2,
  4775. /** Defines the end point of the arc */
  4776. endPoint: Vector2);
  4777. }
  4778. /**
  4779. * Represents a 2D path made up of multiple 2D points
  4780. */
  4781. export class Path2 {
  4782. private _points;
  4783. private _length;
  4784. /**
  4785. * If the path start and end point are the same
  4786. */
  4787. closed: boolean;
  4788. /**
  4789. * Creates a Path2 object from the starting 2D coordinates x and y.
  4790. * @param x the starting points x value
  4791. * @param y the starting points y value
  4792. */
  4793. constructor(x: number, y: number);
  4794. /**
  4795. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4796. * @param x the added points x value
  4797. * @param y the added points y value
  4798. * @returns the updated Path2.
  4799. */
  4800. addLineTo(x: number, y: number): Path2;
  4801. /**
  4802. * 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.
  4803. * @param midX middle point x value
  4804. * @param midY middle point y value
  4805. * @param endX end point x value
  4806. * @param endY end point y value
  4807. * @param numberOfSegments (default: 36)
  4808. * @returns the updated Path2.
  4809. */
  4810. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4811. /**
  4812. * Closes the Path2.
  4813. * @returns the Path2.
  4814. */
  4815. close(): Path2;
  4816. /**
  4817. * Gets the sum of the distance between each sequential point in the path
  4818. * @returns the Path2 total length (float).
  4819. */
  4820. length(): number;
  4821. /**
  4822. * Gets the points which construct the path
  4823. * @returns the Path2 internal array of points.
  4824. */
  4825. getPoints(): Vector2[];
  4826. /**
  4827. * Retreives the point at the distance aways from the starting point
  4828. * @param normalizedLengthPosition the length along the path to retreive the point from
  4829. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4830. */
  4831. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4832. /**
  4833. * Creates a new path starting from an x and y position
  4834. * @param x starting x value
  4835. * @param y starting y value
  4836. * @returns a new Path2 starting at the coordinates (x, y).
  4837. */
  4838. static StartingAt(x: number, y: number): Path2;
  4839. }
  4840. /**
  4841. * Represents a 3D path made up of multiple 3D points
  4842. */
  4843. export class Path3D {
  4844. /**
  4845. * an array of Vector3, the curve axis of the Path3D
  4846. */
  4847. path: Vector3[];
  4848. private _curve;
  4849. private _distances;
  4850. private _tangents;
  4851. private _normals;
  4852. private _binormals;
  4853. private _raw;
  4854. private _alignTangentsWithPath;
  4855. private readonly _pointAtData;
  4856. /**
  4857. * new Path3D(path, normal, raw)
  4858. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4859. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4860. * @param path an array of Vector3, the curve axis of the Path3D
  4861. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4862. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4863. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4864. */
  4865. constructor(
  4866. /**
  4867. * an array of Vector3, the curve axis of the Path3D
  4868. */
  4869. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4870. /**
  4871. * Returns the Path3D array of successive Vector3 designing its curve.
  4872. * @returns the Path3D array of successive Vector3 designing its curve.
  4873. */
  4874. getCurve(): Vector3[];
  4875. /**
  4876. * Returns the Path3D array of successive Vector3 designing its curve.
  4877. * @returns the Path3D array of successive Vector3 designing its curve.
  4878. */
  4879. getPoints(): Vector3[];
  4880. /**
  4881. * @returns the computed length (float) of the path.
  4882. */
  4883. length(): number;
  4884. /**
  4885. * Returns an array populated with tangent vectors on each Path3D curve point.
  4886. * @returns an array populated with tangent vectors on each Path3D curve point.
  4887. */
  4888. getTangents(): Vector3[];
  4889. /**
  4890. * Returns an array populated with normal vectors on each Path3D curve point.
  4891. * @returns an array populated with normal vectors on each Path3D curve point.
  4892. */
  4893. getNormals(): Vector3[];
  4894. /**
  4895. * Returns an array populated with binormal vectors on each Path3D curve point.
  4896. * @returns an array populated with binormal vectors on each Path3D curve point.
  4897. */
  4898. getBinormals(): Vector3[];
  4899. /**
  4900. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4901. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4902. */
  4903. getDistances(): number[];
  4904. /**
  4905. * Returns an interpolated point along this path
  4906. * @param position the position of the point along this path, from 0.0 to 1.0
  4907. * @returns a new Vector3 as the point
  4908. */
  4909. getPointAt(position: number): Vector3;
  4910. /**
  4911. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4912. * @param position the position of the point along this path, from 0.0 to 1.0
  4913. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4914. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4915. */
  4916. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4917. /**
  4918. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4919. * @param position the position of the point along this path, from 0.0 to 1.0
  4920. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4921. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4922. */
  4923. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4924. /**
  4925. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4926. * @param position the position of the point along this path, from 0.0 to 1.0
  4927. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4928. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4929. */
  4930. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4931. /**
  4932. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4933. * @param position the position of the point along this path, from 0.0 to 1.0
  4934. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4935. */
  4936. getDistanceAt(position: number): number;
  4937. /**
  4938. * Returns the array index of the previous point of an interpolated point along this path
  4939. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4940. * @returns the array index
  4941. */
  4942. getPreviousPointIndexAt(position: number): number;
  4943. /**
  4944. * 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)
  4945. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4946. * @returns the sub position
  4947. */
  4948. getSubPositionAt(position: number): number;
  4949. /**
  4950. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4951. * @param target the vector of which to get the closest position to
  4952. * @returns the position of the closest virtual point on this path to the target vector
  4953. */
  4954. getClosestPositionTo(target: Vector3): number;
  4955. /**
  4956. * Returns a sub path (slice) of this path
  4957. * @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
  4958. * @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
  4959. * @returns a sub path (slice) of this path
  4960. */
  4961. slice(start?: number, end?: number): Path3D;
  4962. /**
  4963. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4964. * @param path path which all values are copied into the curves points
  4965. * @param firstNormal which should be projected onto the curve
  4966. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4967. * @returns the same object updated.
  4968. */
  4969. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4970. private _compute;
  4971. private _getFirstNonNullVector;
  4972. private _getLastNonNullVector;
  4973. private _normalVector;
  4974. /**
  4975. * Updates the point at data for an interpolated point along this curve
  4976. * @param position the position of the point along this curve, from 0.0 to 1.0
  4977. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4978. * @returns the (updated) point at data
  4979. */
  4980. private _updatePointAtData;
  4981. /**
  4982. * Updates the point at data from the specified parameters
  4983. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4984. * @param point the interpolated point
  4985. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4986. */
  4987. private _setPointAtData;
  4988. /**
  4989. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4990. */
  4991. private _updateInterpolationMatrix;
  4992. }
  4993. /**
  4994. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4995. * A Curve3 is designed from a series of successive Vector3.
  4996. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4997. */
  4998. export class Curve3 {
  4999. private _points;
  5000. private _length;
  5001. /**
  5002. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5003. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5004. * @param v1 (Vector3) the control point
  5005. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5006. * @param nbPoints (integer) the wanted number of points in the curve
  5007. * @returns the created Curve3
  5008. */
  5009. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5010. /**
  5011. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5012. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5013. * @param v1 (Vector3) the first control point
  5014. * @param v2 (Vector3) the second control point
  5015. * @param v3 (Vector3) the end point of the Cubic Bezier
  5016. * @param nbPoints (integer) the wanted number of points in the curve
  5017. * @returns the created Curve3
  5018. */
  5019. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5020. /**
  5021. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5022. * @param p1 (Vector3) the origin point of the Hermite Spline
  5023. * @param t1 (Vector3) the tangent vector at the origin point
  5024. * @param p2 (Vector3) the end point of the Hermite Spline
  5025. * @param t2 (Vector3) the tangent vector at the end point
  5026. * @param nbPoints (integer) the wanted number of points in the curve
  5027. * @returns the created Curve3
  5028. */
  5029. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5030. /**
  5031. * Returns a Curve3 object along a CatmullRom Spline curve :
  5032. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5033. * @param nbPoints (integer) the wanted number of points between each curve control points
  5034. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5035. * @returns the created Curve3
  5036. */
  5037. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5038. /**
  5039. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5040. * A Curve3 is designed from a series of successive Vector3.
  5041. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5042. * @param points points which make up the curve
  5043. */
  5044. constructor(points: Vector3[]);
  5045. /**
  5046. * @returns the Curve3 stored array of successive Vector3
  5047. */
  5048. getPoints(): Vector3[];
  5049. /**
  5050. * @returns the computed length (float) of the curve.
  5051. */
  5052. length(): number;
  5053. /**
  5054. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5055. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5056. * curveA and curveB keep unchanged.
  5057. * @param curve the curve to continue from this curve
  5058. * @returns the newly constructed curve
  5059. */
  5060. continue(curve: DeepImmutable<Curve3>): Curve3;
  5061. private _computeLength;
  5062. }
  5063. }
  5064. declare module "babylonjs/Animations/easing" {
  5065. /**
  5066. * This represents the main contract an easing function should follow.
  5067. * Easing functions are used throughout the animation system.
  5068. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5069. */
  5070. export interface IEasingFunction {
  5071. /**
  5072. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5073. * of the easing function.
  5074. * The link below provides some of the most common examples of easing functions.
  5075. * @see https://easings.net/
  5076. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5077. * @returns the corresponding value on the curve defined by the easing function
  5078. */
  5079. ease(gradient: number): number;
  5080. }
  5081. /**
  5082. * Base class used for every default easing function.
  5083. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5084. */
  5085. export class EasingFunction implements IEasingFunction {
  5086. /**
  5087. * Interpolation follows the mathematical formula associated with the easing function.
  5088. */
  5089. static readonly EASINGMODE_EASEIN: number;
  5090. /**
  5091. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5092. */
  5093. static readonly EASINGMODE_EASEOUT: number;
  5094. /**
  5095. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5096. */
  5097. static readonly EASINGMODE_EASEINOUT: number;
  5098. private _easingMode;
  5099. /**
  5100. * Sets the easing mode of the current function.
  5101. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5102. */
  5103. setEasingMode(easingMode: number): void;
  5104. /**
  5105. * Gets the current easing mode.
  5106. * @returns the easing mode
  5107. */
  5108. getEasingMode(): number;
  5109. /**
  5110. * @hidden
  5111. */
  5112. easeInCore(gradient: number): number;
  5113. /**
  5114. * Given an input gradient between 0 and 1, this returns the corresponding value
  5115. * of the easing function.
  5116. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5117. * @returns the corresponding value on the curve defined by the easing function
  5118. */
  5119. ease(gradient: number): number;
  5120. }
  5121. /**
  5122. * Easing function with a circle shape (see link below).
  5123. * @see https://easings.net/#easeInCirc
  5124. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5125. */
  5126. export class CircleEase extends EasingFunction implements IEasingFunction {
  5127. /** @hidden */
  5128. easeInCore(gradient: number): number;
  5129. }
  5130. /**
  5131. * Easing function with a ease back shape (see link below).
  5132. * @see https://easings.net/#easeInBack
  5133. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5134. */
  5135. export class BackEase extends EasingFunction implements IEasingFunction {
  5136. /** Defines the amplitude of the function */
  5137. amplitude: number;
  5138. /**
  5139. * Instantiates a back ease easing
  5140. * @see https://easings.net/#easeInBack
  5141. * @param amplitude Defines the amplitude of the function
  5142. */
  5143. constructor(
  5144. /** Defines the amplitude of the function */
  5145. amplitude?: number);
  5146. /** @hidden */
  5147. easeInCore(gradient: number): number;
  5148. }
  5149. /**
  5150. * Easing function with a bouncing shape (see link below).
  5151. * @see https://easings.net/#easeInBounce
  5152. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5153. */
  5154. export class BounceEase extends EasingFunction implements IEasingFunction {
  5155. /** Defines the number of bounces */
  5156. bounces: number;
  5157. /** Defines the amplitude of the bounce */
  5158. bounciness: number;
  5159. /**
  5160. * Instantiates a bounce easing
  5161. * @see https://easings.net/#easeInBounce
  5162. * @param bounces Defines the number of bounces
  5163. * @param bounciness Defines the amplitude of the bounce
  5164. */
  5165. constructor(
  5166. /** Defines the number of bounces */
  5167. bounces?: number,
  5168. /** Defines the amplitude of the bounce */
  5169. bounciness?: number);
  5170. /** @hidden */
  5171. easeInCore(gradient: number): number;
  5172. }
  5173. /**
  5174. * Easing function with a power of 3 shape (see link below).
  5175. * @see https://easings.net/#easeInCubic
  5176. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5177. */
  5178. export class CubicEase extends EasingFunction implements IEasingFunction {
  5179. /** @hidden */
  5180. easeInCore(gradient: number): number;
  5181. }
  5182. /**
  5183. * Easing function with an elastic shape (see link below).
  5184. * @see https://easings.net/#easeInElastic
  5185. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5186. */
  5187. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5188. /** Defines the number of oscillations*/
  5189. oscillations: number;
  5190. /** Defines the amplitude of the oscillations*/
  5191. springiness: number;
  5192. /**
  5193. * Instantiates an elastic easing function
  5194. * @see https://easings.net/#easeInElastic
  5195. * @param oscillations Defines the number of oscillations
  5196. * @param springiness Defines the amplitude of the oscillations
  5197. */
  5198. constructor(
  5199. /** Defines the number of oscillations*/
  5200. oscillations?: number,
  5201. /** Defines the amplitude of the oscillations*/
  5202. springiness?: number);
  5203. /** @hidden */
  5204. easeInCore(gradient: number): number;
  5205. }
  5206. /**
  5207. * Easing function with an exponential shape (see link below).
  5208. * @see https://easings.net/#easeInExpo
  5209. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5210. */
  5211. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5212. /** Defines the exponent of the function */
  5213. exponent: number;
  5214. /**
  5215. * Instantiates an exponential easing function
  5216. * @see https://easings.net/#easeInExpo
  5217. * @param exponent Defines the exponent of the function
  5218. */
  5219. constructor(
  5220. /** Defines the exponent of the function */
  5221. exponent?: number);
  5222. /** @hidden */
  5223. easeInCore(gradient: number): number;
  5224. }
  5225. /**
  5226. * Easing function with a power shape (see link below).
  5227. * @see https://easings.net/#easeInQuad
  5228. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5229. */
  5230. export class PowerEase extends EasingFunction implements IEasingFunction {
  5231. /** Defines the power of the function */
  5232. power: number;
  5233. /**
  5234. * Instantiates an power base easing function
  5235. * @see https://easings.net/#easeInQuad
  5236. * @param power Defines the power of the function
  5237. */
  5238. constructor(
  5239. /** Defines the power of the function */
  5240. power?: number);
  5241. /** @hidden */
  5242. easeInCore(gradient: number): number;
  5243. }
  5244. /**
  5245. * Easing function with a power of 2 shape (see link below).
  5246. * @see https://easings.net/#easeInQuad
  5247. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5248. */
  5249. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5250. /** @hidden */
  5251. easeInCore(gradient: number): number;
  5252. }
  5253. /**
  5254. * Easing function with a power of 4 shape (see link below).
  5255. * @see https://easings.net/#easeInQuart
  5256. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5257. */
  5258. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5259. /** @hidden */
  5260. easeInCore(gradient: number): number;
  5261. }
  5262. /**
  5263. * Easing function with a power of 5 shape (see link below).
  5264. * @see https://easings.net/#easeInQuint
  5265. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5266. */
  5267. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5268. /** @hidden */
  5269. easeInCore(gradient: number): number;
  5270. }
  5271. /**
  5272. * Easing function with a sin shape (see link below).
  5273. * @see https://easings.net/#easeInSine
  5274. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5275. */
  5276. export class SineEase extends EasingFunction implements IEasingFunction {
  5277. /** @hidden */
  5278. easeInCore(gradient: number): number;
  5279. }
  5280. /**
  5281. * Easing function with a bezier shape (see link below).
  5282. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5283. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5284. */
  5285. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5286. /** Defines the x component of the start tangent in the bezier curve */
  5287. x1: number;
  5288. /** Defines the y component of the start tangent in the bezier curve */
  5289. y1: number;
  5290. /** Defines the x component of the end tangent in the bezier curve */
  5291. x2: number;
  5292. /** Defines the y component of the end tangent in the bezier curve */
  5293. y2: number;
  5294. /**
  5295. * Instantiates a bezier function
  5296. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5297. * @param x1 Defines the x component of the start tangent in the bezier curve
  5298. * @param y1 Defines the y component of the start tangent in the bezier curve
  5299. * @param x2 Defines the x component of the end tangent in the bezier curve
  5300. * @param y2 Defines the y component of the end tangent in the bezier curve
  5301. */
  5302. constructor(
  5303. /** Defines the x component of the start tangent in the bezier curve */
  5304. x1?: number,
  5305. /** Defines the y component of the start tangent in the bezier curve */
  5306. y1?: number,
  5307. /** Defines the x component of the end tangent in the bezier curve */
  5308. x2?: number,
  5309. /** Defines the y component of the end tangent in the bezier curve */
  5310. y2?: number);
  5311. /** @hidden */
  5312. easeInCore(gradient: number): number;
  5313. }
  5314. }
  5315. declare module "babylonjs/Maths/math.color" {
  5316. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5317. /**
  5318. * Class used to hold a RBG color
  5319. */
  5320. export class Color3 {
  5321. /**
  5322. * Defines the red component (between 0 and 1, default is 0)
  5323. */
  5324. r: number;
  5325. /**
  5326. * Defines the green component (between 0 and 1, default is 0)
  5327. */
  5328. g: number;
  5329. /**
  5330. * Defines the blue component (between 0 and 1, default is 0)
  5331. */
  5332. b: number;
  5333. /**
  5334. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5335. * @param r defines the red component (between 0 and 1, default is 0)
  5336. * @param g defines the green component (between 0 and 1, default is 0)
  5337. * @param b defines the blue component (between 0 and 1, default is 0)
  5338. */
  5339. constructor(
  5340. /**
  5341. * Defines the red component (between 0 and 1, default is 0)
  5342. */
  5343. r?: number,
  5344. /**
  5345. * Defines the green component (between 0 and 1, default is 0)
  5346. */
  5347. g?: number,
  5348. /**
  5349. * Defines the blue component (between 0 and 1, default is 0)
  5350. */
  5351. b?: number);
  5352. /**
  5353. * Creates a string with the Color3 current values
  5354. * @returns the string representation of the Color3 object
  5355. */
  5356. toString(): string;
  5357. /**
  5358. * Returns the string "Color3"
  5359. * @returns "Color3"
  5360. */
  5361. getClassName(): string;
  5362. /**
  5363. * Compute the Color3 hash code
  5364. * @returns an unique number that can be used to hash Color3 objects
  5365. */
  5366. getHashCode(): number;
  5367. /**
  5368. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5369. * @param array defines the array where to store the r,g,b components
  5370. * @param index defines an optional index in the target array to define where to start storing values
  5371. * @returns the current Color3 object
  5372. */
  5373. toArray(array: FloatArray, index?: number): Color3;
  5374. /**
  5375. * Returns a new Color4 object from the current Color3 and the given alpha
  5376. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5377. * @returns a new Color4 object
  5378. */
  5379. toColor4(alpha?: number): Color4;
  5380. /**
  5381. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5382. * @returns the new array
  5383. */
  5384. asArray(): number[];
  5385. /**
  5386. * Returns the luminance value
  5387. * @returns a float value
  5388. */
  5389. toLuminance(): number;
  5390. /**
  5391. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5392. * @param otherColor defines the second operand
  5393. * @returns the new Color3 object
  5394. */
  5395. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5396. /**
  5397. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5398. * @param otherColor defines the second operand
  5399. * @param result defines the Color3 object where to store the result
  5400. * @returns the current Color3
  5401. */
  5402. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5403. /**
  5404. * Determines equality between Color3 objects
  5405. * @param otherColor defines the second operand
  5406. * @returns true if the rgb values are equal to the given ones
  5407. */
  5408. equals(otherColor: DeepImmutable<Color3>): boolean;
  5409. /**
  5410. * Determines equality between the current Color3 object and a set of r,b,g values
  5411. * @param r defines the red component to check
  5412. * @param g defines the green component to check
  5413. * @param b defines the blue component to check
  5414. * @returns true if the rgb values are equal to the given ones
  5415. */
  5416. equalsFloats(r: number, g: number, b: number): boolean;
  5417. /**
  5418. * Multiplies in place each rgb value by scale
  5419. * @param scale defines the scaling factor
  5420. * @returns the updated Color3
  5421. */
  5422. scale(scale: number): Color3;
  5423. /**
  5424. * Multiplies the rgb values by scale and stores the result into "result"
  5425. * @param scale defines the scaling factor
  5426. * @param result defines the Color3 object where to store the result
  5427. * @returns the unmodified current Color3
  5428. */
  5429. scaleToRef(scale: number, result: Color3): Color3;
  5430. /**
  5431. * Scale the current Color3 values by a factor and add the result to a given Color3
  5432. * @param scale defines the scale factor
  5433. * @param result defines color to store the result into
  5434. * @returns the unmodified current Color3
  5435. */
  5436. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5437. /**
  5438. * Clamps the rgb values by the min and max values and stores the result into "result"
  5439. * @param min defines minimum clamping value (default is 0)
  5440. * @param max defines maximum clamping value (default is 1)
  5441. * @param result defines color to store the result into
  5442. * @returns the original Color3
  5443. */
  5444. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5445. /**
  5446. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5447. * @param otherColor defines the second operand
  5448. * @returns the new Color3
  5449. */
  5450. add(otherColor: DeepImmutable<Color3>): Color3;
  5451. /**
  5452. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5453. * @param otherColor defines the second operand
  5454. * @param result defines Color3 object to store the result into
  5455. * @returns the unmodified current Color3
  5456. */
  5457. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5458. /**
  5459. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5460. * @param otherColor defines the second operand
  5461. * @returns the new Color3
  5462. */
  5463. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5464. /**
  5465. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5466. * @param otherColor defines the second operand
  5467. * @param result defines Color3 object to store the result into
  5468. * @returns the unmodified current Color3
  5469. */
  5470. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5471. /**
  5472. * Copy the current object
  5473. * @returns a new Color3 copied the current one
  5474. */
  5475. clone(): Color3;
  5476. /**
  5477. * Copies the rgb values from the source in the current Color3
  5478. * @param source defines the source Color3 object
  5479. * @returns the updated Color3 object
  5480. */
  5481. copyFrom(source: DeepImmutable<Color3>): Color3;
  5482. /**
  5483. * Updates the Color3 rgb values from the given floats
  5484. * @param r defines the red component to read from
  5485. * @param g defines the green component to read from
  5486. * @param b defines the blue component to read from
  5487. * @returns the current Color3 object
  5488. */
  5489. copyFromFloats(r: number, g: number, b: number): Color3;
  5490. /**
  5491. * Updates the Color3 rgb values from the given floats
  5492. * @param r defines the red component to read from
  5493. * @param g defines the green component to read from
  5494. * @param b defines the blue component to read from
  5495. * @returns the current Color3 object
  5496. */
  5497. set(r: number, g: number, b: number): Color3;
  5498. /**
  5499. * Compute the Color3 hexadecimal code as a string
  5500. * @returns a string containing the hexadecimal representation of the Color3 object
  5501. */
  5502. toHexString(): string;
  5503. /**
  5504. * Computes a new Color3 converted from the current one to linear space
  5505. * @returns a new Color3 object
  5506. */
  5507. toLinearSpace(): Color3;
  5508. /**
  5509. * Converts current color in rgb space to HSV values
  5510. * @returns a new color3 representing the HSV values
  5511. */
  5512. toHSV(): Color3;
  5513. /**
  5514. * Converts current color in rgb space to HSV values
  5515. * @param result defines the Color3 where to store the HSV values
  5516. */
  5517. toHSVToRef(result: Color3): void;
  5518. /**
  5519. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5520. * @param convertedColor defines the Color3 object where to store the linear space version
  5521. * @returns the unmodified Color3
  5522. */
  5523. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5524. /**
  5525. * Computes a new Color3 converted from the current one to gamma space
  5526. * @returns a new Color3 object
  5527. */
  5528. toGammaSpace(): Color3;
  5529. /**
  5530. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5531. * @param convertedColor defines the Color3 object where to store the gamma space version
  5532. * @returns the unmodified Color3
  5533. */
  5534. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5535. private static _BlackReadOnly;
  5536. /**
  5537. * Convert Hue, saturation and value to a Color3 (RGB)
  5538. * @param hue defines the hue
  5539. * @param saturation defines the saturation
  5540. * @param value defines the value
  5541. * @param result defines the Color3 where to store the RGB values
  5542. */
  5543. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5544. /**
  5545. * Creates a new Color3 from the string containing valid hexadecimal values
  5546. * @param hex defines a string containing valid hexadecimal values
  5547. * @returns a new Color3 object
  5548. */
  5549. static FromHexString(hex: string): Color3;
  5550. /**
  5551. * Creates a new Color3 from the starting index of the given array
  5552. * @param array defines the source array
  5553. * @param offset defines an offset in the source array
  5554. * @returns a new Color3 object
  5555. */
  5556. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5557. /**
  5558. * Creates a new Color3 from integer values (< 256)
  5559. * @param r defines the red component to read from (value between 0 and 255)
  5560. * @param g defines the green component to read from (value between 0 and 255)
  5561. * @param b defines the blue component to read from (value between 0 and 255)
  5562. * @returns a new Color3 object
  5563. */
  5564. static FromInts(r: number, g: number, b: number): Color3;
  5565. /**
  5566. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5567. * @param start defines the start Color3 value
  5568. * @param end defines the end Color3 value
  5569. * @param amount defines the gradient value between start and end
  5570. * @returns a new Color3 object
  5571. */
  5572. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5573. /**
  5574. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5575. * @param left defines the start value
  5576. * @param right defines the end value
  5577. * @param amount defines the gradient factor
  5578. * @param result defines the Color3 object where to store the result
  5579. */
  5580. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5581. /**
  5582. * Returns a Color3 value containing a red color
  5583. * @returns a new Color3 object
  5584. */
  5585. static Red(): Color3;
  5586. /**
  5587. * Returns a Color3 value containing a green color
  5588. * @returns a new Color3 object
  5589. */
  5590. static Green(): Color3;
  5591. /**
  5592. * Returns a Color3 value containing a blue color
  5593. * @returns a new Color3 object
  5594. */
  5595. static Blue(): Color3;
  5596. /**
  5597. * Returns a Color3 value containing a black color
  5598. * @returns a new Color3 object
  5599. */
  5600. static Black(): Color3;
  5601. /**
  5602. * Gets a Color3 value containing a black color that must not be updated
  5603. */
  5604. static get BlackReadOnly(): DeepImmutable<Color3>;
  5605. /**
  5606. * Returns a Color3 value containing a white color
  5607. * @returns a new Color3 object
  5608. */
  5609. static White(): Color3;
  5610. /**
  5611. * Returns a Color3 value containing a purple color
  5612. * @returns a new Color3 object
  5613. */
  5614. static Purple(): Color3;
  5615. /**
  5616. * Returns a Color3 value containing a magenta color
  5617. * @returns a new Color3 object
  5618. */
  5619. static Magenta(): Color3;
  5620. /**
  5621. * Returns a Color3 value containing a yellow color
  5622. * @returns a new Color3 object
  5623. */
  5624. static Yellow(): Color3;
  5625. /**
  5626. * Returns a Color3 value containing a gray color
  5627. * @returns a new Color3 object
  5628. */
  5629. static Gray(): Color3;
  5630. /**
  5631. * Returns a Color3 value containing a teal color
  5632. * @returns a new Color3 object
  5633. */
  5634. static Teal(): Color3;
  5635. /**
  5636. * Returns a Color3 value containing a random color
  5637. * @returns a new Color3 object
  5638. */
  5639. static Random(): Color3;
  5640. }
  5641. /**
  5642. * Class used to hold a RBGA color
  5643. */
  5644. export class Color4 {
  5645. /**
  5646. * Defines the red component (between 0 and 1, default is 0)
  5647. */
  5648. r: number;
  5649. /**
  5650. * Defines the green component (between 0 and 1, default is 0)
  5651. */
  5652. g: number;
  5653. /**
  5654. * Defines the blue component (between 0 and 1, default is 0)
  5655. */
  5656. b: number;
  5657. /**
  5658. * Defines the alpha component (between 0 and 1, default is 1)
  5659. */
  5660. a: number;
  5661. /**
  5662. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5663. * @param r defines the red component (between 0 and 1, default is 0)
  5664. * @param g defines the green component (between 0 and 1, default is 0)
  5665. * @param b defines the blue component (between 0 and 1, default is 0)
  5666. * @param a defines the alpha component (between 0 and 1, default is 1)
  5667. */
  5668. constructor(
  5669. /**
  5670. * Defines the red component (between 0 and 1, default is 0)
  5671. */
  5672. r?: number,
  5673. /**
  5674. * Defines the green component (between 0 and 1, default is 0)
  5675. */
  5676. g?: number,
  5677. /**
  5678. * Defines the blue component (between 0 and 1, default is 0)
  5679. */
  5680. b?: number,
  5681. /**
  5682. * Defines the alpha component (between 0 and 1, default is 1)
  5683. */
  5684. a?: number);
  5685. /**
  5686. * Adds in place the given Color4 values to the current Color4 object
  5687. * @param right defines the second operand
  5688. * @returns the current updated Color4 object
  5689. */
  5690. addInPlace(right: DeepImmutable<Color4>): Color4;
  5691. /**
  5692. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5693. * @returns the new array
  5694. */
  5695. asArray(): number[];
  5696. /**
  5697. * Stores from the starting index in the given array the Color4 successive values
  5698. * @param array defines the array where to store the r,g,b components
  5699. * @param index defines an optional index in the target array to define where to start storing values
  5700. * @returns the current Color4 object
  5701. */
  5702. toArray(array: number[], index?: number): Color4;
  5703. /**
  5704. * Determines equality between Color4 objects
  5705. * @param otherColor defines the second operand
  5706. * @returns true if the rgba values are equal to the given ones
  5707. */
  5708. equals(otherColor: DeepImmutable<Color4>): boolean;
  5709. /**
  5710. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5711. * @param right defines the second operand
  5712. * @returns a new Color4 object
  5713. */
  5714. add(right: DeepImmutable<Color4>): Color4;
  5715. /**
  5716. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5717. * @param right defines the second operand
  5718. * @returns a new Color4 object
  5719. */
  5720. subtract(right: DeepImmutable<Color4>): Color4;
  5721. /**
  5722. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5723. * @param right defines the second operand
  5724. * @param result defines the Color4 object where to store the result
  5725. * @returns the current Color4 object
  5726. */
  5727. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5728. /**
  5729. * Creates a new Color4 with the current Color4 values multiplied by scale
  5730. * @param scale defines the scaling factor to apply
  5731. * @returns a new Color4 object
  5732. */
  5733. scale(scale: number): Color4;
  5734. /**
  5735. * Multiplies the current Color4 values by scale and stores the result in "result"
  5736. * @param scale defines the scaling factor to apply
  5737. * @param result defines the Color4 object where to store the result
  5738. * @returns the current unmodified Color4
  5739. */
  5740. scaleToRef(scale: number, result: Color4): Color4;
  5741. /**
  5742. * Scale the current Color4 values by a factor and add the result to a given Color4
  5743. * @param scale defines the scale factor
  5744. * @param result defines the Color4 object where to store the result
  5745. * @returns the unmodified current Color4
  5746. */
  5747. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5748. /**
  5749. * Clamps the rgb values by the min and max values and stores the result into "result"
  5750. * @param min defines minimum clamping value (default is 0)
  5751. * @param max defines maximum clamping value (default is 1)
  5752. * @param result defines color to store the result into.
  5753. * @returns the cuurent Color4
  5754. */
  5755. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5756. /**
  5757. * Multipy an Color4 value by another and return a new Color4 object
  5758. * @param color defines the Color4 value to multiply by
  5759. * @returns a new Color4 object
  5760. */
  5761. multiply(color: Color4): Color4;
  5762. /**
  5763. * Multipy a Color4 value by another and push the result in a reference value
  5764. * @param color defines the Color4 value to multiply by
  5765. * @param result defines the Color4 to fill the result in
  5766. * @returns the result Color4
  5767. */
  5768. multiplyToRef(color: Color4, result: Color4): Color4;
  5769. /**
  5770. * Creates a string with the Color4 current values
  5771. * @returns the string representation of the Color4 object
  5772. */
  5773. toString(): string;
  5774. /**
  5775. * Returns the string "Color4"
  5776. * @returns "Color4"
  5777. */
  5778. getClassName(): string;
  5779. /**
  5780. * Compute the Color4 hash code
  5781. * @returns an unique number that can be used to hash Color4 objects
  5782. */
  5783. getHashCode(): number;
  5784. /**
  5785. * Creates a new Color4 copied from the current one
  5786. * @returns a new Color4 object
  5787. */
  5788. clone(): Color4;
  5789. /**
  5790. * Copies the given Color4 values into the current one
  5791. * @param source defines the source Color4 object
  5792. * @returns the current updated Color4 object
  5793. */
  5794. copyFrom(source: Color4): Color4;
  5795. /**
  5796. * Copies the given float values into the current one
  5797. * @param r defines the red component to read from
  5798. * @param g defines the green component to read from
  5799. * @param b defines the blue component to read from
  5800. * @param a defines the alpha component to read from
  5801. * @returns the current updated Color4 object
  5802. */
  5803. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5804. /**
  5805. * Copies the given float values into the current one
  5806. * @param r defines the red component to read from
  5807. * @param g defines the green component to read from
  5808. * @param b defines the blue component to read from
  5809. * @param a defines the alpha component to read from
  5810. * @returns the current updated Color4 object
  5811. */
  5812. set(r: number, g: number, b: number, a: number): Color4;
  5813. /**
  5814. * Compute the Color4 hexadecimal code as a string
  5815. * @returns a string containing the hexadecimal representation of the Color4 object
  5816. */
  5817. toHexString(): string;
  5818. /**
  5819. * Computes a new Color4 converted from the current one to linear space
  5820. * @returns a new Color4 object
  5821. */
  5822. toLinearSpace(): Color4;
  5823. /**
  5824. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5825. * @param convertedColor defines the Color4 object where to store the linear space version
  5826. * @returns the unmodified Color4
  5827. */
  5828. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5829. /**
  5830. * Computes a new Color4 converted from the current one to gamma space
  5831. * @returns a new Color4 object
  5832. */
  5833. toGammaSpace(): Color4;
  5834. /**
  5835. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5836. * @param convertedColor defines the Color4 object where to store the gamma space version
  5837. * @returns the unmodified Color4
  5838. */
  5839. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5840. /**
  5841. * Creates a new Color4 from the string containing valid hexadecimal values
  5842. * @param hex defines a string containing valid hexadecimal values
  5843. * @returns a new Color4 object
  5844. */
  5845. static FromHexString(hex: string): Color4;
  5846. /**
  5847. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5848. * @param left defines the start value
  5849. * @param right defines the end value
  5850. * @param amount defines the gradient factor
  5851. * @returns a new Color4 object
  5852. */
  5853. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5854. /**
  5855. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5856. * @param left defines the start value
  5857. * @param right defines the end value
  5858. * @param amount defines the gradient factor
  5859. * @param result defines the Color4 object where to store data
  5860. */
  5861. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5862. /**
  5863. * Creates a new Color4 from a Color3 and an alpha value
  5864. * @param color3 defines the source Color3 to read from
  5865. * @param alpha defines the alpha component (1.0 by default)
  5866. * @returns a new Color4 object
  5867. */
  5868. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5869. /**
  5870. * Creates a new Color4 from the starting index element of the given array
  5871. * @param array defines the source array to read from
  5872. * @param offset defines the offset in the source array
  5873. * @returns a new Color4 object
  5874. */
  5875. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5876. /**
  5877. * Creates a new Color3 from integer values (< 256)
  5878. * @param r defines the red component to read from (value between 0 and 255)
  5879. * @param g defines the green component to read from (value between 0 and 255)
  5880. * @param b defines the blue component to read from (value between 0 and 255)
  5881. * @param a defines the alpha component to read from (value between 0 and 255)
  5882. * @returns a new Color3 object
  5883. */
  5884. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5885. /**
  5886. * Check the content of a given array and convert it to an array containing RGBA data
  5887. * If the original array was already containing count * 4 values then it is returned directly
  5888. * @param colors defines the array to check
  5889. * @param count defines the number of RGBA data to expect
  5890. * @returns an array containing count * 4 values (RGBA)
  5891. */
  5892. static CheckColors4(colors: number[], count: number): number[];
  5893. }
  5894. /**
  5895. * @hidden
  5896. */
  5897. export class TmpColors {
  5898. static Color3: Color3[];
  5899. static Color4: Color4[];
  5900. }
  5901. }
  5902. declare module "babylonjs/Animations/animationKey" {
  5903. /**
  5904. * Defines an interface which represents an animation key frame
  5905. */
  5906. export interface IAnimationKey {
  5907. /**
  5908. * Frame of the key frame
  5909. */
  5910. frame: number;
  5911. /**
  5912. * Value at the specifies key frame
  5913. */
  5914. value: any;
  5915. /**
  5916. * The input tangent for the cubic hermite spline
  5917. */
  5918. inTangent?: any;
  5919. /**
  5920. * The output tangent for the cubic hermite spline
  5921. */
  5922. outTangent?: any;
  5923. /**
  5924. * The animation interpolation type
  5925. */
  5926. interpolation?: AnimationKeyInterpolation;
  5927. }
  5928. /**
  5929. * Enum for the animation key frame interpolation type
  5930. */
  5931. export enum AnimationKeyInterpolation {
  5932. /**
  5933. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5934. */
  5935. STEP = 1
  5936. }
  5937. }
  5938. declare module "babylonjs/Animations/animationRange" {
  5939. /**
  5940. * Represents the range of an animation
  5941. */
  5942. export class AnimationRange {
  5943. /**The name of the animation range**/
  5944. name: string;
  5945. /**The starting frame of the animation */
  5946. from: number;
  5947. /**The ending frame of the animation*/
  5948. to: number;
  5949. /**
  5950. * Initializes the range of an animation
  5951. * @param name The name of the animation range
  5952. * @param from The starting frame of the animation
  5953. * @param to The ending frame of the animation
  5954. */
  5955. constructor(
  5956. /**The name of the animation range**/
  5957. name: string,
  5958. /**The starting frame of the animation */
  5959. from: number,
  5960. /**The ending frame of the animation*/
  5961. to: number);
  5962. /**
  5963. * Makes a copy of the animation range
  5964. * @returns A copy of the animation range
  5965. */
  5966. clone(): AnimationRange;
  5967. }
  5968. }
  5969. declare module "babylonjs/Animations/animationEvent" {
  5970. /**
  5971. * Composed of a frame, and an action function
  5972. */
  5973. export class AnimationEvent {
  5974. /** The frame for which the event is triggered **/
  5975. frame: number;
  5976. /** The event to perform when triggered **/
  5977. action: (currentFrame: number) => void;
  5978. /** Specifies if the event should be triggered only once**/
  5979. onlyOnce?: boolean | undefined;
  5980. /**
  5981. * Specifies if the animation event is done
  5982. */
  5983. isDone: boolean;
  5984. /**
  5985. * Initializes the animation event
  5986. * @param frame The frame for which the event is triggered
  5987. * @param action The event to perform when triggered
  5988. * @param onlyOnce Specifies if the event should be triggered only once
  5989. */
  5990. constructor(
  5991. /** The frame for which the event is triggered **/
  5992. frame: number,
  5993. /** The event to perform when triggered **/
  5994. action: (currentFrame: number) => void,
  5995. /** Specifies if the event should be triggered only once**/
  5996. onlyOnce?: boolean | undefined);
  5997. /** @hidden */
  5998. _clone(): AnimationEvent;
  5999. }
  6000. }
  6001. declare module "babylonjs/Behaviors/behavior" {
  6002. import { Nullable } from "babylonjs/types";
  6003. /**
  6004. * Interface used to define a behavior
  6005. */
  6006. export interface Behavior<T> {
  6007. /** gets or sets behavior's name */
  6008. name: string;
  6009. /**
  6010. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6011. */
  6012. init(): void;
  6013. /**
  6014. * Called when the behavior is attached to a target
  6015. * @param target defines the target where the behavior is attached to
  6016. */
  6017. attach(target: T): void;
  6018. /**
  6019. * Called when the behavior is detached from its target
  6020. */
  6021. detach(): void;
  6022. }
  6023. /**
  6024. * Interface implemented by classes supporting behaviors
  6025. */
  6026. export interface IBehaviorAware<T> {
  6027. /**
  6028. * Attach a behavior
  6029. * @param behavior defines the behavior to attach
  6030. * @returns the current host
  6031. */
  6032. addBehavior(behavior: Behavior<T>): T;
  6033. /**
  6034. * Remove a behavior from the current object
  6035. * @param behavior defines the behavior to detach
  6036. * @returns the current host
  6037. */
  6038. removeBehavior(behavior: Behavior<T>): T;
  6039. /**
  6040. * Gets a behavior using its name to search
  6041. * @param name defines the name to search
  6042. * @returns the behavior or null if not found
  6043. */
  6044. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6045. }
  6046. }
  6047. declare module "babylonjs/Misc/smartArray" {
  6048. /**
  6049. * Defines an array and its length.
  6050. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6051. */
  6052. export interface ISmartArrayLike<T> {
  6053. /**
  6054. * The data of the array.
  6055. */
  6056. data: Array<T>;
  6057. /**
  6058. * The active length of the array.
  6059. */
  6060. length: number;
  6061. }
  6062. /**
  6063. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6064. */
  6065. export class SmartArray<T> implements ISmartArrayLike<T> {
  6066. /**
  6067. * The full set of data from the array.
  6068. */
  6069. data: Array<T>;
  6070. /**
  6071. * The active length of the array.
  6072. */
  6073. length: number;
  6074. protected _id: number;
  6075. /**
  6076. * Instantiates a Smart Array.
  6077. * @param capacity defines the default capacity of the array.
  6078. */
  6079. constructor(capacity: number);
  6080. /**
  6081. * Pushes a value at the end of the active data.
  6082. * @param value defines the object to push in the array.
  6083. */
  6084. push(value: T): void;
  6085. /**
  6086. * Iterates over the active data and apply the lambda to them.
  6087. * @param func defines the action to apply on each value.
  6088. */
  6089. forEach(func: (content: T) => void): void;
  6090. /**
  6091. * Sorts the full sets of data.
  6092. * @param compareFn defines the comparison function to apply.
  6093. */
  6094. sort(compareFn: (a: T, b: T) => number): void;
  6095. /**
  6096. * Resets the active data to an empty array.
  6097. */
  6098. reset(): void;
  6099. /**
  6100. * Releases all the data from the array as well as the array.
  6101. */
  6102. dispose(): void;
  6103. /**
  6104. * Concats the active data with a given array.
  6105. * @param array defines the data to concatenate with.
  6106. */
  6107. concat(array: any): void;
  6108. /**
  6109. * Returns the position of a value in the active data.
  6110. * @param value defines the value to find the index for
  6111. * @returns the index if found in the active data otherwise -1
  6112. */
  6113. indexOf(value: T): number;
  6114. /**
  6115. * Returns whether an element is part of the active data.
  6116. * @param value defines the value to look for
  6117. * @returns true if found in the active data otherwise false
  6118. */
  6119. contains(value: T): boolean;
  6120. private static _GlobalId;
  6121. }
  6122. /**
  6123. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6124. * The data in this array can only be present once
  6125. */
  6126. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6127. private _duplicateId;
  6128. /**
  6129. * Pushes a value at the end of the active data.
  6130. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6131. * @param value defines the object to push in the array.
  6132. */
  6133. push(value: T): void;
  6134. /**
  6135. * Pushes a value at the end of the active data.
  6136. * If the data is already present, it won t be added again
  6137. * @param value defines the object to push in the array.
  6138. * @returns true if added false if it was already present
  6139. */
  6140. pushNoDuplicate(value: T): boolean;
  6141. /**
  6142. * Resets the active data to an empty array.
  6143. */
  6144. reset(): void;
  6145. /**
  6146. * Concats the active data with a given array.
  6147. * This ensures no dupplicate will be present in the result.
  6148. * @param array defines the data to concatenate with.
  6149. */
  6150. concatWithNoDuplicate(array: any): void;
  6151. }
  6152. }
  6153. declare module "babylonjs/Cameras/cameraInputsManager" {
  6154. import { Nullable } from "babylonjs/types";
  6155. import { Camera } from "babylonjs/Cameras/camera";
  6156. /**
  6157. * @ignore
  6158. * This is a list of all the different input types that are available in the application.
  6159. * Fo instance: ArcRotateCameraGamepadInput...
  6160. */
  6161. export var CameraInputTypes: {};
  6162. /**
  6163. * This is the contract to implement in order to create a new input class.
  6164. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6165. */
  6166. export interface ICameraInput<TCamera extends Camera> {
  6167. /**
  6168. * Defines the camera the input is attached to.
  6169. */
  6170. camera: Nullable<TCamera>;
  6171. /**
  6172. * Gets the class name of the current intput.
  6173. * @returns the class name
  6174. */
  6175. getClassName(): string;
  6176. /**
  6177. * Get the friendly name associated with the input class.
  6178. * @returns the input friendly name
  6179. */
  6180. getSimpleName(): string;
  6181. /**
  6182. * Attach the input controls to a specific dom element to get the input from.
  6183. * @param element Defines the element the controls should be listened from
  6184. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6185. */
  6186. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6187. /**
  6188. * Detach the current controls from the specified dom element.
  6189. * @param element Defines the element to stop listening the inputs from
  6190. */
  6191. detachControl(element: Nullable<HTMLElement>): void;
  6192. /**
  6193. * Update the current camera state depending on the inputs that have been used this frame.
  6194. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6195. */
  6196. checkInputs?: () => void;
  6197. }
  6198. /**
  6199. * Represents a map of input types to input instance or input index to input instance.
  6200. */
  6201. export interface CameraInputsMap<TCamera extends Camera> {
  6202. /**
  6203. * Accessor to the input by input type.
  6204. */
  6205. [name: string]: ICameraInput<TCamera>;
  6206. /**
  6207. * Accessor to the input by input index.
  6208. */
  6209. [idx: number]: ICameraInput<TCamera>;
  6210. }
  6211. /**
  6212. * This represents the input manager used within a camera.
  6213. * It helps dealing with all the different kind of input attached to a camera.
  6214. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6215. */
  6216. export class CameraInputsManager<TCamera extends Camera> {
  6217. /**
  6218. * Defines the list of inputs attahed to the camera.
  6219. */
  6220. attached: CameraInputsMap<TCamera>;
  6221. /**
  6222. * Defines the dom element the camera is collecting inputs from.
  6223. * This is null if the controls have not been attached.
  6224. */
  6225. attachedElement: Nullable<HTMLElement>;
  6226. /**
  6227. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6228. */
  6229. noPreventDefault: boolean;
  6230. /**
  6231. * Defined the camera the input manager belongs to.
  6232. */
  6233. camera: TCamera;
  6234. /**
  6235. * Update the current camera state depending on the inputs that have been used this frame.
  6236. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6237. */
  6238. checkInputs: () => void;
  6239. /**
  6240. * Instantiate a new Camera Input Manager.
  6241. * @param camera Defines the camera the input manager blongs to
  6242. */
  6243. constructor(camera: TCamera);
  6244. /**
  6245. * Add an input method to a camera
  6246. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6247. * @param input camera input method
  6248. */
  6249. add(input: ICameraInput<TCamera>): void;
  6250. /**
  6251. * Remove a specific input method from a camera
  6252. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6253. * @param inputToRemove camera input method
  6254. */
  6255. remove(inputToRemove: ICameraInput<TCamera>): void;
  6256. /**
  6257. * Remove a specific input type from a camera
  6258. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6259. * @param inputType the type of the input to remove
  6260. */
  6261. removeByType(inputType: string): void;
  6262. private _addCheckInputs;
  6263. /**
  6264. * Attach the input controls to the currently attached dom element to listen the events from.
  6265. * @param input Defines the input to attach
  6266. */
  6267. attachInput(input: ICameraInput<TCamera>): void;
  6268. /**
  6269. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6270. * @param element Defines the dom element to collect the events from
  6271. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6272. */
  6273. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6274. /**
  6275. * Detach the current manager inputs controls from a specific dom element.
  6276. * @param element Defines the dom element to collect the events from
  6277. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6278. */
  6279. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6280. /**
  6281. * Rebuild the dynamic inputCheck function from the current list of
  6282. * defined inputs in the manager.
  6283. */
  6284. rebuildInputCheck(): void;
  6285. /**
  6286. * Remove all attached input methods from a camera
  6287. */
  6288. clear(): void;
  6289. /**
  6290. * Serialize the current input manager attached to a camera.
  6291. * This ensures than once parsed,
  6292. * the input associated to the camera will be identical to the current ones
  6293. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6294. */
  6295. serialize(serializedCamera: any): void;
  6296. /**
  6297. * Parses an input manager serialized JSON to restore the previous list of inputs
  6298. * and states associated to a camera.
  6299. * @param parsedCamera Defines the JSON to parse
  6300. */
  6301. parse(parsedCamera: any): void;
  6302. }
  6303. }
  6304. declare module "babylonjs/Meshes/buffer" {
  6305. import { Nullable, DataArray } from "babylonjs/types";
  6306. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6307. /**
  6308. * Class used to store data that will be store in GPU memory
  6309. */
  6310. export class Buffer {
  6311. private _engine;
  6312. private _buffer;
  6313. /** @hidden */
  6314. _data: Nullable<DataArray>;
  6315. private _updatable;
  6316. private _instanced;
  6317. private _divisor;
  6318. /**
  6319. * Gets the byte stride.
  6320. */
  6321. readonly byteStride: number;
  6322. /**
  6323. * Constructor
  6324. * @param engine the engine
  6325. * @param data the data to use for this buffer
  6326. * @param updatable whether the data is updatable
  6327. * @param stride the stride (optional)
  6328. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6329. * @param instanced whether the buffer is instanced (optional)
  6330. * @param useBytes set to true if the stride in in bytes (optional)
  6331. * @param divisor sets an optional divisor for instances (1 by default)
  6332. */
  6333. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6334. /**
  6335. * Create a new VertexBuffer based on the current buffer
  6336. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6337. * @param offset defines offset in the buffer (0 by default)
  6338. * @param size defines the size in floats of attributes (position is 3 for instance)
  6339. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6340. * @param instanced defines if the vertex buffer contains indexed data
  6341. * @param useBytes defines if the offset and stride are in bytes *
  6342. * @param divisor sets an optional divisor for instances (1 by default)
  6343. * @returns the new vertex buffer
  6344. */
  6345. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6346. /**
  6347. * Gets a boolean indicating if the Buffer is updatable?
  6348. * @returns true if the buffer is updatable
  6349. */
  6350. isUpdatable(): boolean;
  6351. /**
  6352. * Gets current buffer's data
  6353. * @returns a DataArray or null
  6354. */
  6355. getData(): Nullable<DataArray>;
  6356. /**
  6357. * Gets underlying native buffer
  6358. * @returns underlying native buffer
  6359. */
  6360. getBuffer(): Nullable<DataBuffer>;
  6361. /**
  6362. * Gets the stride in float32 units (i.e. byte stride / 4).
  6363. * May not be an integer if the byte stride is not divisible by 4.
  6364. * @returns the stride in float32 units
  6365. * @deprecated Please use byteStride instead.
  6366. */
  6367. getStrideSize(): number;
  6368. /**
  6369. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6370. * @param data defines the data to store
  6371. */
  6372. create(data?: Nullable<DataArray>): void;
  6373. /** @hidden */
  6374. _rebuild(): void;
  6375. /**
  6376. * Update current buffer data
  6377. * @param data defines the data to store
  6378. */
  6379. update(data: DataArray): void;
  6380. /**
  6381. * Updates the data directly.
  6382. * @param data the new data
  6383. * @param offset the new offset
  6384. * @param vertexCount the vertex count (optional)
  6385. * @param useBytes set to true if the offset is in bytes
  6386. */
  6387. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6388. /**
  6389. * Release all resources
  6390. */
  6391. dispose(): void;
  6392. }
  6393. /**
  6394. * Specialized buffer used to store vertex data
  6395. */
  6396. export class VertexBuffer {
  6397. /** @hidden */
  6398. _buffer: Buffer;
  6399. private _kind;
  6400. private _size;
  6401. private _ownsBuffer;
  6402. private _instanced;
  6403. private _instanceDivisor;
  6404. /**
  6405. * The byte type.
  6406. */
  6407. static readonly BYTE: number;
  6408. /**
  6409. * The unsigned byte type.
  6410. */
  6411. static readonly UNSIGNED_BYTE: number;
  6412. /**
  6413. * The short type.
  6414. */
  6415. static readonly SHORT: number;
  6416. /**
  6417. * The unsigned short type.
  6418. */
  6419. static readonly UNSIGNED_SHORT: number;
  6420. /**
  6421. * The integer type.
  6422. */
  6423. static readonly INT: number;
  6424. /**
  6425. * The unsigned integer type.
  6426. */
  6427. static readonly UNSIGNED_INT: number;
  6428. /**
  6429. * The float type.
  6430. */
  6431. static readonly FLOAT: number;
  6432. /**
  6433. * Gets or sets the instance divisor when in instanced mode
  6434. */
  6435. get instanceDivisor(): number;
  6436. set instanceDivisor(value: number);
  6437. /**
  6438. * Gets the byte stride.
  6439. */
  6440. readonly byteStride: number;
  6441. /**
  6442. * Gets the byte offset.
  6443. */
  6444. readonly byteOffset: number;
  6445. /**
  6446. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6447. */
  6448. readonly normalized: boolean;
  6449. /**
  6450. * Gets the data type of each component in the array.
  6451. */
  6452. readonly type: number;
  6453. /**
  6454. * Constructor
  6455. * @param engine the engine
  6456. * @param data the data to use for this vertex buffer
  6457. * @param kind the vertex buffer kind
  6458. * @param updatable whether the data is updatable
  6459. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6460. * @param stride the stride (optional)
  6461. * @param instanced whether the buffer is instanced (optional)
  6462. * @param offset the offset of the data (optional)
  6463. * @param size the number of components (optional)
  6464. * @param type the type of the component (optional)
  6465. * @param normalized whether the data contains normalized data (optional)
  6466. * @param useBytes set to true if stride and offset are in bytes (optional)
  6467. * @param divisor defines the instance divisor to use (1 by default)
  6468. */
  6469. 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);
  6470. /** @hidden */
  6471. _rebuild(): void;
  6472. /**
  6473. * Returns the kind of the VertexBuffer (string)
  6474. * @returns a string
  6475. */
  6476. getKind(): string;
  6477. /**
  6478. * Gets a boolean indicating if the VertexBuffer is updatable?
  6479. * @returns true if the buffer is updatable
  6480. */
  6481. isUpdatable(): boolean;
  6482. /**
  6483. * Gets current buffer's data
  6484. * @returns a DataArray or null
  6485. */
  6486. getData(): Nullable<DataArray>;
  6487. /**
  6488. * Gets underlying native buffer
  6489. * @returns underlying native buffer
  6490. */
  6491. getBuffer(): Nullable<DataBuffer>;
  6492. /**
  6493. * Gets the stride in float32 units (i.e. byte stride / 4).
  6494. * May not be an integer if the byte stride is not divisible by 4.
  6495. * @returns the stride in float32 units
  6496. * @deprecated Please use byteStride instead.
  6497. */
  6498. getStrideSize(): number;
  6499. /**
  6500. * Returns the offset as a multiple of the type byte length.
  6501. * @returns the offset in bytes
  6502. * @deprecated Please use byteOffset instead.
  6503. */
  6504. getOffset(): number;
  6505. /**
  6506. * Returns the number of components per vertex attribute (integer)
  6507. * @returns the size in float
  6508. */
  6509. getSize(): number;
  6510. /**
  6511. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6512. * @returns true if this buffer is instanced
  6513. */
  6514. getIsInstanced(): boolean;
  6515. /**
  6516. * Returns the instancing divisor, zero for non-instanced (integer).
  6517. * @returns a number
  6518. */
  6519. getInstanceDivisor(): number;
  6520. /**
  6521. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6522. * @param data defines the data to store
  6523. */
  6524. create(data?: DataArray): void;
  6525. /**
  6526. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6527. * This function will create a new buffer if the current one is not updatable
  6528. * @param data defines the data to store
  6529. */
  6530. update(data: DataArray): void;
  6531. /**
  6532. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6533. * Returns the directly updated WebGLBuffer.
  6534. * @param data the new data
  6535. * @param offset the new offset
  6536. * @param useBytes set to true if the offset is in bytes
  6537. */
  6538. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6539. /**
  6540. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6541. */
  6542. dispose(): void;
  6543. /**
  6544. * Enumerates each value of this vertex buffer as numbers.
  6545. * @param count the number of values to enumerate
  6546. * @param callback the callback function called for each value
  6547. */
  6548. forEach(count: number, callback: (value: number, index: number) => void): void;
  6549. /**
  6550. * Positions
  6551. */
  6552. static readonly PositionKind: string;
  6553. /**
  6554. * Normals
  6555. */
  6556. static readonly NormalKind: string;
  6557. /**
  6558. * Tangents
  6559. */
  6560. static readonly TangentKind: string;
  6561. /**
  6562. * Texture coordinates
  6563. */
  6564. static readonly UVKind: string;
  6565. /**
  6566. * Texture coordinates 2
  6567. */
  6568. static readonly UV2Kind: string;
  6569. /**
  6570. * Texture coordinates 3
  6571. */
  6572. static readonly UV3Kind: string;
  6573. /**
  6574. * Texture coordinates 4
  6575. */
  6576. static readonly UV4Kind: string;
  6577. /**
  6578. * Texture coordinates 5
  6579. */
  6580. static readonly UV5Kind: string;
  6581. /**
  6582. * Texture coordinates 6
  6583. */
  6584. static readonly UV6Kind: string;
  6585. /**
  6586. * Colors
  6587. */
  6588. static readonly ColorKind: string;
  6589. /**
  6590. * Matrix indices (for bones)
  6591. */
  6592. static readonly MatricesIndicesKind: string;
  6593. /**
  6594. * Matrix weights (for bones)
  6595. */
  6596. static readonly MatricesWeightsKind: string;
  6597. /**
  6598. * Additional matrix indices (for bones)
  6599. */
  6600. static readonly MatricesIndicesExtraKind: string;
  6601. /**
  6602. * Additional matrix weights (for bones)
  6603. */
  6604. static readonly MatricesWeightsExtraKind: string;
  6605. /**
  6606. * Deduces the stride given a kind.
  6607. * @param kind The kind string to deduce
  6608. * @returns The deduced stride
  6609. */
  6610. static DeduceStride(kind: string): number;
  6611. /**
  6612. * Gets the byte length of the given type.
  6613. * @param type the type
  6614. * @returns the number of bytes
  6615. */
  6616. static GetTypeByteLength(type: number): number;
  6617. /**
  6618. * Enumerates each value of the given parameters as numbers.
  6619. * @param data the data to enumerate
  6620. * @param byteOffset the byte offset of the data
  6621. * @param byteStride the byte stride of the data
  6622. * @param componentCount the number of components per element
  6623. * @param componentType the type of the component
  6624. * @param count the number of values to enumerate
  6625. * @param normalized whether the data is normalized
  6626. * @param callback the callback function called for each value
  6627. */
  6628. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6629. private static _GetFloatValue;
  6630. }
  6631. }
  6632. declare module "babylonjs/Collisions/intersectionInfo" {
  6633. import { Nullable } from "babylonjs/types";
  6634. /**
  6635. * @hidden
  6636. */
  6637. export class IntersectionInfo {
  6638. bu: Nullable<number>;
  6639. bv: Nullable<number>;
  6640. distance: number;
  6641. faceId: number;
  6642. subMeshId: number;
  6643. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6644. }
  6645. }
  6646. declare module "babylonjs/Maths/math.plane" {
  6647. import { DeepImmutable } from "babylonjs/types";
  6648. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6649. /**
  6650. * Represens a plane by the equation ax + by + cz + d = 0
  6651. */
  6652. export class Plane {
  6653. private static _TmpMatrix;
  6654. /**
  6655. * Normal of the plane (a,b,c)
  6656. */
  6657. normal: Vector3;
  6658. /**
  6659. * d component of the plane
  6660. */
  6661. d: number;
  6662. /**
  6663. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6664. * @param a a component of the plane
  6665. * @param b b component of the plane
  6666. * @param c c component of the plane
  6667. * @param d d component of the plane
  6668. */
  6669. constructor(a: number, b: number, c: number, d: number);
  6670. /**
  6671. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6672. */
  6673. asArray(): number[];
  6674. /**
  6675. * @returns a new plane copied from the current Plane.
  6676. */
  6677. clone(): Plane;
  6678. /**
  6679. * @returns the string "Plane".
  6680. */
  6681. getClassName(): string;
  6682. /**
  6683. * @returns the Plane hash code.
  6684. */
  6685. getHashCode(): number;
  6686. /**
  6687. * Normalize the current Plane in place.
  6688. * @returns the updated Plane.
  6689. */
  6690. normalize(): Plane;
  6691. /**
  6692. * Applies a transformation the plane and returns the result
  6693. * @param transformation the transformation matrix to be applied to the plane
  6694. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6695. */
  6696. transform(transformation: DeepImmutable<Matrix>): Plane;
  6697. /**
  6698. * Calcualtte the dot product between the point and the plane normal
  6699. * @param point point to calculate the dot product with
  6700. * @returns the dot product (float) of the point coordinates and the plane normal.
  6701. */
  6702. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6703. /**
  6704. * Updates the current Plane from the plane defined by the three given points.
  6705. * @param point1 one of the points used to contruct the plane
  6706. * @param point2 one of the points used to contruct the plane
  6707. * @param point3 one of the points used to contruct the plane
  6708. * @returns the updated Plane.
  6709. */
  6710. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6711. /**
  6712. * Checks if the plane is facing a given direction
  6713. * @param direction the direction to check if the plane is facing
  6714. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6715. * @returns True is the vector "direction" is the same side than the plane normal.
  6716. */
  6717. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6718. /**
  6719. * Calculates the distance to a point
  6720. * @param point point to calculate distance to
  6721. * @returns the signed distance (float) from the given point to the Plane.
  6722. */
  6723. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6724. /**
  6725. * Creates a plane from an array
  6726. * @param array the array to create a plane from
  6727. * @returns a new Plane from the given array.
  6728. */
  6729. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6730. /**
  6731. * Creates a plane from three points
  6732. * @param point1 point used to create the plane
  6733. * @param point2 point used to create the plane
  6734. * @param point3 point used to create the plane
  6735. * @returns a new Plane defined by the three given points.
  6736. */
  6737. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6738. /**
  6739. * Creates a plane from an origin point and a normal
  6740. * @param origin origin of the plane to be constructed
  6741. * @param normal normal of the plane to be constructed
  6742. * @returns a new Plane the normal vector to this plane at the given origin point.
  6743. * Note : the vector "normal" is updated because normalized.
  6744. */
  6745. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6746. /**
  6747. * Calculates the distance from a plane and a point
  6748. * @param origin origin of the plane to be constructed
  6749. * @param normal normal of the plane to be constructed
  6750. * @param point point to calculate distance to
  6751. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6752. */
  6753. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6754. }
  6755. }
  6756. declare module "babylonjs/Culling/boundingSphere" {
  6757. import { DeepImmutable } from "babylonjs/types";
  6758. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6759. import { Plane } from "babylonjs/Maths/math.plane";
  6760. /**
  6761. * Class used to store bounding sphere information
  6762. */
  6763. export class BoundingSphere {
  6764. /**
  6765. * Gets the center of the bounding sphere in local space
  6766. */
  6767. readonly center: Vector3;
  6768. /**
  6769. * Radius of the bounding sphere in local space
  6770. */
  6771. radius: number;
  6772. /**
  6773. * Gets the center of the bounding sphere in world space
  6774. */
  6775. readonly centerWorld: Vector3;
  6776. /**
  6777. * Radius of the bounding sphere in world space
  6778. */
  6779. radiusWorld: number;
  6780. /**
  6781. * Gets the minimum vector in local space
  6782. */
  6783. readonly minimum: Vector3;
  6784. /**
  6785. * Gets the maximum vector in local space
  6786. */
  6787. readonly maximum: Vector3;
  6788. private _worldMatrix;
  6789. private static readonly TmpVector3;
  6790. /**
  6791. * Creates a new bounding sphere
  6792. * @param min defines the minimum vector (in local space)
  6793. * @param max defines the maximum vector (in local space)
  6794. * @param worldMatrix defines the new world matrix
  6795. */
  6796. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6797. /**
  6798. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6799. * @param min defines the new minimum vector (in local space)
  6800. * @param max defines the new maximum vector (in local space)
  6801. * @param worldMatrix defines the new world matrix
  6802. */
  6803. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6804. /**
  6805. * Scale the current bounding sphere by applying a scale factor
  6806. * @param factor defines the scale factor to apply
  6807. * @returns the current bounding box
  6808. */
  6809. scale(factor: number): BoundingSphere;
  6810. /**
  6811. * Gets the world matrix of the bounding box
  6812. * @returns a matrix
  6813. */
  6814. getWorldMatrix(): DeepImmutable<Matrix>;
  6815. /** @hidden */
  6816. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6817. /**
  6818. * Tests if the bounding sphere is intersecting the frustum planes
  6819. * @param frustumPlanes defines the frustum planes to test
  6820. * @returns true if there is an intersection
  6821. */
  6822. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6823. /**
  6824. * Tests if the bounding sphere center is in between the frustum planes.
  6825. * Used for optimistic fast inclusion.
  6826. * @param frustumPlanes defines the frustum planes to test
  6827. * @returns true if the sphere center is in between the frustum planes
  6828. */
  6829. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6830. /**
  6831. * Tests if a point is inside the bounding sphere
  6832. * @param point defines the point to test
  6833. * @returns true if the point is inside the bounding sphere
  6834. */
  6835. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6836. /**
  6837. * Checks if two sphere intersct
  6838. * @param sphere0 sphere 0
  6839. * @param sphere1 sphere 1
  6840. * @returns true if the speres intersect
  6841. */
  6842. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6843. }
  6844. }
  6845. declare module "babylonjs/Culling/boundingBox" {
  6846. import { DeepImmutable } from "babylonjs/types";
  6847. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6848. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6849. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6850. import { Plane } from "babylonjs/Maths/math.plane";
  6851. /**
  6852. * Class used to store bounding box information
  6853. */
  6854. export class BoundingBox implements ICullable {
  6855. /**
  6856. * Gets the 8 vectors representing the bounding box in local space
  6857. */
  6858. readonly vectors: Vector3[];
  6859. /**
  6860. * Gets the center of the bounding box in local space
  6861. */
  6862. readonly center: Vector3;
  6863. /**
  6864. * Gets the center of the bounding box in world space
  6865. */
  6866. readonly centerWorld: Vector3;
  6867. /**
  6868. * Gets the extend size in local space
  6869. */
  6870. readonly extendSize: Vector3;
  6871. /**
  6872. * Gets the extend size in world space
  6873. */
  6874. readonly extendSizeWorld: Vector3;
  6875. /**
  6876. * Gets the OBB (object bounding box) directions
  6877. */
  6878. readonly directions: Vector3[];
  6879. /**
  6880. * Gets the 8 vectors representing the bounding box in world space
  6881. */
  6882. readonly vectorsWorld: Vector3[];
  6883. /**
  6884. * Gets the minimum vector in world space
  6885. */
  6886. readonly minimumWorld: Vector3;
  6887. /**
  6888. * Gets the maximum vector in world space
  6889. */
  6890. readonly maximumWorld: Vector3;
  6891. /**
  6892. * Gets the minimum vector in local space
  6893. */
  6894. readonly minimum: Vector3;
  6895. /**
  6896. * Gets the maximum vector in local space
  6897. */
  6898. readonly maximum: Vector3;
  6899. private _worldMatrix;
  6900. private static readonly TmpVector3;
  6901. /**
  6902. * @hidden
  6903. */
  6904. _tag: number;
  6905. /**
  6906. * Creates a new bounding box
  6907. * @param min defines the minimum vector (in local space)
  6908. * @param max defines the maximum vector (in local space)
  6909. * @param worldMatrix defines the new world matrix
  6910. */
  6911. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6912. /**
  6913. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6914. * @param min defines the new minimum vector (in local space)
  6915. * @param max defines the new maximum vector (in local space)
  6916. * @param worldMatrix defines the new world matrix
  6917. */
  6918. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6919. /**
  6920. * Scale the current bounding box by applying a scale factor
  6921. * @param factor defines the scale factor to apply
  6922. * @returns the current bounding box
  6923. */
  6924. scale(factor: number): BoundingBox;
  6925. /**
  6926. * Gets the world matrix of the bounding box
  6927. * @returns a matrix
  6928. */
  6929. getWorldMatrix(): DeepImmutable<Matrix>;
  6930. /** @hidden */
  6931. _update(world: DeepImmutable<Matrix>): void;
  6932. /**
  6933. * Tests if the bounding box is intersecting the frustum planes
  6934. * @param frustumPlanes defines the frustum planes to test
  6935. * @returns true if there is an intersection
  6936. */
  6937. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6938. /**
  6939. * Tests if the bounding box is entirely inside the frustum planes
  6940. * @param frustumPlanes defines the frustum planes to test
  6941. * @returns true if there is an inclusion
  6942. */
  6943. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6944. /**
  6945. * Tests if a point is inside the bounding box
  6946. * @param point defines the point to test
  6947. * @returns true if the point is inside the bounding box
  6948. */
  6949. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6950. /**
  6951. * Tests if the bounding box intersects with a bounding sphere
  6952. * @param sphere defines the sphere to test
  6953. * @returns true if there is an intersection
  6954. */
  6955. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6956. /**
  6957. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6958. * @param min defines the min vector to use
  6959. * @param max defines the max vector to use
  6960. * @returns true if there is an intersection
  6961. */
  6962. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6963. /**
  6964. * Tests if two bounding boxes are intersections
  6965. * @param box0 defines the first box to test
  6966. * @param box1 defines the second box to test
  6967. * @returns true if there is an intersection
  6968. */
  6969. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6970. /**
  6971. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6972. * @param minPoint defines the minimum vector of the bounding box
  6973. * @param maxPoint defines the maximum vector of the bounding box
  6974. * @param sphereCenter defines the sphere center
  6975. * @param sphereRadius defines the sphere radius
  6976. * @returns true if there is an intersection
  6977. */
  6978. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6979. /**
  6980. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6981. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6982. * @param frustumPlanes defines the frustum planes to test
  6983. * @return true if there is an inclusion
  6984. */
  6985. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6986. /**
  6987. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6988. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6989. * @param frustumPlanes defines the frustum planes to test
  6990. * @return true if there is an intersection
  6991. */
  6992. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6993. }
  6994. }
  6995. declare module "babylonjs/Collisions/collider" {
  6996. import { Nullable, IndicesArray } from "babylonjs/types";
  6997. import { Vector3 } from "babylonjs/Maths/math.vector";
  6998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6999. import { Plane } from "babylonjs/Maths/math.plane";
  7000. /** @hidden */
  7001. export class Collider {
  7002. /** Define if a collision was found */
  7003. collisionFound: boolean;
  7004. /**
  7005. * Define last intersection point in local space
  7006. */
  7007. intersectionPoint: Vector3;
  7008. /**
  7009. * Define last collided mesh
  7010. */
  7011. collidedMesh: Nullable<AbstractMesh>;
  7012. private _collisionPoint;
  7013. private _planeIntersectionPoint;
  7014. private _tempVector;
  7015. private _tempVector2;
  7016. private _tempVector3;
  7017. private _tempVector4;
  7018. private _edge;
  7019. private _baseToVertex;
  7020. private _destinationPoint;
  7021. private _slidePlaneNormal;
  7022. private _displacementVector;
  7023. /** @hidden */
  7024. _radius: Vector3;
  7025. /** @hidden */
  7026. _retry: number;
  7027. private _velocity;
  7028. private _basePoint;
  7029. private _epsilon;
  7030. /** @hidden */
  7031. _velocityWorldLength: number;
  7032. /** @hidden */
  7033. _basePointWorld: Vector3;
  7034. private _velocityWorld;
  7035. private _normalizedVelocity;
  7036. /** @hidden */
  7037. _initialVelocity: Vector3;
  7038. /** @hidden */
  7039. _initialPosition: Vector3;
  7040. private _nearestDistance;
  7041. private _collisionMask;
  7042. get collisionMask(): number;
  7043. set collisionMask(mask: number);
  7044. /**
  7045. * Gets the plane normal used to compute the sliding response (in local space)
  7046. */
  7047. get slidePlaneNormal(): Vector3;
  7048. /** @hidden */
  7049. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7050. /** @hidden */
  7051. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7052. /** @hidden */
  7053. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7054. /** @hidden */
  7055. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7056. /** @hidden */
  7057. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7058. /** @hidden */
  7059. _getResponse(pos: Vector3, vel: Vector3): void;
  7060. }
  7061. }
  7062. declare module "babylonjs/Culling/boundingInfo" {
  7063. import { DeepImmutable } from "babylonjs/types";
  7064. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7065. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7066. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7067. import { Plane } from "babylonjs/Maths/math.plane";
  7068. import { Collider } from "babylonjs/Collisions/collider";
  7069. /**
  7070. * Interface for cullable objects
  7071. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7072. */
  7073. export interface ICullable {
  7074. /**
  7075. * Checks if the object or part of the object is in the frustum
  7076. * @param frustumPlanes Camera near/planes
  7077. * @returns true if the object is in frustum otherwise false
  7078. */
  7079. isInFrustum(frustumPlanes: Plane[]): boolean;
  7080. /**
  7081. * Checks if a cullable object (mesh...) is in the camera frustum
  7082. * Unlike isInFrustum this cheks the full bounding box
  7083. * @param frustumPlanes Camera near/planes
  7084. * @returns true if the object is in frustum otherwise false
  7085. */
  7086. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7087. }
  7088. /**
  7089. * Info for a bounding data of a mesh
  7090. */
  7091. export class BoundingInfo implements ICullable {
  7092. /**
  7093. * Bounding box for the mesh
  7094. */
  7095. readonly boundingBox: BoundingBox;
  7096. /**
  7097. * Bounding sphere for the mesh
  7098. */
  7099. readonly boundingSphere: BoundingSphere;
  7100. private _isLocked;
  7101. private static readonly TmpVector3;
  7102. /**
  7103. * Constructs bounding info
  7104. * @param minimum min vector of the bounding box/sphere
  7105. * @param maximum max vector of the bounding box/sphere
  7106. * @param worldMatrix defines the new world matrix
  7107. */
  7108. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7109. /**
  7110. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7111. * @param min defines the new minimum vector (in local space)
  7112. * @param max defines the new maximum vector (in local space)
  7113. * @param worldMatrix defines the new world matrix
  7114. */
  7115. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7116. /**
  7117. * min vector of the bounding box/sphere
  7118. */
  7119. get minimum(): Vector3;
  7120. /**
  7121. * max vector of the bounding box/sphere
  7122. */
  7123. get maximum(): Vector3;
  7124. /**
  7125. * If the info is locked and won't be updated to avoid perf overhead
  7126. */
  7127. get isLocked(): boolean;
  7128. set isLocked(value: boolean);
  7129. /**
  7130. * Updates the bounding sphere and box
  7131. * @param world world matrix to be used to update
  7132. */
  7133. update(world: DeepImmutable<Matrix>): void;
  7134. /**
  7135. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7136. * @param center New center of the bounding info
  7137. * @param extend New extend of the bounding info
  7138. * @returns the current bounding info
  7139. */
  7140. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7141. /**
  7142. * Scale the current bounding info by applying a scale factor
  7143. * @param factor defines the scale factor to apply
  7144. * @returns the current bounding info
  7145. */
  7146. scale(factor: number): BoundingInfo;
  7147. /**
  7148. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7149. * @param frustumPlanes defines the frustum to test
  7150. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7151. * @returns true if the bounding info is in the frustum planes
  7152. */
  7153. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7154. /**
  7155. * Gets the world distance between the min and max points of the bounding box
  7156. */
  7157. get diagonalLength(): number;
  7158. /**
  7159. * Checks if a cullable object (mesh...) is in the camera frustum
  7160. * Unlike isInFrustum this cheks the full bounding box
  7161. * @param frustumPlanes Camera near/planes
  7162. * @returns true if the object is in frustum otherwise false
  7163. */
  7164. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7165. /** @hidden */
  7166. _checkCollision(collider: Collider): boolean;
  7167. /**
  7168. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7169. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7170. * @param point the point to check intersection with
  7171. * @returns if the point intersects
  7172. */
  7173. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7174. /**
  7175. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7176. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7177. * @param boundingInfo the bounding info to check intersection with
  7178. * @param precise if the intersection should be done using OBB
  7179. * @returns if the bounding info intersects
  7180. */
  7181. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7182. }
  7183. }
  7184. declare module "babylonjs/Maths/math.functions" {
  7185. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7186. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7187. /**
  7188. * Extracts minimum and maximum values from a list of indexed positions
  7189. * @param positions defines the positions to use
  7190. * @param indices defines the indices to the positions
  7191. * @param indexStart defines the start index
  7192. * @param indexCount defines the end index
  7193. * @param bias defines bias value to add to the result
  7194. * @return minimum and maximum values
  7195. */
  7196. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7197. minimum: Vector3;
  7198. maximum: Vector3;
  7199. };
  7200. /**
  7201. * Extracts minimum and maximum values from a list of positions
  7202. * @param positions defines the positions to use
  7203. * @param start defines the start index in the positions array
  7204. * @param count defines the number of positions to handle
  7205. * @param bias defines bias value to add to the result
  7206. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7207. * @return minimum and maximum values
  7208. */
  7209. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7210. minimum: Vector3;
  7211. maximum: Vector3;
  7212. };
  7213. }
  7214. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7215. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7216. /** @hidden */
  7217. export class WebGLDataBuffer extends DataBuffer {
  7218. private _buffer;
  7219. constructor(resource: WebGLBuffer);
  7220. get underlyingResource(): any;
  7221. }
  7222. }
  7223. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7224. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7225. import { Nullable } from "babylonjs/types";
  7226. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7227. /** @hidden */
  7228. export class WebGLPipelineContext implements IPipelineContext {
  7229. engine: ThinEngine;
  7230. program: Nullable<WebGLProgram>;
  7231. context?: WebGLRenderingContext;
  7232. vertexShader?: WebGLShader;
  7233. fragmentShader?: WebGLShader;
  7234. isParallelCompiled: boolean;
  7235. onCompiled?: () => void;
  7236. transformFeedback?: WebGLTransformFeedback | null;
  7237. vertexCompilationError: Nullable<string>;
  7238. fragmentCompilationError: Nullable<string>;
  7239. programLinkError: Nullable<string>;
  7240. programValidationError: Nullable<string>;
  7241. get isAsync(): boolean;
  7242. get isReady(): boolean;
  7243. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7244. _getVertexShaderCode(): string | null;
  7245. _getFragmentShaderCode(): string | null;
  7246. }
  7247. }
  7248. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7249. import { FloatArray, Nullable } from "babylonjs/types";
  7250. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7251. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7252. module "babylonjs/Engines/thinEngine" {
  7253. interface ThinEngine {
  7254. /**
  7255. * Create an uniform buffer
  7256. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7257. * @param elements defines the content of the uniform buffer
  7258. * @returns the webGL uniform buffer
  7259. */
  7260. createUniformBuffer(elements: FloatArray): DataBuffer;
  7261. /**
  7262. * Create a dynamic uniform buffer
  7263. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7264. * @param elements defines the content of the uniform buffer
  7265. * @returns the webGL uniform buffer
  7266. */
  7267. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7268. /**
  7269. * Update an existing uniform buffer
  7270. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7271. * @param uniformBuffer defines the target uniform buffer
  7272. * @param elements defines the content to update
  7273. * @param offset defines the offset in the uniform buffer where update should start
  7274. * @param count defines the size of the data to update
  7275. */
  7276. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7277. /**
  7278. * Bind an uniform buffer to the current webGL context
  7279. * @param buffer defines the buffer to bind
  7280. */
  7281. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7282. /**
  7283. * Bind a buffer to the current webGL context at a given location
  7284. * @param buffer defines the buffer to bind
  7285. * @param location defines the index where to bind the buffer
  7286. */
  7287. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7288. /**
  7289. * Bind a specific block at a given index in a specific shader program
  7290. * @param pipelineContext defines the pipeline context to use
  7291. * @param blockName defines the block name
  7292. * @param index defines the index where to bind the block
  7293. */
  7294. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7295. }
  7296. }
  7297. }
  7298. declare module "babylonjs/Materials/uniformBuffer" {
  7299. import { Nullable, FloatArray } from "babylonjs/types";
  7300. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7301. import { Engine } from "babylonjs/Engines/engine";
  7302. import { Effect } from "babylonjs/Materials/effect";
  7303. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7304. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7305. import { Color3 } from "babylonjs/Maths/math.color";
  7306. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7307. /**
  7308. * Uniform buffer objects.
  7309. *
  7310. * Handles blocks of uniform on the GPU.
  7311. *
  7312. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7313. *
  7314. * For more information, please refer to :
  7315. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7316. */
  7317. export class UniformBuffer {
  7318. private _engine;
  7319. private _buffer;
  7320. private _data;
  7321. private _bufferData;
  7322. private _dynamic?;
  7323. private _uniformLocations;
  7324. private _uniformSizes;
  7325. private _uniformLocationPointer;
  7326. private _needSync;
  7327. private _noUBO;
  7328. private _currentEffect;
  7329. /** @hidden */
  7330. _alreadyBound: boolean;
  7331. private static _MAX_UNIFORM_SIZE;
  7332. private static _tempBuffer;
  7333. /**
  7334. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7335. * This is dynamic to allow compat with webgl 1 and 2.
  7336. * You will need to pass the name of the uniform as well as the value.
  7337. */
  7338. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7339. /**
  7340. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7341. * This is dynamic to allow compat with webgl 1 and 2.
  7342. * You will need to pass the name of the uniform as well as the value.
  7343. */
  7344. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7345. /**
  7346. * Lambda to Update a single float in a uniform buffer.
  7347. * This is dynamic to allow compat with webgl 1 and 2.
  7348. * You will need to pass the name of the uniform as well as the value.
  7349. */
  7350. updateFloat: (name: string, x: number) => void;
  7351. /**
  7352. * Lambda to Update a vec2 of float in a uniform buffer.
  7353. * This is dynamic to allow compat with webgl 1 and 2.
  7354. * You will need to pass the name of the uniform as well as the value.
  7355. */
  7356. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7357. /**
  7358. * Lambda to Update a vec3 of float in a uniform buffer.
  7359. * This is dynamic to allow compat with webgl 1 and 2.
  7360. * You will need to pass the name of the uniform as well as the value.
  7361. */
  7362. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7363. /**
  7364. * Lambda to Update a vec4 of float in a uniform buffer.
  7365. * This is dynamic to allow compat with webgl 1 and 2.
  7366. * You will need to pass the name of the uniform as well as the value.
  7367. */
  7368. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7369. /**
  7370. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7371. * This is dynamic to allow compat with webgl 1 and 2.
  7372. * You will need to pass the name of the uniform as well as the value.
  7373. */
  7374. updateMatrix: (name: string, mat: Matrix) => void;
  7375. /**
  7376. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7377. * This is dynamic to allow compat with webgl 1 and 2.
  7378. * You will need to pass the name of the uniform as well as the value.
  7379. */
  7380. updateVector3: (name: string, vector: Vector3) => void;
  7381. /**
  7382. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7383. * This is dynamic to allow compat with webgl 1 and 2.
  7384. * You will need to pass the name of the uniform as well as the value.
  7385. */
  7386. updateVector4: (name: string, vector: Vector4) => void;
  7387. /**
  7388. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7389. * This is dynamic to allow compat with webgl 1 and 2.
  7390. * You will need to pass the name of the uniform as well as the value.
  7391. */
  7392. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7393. /**
  7394. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7395. * This is dynamic to allow compat with webgl 1 and 2.
  7396. * You will need to pass the name of the uniform as well as the value.
  7397. */
  7398. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7399. /**
  7400. * Instantiates a new Uniform buffer objects.
  7401. *
  7402. * Handles blocks of uniform on the GPU.
  7403. *
  7404. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7405. *
  7406. * For more information, please refer to :
  7407. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7408. * @param engine Define the engine the buffer is associated with
  7409. * @param data Define the data contained in the buffer
  7410. * @param dynamic Define if the buffer is updatable
  7411. */
  7412. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7413. /**
  7414. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7415. * or just falling back on setUniformXXX calls.
  7416. */
  7417. get useUbo(): boolean;
  7418. /**
  7419. * Indicates if the WebGL underlying uniform buffer is in sync
  7420. * with the javascript cache data.
  7421. */
  7422. get isSync(): boolean;
  7423. /**
  7424. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7425. * Also, a dynamic UniformBuffer will disable cache verification and always
  7426. * update the underlying WebGL uniform buffer to the GPU.
  7427. * @returns if Dynamic, otherwise false
  7428. */
  7429. isDynamic(): boolean;
  7430. /**
  7431. * The data cache on JS side.
  7432. * @returns the underlying data as a float array
  7433. */
  7434. getData(): Float32Array;
  7435. /**
  7436. * The underlying WebGL Uniform buffer.
  7437. * @returns the webgl buffer
  7438. */
  7439. getBuffer(): Nullable<DataBuffer>;
  7440. /**
  7441. * std140 layout specifies how to align data within an UBO structure.
  7442. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7443. * for specs.
  7444. */
  7445. private _fillAlignment;
  7446. /**
  7447. * Adds an uniform in the buffer.
  7448. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7449. * for the layout to be correct !
  7450. * @param name Name of the uniform, as used in the uniform block in the shader.
  7451. * @param size Data size, or data directly.
  7452. */
  7453. addUniform(name: string, size: number | number[]): void;
  7454. /**
  7455. * Adds a Matrix 4x4 to the uniform buffer.
  7456. * @param name Name of the uniform, as used in the uniform block in the shader.
  7457. * @param mat A 4x4 matrix.
  7458. */
  7459. addMatrix(name: string, mat: Matrix): void;
  7460. /**
  7461. * Adds a vec2 to the uniform buffer.
  7462. * @param name Name of the uniform, as used in the uniform block in the shader.
  7463. * @param x Define the x component value of the vec2
  7464. * @param y Define the y component value of the vec2
  7465. */
  7466. addFloat2(name: string, x: number, y: number): void;
  7467. /**
  7468. * Adds a vec3 to the uniform buffer.
  7469. * @param name Name of the uniform, as used in the uniform block in the shader.
  7470. * @param x Define the x component value of the vec3
  7471. * @param y Define the y component value of the vec3
  7472. * @param z Define the z component value of the vec3
  7473. */
  7474. addFloat3(name: string, x: number, y: number, z: number): void;
  7475. /**
  7476. * Adds a vec3 to the uniform buffer.
  7477. * @param name Name of the uniform, as used in the uniform block in the shader.
  7478. * @param color Define the vec3 from a Color
  7479. */
  7480. addColor3(name: string, color: Color3): void;
  7481. /**
  7482. * Adds a vec4 to the uniform buffer.
  7483. * @param name Name of the uniform, as used in the uniform block in the shader.
  7484. * @param color Define the rgb components from a Color
  7485. * @param alpha Define the a component of the vec4
  7486. */
  7487. addColor4(name: string, color: Color3, alpha: number): void;
  7488. /**
  7489. * Adds a vec3 to the uniform buffer.
  7490. * @param name Name of the uniform, as used in the uniform block in the shader.
  7491. * @param vector Define the vec3 components from a Vector
  7492. */
  7493. addVector3(name: string, vector: Vector3): void;
  7494. /**
  7495. * Adds a Matrix 3x3 to the uniform buffer.
  7496. * @param name Name of the uniform, as used in the uniform block in the shader.
  7497. */
  7498. addMatrix3x3(name: string): void;
  7499. /**
  7500. * Adds a Matrix 2x2 to the uniform buffer.
  7501. * @param name Name of the uniform, as used in the uniform block in the shader.
  7502. */
  7503. addMatrix2x2(name: string): void;
  7504. /**
  7505. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7506. */
  7507. create(): void;
  7508. /** @hidden */
  7509. _rebuild(): void;
  7510. /**
  7511. * Updates the WebGL Uniform Buffer on the GPU.
  7512. * If the `dynamic` flag is set to true, no cache comparison is done.
  7513. * Otherwise, the buffer will be updated only if the cache differs.
  7514. */
  7515. update(): void;
  7516. /**
  7517. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7518. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7519. * @param data Define the flattened data
  7520. * @param size Define the size of the data.
  7521. */
  7522. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7523. private _valueCache;
  7524. private _cacheMatrix;
  7525. private _updateMatrix3x3ForUniform;
  7526. private _updateMatrix3x3ForEffect;
  7527. private _updateMatrix2x2ForEffect;
  7528. private _updateMatrix2x2ForUniform;
  7529. private _updateFloatForEffect;
  7530. private _updateFloatForUniform;
  7531. private _updateFloat2ForEffect;
  7532. private _updateFloat2ForUniform;
  7533. private _updateFloat3ForEffect;
  7534. private _updateFloat3ForUniform;
  7535. private _updateFloat4ForEffect;
  7536. private _updateFloat4ForUniform;
  7537. private _updateMatrixForEffect;
  7538. private _updateMatrixForUniform;
  7539. private _updateVector3ForEffect;
  7540. private _updateVector3ForUniform;
  7541. private _updateVector4ForEffect;
  7542. private _updateVector4ForUniform;
  7543. private _updateColor3ForEffect;
  7544. private _updateColor3ForUniform;
  7545. private _updateColor4ForEffect;
  7546. private _updateColor4ForUniform;
  7547. /**
  7548. * Sets a sampler uniform on the effect.
  7549. * @param name Define the name of the sampler.
  7550. * @param texture Define the texture to set in the sampler
  7551. */
  7552. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7553. /**
  7554. * Directly updates the value of the uniform in the cache AND on the GPU.
  7555. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7556. * @param data Define the flattened data
  7557. */
  7558. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7559. /**
  7560. * Binds this uniform buffer to an effect.
  7561. * @param effect Define the effect to bind the buffer to
  7562. * @param name Name of the uniform block in the shader.
  7563. */
  7564. bindToEffect(effect: Effect, name: string): void;
  7565. /**
  7566. * Disposes the uniform buffer.
  7567. */
  7568. dispose(): void;
  7569. }
  7570. }
  7571. declare module "babylonjs/Misc/iInspectable" {
  7572. /**
  7573. * Enum that determines the text-wrapping mode to use.
  7574. */
  7575. export enum InspectableType {
  7576. /**
  7577. * Checkbox for booleans
  7578. */
  7579. Checkbox = 0,
  7580. /**
  7581. * Sliders for numbers
  7582. */
  7583. Slider = 1,
  7584. /**
  7585. * Vector3
  7586. */
  7587. Vector3 = 2,
  7588. /**
  7589. * Quaternions
  7590. */
  7591. Quaternion = 3,
  7592. /**
  7593. * Color3
  7594. */
  7595. Color3 = 4,
  7596. /**
  7597. * String
  7598. */
  7599. String = 5
  7600. }
  7601. /**
  7602. * Interface used to define custom inspectable properties.
  7603. * This interface is used by the inspector to display custom property grids
  7604. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7605. */
  7606. export interface IInspectable {
  7607. /**
  7608. * Gets the label to display
  7609. */
  7610. label: string;
  7611. /**
  7612. * Gets the name of the property to edit
  7613. */
  7614. propertyName: string;
  7615. /**
  7616. * Gets the type of the editor to use
  7617. */
  7618. type: InspectableType;
  7619. /**
  7620. * Gets the minimum value of the property when using in "slider" mode
  7621. */
  7622. min?: number;
  7623. /**
  7624. * Gets the maximum value of the property when using in "slider" mode
  7625. */
  7626. max?: number;
  7627. /**
  7628. * Gets the setp to use when using in "slider" mode
  7629. */
  7630. step?: number;
  7631. }
  7632. }
  7633. declare module "babylonjs/Misc/timingTools" {
  7634. /**
  7635. * Class used to provide helper for timing
  7636. */
  7637. export class TimingTools {
  7638. /**
  7639. * Polyfill for setImmediate
  7640. * @param action defines the action to execute after the current execution block
  7641. */
  7642. static SetImmediate(action: () => void): void;
  7643. }
  7644. }
  7645. declare module "babylonjs/Misc/instantiationTools" {
  7646. /**
  7647. * Class used to enable instatition of objects by class name
  7648. */
  7649. export class InstantiationTools {
  7650. /**
  7651. * Use this object to register external classes like custom textures or material
  7652. * to allow the laoders to instantiate them
  7653. */
  7654. static RegisteredExternalClasses: {
  7655. [key: string]: Object;
  7656. };
  7657. /**
  7658. * Tries to instantiate a new object from a given class name
  7659. * @param className defines the class name to instantiate
  7660. * @returns the new object or null if the system was not able to do the instantiation
  7661. */
  7662. static Instantiate(className: string): any;
  7663. }
  7664. }
  7665. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7666. /**
  7667. * Define options used to create a depth texture
  7668. */
  7669. export class DepthTextureCreationOptions {
  7670. /** Specifies whether or not a stencil should be allocated in the texture */
  7671. generateStencil?: boolean;
  7672. /** Specifies whether or not bilinear filtering is enable on the texture */
  7673. bilinearFiltering?: boolean;
  7674. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7675. comparisonFunction?: number;
  7676. /** Specifies if the created texture is a cube texture */
  7677. isCube?: boolean;
  7678. }
  7679. }
  7680. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7681. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7682. import { Nullable } from "babylonjs/types";
  7683. import { Scene } from "babylonjs/scene";
  7684. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7685. module "babylonjs/Engines/thinEngine" {
  7686. interface ThinEngine {
  7687. /**
  7688. * Creates a depth stencil cube texture.
  7689. * This is only available in WebGL 2.
  7690. * @param size The size of face edge in the cube texture.
  7691. * @param options The options defining the cube texture.
  7692. * @returns The cube texture
  7693. */
  7694. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7695. /**
  7696. * Creates a cube texture
  7697. * @param rootUrl defines the url where the files to load is located
  7698. * @param scene defines the current scene
  7699. * @param files defines the list of files to load (1 per face)
  7700. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7701. * @param onLoad defines an optional callback raised when the texture is loaded
  7702. * @param onError defines an optional callback raised if there is an issue to load the texture
  7703. * @param format defines the format of the data
  7704. * @param forcedExtension defines the extension to use to pick the right loader
  7705. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7706. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7707. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7708. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7709. * @returns the cube texture as an InternalTexture
  7710. */
  7711. 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;
  7712. /**
  7713. * Creates a cube texture
  7714. * @param rootUrl defines the url where the files to load is located
  7715. * @param scene defines the current scene
  7716. * @param files defines the list of files to load (1 per face)
  7717. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7718. * @param onLoad defines an optional callback raised when the texture is loaded
  7719. * @param onError defines an optional callback raised if there is an issue to load the texture
  7720. * @param format defines the format of the data
  7721. * @param forcedExtension defines the extension to use to pick the right loader
  7722. * @returns the cube texture as an InternalTexture
  7723. */
  7724. 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;
  7725. /**
  7726. * Creates a cube texture
  7727. * @param rootUrl defines the url where the files to load is located
  7728. * @param scene defines the current scene
  7729. * @param files defines the list of files to load (1 per face)
  7730. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7731. * @param onLoad defines an optional callback raised when the texture is loaded
  7732. * @param onError defines an optional callback raised if there is an issue to load the texture
  7733. * @param format defines the format of the data
  7734. * @param forcedExtension defines the extension to use to pick the right loader
  7735. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7736. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7737. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7738. * @returns the cube texture as an InternalTexture
  7739. */
  7740. 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;
  7741. /** @hidden */
  7742. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7743. /** @hidden */
  7744. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7745. /** @hidden */
  7746. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7747. /** @hidden */
  7748. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7749. /**
  7750. * @hidden
  7751. */
  7752. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7753. }
  7754. }
  7755. }
  7756. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7757. import { Nullable } from "babylonjs/types";
  7758. import { Scene } from "babylonjs/scene";
  7759. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7760. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7761. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7762. import { Observable } from "babylonjs/Misc/observable";
  7763. /**
  7764. * Class for creating a cube texture
  7765. */
  7766. export class CubeTexture extends BaseTexture {
  7767. private _delayedOnLoad;
  7768. /**
  7769. * Observable triggered once the texture has been loaded.
  7770. */
  7771. onLoadObservable: Observable<CubeTexture>;
  7772. /**
  7773. * The url of the texture
  7774. */
  7775. url: string;
  7776. /**
  7777. * Gets or sets the center of the bounding box associated with the cube texture.
  7778. * It must define where the camera used to render the texture was set
  7779. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7780. */
  7781. boundingBoxPosition: Vector3;
  7782. private _boundingBoxSize;
  7783. /**
  7784. * Gets or sets the size of the bounding box associated with the cube texture
  7785. * When defined, the cubemap will switch to local mode
  7786. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7787. * @example https://www.babylonjs-playground.com/#RNASML
  7788. */
  7789. set boundingBoxSize(value: Vector3);
  7790. /**
  7791. * Returns the bounding box size
  7792. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7793. */
  7794. get boundingBoxSize(): Vector3;
  7795. protected _rotationY: number;
  7796. /**
  7797. * Sets texture matrix rotation angle around Y axis in radians.
  7798. */
  7799. set rotationY(value: number);
  7800. /**
  7801. * Gets texture matrix rotation angle around Y axis radians.
  7802. */
  7803. get rotationY(): number;
  7804. /**
  7805. * Are mip maps generated for this texture or not.
  7806. */
  7807. get noMipmap(): boolean;
  7808. private _noMipmap;
  7809. private _files;
  7810. protected _forcedExtension: Nullable<string>;
  7811. private _extensions;
  7812. private _textureMatrix;
  7813. private _format;
  7814. private _createPolynomials;
  7815. /** @hidden */
  7816. _prefiltered: boolean;
  7817. /**
  7818. * Creates a cube texture from an array of image urls
  7819. * @param files defines an array of image urls
  7820. * @param scene defines the hosting scene
  7821. * @param noMipmap specifies if mip maps are not used
  7822. * @returns a cube texture
  7823. */
  7824. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7825. /**
  7826. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7827. * @param url defines the url of the prefiltered texture
  7828. * @param scene defines the scene the texture is attached to
  7829. * @param forcedExtension defines the extension of the file if different from the url
  7830. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7831. * @return the prefiltered texture
  7832. */
  7833. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7834. /**
  7835. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7836. * as prefiltered data.
  7837. * @param rootUrl defines the url of the texture or the root name of the six images
  7838. * @param scene defines the scene the texture is attached to
  7839. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7840. * @param noMipmap defines if mipmaps should be created or not
  7841. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7842. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7843. * @param onError defines a callback triggered in case of error during load
  7844. * @param format defines the internal format to use for the texture once loaded
  7845. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7846. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7847. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7848. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7849. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7850. * @return the cube texture
  7851. */
  7852. 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);
  7853. /**
  7854. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7855. */
  7856. get isPrefiltered(): boolean;
  7857. /**
  7858. * Get the current class name of the texture useful for serialization or dynamic coding.
  7859. * @returns "CubeTexture"
  7860. */
  7861. getClassName(): string;
  7862. /**
  7863. * Update the url (and optional buffer) of this texture if url was null during construction.
  7864. * @param url the url of the texture
  7865. * @param forcedExtension defines the extension to use
  7866. * @param onLoad callback called when the texture is loaded (defaults to null)
  7867. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7868. */
  7869. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7870. /**
  7871. * Delays loading of the cube texture
  7872. * @param forcedExtension defines the extension to use
  7873. */
  7874. delayLoad(forcedExtension?: string): void;
  7875. /**
  7876. * Returns the reflection texture matrix
  7877. * @returns the reflection texture matrix
  7878. */
  7879. getReflectionTextureMatrix(): Matrix;
  7880. /**
  7881. * Sets the reflection texture matrix
  7882. * @param value Reflection texture matrix
  7883. */
  7884. setReflectionTextureMatrix(value: Matrix): void;
  7885. /**
  7886. * Parses text to create a cube texture
  7887. * @param parsedTexture define the serialized text to read from
  7888. * @param scene defines the hosting scene
  7889. * @param rootUrl defines the root url of the cube texture
  7890. * @returns a cube texture
  7891. */
  7892. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7893. /**
  7894. * Makes a clone, or deep copy, of the cube texture
  7895. * @returns a new cube texture
  7896. */
  7897. clone(): CubeTexture;
  7898. }
  7899. }
  7900. declare module "babylonjs/Materials/materialDefines" {
  7901. /**
  7902. * Manages the defines for the Material
  7903. */
  7904. export class MaterialDefines {
  7905. /** @hidden */
  7906. protected _keys: string[];
  7907. private _isDirty;
  7908. /** @hidden */
  7909. _renderId: number;
  7910. /** @hidden */
  7911. _areLightsDirty: boolean;
  7912. /** @hidden */
  7913. _areLightsDisposed: boolean;
  7914. /** @hidden */
  7915. _areAttributesDirty: boolean;
  7916. /** @hidden */
  7917. _areTexturesDirty: boolean;
  7918. /** @hidden */
  7919. _areFresnelDirty: boolean;
  7920. /** @hidden */
  7921. _areMiscDirty: boolean;
  7922. /** @hidden */
  7923. _areImageProcessingDirty: boolean;
  7924. /** @hidden */
  7925. _normals: boolean;
  7926. /** @hidden */
  7927. _uvs: boolean;
  7928. /** @hidden */
  7929. _needNormals: boolean;
  7930. /** @hidden */
  7931. _needUVs: boolean;
  7932. [id: string]: any;
  7933. /**
  7934. * Specifies if the material needs to be re-calculated
  7935. */
  7936. get isDirty(): boolean;
  7937. /**
  7938. * Marks the material to indicate that it has been re-calculated
  7939. */
  7940. markAsProcessed(): void;
  7941. /**
  7942. * Marks the material to indicate that it needs to be re-calculated
  7943. */
  7944. markAsUnprocessed(): void;
  7945. /**
  7946. * Marks the material to indicate all of its defines need to be re-calculated
  7947. */
  7948. markAllAsDirty(): void;
  7949. /**
  7950. * Marks the material to indicate that image processing needs to be re-calculated
  7951. */
  7952. markAsImageProcessingDirty(): void;
  7953. /**
  7954. * Marks the material to indicate the lights need to be re-calculated
  7955. * @param disposed Defines whether the light is dirty due to dispose or not
  7956. */
  7957. markAsLightDirty(disposed?: boolean): void;
  7958. /**
  7959. * Marks the attribute state as changed
  7960. */
  7961. markAsAttributesDirty(): void;
  7962. /**
  7963. * Marks the texture state as changed
  7964. */
  7965. markAsTexturesDirty(): void;
  7966. /**
  7967. * Marks the fresnel state as changed
  7968. */
  7969. markAsFresnelDirty(): void;
  7970. /**
  7971. * Marks the misc state as changed
  7972. */
  7973. markAsMiscDirty(): void;
  7974. /**
  7975. * Rebuilds the material defines
  7976. */
  7977. rebuild(): void;
  7978. /**
  7979. * Specifies if two material defines are equal
  7980. * @param other - A material define instance to compare to
  7981. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7982. */
  7983. isEqual(other: MaterialDefines): boolean;
  7984. /**
  7985. * Clones this instance's defines to another instance
  7986. * @param other - material defines to clone values to
  7987. */
  7988. cloneTo(other: MaterialDefines): void;
  7989. /**
  7990. * Resets the material define values
  7991. */
  7992. reset(): void;
  7993. /**
  7994. * Converts the material define values to a string
  7995. * @returns - String of material define information
  7996. */
  7997. toString(): string;
  7998. }
  7999. }
  8000. declare module "babylonjs/Materials/colorCurves" {
  8001. import { Effect } from "babylonjs/Materials/effect";
  8002. /**
  8003. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8004. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8005. * 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;
  8006. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8007. */
  8008. export class ColorCurves {
  8009. private _dirty;
  8010. private _tempColor;
  8011. private _globalCurve;
  8012. private _highlightsCurve;
  8013. private _midtonesCurve;
  8014. private _shadowsCurve;
  8015. private _positiveCurve;
  8016. private _negativeCurve;
  8017. private _globalHue;
  8018. private _globalDensity;
  8019. private _globalSaturation;
  8020. private _globalExposure;
  8021. /**
  8022. * Gets the global Hue value.
  8023. * 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).
  8024. */
  8025. get globalHue(): number;
  8026. /**
  8027. * Sets the global Hue value.
  8028. * 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).
  8029. */
  8030. set globalHue(value: number);
  8031. /**
  8032. * Gets the global Density value.
  8033. * 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.
  8034. * Values less than zero provide a filter of opposite hue.
  8035. */
  8036. get globalDensity(): number;
  8037. /**
  8038. * Sets the global Density value.
  8039. * 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.
  8040. * Values less than zero provide a filter of opposite hue.
  8041. */
  8042. set globalDensity(value: number);
  8043. /**
  8044. * Gets the global Saturation value.
  8045. * 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.
  8046. */
  8047. get globalSaturation(): number;
  8048. /**
  8049. * Sets the global Saturation value.
  8050. * 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.
  8051. */
  8052. set globalSaturation(value: number);
  8053. /**
  8054. * Gets the global Exposure value.
  8055. * 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.
  8056. */
  8057. get globalExposure(): number;
  8058. /**
  8059. * Sets the global Exposure value.
  8060. * 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.
  8061. */
  8062. set globalExposure(value: number);
  8063. private _highlightsHue;
  8064. private _highlightsDensity;
  8065. private _highlightsSaturation;
  8066. private _highlightsExposure;
  8067. /**
  8068. * Gets the highlights Hue value.
  8069. * 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).
  8070. */
  8071. get highlightsHue(): number;
  8072. /**
  8073. * Sets the highlights Hue value.
  8074. * 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).
  8075. */
  8076. set highlightsHue(value: number);
  8077. /**
  8078. * Gets the highlights Density value.
  8079. * 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.
  8080. * Values less than zero provide a filter of opposite hue.
  8081. */
  8082. get highlightsDensity(): number;
  8083. /**
  8084. * Sets the highlights Density value.
  8085. * 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.
  8086. * Values less than zero provide a filter of opposite hue.
  8087. */
  8088. set highlightsDensity(value: number);
  8089. /**
  8090. * Gets the highlights Saturation value.
  8091. * 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.
  8092. */
  8093. get highlightsSaturation(): number;
  8094. /**
  8095. * Sets the highlights Saturation value.
  8096. * 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.
  8097. */
  8098. set highlightsSaturation(value: number);
  8099. /**
  8100. * Gets the highlights Exposure value.
  8101. * 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.
  8102. */
  8103. get highlightsExposure(): number;
  8104. /**
  8105. * Sets the highlights Exposure value.
  8106. * 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.
  8107. */
  8108. set highlightsExposure(value: number);
  8109. private _midtonesHue;
  8110. private _midtonesDensity;
  8111. private _midtonesSaturation;
  8112. private _midtonesExposure;
  8113. /**
  8114. * Gets the midtones Hue value.
  8115. * 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).
  8116. */
  8117. get midtonesHue(): number;
  8118. /**
  8119. * Sets the midtones Hue value.
  8120. * 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).
  8121. */
  8122. set midtonesHue(value: number);
  8123. /**
  8124. * Gets the midtones Density value.
  8125. * 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.
  8126. * Values less than zero provide a filter of opposite hue.
  8127. */
  8128. get midtonesDensity(): number;
  8129. /**
  8130. * Sets the midtones Density value.
  8131. * 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.
  8132. * Values less than zero provide a filter of opposite hue.
  8133. */
  8134. set midtonesDensity(value: number);
  8135. /**
  8136. * Gets the midtones Saturation value.
  8137. * 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.
  8138. */
  8139. get midtonesSaturation(): number;
  8140. /**
  8141. * Sets the midtones Saturation value.
  8142. * 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.
  8143. */
  8144. set midtonesSaturation(value: number);
  8145. /**
  8146. * Gets the midtones Exposure value.
  8147. * 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.
  8148. */
  8149. get midtonesExposure(): number;
  8150. /**
  8151. * Sets the midtones Exposure value.
  8152. * 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.
  8153. */
  8154. set midtonesExposure(value: number);
  8155. private _shadowsHue;
  8156. private _shadowsDensity;
  8157. private _shadowsSaturation;
  8158. private _shadowsExposure;
  8159. /**
  8160. * Gets the shadows Hue value.
  8161. * 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).
  8162. */
  8163. get shadowsHue(): number;
  8164. /**
  8165. * Sets the shadows Hue value.
  8166. * 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).
  8167. */
  8168. set shadowsHue(value: number);
  8169. /**
  8170. * Gets the shadows Density value.
  8171. * 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.
  8172. * Values less than zero provide a filter of opposite hue.
  8173. */
  8174. get shadowsDensity(): number;
  8175. /**
  8176. * Sets the shadows Density value.
  8177. * 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.
  8178. * Values less than zero provide a filter of opposite hue.
  8179. */
  8180. set shadowsDensity(value: number);
  8181. /**
  8182. * Gets the shadows Saturation value.
  8183. * 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.
  8184. */
  8185. get shadowsSaturation(): number;
  8186. /**
  8187. * Sets the shadows Saturation value.
  8188. * 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.
  8189. */
  8190. set shadowsSaturation(value: number);
  8191. /**
  8192. * Gets the shadows Exposure value.
  8193. * 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.
  8194. */
  8195. get shadowsExposure(): number;
  8196. /**
  8197. * Sets the shadows Exposure value.
  8198. * 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.
  8199. */
  8200. set shadowsExposure(value: number);
  8201. /**
  8202. * Returns the class name
  8203. * @returns The class name
  8204. */
  8205. getClassName(): string;
  8206. /**
  8207. * Binds the color curves to the shader.
  8208. * @param colorCurves The color curve to bind
  8209. * @param effect The effect to bind to
  8210. * @param positiveUniform The positive uniform shader parameter
  8211. * @param neutralUniform The neutral uniform shader parameter
  8212. * @param negativeUniform The negative uniform shader parameter
  8213. */
  8214. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8215. /**
  8216. * Prepare the list of uniforms associated with the ColorCurves effects.
  8217. * @param uniformsList The list of uniforms used in the effect
  8218. */
  8219. static PrepareUniforms(uniformsList: string[]): void;
  8220. /**
  8221. * Returns color grading data based on a hue, density, saturation and exposure value.
  8222. * @param filterHue The hue of the color filter.
  8223. * @param filterDensity The density of the color filter.
  8224. * @param saturation The saturation.
  8225. * @param exposure The exposure.
  8226. * @param result The result data container.
  8227. */
  8228. private getColorGradingDataToRef;
  8229. /**
  8230. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8231. * @param value The input slider value in range [-100,100].
  8232. * @returns Adjusted value.
  8233. */
  8234. private static applyColorGradingSliderNonlinear;
  8235. /**
  8236. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8237. * @param hue The hue (H) input.
  8238. * @param saturation The saturation (S) input.
  8239. * @param brightness The brightness (B) input.
  8240. * @result An RGBA color represented as Vector4.
  8241. */
  8242. private static fromHSBToRef;
  8243. /**
  8244. * Returns a value clamped between min and max
  8245. * @param value The value to clamp
  8246. * @param min The minimum of value
  8247. * @param max The maximum of value
  8248. * @returns The clamped value.
  8249. */
  8250. private static clamp;
  8251. /**
  8252. * Clones the current color curve instance.
  8253. * @return The cloned curves
  8254. */
  8255. clone(): ColorCurves;
  8256. /**
  8257. * Serializes the current color curve instance to a json representation.
  8258. * @return a JSON representation
  8259. */
  8260. serialize(): any;
  8261. /**
  8262. * Parses the color curve from a json representation.
  8263. * @param source the JSON source to parse
  8264. * @return The parsed curves
  8265. */
  8266. static Parse(source: any): ColorCurves;
  8267. }
  8268. }
  8269. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8270. import { Observable } from "babylonjs/Misc/observable";
  8271. import { Nullable } from "babylonjs/types";
  8272. import { Color4 } from "babylonjs/Maths/math.color";
  8273. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8274. import { Effect } from "babylonjs/Materials/effect";
  8275. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8276. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8277. /**
  8278. * Interface to follow in your material defines to integrate easily the
  8279. * Image proccessing functions.
  8280. * @hidden
  8281. */
  8282. export interface IImageProcessingConfigurationDefines {
  8283. IMAGEPROCESSING: boolean;
  8284. VIGNETTE: boolean;
  8285. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8286. VIGNETTEBLENDMODEOPAQUE: boolean;
  8287. TONEMAPPING: boolean;
  8288. TONEMAPPING_ACES: boolean;
  8289. CONTRAST: boolean;
  8290. EXPOSURE: boolean;
  8291. COLORCURVES: boolean;
  8292. COLORGRADING: boolean;
  8293. COLORGRADING3D: boolean;
  8294. SAMPLER3DGREENDEPTH: boolean;
  8295. SAMPLER3DBGRMAP: boolean;
  8296. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8297. }
  8298. /**
  8299. * @hidden
  8300. */
  8301. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8302. IMAGEPROCESSING: boolean;
  8303. VIGNETTE: boolean;
  8304. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8305. VIGNETTEBLENDMODEOPAQUE: boolean;
  8306. TONEMAPPING: boolean;
  8307. TONEMAPPING_ACES: boolean;
  8308. CONTRAST: boolean;
  8309. COLORCURVES: boolean;
  8310. COLORGRADING: boolean;
  8311. COLORGRADING3D: boolean;
  8312. SAMPLER3DGREENDEPTH: boolean;
  8313. SAMPLER3DBGRMAP: boolean;
  8314. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8315. EXPOSURE: boolean;
  8316. constructor();
  8317. }
  8318. /**
  8319. * This groups together the common properties used for image processing either in direct forward pass
  8320. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8321. * or not.
  8322. */
  8323. export class ImageProcessingConfiguration {
  8324. /**
  8325. * Default tone mapping applied in BabylonJS.
  8326. */
  8327. static readonly TONEMAPPING_STANDARD: number;
  8328. /**
  8329. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8330. * to other engines rendering to increase portability.
  8331. */
  8332. static readonly TONEMAPPING_ACES: number;
  8333. /**
  8334. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8335. */
  8336. colorCurves: Nullable<ColorCurves>;
  8337. private _colorCurvesEnabled;
  8338. /**
  8339. * Gets wether the color curves effect is enabled.
  8340. */
  8341. get colorCurvesEnabled(): boolean;
  8342. /**
  8343. * Sets wether the color curves effect is enabled.
  8344. */
  8345. set colorCurvesEnabled(value: boolean);
  8346. private _colorGradingTexture;
  8347. /**
  8348. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8349. */
  8350. get colorGradingTexture(): Nullable<BaseTexture>;
  8351. /**
  8352. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8353. */
  8354. set colorGradingTexture(value: Nullable<BaseTexture>);
  8355. private _colorGradingEnabled;
  8356. /**
  8357. * Gets wether the color grading effect is enabled.
  8358. */
  8359. get colorGradingEnabled(): boolean;
  8360. /**
  8361. * Sets wether the color grading effect is enabled.
  8362. */
  8363. set colorGradingEnabled(value: boolean);
  8364. private _colorGradingWithGreenDepth;
  8365. /**
  8366. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8367. */
  8368. get colorGradingWithGreenDepth(): boolean;
  8369. /**
  8370. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8371. */
  8372. set colorGradingWithGreenDepth(value: boolean);
  8373. private _colorGradingBGR;
  8374. /**
  8375. * Gets wether the color grading texture contains BGR values.
  8376. */
  8377. get colorGradingBGR(): boolean;
  8378. /**
  8379. * Sets wether the color grading texture contains BGR values.
  8380. */
  8381. set colorGradingBGR(value: boolean);
  8382. /** @hidden */
  8383. _exposure: number;
  8384. /**
  8385. * Gets the Exposure used in the effect.
  8386. */
  8387. get exposure(): number;
  8388. /**
  8389. * Sets the Exposure used in the effect.
  8390. */
  8391. set exposure(value: number);
  8392. private _toneMappingEnabled;
  8393. /**
  8394. * Gets wether the tone mapping effect is enabled.
  8395. */
  8396. get toneMappingEnabled(): boolean;
  8397. /**
  8398. * Sets wether the tone mapping effect is enabled.
  8399. */
  8400. set toneMappingEnabled(value: boolean);
  8401. private _toneMappingType;
  8402. /**
  8403. * Gets the type of tone mapping effect.
  8404. */
  8405. get toneMappingType(): number;
  8406. /**
  8407. * Sets the type of tone mapping effect used in BabylonJS.
  8408. */
  8409. set toneMappingType(value: number);
  8410. protected _contrast: number;
  8411. /**
  8412. * Gets the contrast used in the effect.
  8413. */
  8414. get contrast(): number;
  8415. /**
  8416. * Sets the contrast used in the effect.
  8417. */
  8418. set contrast(value: number);
  8419. /**
  8420. * Vignette stretch size.
  8421. */
  8422. vignetteStretch: number;
  8423. /**
  8424. * Vignette centre X Offset.
  8425. */
  8426. vignetteCentreX: number;
  8427. /**
  8428. * Vignette centre Y Offset.
  8429. */
  8430. vignetteCentreY: number;
  8431. /**
  8432. * Vignette weight or intensity of the vignette effect.
  8433. */
  8434. vignetteWeight: number;
  8435. /**
  8436. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8437. * if vignetteEnabled is set to true.
  8438. */
  8439. vignetteColor: Color4;
  8440. /**
  8441. * Camera field of view used by the Vignette effect.
  8442. */
  8443. vignetteCameraFov: number;
  8444. private _vignetteBlendMode;
  8445. /**
  8446. * Gets the vignette blend mode allowing different kind of effect.
  8447. */
  8448. get vignetteBlendMode(): number;
  8449. /**
  8450. * Sets the vignette blend mode allowing different kind of effect.
  8451. */
  8452. set vignetteBlendMode(value: number);
  8453. private _vignetteEnabled;
  8454. /**
  8455. * Gets wether the vignette effect is enabled.
  8456. */
  8457. get vignetteEnabled(): boolean;
  8458. /**
  8459. * Sets wether the vignette effect is enabled.
  8460. */
  8461. set vignetteEnabled(value: boolean);
  8462. private _applyByPostProcess;
  8463. /**
  8464. * Gets wether the image processing is applied through a post process or not.
  8465. */
  8466. get applyByPostProcess(): boolean;
  8467. /**
  8468. * Sets wether the image processing is applied through a post process or not.
  8469. */
  8470. set applyByPostProcess(value: boolean);
  8471. private _isEnabled;
  8472. /**
  8473. * Gets wether the image processing is enabled or not.
  8474. */
  8475. get isEnabled(): boolean;
  8476. /**
  8477. * Sets wether the image processing is enabled or not.
  8478. */
  8479. set isEnabled(value: boolean);
  8480. /**
  8481. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8482. */
  8483. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8484. /**
  8485. * Method called each time the image processing information changes requires to recompile the effect.
  8486. */
  8487. protected _updateParameters(): void;
  8488. /**
  8489. * Gets the current class name.
  8490. * @return "ImageProcessingConfiguration"
  8491. */
  8492. getClassName(): string;
  8493. /**
  8494. * Prepare the list of uniforms associated with the Image Processing effects.
  8495. * @param uniforms The list of uniforms used in the effect
  8496. * @param defines the list of defines currently in use
  8497. */
  8498. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8499. /**
  8500. * Prepare the list of samplers associated with the Image Processing effects.
  8501. * @param samplersList The list of uniforms used in the effect
  8502. * @param defines the list of defines currently in use
  8503. */
  8504. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8505. /**
  8506. * Prepare the list of defines associated to the shader.
  8507. * @param defines the list of defines to complete
  8508. * @param forPostProcess Define if we are currently in post process mode or not
  8509. */
  8510. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8511. /**
  8512. * Returns true if all the image processing information are ready.
  8513. * @returns True if ready, otherwise, false
  8514. */
  8515. isReady(): boolean;
  8516. /**
  8517. * Binds the image processing to the shader.
  8518. * @param effect The effect to bind to
  8519. * @param overrideAspectRatio Override the aspect ratio of the effect
  8520. */
  8521. bind(effect: Effect, overrideAspectRatio?: number): void;
  8522. /**
  8523. * Clones the current image processing instance.
  8524. * @return The cloned image processing
  8525. */
  8526. clone(): ImageProcessingConfiguration;
  8527. /**
  8528. * Serializes the current image processing instance to a json representation.
  8529. * @return a JSON representation
  8530. */
  8531. serialize(): any;
  8532. /**
  8533. * Parses the image processing from a json representation.
  8534. * @param source the JSON source to parse
  8535. * @return The parsed image processing
  8536. */
  8537. static Parse(source: any): ImageProcessingConfiguration;
  8538. private static _VIGNETTEMODE_MULTIPLY;
  8539. private static _VIGNETTEMODE_OPAQUE;
  8540. /**
  8541. * Used to apply the vignette as a mix with the pixel color.
  8542. */
  8543. static get VIGNETTEMODE_MULTIPLY(): number;
  8544. /**
  8545. * Used to apply the vignette as a replacement of the pixel color.
  8546. */
  8547. static get VIGNETTEMODE_OPAQUE(): number;
  8548. }
  8549. }
  8550. declare module "babylonjs/Shaders/postprocess.vertex" {
  8551. /** @hidden */
  8552. export var postprocessVertexShader: {
  8553. name: string;
  8554. shader: string;
  8555. };
  8556. }
  8557. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8558. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8559. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8560. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8561. module "babylonjs/Engines/thinEngine" {
  8562. interface ThinEngine {
  8563. /**
  8564. * Creates a new render target texture
  8565. * @param size defines the size of the texture
  8566. * @param options defines the options used to create the texture
  8567. * @returns a new render target texture stored in an InternalTexture
  8568. */
  8569. createRenderTargetTexture(size: number | {
  8570. width: number;
  8571. height: number;
  8572. layers?: number;
  8573. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8574. /**
  8575. * Creates a depth stencil texture.
  8576. * This is only available in WebGL 2 or with the depth texture extension available.
  8577. * @param size The size of face edge in the texture.
  8578. * @param options The options defining the texture.
  8579. * @returns The texture
  8580. */
  8581. createDepthStencilTexture(size: number | {
  8582. width: number;
  8583. height: number;
  8584. layers?: number;
  8585. }, options: DepthTextureCreationOptions): InternalTexture;
  8586. /** @hidden */
  8587. _createDepthStencilTexture(size: number | {
  8588. width: number;
  8589. height: number;
  8590. layers?: number;
  8591. }, options: DepthTextureCreationOptions): InternalTexture;
  8592. }
  8593. }
  8594. }
  8595. declare module "babylonjs/Maths/math.axis" {
  8596. import { Vector3 } from "babylonjs/Maths/math.vector";
  8597. /** Defines supported spaces */
  8598. export enum Space {
  8599. /** Local (object) space */
  8600. LOCAL = 0,
  8601. /** World space */
  8602. WORLD = 1,
  8603. /** Bone space */
  8604. BONE = 2
  8605. }
  8606. /** Defines the 3 main axes */
  8607. export class Axis {
  8608. /** X axis */
  8609. static X: Vector3;
  8610. /** Y axis */
  8611. static Y: Vector3;
  8612. /** Z axis */
  8613. static Z: Vector3;
  8614. }
  8615. }
  8616. declare module "babylonjs/Cameras/targetCamera" {
  8617. import { Nullable } from "babylonjs/types";
  8618. import { Camera } from "babylonjs/Cameras/camera";
  8619. import { Scene } from "babylonjs/scene";
  8620. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8621. /**
  8622. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8623. * This is the base of the follow, arc rotate cameras and Free camera
  8624. * @see http://doc.babylonjs.com/features/cameras
  8625. */
  8626. export class TargetCamera extends Camera {
  8627. private static _RigCamTransformMatrix;
  8628. private static _TargetTransformMatrix;
  8629. private static _TargetFocalPoint;
  8630. /**
  8631. * Define the current direction the camera is moving to
  8632. */
  8633. cameraDirection: Vector3;
  8634. /**
  8635. * Define the current rotation the camera is rotating to
  8636. */
  8637. cameraRotation: Vector2;
  8638. /**
  8639. * When set, the up vector of the camera will be updated by the rotation of the camera
  8640. */
  8641. updateUpVectorFromRotation: boolean;
  8642. private _tmpQuaternion;
  8643. /**
  8644. * Define the current rotation of the camera
  8645. */
  8646. rotation: Vector3;
  8647. /**
  8648. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8649. */
  8650. rotationQuaternion: Quaternion;
  8651. /**
  8652. * Define the current speed of the camera
  8653. */
  8654. speed: number;
  8655. /**
  8656. * Add constraint to the camera to prevent it to move freely in all directions and
  8657. * around all axis.
  8658. */
  8659. noRotationConstraint: boolean;
  8660. /**
  8661. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8662. * panning
  8663. */
  8664. invertRotation: boolean;
  8665. /**
  8666. * Speed multiplier for inverse camera panning
  8667. */
  8668. inverseRotationSpeed: number;
  8669. /**
  8670. * Define the current target of the camera as an object or a position.
  8671. */
  8672. lockedTarget: any;
  8673. /** @hidden */
  8674. _currentTarget: Vector3;
  8675. /** @hidden */
  8676. _initialFocalDistance: number;
  8677. /** @hidden */
  8678. _viewMatrix: Matrix;
  8679. /** @hidden */
  8680. _camMatrix: Matrix;
  8681. /** @hidden */
  8682. _cameraTransformMatrix: Matrix;
  8683. /** @hidden */
  8684. _cameraRotationMatrix: Matrix;
  8685. /** @hidden */
  8686. _referencePoint: Vector3;
  8687. /** @hidden */
  8688. _transformedReferencePoint: Vector3;
  8689. protected _globalCurrentTarget: Vector3;
  8690. protected _globalCurrentUpVector: Vector3;
  8691. /** @hidden */
  8692. _reset: () => void;
  8693. private _defaultUp;
  8694. /**
  8695. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8696. * This is the base of the follow, arc rotate cameras and Free camera
  8697. * @see http://doc.babylonjs.com/features/cameras
  8698. * @param name Defines the name of the camera in the scene
  8699. * @param position Defines the start position of the camera in the scene
  8700. * @param scene Defines the scene the camera belongs to
  8701. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8702. */
  8703. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8704. /**
  8705. * Gets the position in front of the camera at a given distance.
  8706. * @param distance The distance from the camera we want the position to be
  8707. * @returns the position
  8708. */
  8709. getFrontPosition(distance: number): Vector3;
  8710. /** @hidden */
  8711. _getLockedTargetPosition(): Nullable<Vector3>;
  8712. private _storedPosition;
  8713. private _storedRotation;
  8714. private _storedRotationQuaternion;
  8715. /**
  8716. * Store current camera state of the camera (fov, position, rotation, etc..)
  8717. * @returns the camera
  8718. */
  8719. storeState(): Camera;
  8720. /**
  8721. * Restored camera state. You must call storeState() first
  8722. * @returns whether it was successful or not
  8723. * @hidden
  8724. */
  8725. _restoreStateValues(): boolean;
  8726. /** @hidden */
  8727. _initCache(): void;
  8728. /** @hidden */
  8729. _updateCache(ignoreParentClass?: boolean): void;
  8730. /** @hidden */
  8731. _isSynchronizedViewMatrix(): boolean;
  8732. /** @hidden */
  8733. _computeLocalCameraSpeed(): number;
  8734. /**
  8735. * Defines the target the camera should look at.
  8736. * @param target Defines the new target as a Vector or a mesh
  8737. */
  8738. setTarget(target: Vector3): void;
  8739. /**
  8740. * Return the current target position of the camera. This value is expressed in local space.
  8741. * @returns the target position
  8742. */
  8743. getTarget(): Vector3;
  8744. /** @hidden */
  8745. _decideIfNeedsToMove(): boolean;
  8746. /** @hidden */
  8747. _updatePosition(): void;
  8748. /** @hidden */
  8749. _checkInputs(): void;
  8750. protected _updateCameraRotationMatrix(): void;
  8751. /**
  8752. * 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)
  8753. * @returns the current camera
  8754. */
  8755. private _rotateUpVectorWithCameraRotationMatrix;
  8756. private _cachedRotationZ;
  8757. private _cachedQuaternionRotationZ;
  8758. /** @hidden */
  8759. _getViewMatrix(): Matrix;
  8760. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8761. /**
  8762. * @hidden
  8763. */
  8764. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8765. /**
  8766. * @hidden
  8767. */
  8768. _updateRigCameras(): void;
  8769. private _getRigCamPositionAndTarget;
  8770. /**
  8771. * Gets the current object class name.
  8772. * @return the class name
  8773. */
  8774. getClassName(): string;
  8775. }
  8776. }
  8777. declare module "babylonjs/Events/keyboardEvents" {
  8778. /**
  8779. * Gather the list of keyboard event types as constants.
  8780. */
  8781. export class KeyboardEventTypes {
  8782. /**
  8783. * The keydown event is fired when a key becomes active (pressed).
  8784. */
  8785. static readonly KEYDOWN: number;
  8786. /**
  8787. * The keyup event is fired when a key has been released.
  8788. */
  8789. static readonly KEYUP: number;
  8790. }
  8791. /**
  8792. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8793. */
  8794. export class 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. * Instantiates a new keyboard info.
  8805. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8806. * @param type Defines the type of event (KeyboardEventTypes)
  8807. * @param event Defines the related dom event
  8808. */
  8809. constructor(
  8810. /**
  8811. * Defines the type of event (KeyboardEventTypes)
  8812. */
  8813. type: number,
  8814. /**
  8815. * Defines the related dom event
  8816. */
  8817. event: KeyboardEvent);
  8818. }
  8819. /**
  8820. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8821. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8822. */
  8823. export class KeyboardInfoPre extends KeyboardInfo {
  8824. /**
  8825. * Defines the type of event (KeyboardEventTypes)
  8826. */
  8827. type: number;
  8828. /**
  8829. * Defines the related dom event
  8830. */
  8831. event: KeyboardEvent;
  8832. /**
  8833. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8834. */
  8835. skipOnPointerObservable: boolean;
  8836. /**
  8837. * Instantiates a new keyboard pre info.
  8838. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8839. * @param type Defines the type of event (KeyboardEventTypes)
  8840. * @param event Defines the related dom event
  8841. */
  8842. constructor(
  8843. /**
  8844. * Defines the type of event (KeyboardEventTypes)
  8845. */
  8846. type: number,
  8847. /**
  8848. * Defines the related dom event
  8849. */
  8850. event: KeyboardEvent);
  8851. }
  8852. }
  8853. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8854. import { Nullable } from "babylonjs/types";
  8855. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8856. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8857. /**
  8858. * Manage the keyboard inputs to control the movement of a free camera.
  8859. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8860. */
  8861. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8862. /**
  8863. * Defines the camera the input is attached to.
  8864. */
  8865. camera: FreeCamera;
  8866. /**
  8867. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8868. */
  8869. keysUp: number[];
  8870. /**
  8871. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  8872. */
  8873. keysUpward: number[];
  8874. /**
  8875. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8876. */
  8877. keysDown: number[];
  8878. /**
  8879. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  8880. */
  8881. keysDownward: number[];
  8882. /**
  8883. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8884. */
  8885. keysLeft: number[];
  8886. /**
  8887. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8888. */
  8889. keysRight: number[];
  8890. private _keys;
  8891. private _onCanvasBlurObserver;
  8892. private _onKeyboardObserver;
  8893. private _engine;
  8894. private _scene;
  8895. /**
  8896. * Attach the input controls to a specific dom element to get the input from.
  8897. * @param element Defines the element the controls should be listened from
  8898. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8899. */
  8900. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8901. /**
  8902. * Detach the current controls from the specified dom element.
  8903. * @param element Defines the element to stop listening the inputs from
  8904. */
  8905. detachControl(element: Nullable<HTMLElement>): void;
  8906. /**
  8907. * Update the current camera state depending on the inputs that have been used this frame.
  8908. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8909. */
  8910. checkInputs(): void;
  8911. /**
  8912. * Gets the class name of the current intput.
  8913. * @returns the class name
  8914. */
  8915. getClassName(): string;
  8916. /** @hidden */
  8917. _onLostFocus(): void;
  8918. /**
  8919. * Get the friendly name associated with the input class.
  8920. * @returns the input friendly name
  8921. */
  8922. getSimpleName(): string;
  8923. }
  8924. }
  8925. declare module "babylonjs/Lights/shadowLight" {
  8926. import { Camera } from "babylonjs/Cameras/camera";
  8927. import { Scene } from "babylonjs/scene";
  8928. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8929. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8930. import { Light } from "babylonjs/Lights/light";
  8931. /**
  8932. * Interface describing all the common properties and methods a shadow light needs to implement.
  8933. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8934. * as well as binding the different shadow properties to the effects.
  8935. */
  8936. export interface IShadowLight extends Light {
  8937. /**
  8938. * The light id in the scene (used in scene.findLighById for instance)
  8939. */
  8940. id: string;
  8941. /**
  8942. * The position the shdow will be casted from.
  8943. */
  8944. position: Vector3;
  8945. /**
  8946. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8947. */
  8948. direction: Vector3;
  8949. /**
  8950. * The transformed position. Position of the light in world space taking parenting in account.
  8951. */
  8952. transformedPosition: Vector3;
  8953. /**
  8954. * The transformed direction. Direction of the light in world space taking parenting in account.
  8955. */
  8956. transformedDirection: Vector3;
  8957. /**
  8958. * The friendly name of the light in the scene.
  8959. */
  8960. name: string;
  8961. /**
  8962. * Defines the shadow projection clipping minimum z value.
  8963. */
  8964. shadowMinZ: number;
  8965. /**
  8966. * Defines the shadow projection clipping maximum z value.
  8967. */
  8968. shadowMaxZ: number;
  8969. /**
  8970. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8971. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8972. */
  8973. computeTransformedInformation(): boolean;
  8974. /**
  8975. * Gets the scene the light belongs to.
  8976. * @returns The scene
  8977. */
  8978. getScene(): Scene;
  8979. /**
  8980. * Callback defining a custom Projection Matrix Builder.
  8981. * This can be used to override the default projection matrix computation.
  8982. */
  8983. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8984. /**
  8985. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8986. * @param matrix The materix to updated with the projection information
  8987. * @param viewMatrix The transform matrix of the light
  8988. * @param renderList The list of mesh to render in the map
  8989. * @returns The current light
  8990. */
  8991. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8992. /**
  8993. * Gets the current depth scale used in ESM.
  8994. * @returns The scale
  8995. */
  8996. getDepthScale(): number;
  8997. /**
  8998. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8999. * @returns true if a cube texture needs to be use
  9000. */
  9001. needCube(): boolean;
  9002. /**
  9003. * Detects if the projection matrix requires to be recomputed this frame.
  9004. * @returns true if it requires to be recomputed otherwise, false.
  9005. */
  9006. needProjectionMatrixCompute(): boolean;
  9007. /**
  9008. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9009. */
  9010. forceProjectionMatrixCompute(): void;
  9011. /**
  9012. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9013. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9014. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9015. */
  9016. getShadowDirection(faceIndex?: number): Vector3;
  9017. /**
  9018. * Gets the minZ used for shadow according to both the scene and the light.
  9019. * @param activeCamera The camera we are returning the min for
  9020. * @returns the depth min z
  9021. */
  9022. getDepthMinZ(activeCamera: Camera): number;
  9023. /**
  9024. * Gets the maxZ used for shadow according to both the scene and the light.
  9025. * @param activeCamera The camera we are returning the max for
  9026. * @returns the depth max z
  9027. */
  9028. getDepthMaxZ(activeCamera: Camera): number;
  9029. }
  9030. /**
  9031. * Base implementation IShadowLight
  9032. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9033. */
  9034. export abstract class ShadowLight extends Light implements IShadowLight {
  9035. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9036. protected _position: Vector3;
  9037. protected _setPosition(value: Vector3): void;
  9038. /**
  9039. * Sets the position the shadow will be casted from. Also use as the light position for both
  9040. * point and spot lights.
  9041. */
  9042. get position(): Vector3;
  9043. /**
  9044. * Sets the position the shadow will be casted from. Also use as the light position for both
  9045. * point and spot lights.
  9046. */
  9047. set position(value: Vector3);
  9048. protected _direction: Vector3;
  9049. protected _setDirection(value: Vector3): void;
  9050. /**
  9051. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9052. * Also use as the light direction on spot and directional lights.
  9053. */
  9054. get direction(): Vector3;
  9055. /**
  9056. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9057. * Also use as the light direction on spot and directional lights.
  9058. */
  9059. set direction(value: Vector3);
  9060. protected _shadowMinZ: number;
  9061. /**
  9062. * Gets the shadow projection clipping minimum z value.
  9063. */
  9064. get shadowMinZ(): number;
  9065. /**
  9066. * Sets the shadow projection clipping minimum z value.
  9067. */
  9068. set shadowMinZ(value: number);
  9069. protected _shadowMaxZ: number;
  9070. /**
  9071. * Sets the shadow projection clipping maximum z value.
  9072. */
  9073. get shadowMaxZ(): number;
  9074. /**
  9075. * Gets the shadow projection clipping maximum z value.
  9076. */
  9077. set shadowMaxZ(value: number);
  9078. /**
  9079. * Callback defining a custom Projection Matrix Builder.
  9080. * This can be used to override the default projection matrix computation.
  9081. */
  9082. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9083. /**
  9084. * The transformed position. Position of the light in world space taking parenting in account.
  9085. */
  9086. transformedPosition: Vector3;
  9087. /**
  9088. * The transformed direction. Direction of the light in world space taking parenting in account.
  9089. */
  9090. transformedDirection: Vector3;
  9091. private _needProjectionMatrixCompute;
  9092. /**
  9093. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9094. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9095. */
  9096. computeTransformedInformation(): boolean;
  9097. /**
  9098. * Return the depth scale used for the shadow map.
  9099. * @returns the depth scale.
  9100. */
  9101. getDepthScale(): number;
  9102. /**
  9103. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9104. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9105. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9106. */
  9107. getShadowDirection(faceIndex?: number): Vector3;
  9108. /**
  9109. * Returns the ShadowLight absolute position in the World.
  9110. * @returns the position vector in world space
  9111. */
  9112. getAbsolutePosition(): Vector3;
  9113. /**
  9114. * Sets the ShadowLight direction toward the passed target.
  9115. * @param target The point to target in local space
  9116. * @returns the updated ShadowLight direction
  9117. */
  9118. setDirectionToTarget(target: Vector3): Vector3;
  9119. /**
  9120. * Returns the light rotation in euler definition.
  9121. * @returns the x y z rotation in local space.
  9122. */
  9123. getRotation(): Vector3;
  9124. /**
  9125. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9126. * @returns true if a cube texture needs to be use
  9127. */
  9128. needCube(): boolean;
  9129. /**
  9130. * Detects if the projection matrix requires to be recomputed this frame.
  9131. * @returns true if it requires to be recomputed otherwise, false.
  9132. */
  9133. needProjectionMatrixCompute(): boolean;
  9134. /**
  9135. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9136. */
  9137. forceProjectionMatrixCompute(): void;
  9138. /** @hidden */
  9139. _initCache(): void;
  9140. /** @hidden */
  9141. _isSynchronized(): boolean;
  9142. /**
  9143. * Computes the world matrix of the node
  9144. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9145. * @returns the world matrix
  9146. */
  9147. computeWorldMatrix(force?: boolean): Matrix;
  9148. /**
  9149. * Gets the minZ used for shadow according to both the scene and the light.
  9150. * @param activeCamera The camera we are returning the min for
  9151. * @returns the depth min z
  9152. */
  9153. getDepthMinZ(activeCamera: Camera): number;
  9154. /**
  9155. * Gets the maxZ used for shadow according to both the scene and the light.
  9156. * @param activeCamera The camera we are returning the max for
  9157. * @returns the depth max z
  9158. */
  9159. getDepthMaxZ(activeCamera: Camera): number;
  9160. /**
  9161. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9162. * @param matrix The materix to updated with the projection information
  9163. * @param viewMatrix The transform matrix of the light
  9164. * @param renderList The list of mesh to render in the map
  9165. * @returns The current light
  9166. */
  9167. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9168. }
  9169. }
  9170. declare module "babylonjs/Materials/effectFallbacks" {
  9171. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9172. import { Effect } from "babylonjs/Materials/effect";
  9173. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9174. /**
  9175. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9176. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9177. */
  9178. export class EffectFallbacks implements IEffectFallbacks {
  9179. private _defines;
  9180. private _currentRank;
  9181. private _maxRank;
  9182. private _mesh;
  9183. /**
  9184. * Removes the fallback from the bound mesh.
  9185. */
  9186. unBindMesh(): void;
  9187. /**
  9188. * Adds a fallback on the specified property.
  9189. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9190. * @param define The name of the define in the shader
  9191. */
  9192. addFallback(rank: number, define: string): void;
  9193. /**
  9194. * Sets the mesh to use CPU skinning when needing to fallback.
  9195. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9196. * @param mesh The mesh to use the fallbacks.
  9197. */
  9198. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9199. /**
  9200. * Checks to see if more fallbacks are still availible.
  9201. */
  9202. get hasMoreFallbacks(): boolean;
  9203. /**
  9204. * Removes the defines that should be removed when falling back.
  9205. * @param currentDefines defines the current define statements for the shader.
  9206. * @param effect defines the current effect we try to compile
  9207. * @returns The resulting defines with defines of the current rank removed.
  9208. */
  9209. reduce(currentDefines: string, effect: Effect): string;
  9210. }
  9211. }
  9212. declare module "babylonjs/Materials/materialHelper" {
  9213. import { Nullable } from "babylonjs/types";
  9214. import { Scene } from "babylonjs/scene";
  9215. import { Engine } from "babylonjs/Engines/engine";
  9216. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9217. import { Light } from "babylonjs/Lights/light";
  9218. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9219. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9220. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9221. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9222. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9223. /**
  9224. * "Static Class" containing the most commonly used helper while dealing with material for
  9225. * rendering purpose.
  9226. *
  9227. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9228. *
  9229. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9230. */
  9231. export class MaterialHelper {
  9232. /**
  9233. * Bind the current view position to an effect.
  9234. * @param effect The effect to be bound
  9235. * @param scene The scene the eyes position is used from
  9236. */
  9237. static BindEyePosition(effect: Effect, scene: Scene): void;
  9238. /**
  9239. * Helps preparing the defines values about the UVs in used in the effect.
  9240. * UVs are shared as much as we can accross channels in the shaders.
  9241. * @param texture The texture we are preparing the UVs for
  9242. * @param defines The defines to update
  9243. * @param key The channel key "diffuse", "specular"... used in the shader
  9244. */
  9245. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9246. /**
  9247. * Binds a texture matrix value to its corrsponding uniform
  9248. * @param texture The texture to bind the matrix for
  9249. * @param uniformBuffer The uniform buffer receivin the data
  9250. * @param key The channel key "diffuse", "specular"... used in the shader
  9251. */
  9252. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9253. /**
  9254. * Gets the current status of the fog (should it be enabled?)
  9255. * @param mesh defines the mesh to evaluate for fog support
  9256. * @param scene defines the hosting scene
  9257. * @returns true if fog must be enabled
  9258. */
  9259. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9260. /**
  9261. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9262. * @param mesh defines the current mesh
  9263. * @param scene defines the current scene
  9264. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9265. * @param pointsCloud defines if point cloud rendering has to be turned on
  9266. * @param fogEnabled defines if fog has to be turned on
  9267. * @param alphaTest defines if alpha testing has to be turned on
  9268. * @param defines defines the current list of defines
  9269. */
  9270. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9271. /**
  9272. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9273. * @param scene defines the current scene
  9274. * @param engine defines the current engine
  9275. * @param defines specifies the list of active defines
  9276. * @param useInstances defines if instances have to be turned on
  9277. * @param useClipPlane defines if clip plane have to be turned on
  9278. */
  9279. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9280. /**
  9281. * Prepares the defines for bones
  9282. * @param mesh The mesh containing the geometry data we will draw
  9283. * @param defines The defines to update
  9284. */
  9285. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9286. /**
  9287. * Prepares the defines for morph targets
  9288. * @param mesh The mesh containing the geometry data we will draw
  9289. * @param defines The defines to update
  9290. */
  9291. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9292. /**
  9293. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9294. * @param mesh The mesh containing the geometry data we will draw
  9295. * @param defines The defines to update
  9296. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9297. * @param useBones Precise whether bones should be used or not (override mesh info)
  9298. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9299. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9300. * @returns false if defines are considered not dirty and have not been checked
  9301. */
  9302. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9303. /**
  9304. * Prepares the defines related to multiview
  9305. * @param scene The scene we are intending to draw
  9306. * @param defines The defines to update
  9307. */
  9308. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9309. /**
  9310. * Prepares the defines related to the light information passed in parameter
  9311. * @param scene The scene we are intending to draw
  9312. * @param mesh The mesh the effect is compiling for
  9313. * @param light The light the effect is compiling for
  9314. * @param lightIndex The index of the light
  9315. * @param defines The defines to update
  9316. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9317. * @param state Defines the current state regarding what is needed (normals, etc...)
  9318. */
  9319. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9320. needNormals: boolean;
  9321. needRebuild: boolean;
  9322. shadowEnabled: boolean;
  9323. specularEnabled: boolean;
  9324. lightmapMode: boolean;
  9325. }): void;
  9326. /**
  9327. * Prepares the defines related to the light information passed in parameter
  9328. * @param scene The scene we are intending to draw
  9329. * @param mesh The mesh the effect is compiling for
  9330. * @param defines The defines to update
  9331. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9332. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9333. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9334. * @returns true if normals will be required for the rest of the effect
  9335. */
  9336. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9337. /**
  9338. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9339. * @param lightIndex defines the light index
  9340. * @param uniformsList The uniform list
  9341. * @param samplersList The sampler list
  9342. * @param projectedLightTexture defines if projected texture must be used
  9343. * @param uniformBuffersList defines an optional list of uniform buffers
  9344. */
  9345. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9346. /**
  9347. * Prepares the uniforms and samplers list to be used in the effect
  9348. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9349. * @param samplersList The sampler list
  9350. * @param defines The defines helping in the list generation
  9351. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9352. */
  9353. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9354. /**
  9355. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9356. * @param defines The defines to update while falling back
  9357. * @param fallbacks The authorized effect fallbacks
  9358. * @param maxSimultaneousLights The maximum number of lights allowed
  9359. * @param rank the current rank of the Effect
  9360. * @returns The newly affected rank
  9361. */
  9362. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9363. private static _TmpMorphInfluencers;
  9364. /**
  9365. * Prepares the list of attributes required for morph targets according to the effect defines.
  9366. * @param attribs The current list of supported attribs
  9367. * @param mesh The mesh to prepare the morph targets attributes for
  9368. * @param influencers The number of influencers
  9369. */
  9370. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9371. /**
  9372. * Prepares the list of attributes required for morph targets according to the effect defines.
  9373. * @param attribs The current list of supported attribs
  9374. * @param mesh The mesh to prepare the morph targets attributes for
  9375. * @param defines The current Defines of the effect
  9376. */
  9377. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9378. /**
  9379. * Prepares the list of attributes required for bones according to the effect defines.
  9380. * @param attribs The current list of supported attribs
  9381. * @param mesh The mesh to prepare the bones attributes for
  9382. * @param defines The current Defines of the effect
  9383. * @param fallbacks The current efffect fallback strategy
  9384. */
  9385. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9386. /**
  9387. * Check and prepare the list of attributes required for instances according to the effect defines.
  9388. * @param attribs The current list of supported attribs
  9389. * @param defines The current MaterialDefines of the effect
  9390. */
  9391. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9392. /**
  9393. * Add the list of attributes required for instances to the attribs array.
  9394. * @param attribs The current list of supported attribs
  9395. */
  9396. static PushAttributesForInstances(attribs: string[]): void;
  9397. /**
  9398. * Binds the light information to the effect.
  9399. * @param light The light containing the generator
  9400. * @param effect The effect we are binding the data to
  9401. * @param lightIndex The light index in the effect used to render
  9402. */
  9403. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9404. /**
  9405. * Binds the lights information from the scene to the effect for the given mesh.
  9406. * @param light Light to bind
  9407. * @param lightIndex Light index
  9408. * @param scene The scene where the light belongs to
  9409. * @param effect The effect we are binding the data to
  9410. * @param useSpecular Defines if specular is supported
  9411. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9412. */
  9413. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9414. /**
  9415. * Binds the lights information from the scene to the effect for the given mesh.
  9416. * @param scene The scene the lights belongs to
  9417. * @param mesh The mesh we are binding the information to render
  9418. * @param effect The effect we are binding the data to
  9419. * @param defines The generated defines for the effect
  9420. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9421. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9422. */
  9423. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9424. private static _tempFogColor;
  9425. /**
  9426. * Binds the fog information from the scene to the effect for the given mesh.
  9427. * @param scene The scene the lights belongs to
  9428. * @param mesh The mesh we are binding the information to render
  9429. * @param effect The effect we are binding the data to
  9430. * @param linearSpace Defines if the fog effect is applied in linear space
  9431. */
  9432. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9433. /**
  9434. * Binds the bones information from the mesh to the effect.
  9435. * @param mesh The mesh we are binding the information to render
  9436. * @param effect The effect we are binding the data to
  9437. */
  9438. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9439. /**
  9440. * Binds the morph targets information from the mesh to the effect.
  9441. * @param abstractMesh The mesh we are binding the information to render
  9442. * @param effect The effect we are binding the data to
  9443. */
  9444. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9445. /**
  9446. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9447. * @param defines The generated defines used in the effect
  9448. * @param effect The effect we are binding the data to
  9449. * @param scene The scene we are willing to render with logarithmic scale for
  9450. */
  9451. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9452. /**
  9453. * Binds the clip plane information from the scene to the effect.
  9454. * @param scene The scene the clip plane information are extracted from
  9455. * @param effect The effect we are binding the data to
  9456. */
  9457. static BindClipPlane(effect: Effect, scene: Scene): void;
  9458. }
  9459. }
  9460. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9461. /** @hidden */
  9462. export var packingFunctions: {
  9463. name: string;
  9464. shader: string;
  9465. };
  9466. }
  9467. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9468. /** @hidden */
  9469. export var clipPlaneFragmentDeclaration: {
  9470. name: string;
  9471. shader: string;
  9472. };
  9473. }
  9474. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9475. /** @hidden */
  9476. export var clipPlaneFragment: {
  9477. name: string;
  9478. shader: string;
  9479. };
  9480. }
  9481. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9482. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9483. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9484. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9485. /** @hidden */
  9486. export var shadowMapPixelShader: {
  9487. name: string;
  9488. shader: string;
  9489. };
  9490. }
  9491. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9492. /** @hidden */
  9493. export var bonesDeclaration: {
  9494. name: string;
  9495. shader: string;
  9496. };
  9497. }
  9498. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9499. /** @hidden */
  9500. export var morphTargetsVertexGlobalDeclaration: {
  9501. name: string;
  9502. shader: string;
  9503. };
  9504. }
  9505. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9506. /** @hidden */
  9507. export var morphTargetsVertexDeclaration: {
  9508. name: string;
  9509. shader: string;
  9510. };
  9511. }
  9512. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9513. /** @hidden */
  9514. export var instancesDeclaration: {
  9515. name: string;
  9516. shader: string;
  9517. };
  9518. }
  9519. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9520. /** @hidden */
  9521. export var helperFunctions: {
  9522. name: string;
  9523. shader: string;
  9524. };
  9525. }
  9526. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9527. /** @hidden */
  9528. export var clipPlaneVertexDeclaration: {
  9529. name: string;
  9530. shader: string;
  9531. };
  9532. }
  9533. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9534. /** @hidden */
  9535. export var morphTargetsVertex: {
  9536. name: string;
  9537. shader: string;
  9538. };
  9539. }
  9540. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9541. /** @hidden */
  9542. export var instancesVertex: {
  9543. name: string;
  9544. shader: string;
  9545. };
  9546. }
  9547. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9548. /** @hidden */
  9549. export var bonesVertex: {
  9550. name: string;
  9551. shader: string;
  9552. };
  9553. }
  9554. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9555. /** @hidden */
  9556. export var clipPlaneVertex: {
  9557. name: string;
  9558. shader: string;
  9559. };
  9560. }
  9561. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9562. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9563. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9564. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9565. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9566. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9567. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9568. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9569. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9570. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9571. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9572. /** @hidden */
  9573. export var shadowMapVertexShader: {
  9574. name: string;
  9575. shader: string;
  9576. };
  9577. }
  9578. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9579. /** @hidden */
  9580. export var depthBoxBlurPixelShader: {
  9581. name: string;
  9582. shader: string;
  9583. };
  9584. }
  9585. declare module "babylonjs/Culling/ray" {
  9586. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  9587. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9588. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9589. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9590. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  9591. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  9592. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  9593. import { Plane } from "babylonjs/Maths/math.plane";
  9594. /**
  9595. * Class representing a ray with position and direction
  9596. */
  9597. export class Ray {
  9598. /** origin point */
  9599. origin: Vector3;
  9600. /** direction */
  9601. direction: Vector3;
  9602. /** length of the ray */
  9603. length: number;
  9604. private static readonly TmpVector3;
  9605. private _tmpRay;
  9606. /**
  9607. * Creates a new ray
  9608. * @param origin origin point
  9609. * @param direction direction
  9610. * @param length length of the ray
  9611. */
  9612. constructor(
  9613. /** origin point */
  9614. origin: Vector3,
  9615. /** direction */
  9616. direction: Vector3,
  9617. /** length of the ray */
  9618. length?: number);
  9619. /**
  9620. * Checks if the ray intersects a box
  9621. * @param minimum bound of the box
  9622. * @param maximum bound of the box
  9623. * @param intersectionTreshold extra extend to be added to the box in all direction
  9624. * @returns if the box was hit
  9625. */
  9626. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9627. /**
  9628. * Checks if the ray intersects a box
  9629. * @param box the bounding box to check
  9630. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9631. * @returns if the box was hit
  9632. */
  9633. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9634. /**
  9635. * If the ray hits a sphere
  9636. * @param sphere the bounding sphere to check
  9637. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9638. * @returns true if it hits the sphere
  9639. */
  9640. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9641. /**
  9642. * If the ray hits a triange
  9643. * @param vertex0 triangle vertex
  9644. * @param vertex1 triangle vertex
  9645. * @param vertex2 triangle vertex
  9646. * @returns intersection information if hit
  9647. */
  9648. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9649. /**
  9650. * Checks if ray intersects a plane
  9651. * @param plane the plane to check
  9652. * @returns the distance away it was hit
  9653. */
  9654. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9655. /**
  9656. * Calculate the intercept of a ray on a given axis
  9657. * @param axis to check 'x' | 'y' | 'z'
  9658. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9659. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9660. */
  9661. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9662. /**
  9663. * Checks if ray intersects a mesh
  9664. * @param mesh the mesh to check
  9665. * @param fastCheck if only the bounding box should checked
  9666. * @returns picking info of the intersecton
  9667. */
  9668. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9669. /**
  9670. * Checks if ray intersects a mesh
  9671. * @param meshes the meshes to check
  9672. * @param fastCheck if only the bounding box should checked
  9673. * @param results array to store result in
  9674. * @returns Array of picking infos
  9675. */
  9676. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9677. private _comparePickingInfo;
  9678. private static smallnum;
  9679. private static rayl;
  9680. /**
  9681. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9682. * @param sega the first point of the segment to test the intersection against
  9683. * @param segb the second point of the segment to test the intersection against
  9684. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9685. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9686. */
  9687. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9688. /**
  9689. * Update the ray from viewport position
  9690. * @param x position
  9691. * @param y y position
  9692. * @param viewportWidth viewport width
  9693. * @param viewportHeight viewport height
  9694. * @param world world matrix
  9695. * @param view view matrix
  9696. * @param projection projection matrix
  9697. * @returns this ray updated
  9698. */
  9699. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9700. /**
  9701. * Creates a ray with origin and direction of 0,0,0
  9702. * @returns the new ray
  9703. */
  9704. static Zero(): Ray;
  9705. /**
  9706. * Creates a new ray from screen space and viewport
  9707. * @param x position
  9708. * @param y y position
  9709. * @param viewportWidth viewport width
  9710. * @param viewportHeight viewport height
  9711. * @param world world matrix
  9712. * @param view view matrix
  9713. * @param projection projection matrix
  9714. * @returns new ray
  9715. */
  9716. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9717. /**
  9718. * 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
  9719. * transformed to the given world matrix.
  9720. * @param origin The origin point
  9721. * @param end The end point
  9722. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9723. * @returns the new ray
  9724. */
  9725. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9726. /**
  9727. * Transforms a ray by a matrix
  9728. * @param ray ray to transform
  9729. * @param matrix matrix to apply
  9730. * @returns the resulting new ray
  9731. */
  9732. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9733. /**
  9734. * Transforms a ray by a matrix
  9735. * @param ray ray to transform
  9736. * @param matrix matrix to apply
  9737. * @param result ray to store result in
  9738. */
  9739. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9740. /**
  9741. * Unproject a ray from screen space to object space
  9742. * @param sourceX defines the screen space x coordinate to use
  9743. * @param sourceY defines the screen space y coordinate to use
  9744. * @param viewportWidth defines the current width of the viewport
  9745. * @param viewportHeight defines the current height of the viewport
  9746. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9747. * @param view defines the view matrix to use
  9748. * @param projection defines the projection matrix to use
  9749. */
  9750. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9751. }
  9752. /**
  9753. * Type used to define predicate used to select faces when a mesh intersection is detected
  9754. */
  9755. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9756. module "babylonjs/scene" {
  9757. interface Scene {
  9758. /** @hidden */
  9759. _tempPickingRay: Nullable<Ray>;
  9760. /** @hidden */
  9761. _cachedRayForTransform: Ray;
  9762. /** @hidden */
  9763. _pickWithRayInverseMatrix: Matrix;
  9764. /** @hidden */
  9765. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9766. /** @hidden */
  9767. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9768. }
  9769. }
  9770. }
  9771. declare module "babylonjs/sceneComponent" {
  9772. import { Scene } from "babylonjs/scene";
  9773. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9774. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9775. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  9776. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  9777. import { Nullable } from "babylonjs/types";
  9778. import { Camera } from "babylonjs/Cameras/camera";
  9779. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9780. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9781. import { AbstractScene } from "babylonjs/abstractScene";
  9782. import { Mesh } from "babylonjs/Meshes/mesh";
  9783. /**
  9784. * Groups all the scene component constants in one place to ease maintenance.
  9785. * @hidden
  9786. */
  9787. export class SceneComponentConstants {
  9788. static readonly NAME_EFFECTLAYER: string;
  9789. static readonly NAME_LAYER: string;
  9790. static readonly NAME_LENSFLARESYSTEM: string;
  9791. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9792. static readonly NAME_PARTICLESYSTEM: string;
  9793. static readonly NAME_GAMEPAD: string;
  9794. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9795. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9796. static readonly NAME_DEPTHRENDERER: string;
  9797. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9798. static readonly NAME_SPRITE: string;
  9799. static readonly NAME_OUTLINERENDERER: string;
  9800. static readonly NAME_PROCEDURALTEXTURE: string;
  9801. static readonly NAME_SHADOWGENERATOR: string;
  9802. static readonly NAME_OCTREE: string;
  9803. static readonly NAME_PHYSICSENGINE: string;
  9804. static readonly NAME_AUDIO: string;
  9805. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9806. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9807. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9808. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9809. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9810. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9811. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9812. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9813. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9814. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9815. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9816. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9817. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9818. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9819. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9820. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9821. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9822. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9823. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9824. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9825. static readonly STEP_AFTERRENDER_AUDIO: number;
  9826. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9827. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9828. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9829. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9830. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9831. static readonly STEP_POINTERMOVE_SPRITE: number;
  9832. static readonly STEP_POINTERDOWN_SPRITE: number;
  9833. static readonly STEP_POINTERUP_SPRITE: number;
  9834. }
  9835. /**
  9836. * This represents a scene component.
  9837. *
  9838. * This is used to decouple the dependency the scene is having on the different workloads like
  9839. * layers, post processes...
  9840. */
  9841. export interface ISceneComponent {
  9842. /**
  9843. * The name of the component. Each component must have a unique name.
  9844. */
  9845. name: string;
  9846. /**
  9847. * The scene the component belongs to.
  9848. */
  9849. scene: Scene;
  9850. /**
  9851. * Register the component to one instance of a scene.
  9852. */
  9853. register(): void;
  9854. /**
  9855. * Rebuilds the elements related to this component in case of
  9856. * context lost for instance.
  9857. */
  9858. rebuild(): void;
  9859. /**
  9860. * Disposes the component and the associated ressources.
  9861. */
  9862. dispose(): void;
  9863. }
  9864. /**
  9865. * This represents a SERIALIZABLE scene component.
  9866. *
  9867. * This extends Scene Component to add Serialization methods on top.
  9868. */
  9869. export interface ISceneSerializableComponent extends ISceneComponent {
  9870. /**
  9871. * Adds all the elements from the container to the scene
  9872. * @param container the container holding the elements
  9873. */
  9874. addFromContainer(container: AbstractScene): void;
  9875. /**
  9876. * Removes all the elements in the container from the scene
  9877. * @param container contains the elements to remove
  9878. * @param dispose if the removed element should be disposed (default: false)
  9879. */
  9880. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9881. /**
  9882. * Serializes the component data to the specified json object
  9883. * @param serializationObject The object to serialize to
  9884. */
  9885. serialize(serializationObject: any): void;
  9886. }
  9887. /**
  9888. * Strong typing of a Mesh related stage step action
  9889. */
  9890. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9891. /**
  9892. * Strong typing of a Evaluate Sub Mesh related stage step action
  9893. */
  9894. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9895. /**
  9896. * Strong typing of a Active Mesh related stage step action
  9897. */
  9898. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9899. /**
  9900. * Strong typing of a Camera related stage step action
  9901. */
  9902. export type CameraStageAction = (camera: Camera) => void;
  9903. /**
  9904. * Strong typing of a Camera Frame buffer related stage step action
  9905. */
  9906. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9907. /**
  9908. * Strong typing of a Render Target related stage step action
  9909. */
  9910. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9911. /**
  9912. * Strong typing of a RenderingGroup related stage step action
  9913. */
  9914. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9915. /**
  9916. * Strong typing of a Mesh Render related stage step action
  9917. */
  9918. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9919. /**
  9920. * Strong typing of a simple stage step action
  9921. */
  9922. export type SimpleStageAction = () => void;
  9923. /**
  9924. * Strong typing of a render target action.
  9925. */
  9926. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9927. /**
  9928. * Strong typing of a pointer move action.
  9929. */
  9930. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9931. /**
  9932. * Strong typing of a pointer up/down action.
  9933. */
  9934. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9935. /**
  9936. * Representation of a stage in the scene (Basically a list of ordered steps)
  9937. * @hidden
  9938. */
  9939. export class Stage<T extends Function> extends Array<{
  9940. index: number;
  9941. component: ISceneComponent;
  9942. action: T;
  9943. }> {
  9944. /**
  9945. * Hide ctor from the rest of the world.
  9946. * @param items The items to add.
  9947. */
  9948. private constructor();
  9949. /**
  9950. * Creates a new Stage.
  9951. * @returns A new instance of a Stage
  9952. */
  9953. static Create<T extends Function>(): Stage<T>;
  9954. /**
  9955. * Registers a step in an ordered way in the targeted stage.
  9956. * @param index Defines the position to register the step in
  9957. * @param component Defines the component attached to the step
  9958. * @param action Defines the action to launch during the step
  9959. */
  9960. registerStep(index: number, component: ISceneComponent, action: T): void;
  9961. /**
  9962. * Clears all the steps from the stage.
  9963. */
  9964. clear(): void;
  9965. }
  9966. }
  9967. declare module "babylonjs/Sprites/spriteSceneComponent" {
  9968. import { Nullable } from "babylonjs/types";
  9969. import { Observable } from "babylonjs/Misc/observable";
  9970. import { Scene } from "babylonjs/scene";
  9971. import { Sprite } from "babylonjs/Sprites/sprite";
  9972. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  9973. import { Ray } from "babylonjs/Culling/ray";
  9974. import { Camera } from "babylonjs/Cameras/camera";
  9975. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9976. import { ISceneComponent } from "babylonjs/sceneComponent";
  9977. module "babylonjs/scene" {
  9978. interface Scene {
  9979. /** @hidden */
  9980. _pointerOverSprite: Nullable<Sprite>;
  9981. /** @hidden */
  9982. _pickedDownSprite: Nullable<Sprite>;
  9983. /** @hidden */
  9984. _tempSpritePickingRay: Nullable<Ray>;
  9985. /**
  9986. * All of the sprite managers added to this scene
  9987. * @see http://doc.babylonjs.com/babylon101/sprites
  9988. */
  9989. spriteManagers: Array<ISpriteManager>;
  9990. /**
  9991. * An event triggered when sprites rendering is about to start
  9992. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9993. */
  9994. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9995. /**
  9996. * An event triggered when sprites rendering is done
  9997. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9998. */
  9999. onAfterSpritesRenderingObservable: Observable<Scene>;
  10000. /** @hidden */
  10001. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10002. /** Launch a ray to try to pick a sprite in the scene
  10003. * @param x position on screen
  10004. * @param y position on screen
  10005. * @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
  10006. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  10007. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10008. * @returns a PickingInfo
  10009. */
  10010. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10011. /** Use the given ray to pick a sprite in the scene
  10012. * @param ray The ray (in world space) to use to pick meshes
  10013. * @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
  10014. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  10015. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10016. * @returns a PickingInfo
  10017. */
  10018. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10019. /** @hidden */
  10020. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10021. /** Launch a ray to try to pick sprites in the scene
  10022. * @param x position on screen
  10023. * @param y position on screen
  10024. * @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
  10025. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10026. * @returns a PickingInfo array
  10027. */
  10028. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10029. /** Use the given ray to pick sprites in the scene
  10030. * @param ray The ray (in world space) to use to pick meshes
  10031. * @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
  10032. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10033. * @returns a PickingInfo array
  10034. */
  10035. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10036. /**
  10037. * Force the sprite under the pointer
  10038. * @param sprite defines the sprite to use
  10039. */
  10040. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10041. /**
  10042. * Gets the sprite under the pointer
  10043. * @returns a Sprite or null if no sprite is under the pointer
  10044. */
  10045. getPointerOverSprite(): Nullable<Sprite>;
  10046. }
  10047. }
  10048. /**
  10049. * Defines the sprite scene component responsible to manage sprites
  10050. * in a given scene.
  10051. */
  10052. export class SpriteSceneComponent implements ISceneComponent {
  10053. /**
  10054. * The component name helpfull to identify the component in the list of scene components.
  10055. */
  10056. readonly name: string;
  10057. /**
  10058. * The scene the component belongs to.
  10059. */
  10060. scene: Scene;
  10061. /** @hidden */
  10062. private _spritePredicate;
  10063. /**
  10064. * Creates a new instance of the component for the given scene
  10065. * @param scene Defines the scene to register the component in
  10066. */
  10067. constructor(scene: Scene);
  10068. /**
  10069. * Registers the component in a given scene
  10070. */
  10071. register(): void;
  10072. /**
  10073. * Rebuilds the elements related to this component in case of
  10074. * context lost for instance.
  10075. */
  10076. rebuild(): void;
  10077. /**
  10078. * Disposes the component and the associated ressources.
  10079. */
  10080. dispose(): void;
  10081. private _pickSpriteButKeepRay;
  10082. private _pointerMove;
  10083. private _pointerDown;
  10084. private _pointerUp;
  10085. }
  10086. }
  10087. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  10088. /** @hidden */
  10089. export var fogFragmentDeclaration: {
  10090. name: string;
  10091. shader: string;
  10092. };
  10093. }
  10094. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  10095. /** @hidden */
  10096. export var fogFragment: {
  10097. name: string;
  10098. shader: string;
  10099. };
  10100. }
  10101. declare module "babylonjs/Shaders/sprites.fragment" {
  10102. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  10103. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  10104. /** @hidden */
  10105. export var spritesPixelShader: {
  10106. name: string;
  10107. shader: string;
  10108. };
  10109. }
  10110. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  10111. /** @hidden */
  10112. export var fogVertexDeclaration: {
  10113. name: string;
  10114. shader: string;
  10115. };
  10116. }
  10117. declare module "babylonjs/Shaders/sprites.vertex" {
  10118. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  10119. /** @hidden */
  10120. export var spritesVertexShader: {
  10121. name: string;
  10122. shader: string;
  10123. };
  10124. }
  10125. declare module "babylonjs/Sprites/spriteManager" {
  10126. import { IDisposable, Scene } from "babylonjs/scene";
  10127. import { Nullable } from "babylonjs/types";
  10128. import { Observable } from "babylonjs/Misc/observable";
  10129. import { Sprite } from "babylonjs/Sprites/sprite";
  10130. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10131. import { Camera } from "babylonjs/Cameras/camera";
  10132. import { Texture } from "babylonjs/Materials/Textures/texture";
  10133. import "babylonjs/Shaders/sprites.fragment";
  10134. import "babylonjs/Shaders/sprites.vertex";
  10135. import { Ray } from "babylonjs/Culling/ray";
  10136. /**
  10137. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10138. */
  10139. export interface ISpriteManager extends IDisposable {
  10140. /**
  10141. * Restricts the camera to viewing objects with the same layerMask.
  10142. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10143. */
  10144. layerMask: number;
  10145. /**
  10146. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10147. */
  10148. isPickable: boolean;
  10149. /**
  10150. * Specifies the rendering group id for this mesh (0 by default)
  10151. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10152. */
  10153. renderingGroupId: number;
  10154. /**
  10155. * Defines the list of sprites managed by the manager.
  10156. */
  10157. sprites: Array<Sprite>;
  10158. /**
  10159. * Tests the intersection of a sprite with a specific ray.
  10160. * @param ray The ray we are sending to test the collision
  10161. * @param camera The camera space we are sending rays in
  10162. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10163. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  10164. * @returns picking info or null.
  10165. */
  10166. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10167. /**
  10168. * Intersects the sprites with a ray
  10169. * @param ray defines the ray to intersect with
  10170. * @param camera defines the current active camera
  10171. * @param predicate defines a predicate used to select candidate sprites
  10172. * @returns null if no hit or a PickingInfo array
  10173. */
  10174. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10175. /**
  10176. * Renders the list of sprites on screen.
  10177. */
  10178. render(): void;
  10179. }
  10180. /**
  10181. * Class used to manage multiple sprites on the same spritesheet
  10182. * @see http://doc.babylonjs.com/babylon101/sprites
  10183. */
  10184. export class SpriteManager implements ISpriteManager {
  10185. /** defines the manager's name */
  10186. name: string;
  10187. /** Gets the list of sprites */
  10188. sprites: Sprite[];
  10189. /** Gets or sets the rendering group id (0 by default) */
  10190. renderingGroupId: number;
  10191. /** Gets or sets camera layer mask */
  10192. layerMask: number;
  10193. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10194. fogEnabled: boolean;
  10195. /** Gets or sets a boolean indicating if the sprites are pickable */
  10196. isPickable: boolean;
  10197. /** Defines the default width of a cell in the spritesheet */
  10198. cellWidth: number;
  10199. /** Defines the default height of a cell in the spritesheet */
  10200. cellHeight: number;
  10201. /** Associative array from JSON sprite data file */
  10202. private _cellData;
  10203. /** Array of sprite names from JSON sprite data file */
  10204. private _spriteMap;
  10205. /** True when packed cell data from JSON file is ready*/
  10206. private _packedAndReady;
  10207. /**
  10208. * An event triggered when the manager is disposed.
  10209. */
  10210. onDisposeObservable: Observable<SpriteManager>;
  10211. private _onDisposeObserver;
  10212. /**
  10213. * Callback called when the manager is disposed
  10214. */
  10215. set onDispose(callback: () => void);
  10216. private _capacity;
  10217. private _fromPacked;
  10218. private _spriteTexture;
  10219. private _epsilon;
  10220. private _scene;
  10221. private _vertexData;
  10222. private _buffer;
  10223. private _vertexBuffers;
  10224. private _indexBuffer;
  10225. private _effectBase;
  10226. private _effectFog;
  10227. /**
  10228. * Gets or sets the spritesheet texture
  10229. */
  10230. get texture(): Texture;
  10231. set texture(value: Texture);
  10232. private _blendMode;
  10233. /**
  10234. * Blend mode use to render the particle, it can be any of
  10235. * the static Constants.ALPHA_x properties provided in this class.
  10236. * Default value is Constants.ALPHA_COMBINE
  10237. */
  10238. get blendMode(): number;
  10239. set blendMode(blendMode: number);
  10240. /** Disables writing to the depth buffer when rendering the sprites.
  10241. * It can be handy to disable depth writing when using textures without alpha channel
  10242. * and setting some specific blend modes.
  10243. */
  10244. disableDepthWrite: boolean;
  10245. /**
  10246. * Creates a new sprite manager
  10247. * @param name defines the manager's name
  10248. * @param imgUrl defines the sprite sheet url
  10249. * @param capacity defines the maximum allowed number of sprites
  10250. * @param cellSize defines the size of a sprite cell
  10251. * @param scene defines the hosting scene
  10252. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10253. * @param samplingMode defines the smapling mode to use with spritesheet
  10254. * @param fromPacked set to false; do not alter
  10255. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10256. */
  10257. constructor(
  10258. /** defines the manager's name */
  10259. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10260. private _makePacked;
  10261. private _appendSpriteVertex;
  10262. /**
  10263. * Intersects the sprites with a ray
  10264. * @param ray defines the ray to intersect with
  10265. * @param camera defines the current active camera
  10266. * @param predicate defines a predicate used to select candidate sprites
  10267. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10268. * @returns null if no hit or a PickingInfo
  10269. */
  10270. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10271. /**
  10272. * Intersects the sprites with a ray
  10273. * @param ray defines the ray to intersect with
  10274. * @param camera defines the current active camera
  10275. * @param predicate defines a predicate used to select candidate sprites
  10276. * @returns null if no hit or a PickingInfo array
  10277. */
  10278. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10279. /**
  10280. * Render all child sprites
  10281. */
  10282. render(): void;
  10283. /**
  10284. * Release associated resources
  10285. */
  10286. dispose(): void;
  10287. }
  10288. }
  10289. declare module "babylonjs/Misc/gradients" {
  10290. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  10291. /** Interface used by value gradients (color, factor, ...) */
  10292. export interface IValueGradient {
  10293. /**
  10294. * Gets or sets the gradient value (between 0 and 1)
  10295. */
  10296. gradient: number;
  10297. }
  10298. /** Class used to store color4 gradient */
  10299. export class ColorGradient implements IValueGradient {
  10300. /**
  10301. * Gets or sets the gradient value (between 0 and 1)
  10302. */
  10303. gradient: number;
  10304. /**
  10305. * Gets or sets first associated color
  10306. */
  10307. color1: Color4;
  10308. /**
  10309. * Gets or sets second associated color
  10310. */
  10311. color2?: Color4;
  10312. /**
  10313. * Will get a color picked randomly between color1 and color2.
  10314. * If color2 is undefined then color1 will be used
  10315. * @param result defines the target Color4 to store the result in
  10316. */
  10317. getColorToRef(result: Color4): void;
  10318. }
  10319. /** Class used to store color 3 gradient */
  10320. export class Color3Gradient implements IValueGradient {
  10321. /**
  10322. * Gets or sets the gradient value (between 0 and 1)
  10323. */
  10324. gradient: number;
  10325. /**
  10326. * Gets or sets the associated color
  10327. */
  10328. color: Color3;
  10329. }
  10330. /** Class used to store factor gradient */
  10331. export class FactorGradient implements IValueGradient {
  10332. /**
  10333. * Gets or sets the gradient value (between 0 and 1)
  10334. */
  10335. gradient: number;
  10336. /**
  10337. * Gets or sets first associated factor
  10338. */
  10339. factor1: number;
  10340. /**
  10341. * Gets or sets second associated factor
  10342. */
  10343. factor2?: number;
  10344. /**
  10345. * Will get a number picked randomly between factor1 and factor2.
  10346. * If factor2 is undefined then factor1 will be used
  10347. * @returns the picked number
  10348. */
  10349. getFactor(): number;
  10350. }
  10351. /**
  10352. * Helper used to simplify some generic gradient tasks
  10353. */
  10354. export class GradientHelper {
  10355. /**
  10356. * Gets the current gradient from an array of IValueGradient
  10357. * @param ratio defines the current ratio to get
  10358. * @param gradients defines the array of IValueGradient
  10359. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10360. */
  10361. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10362. }
  10363. }
  10364. declare module "babylonjs/Maths/math.size" {
  10365. /**
  10366. * Interface for the size containing width and height
  10367. */
  10368. export interface ISize {
  10369. /**
  10370. * Width
  10371. */
  10372. width: number;
  10373. /**
  10374. * Heighht
  10375. */
  10376. height: number;
  10377. }
  10378. /**
  10379. * Size containing widht and height
  10380. */
  10381. export class Size implements ISize {
  10382. /**
  10383. * Width
  10384. */
  10385. width: number;
  10386. /**
  10387. * Height
  10388. */
  10389. height: number;
  10390. /**
  10391. * Creates a Size object from the given width and height (floats).
  10392. * @param width width of the new size
  10393. * @param height height of the new size
  10394. */
  10395. constructor(width: number, height: number);
  10396. /**
  10397. * Returns a string with the Size width and height
  10398. * @returns a string with the Size width and height
  10399. */
  10400. toString(): string;
  10401. /**
  10402. * "Size"
  10403. * @returns the string "Size"
  10404. */
  10405. getClassName(): string;
  10406. /**
  10407. * Returns the Size hash code.
  10408. * @returns a hash code for a unique width and height
  10409. */
  10410. getHashCode(): number;
  10411. /**
  10412. * Updates the current size from the given one.
  10413. * @param src the given size
  10414. */
  10415. copyFrom(src: Size): void;
  10416. /**
  10417. * Updates in place the current Size from the given floats.
  10418. * @param width width of the new size
  10419. * @param height height of the new size
  10420. * @returns the updated Size.
  10421. */
  10422. copyFromFloats(width: number, height: number): Size;
  10423. /**
  10424. * Updates in place the current Size from the given floats.
  10425. * @param width width to set
  10426. * @param height height to set
  10427. * @returns the updated Size.
  10428. */
  10429. set(width: number, height: number): Size;
  10430. /**
  10431. * Multiplies the width and height by numbers
  10432. * @param w factor to multiple the width by
  10433. * @param h factor to multiple the height by
  10434. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10435. */
  10436. multiplyByFloats(w: number, h: number): Size;
  10437. /**
  10438. * Clones the size
  10439. * @returns a new Size copied from the given one.
  10440. */
  10441. clone(): Size;
  10442. /**
  10443. * True if the current Size and the given one width and height are strictly equal.
  10444. * @param other the other size to compare against
  10445. * @returns True if the current Size and the given one width and height are strictly equal.
  10446. */
  10447. equals(other: Size): boolean;
  10448. /**
  10449. * The surface of the Size : width * height (float).
  10450. */
  10451. get surface(): number;
  10452. /**
  10453. * Create a new size of zero
  10454. * @returns a new Size set to (0.0, 0.0)
  10455. */
  10456. static Zero(): Size;
  10457. /**
  10458. * Sums the width and height of two sizes
  10459. * @param otherSize size to add to this size
  10460. * @returns a new Size set as the addition result of the current Size and the given one.
  10461. */
  10462. add(otherSize: Size): Size;
  10463. /**
  10464. * Subtracts the width and height of two
  10465. * @param otherSize size to subtract to this size
  10466. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10467. */
  10468. subtract(otherSize: Size): Size;
  10469. /**
  10470. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10471. * @param start starting size to lerp between
  10472. * @param end end size to lerp between
  10473. * @param amount amount to lerp between the start and end values
  10474. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10475. */
  10476. static Lerp(start: Size, end: Size, amount: number): Size;
  10477. }
  10478. }
  10479. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  10480. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10481. import { Nullable } from "babylonjs/types";
  10482. module "babylonjs/Engines/thinEngine" {
  10483. interface ThinEngine {
  10484. /**
  10485. * Creates a dynamic texture
  10486. * @param width defines the width of the texture
  10487. * @param height defines the height of the texture
  10488. * @param generateMipMaps defines if the engine should generate the mip levels
  10489. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10490. * @returns the dynamic texture inside an InternalTexture
  10491. */
  10492. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10493. /**
  10494. * Update the content of a dynamic texture
  10495. * @param texture defines the texture to update
  10496. * @param canvas defines the canvas containing the source
  10497. * @param invertY defines if data must be stored with Y axis inverted
  10498. * @param premulAlpha defines if alpha is stored as premultiplied
  10499. * @param format defines the format of the data
  10500. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10501. */
  10502. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10503. }
  10504. }
  10505. }
  10506. declare module "babylonjs/Misc/canvasGenerator" {
  10507. /**
  10508. * Helper class used to generate a canvas to manipulate images
  10509. */
  10510. export class CanvasGenerator {
  10511. /**
  10512. * Create a new canvas (or offscreen canvas depending on the context)
  10513. * @param width defines the expected width
  10514. * @param height defines the expected height
  10515. * @return a new canvas or offscreen canvas
  10516. */
  10517. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10518. }
  10519. }
  10520. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  10521. import { Scene } from "babylonjs/scene";
  10522. import { Texture } from "babylonjs/Materials/Textures/texture";
  10523. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  10524. /**
  10525. * A class extending Texture allowing drawing on a texture
  10526. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10527. */
  10528. export class DynamicTexture extends Texture {
  10529. private _generateMipMaps;
  10530. private _canvas;
  10531. private _context;
  10532. private _engine;
  10533. /**
  10534. * Creates a DynamicTexture
  10535. * @param name defines the name of the texture
  10536. * @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
  10537. * @param scene defines the scene where you want the texture
  10538. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10539. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10540. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10541. */
  10542. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10543. /**
  10544. * Get the current class name of the texture useful for serialization or dynamic coding.
  10545. * @returns "DynamicTexture"
  10546. */
  10547. getClassName(): string;
  10548. /**
  10549. * Gets the current state of canRescale
  10550. */
  10551. get canRescale(): boolean;
  10552. private _recreate;
  10553. /**
  10554. * Scales the texture
  10555. * @param ratio the scale factor to apply to both width and height
  10556. */
  10557. scale(ratio: number): void;
  10558. /**
  10559. * Resizes the texture
  10560. * @param width the new width
  10561. * @param height the new height
  10562. */
  10563. scaleTo(width: number, height: number): void;
  10564. /**
  10565. * Gets the context of the canvas used by the texture
  10566. * @returns the canvas context of the dynamic texture
  10567. */
  10568. getContext(): CanvasRenderingContext2D;
  10569. /**
  10570. * Clears the texture
  10571. */
  10572. clear(): void;
  10573. /**
  10574. * Updates the texture
  10575. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10576. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10577. */
  10578. update(invertY?: boolean, premulAlpha?: boolean): void;
  10579. /**
  10580. * Draws text onto the texture
  10581. * @param text defines the text to be drawn
  10582. * @param x defines the placement of the text from the left
  10583. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10584. * @param font defines the font to be used with font-style, font-size, font-name
  10585. * @param color defines the color used for the text
  10586. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10587. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10588. * @param update defines whether texture is immediately update (default is true)
  10589. */
  10590. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  10591. /**
  10592. * Clones the texture
  10593. * @returns the clone of the texture.
  10594. */
  10595. clone(): DynamicTexture;
  10596. /**
  10597. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10598. * @returns a serialized dynamic texture object
  10599. */
  10600. serialize(): any;
  10601. /** @hidden */
  10602. _rebuild(): void;
  10603. }
  10604. }
  10605. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  10606. import { Nullable } from "babylonjs/types";
  10607. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10608. import { Scene } from "babylonjs/scene";
  10609. module "babylonjs/Engines/engine" {
  10610. interface Engine {
  10611. /**
  10612. * Creates a raw texture
  10613. * @param data defines the data to store in the texture
  10614. * @param width defines the width of the texture
  10615. * @param height defines the height of the texture
  10616. * @param format defines the format of the data
  10617. * @param generateMipMaps defines if the engine should generate the mip levels
  10618. * @param invertY defines if data must be stored with Y axis inverted
  10619. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10620. * @param compression defines the compression used (null by default)
  10621. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10622. * @returns the raw texture inside an InternalTexture
  10623. */
  10624. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10625. /**
  10626. * Update a raw texture
  10627. * @param texture defines the texture to update
  10628. * @param data defines the data to store in the texture
  10629. * @param format defines the format of the data
  10630. * @param invertY defines if data must be stored with Y axis inverted
  10631. */
  10632. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10633. /**
  10634. * Update a raw texture
  10635. * @param texture defines the texture to update
  10636. * @param data defines the data to store in the texture
  10637. * @param format defines the format of the data
  10638. * @param invertY defines if data must be stored with Y axis inverted
  10639. * @param compression defines the compression used (null by default)
  10640. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10641. */
  10642. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10643. /**
  10644. * Creates a new raw cube texture
  10645. * @param data defines the array of data to use to create each face
  10646. * @param size defines the size of the textures
  10647. * @param format defines the format of the data
  10648. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10649. * @param generateMipMaps defines if the engine should generate the mip levels
  10650. * @param invertY defines if data must be stored with Y axis inverted
  10651. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10652. * @param compression defines the compression used (null by default)
  10653. * @returns the cube texture as an InternalTexture
  10654. */
  10655. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10656. /**
  10657. * Update a raw cube texture
  10658. * @param texture defines the texture to udpdate
  10659. * @param data defines the data to store
  10660. * @param format defines the data format
  10661. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10662. * @param invertY defines if data must be stored with Y axis inverted
  10663. */
  10664. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10665. /**
  10666. * Update a raw cube texture
  10667. * @param texture defines the texture to udpdate
  10668. * @param data defines the data to store
  10669. * @param format defines the data format
  10670. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10671. * @param invertY defines if data must be stored with Y axis inverted
  10672. * @param compression defines the compression used (null by default)
  10673. */
  10674. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10675. /**
  10676. * Update a raw cube texture
  10677. * @param texture defines the texture to udpdate
  10678. * @param data defines the data to store
  10679. * @param format defines the data format
  10680. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10681. * @param invertY defines if data must be stored with Y axis inverted
  10682. * @param compression defines the compression used (null by default)
  10683. * @param level defines which level of the texture to update
  10684. */
  10685. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10686. /**
  10687. * Creates a new raw cube texture from a specified url
  10688. * @param url defines the url where the data is located
  10689. * @param scene defines the current scene
  10690. * @param size defines the size of the textures
  10691. * @param format defines the format of the data
  10692. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10693. * @param noMipmap defines if the engine should avoid generating the mip levels
  10694. * @param callback defines a callback used to extract texture data from loaded data
  10695. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10696. * @param onLoad defines a callback called when texture is loaded
  10697. * @param onError defines a callback called if there is an error
  10698. * @returns the cube texture as an InternalTexture
  10699. */
  10700. 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;
  10701. /**
  10702. * Creates a new raw cube texture from a specified url
  10703. * @param url defines the url where the data is located
  10704. * @param scene defines the current scene
  10705. * @param size defines the size of the textures
  10706. * @param format defines the format of the data
  10707. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10708. * @param noMipmap defines if the engine should avoid generating the mip levels
  10709. * @param callback defines a callback used to extract texture data from loaded data
  10710. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10711. * @param onLoad defines a callback called when texture is loaded
  10712. * @param onError defines a callback called if there is an error
  10713. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10714. * @param invertY defines if data must be stored with Y axis inverted
  10715. * @returns the cube texture as an InternalTexture
  10716. */
  10717. 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;
  10718. /**
  10719. * Creates a new raw 3D texture
  10720. * @param data defines the data used to create the texture
  10721. * @param width defines the width of the texture
  10722. * @param height defines the height of the texture
  10723. * @param depth defines the depth of the texture
  10724. * @param format defines the format of the texture
  10725. * @param generateMipMaps defines if the engine must generate mip levels
  10726. * @param invertY defines if data must be stored with Y axis inverted
  10727. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10728. * @param compression defines the compressed used (can be null)
  10729. * @param textureType defines the compressed used (can be null)
  10730. * @returns a new raw 3D texture (stored in an InternalTexture)
  10731. */
  10732. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10733. /**
  10734. * Update a raw 3D texture
  10735. * @param texture defines the texture to update
  10736. * @param data defines the data to store
  10737. * @param format defines the data format
  10738. * @param invertY defines if data must be stored with Y axis inverted
  10739. */
  10740. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10741. /**
  10742. * Update a raw 3D texture
  10743. * @param texture defines the texture to update
  10744. * @param data defines the data to store
  10745. * @param format defines the data format
  10746. * @param invertY defines if data must be stored with Y axis inverted
  10747. * @param compression defines the used compression (can be null)
  10748. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10749. */
  10750. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10751. /**
  10752. * Creates a new raw 2D array texture
  10753. * @param data defines the data used to create the texture
  10754. * @param width defines the width of the texture
  10755. * @param height defines the height of the texture
  10756. * @param depth defines the number of layers of the texture
  10757. * @param format defines the format of the texture
  10758. * @param generateMipMaps defines if the engine must generate mip levels
  10759. * @param invertY defines if data must be stored with Y axis inverted
  10760. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10761. * @param compression defines the compressed used (can be null)
  10762. * @param textureType defines the compressed used (can be null)
  10763. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10764. */
  10765. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10766. /**
  10767. * Update a raw 2D array texture
  10768. * @param texture defines the texture to update
  10769. * @param data defines the data to store
  10770. * @param format defines the data format
  10771. * @param invertY defines if data must be stored with Y axis inverted
  10772. */
  10773. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10774. /**
  10775. * Update a raw 2D array texture
  10776. * @param texture defines the texture to update
  10777. * @param data defines the data to store
  10778. * @param format defines the data format
  10779. * @param invertY defines if data must be stored with Y axis inverted
  10780. * @param compression defines the used compression (can be null)
  10781. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10782. */
  10783. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10784. }
  10785. }
  10786. }
  10787. declare module "babylonjs/Materials/Textures/rawTexture" {
  10788. import { Scene } from "babylonjs/scene";
  10789. import { Texture } from "babylonjs/Materials/Textures/texture";
  10790. import "babylonjs/Engines/Extensions/engine.rawTexture";
  10791. /**
  10792. * Raw texture can help creating a texture directly from an array of data.
  10793. * This can be super useful if you either get the data from an uncompressed source or
  10794. * if you wish to create your texture pixel by pixel.
  10795. */
  10796. export class RawTexture extends Texture {
  10797. /**
  10798. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10799. */
  10800. format: number;
  10801. private _engine;
  10802. /**
  10803. * Instantiates a new RawTexture.
  10804. * Raw texture can help creating a texture directly from an array of data.
  10805. * This can be super useful if you either get the data from an uncompressed source or
  10806. * if you wish to create your texture pixel by pixel.
  10807. * @param data define the array of data to use to create the texture
  10808. * @param width define the width of the texture
  10809. * @param height define the height of the texture
  10810. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10811. * @param scene define the scene the texture belongs to
  10812. * @param generateMipMaps define whether mip maps should be generated or not
  10813. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10814. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10815. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10816. */
  10817. constructor(data: ArrayBufferView, width: number, height: number,
  10818. /**
  10819. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10820. */
  10821. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10822. /**
  10823. * Updates the texture underlying data.
  10824. * @param data Define the new data of the texture
  10825. */
  10826. update(data: ArrayBufferView): void;
  10827. /**
  10828. * Creates a luminance texture from some data.
  10829. * @param data Define the texture data
  10830. * @param width Define the width of the texture
  10831. * @param height Define the height of the texture
  10832. * @param scene Define the scene the texture belongs to
  10833. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10834. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10835. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10836. * @returns the luminance texture
  10837. */
  10838. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10839. /**
  10840. * Creates a luminance alpha 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. * @returns the luminance alpha texture
  10849. */
  10850. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10851. /**
  10852. * Creates an alpha texture from some data.
  10853. * @param data Define the texture data
  10854. * @param width Define the width of the texture
  10855. * @param height Define the height of the texture
  10856. * @param scene Define the scene the texture belongs to
  10857. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10858. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10859. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10860. * @returns the alpha texture
  10861. */
  10862. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10863. /**
  10864. * Creates a RGB texture from some data.
  10865. * @param data Define the texture data
  10866. * @param width Define the width of the texture
  10867. * @param height Define the height of the texture
  10868. * @param scene Define the scene the texture belongs to
  10869. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10870. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10871. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10872. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10873. * @returns the RGB alpha texture
  10874. */
  10875. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10876. /**
  10877. * Creates a RGBA texture from some data.
  10878. * @param data Define the texture data
  10879. * @param width Define the width of the texture
  10880. * @param height Define the height of the texture
  10881. * @param scene Define the scene the texture belongs to
  10882. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10883. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10884. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10885. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10886. * @returns the RGBA texture
  10887. */
  10888. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10889. /**
  10890. * Creates a R texture from some data.
  10891. * @param data Define the texture data
  10892. * @param width Define the width of the texture
  10893. * @param height Define the height of the texture
  10894. * @param scene Define the scene the texture belongs to
  10895. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10896. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10897. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10898. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10899. * @returns the R texture
  10900. */
  10901. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10902. }
  10903. }
  10904. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  10905. import { Scene } from "babylonjs/scene";
  10906. import { ISceneComponent } from "babylonjs/sceneComponent";
  10907. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  10908. module "babylonjs/abstractScene" {
  10909. interface AbstractScene {
  10910. /**
  10911. * The list of procedural textures added to the scene
  10912. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10913. */
  10914. proceduralTextures: Array<ProceduralTexture>;
  10915. }
  10916. }
  10917. /**
  10918. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10919. * in a given scene.
  10920. */
  10921. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10922. /**
  10923. * The component name helpfull to identify the component in the list of scene components.
  10924. */
  10925. readonly name: string;
  10926. /**
  10927. * The scene the component belongs to.
  10928. */
  10929. scene: Scene;
  10930. /**
  10931. * Creates a new instance of the component for the given scene
  10932. * @param scene Defines the scene to register the component in
  10933. */
  10934. constructor(scene: Scene);
  10935. /**
  10936. * Registers the component in a given scene
  10937. */
  10938. register(): void;
  10939. /**
  10940. * Rebuilds the elements related to this component in case of
  10941. * context lost for instance.
  10942. */
  10943. rebuild(): void;
  10944. /**
  10945. * Disposes the component and the associated ressources.
  10946. */
  10947. dispose(): void;
  10948. private _beforeClear;
  10949. }
  10950. }
  10951. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  10952. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10953. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  10954. module "babylonjs/Engines/thinEngine" {
  10955. interface ThinEngine {
  10956. /**
  10957. * Creates a new render target cube texture
  10958. * @param size defines the size of the texture
  10959. * @param options defines the options used to create the texture
  10960. * @returns a new render target cube texture stored in an InternalTexture
  10961. */
  10962. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10963. }
  10964. }
  10965. }
  10966. declare module "babylonjs/Shaders/procedural.vertex" {
  10967. /** @hidden */
  10968. export var proceduralVertexShader: {
  10969. name: string;
  10970. shader: string;
  10971. };
  10972. }
  10973. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  10974. import { Observable } from "babylonjs/Misc/observable";
  10975. import { Nullable } from "babylonjs/types";
  10976. import { Scene } from "babylonjs/scene";
  10977. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10978. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  10979. import { Effect } from "babylonjs/Materials/effect";
  10980. import { Texture } from "babylonjs/Materials/Textures/texture";
  10981. import "babylonjs/Engines/Extensions/engine.renderTarget";
  10982. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  10983. import "babylonjs/Shaders/procedural.vertex";
  10984. /**
  10985. * 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.
  10986. * This is the base class of any Procedural texture and contains most of the shareable code.
  10987. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10988. */
  10989. export class ProceduralTexture extends Texture {
  10990. isCube: boolean;
  10991. /**
  10992. * Define if the texture is enabled or not (disabled texture will not render)
  10993. */
  10994. isEnabled: boolean;
  10995. /**
  10996. * Define if the texture must be cleared before rendering (default is true)
  10997. */
  10998. autoClear: boolean;
  10999. /**
  11000. * Callback called when the texture is generated
  11001. */
  11002. onGenerated: () => void;
  11003. /**
  11004. * Event raised when the texture is generated
  11005. */
  11006. onGeneratedObservable: Observable<ProceduralTexture>;
  11007. /** @hidden */
  11008. _generateMipMaps: boolean;
  11009. /** @hidden **/
  11010. _effect: Effect;
  11011. /** @hidden */
  11012. _textures: {
  11013. [key: string]: Texture;
  11014. };
  11015. private _size;
  11016. private _currentRefreshId;
  11017. private _frameId;
  11018. private _refreshRate;
  11019. private _vertexBuffers;
  11020. private _indexBuffer;
  11021. private _uniforms;
  11022. private _samplers;
  11023. private _fragment;
  11024. private _floats;
  11025. private _ints;
  11026. private _floatsArrays;
  11027. private _colors3;
  11028. private _colors4;
  11029. private _vectors2;
  11030. private _vectors3;
  11031. private _matrices;
  11032. private _fallbackTexture;
  11033. private _fallbackTextureUsed;
  11034. private _engine;
  11035. private _cachedDefines;
  11036. private _contentUpdateId;
  11037. private _contentData;
  11038. /**
  11039. * Instantiates a new procedural texture.
  11040. * 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.
  11041. * This is the base class of any Procedural texture and contains most of the shareable code.
  11042. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11043. * @param name Define the name of the texture
  11044. * @param size Define the size of the texture to create
  11045. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11046. * @param scene Define the scene the texture belongs to
  11047. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11048. * @param generateMipMaps Define if the texture should creates mip maps or not
  11049. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11050. */
  11051. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11052. /**
  11053. * The effect that is created when initializing the post process.
  11054. * @returns The created effect corresponding the the postprocess.
  11055. */
  11056. getEffect(): Effect;
  11057. /**
  11058. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11059. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11060. */
  11061. getContent(): Nullable<ArrayBufferView>;
  11062. private _createIndexBuffer;
  11063. /** @hidden */
  11064. _rebuild(): void;
  11065. /**
  11066. * Resets the texture in order to recreate its associated resources.
  11067. * This can be called in case of context loss
  11068. */
  11069. reset(): void;
  11070. protected _getDefines(): string;
  11071. /**
  11072. * Is the texture ready to be used ? (rendered at least once)
  11073. * @returns true if ready, otherwise, false.
  11074. */
  11075. isReady(): boolean;
  11076. /**
  11077. * Resets the refresh counter of the texture and start bak from scratch.
  11078. * Could be useful to regenerate the texture if it is setup to render only once.
  11079. */
  11080. resetRefreshCounter(): void;
  11081. /**
  11082. * Set the fragment shader to use in order to render the texture.
  11083. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11084. */
  11085. setFragment(fragment: any): void;
  11086. /**
  11087. * Define the refresh rate of the texture or the rendering frequency.
  11088. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11089. */
  11090. get refreshRate(): number;
  11091. set refreshRate(value: number);
  11092. /** @hidden */
  11093. _shouldRender(): boolean;
  11094. /**
  11095. * Get the size the texture is rendering at.
  11096. * @returns the size (texture is always squared)
  11097. */
  11098. getRenderSize(): number;
  11099. /**
  11100. * Resize the texture to new value.
  11101. * @param size Define the new size the texture should have
  11102. * @param generateMipMaps Define whether the new texture should create mip maps
  11103. */
  11104. resize(size: number, generateMipMaps: boolean): void;
  11105. private _checkUniform;
  11106. /**
  11107. * Set a texture in the shader program used to render.
  11108. * @param name Define the name of the uniform samplers as defined in the shader
  11109. * @param texture Define the texture to bind to this sampler
  11110. * @return the texture itself allowing "fluent" like uniform updates
  11111. */
  11112. setTexture(name: string, texture: Texture): ProceduralTexture;
  11113. /**
  11114. * Set a float in the shader.
  11115. * @param name Define the name of the uniform as defined in the shader
  11116. * @param value Define the value to give to the uniform
  11117. * @return the texture itself allowing "fluent" like uniform updates
  11118. */
  11119. setFloat(name: string, value: number): ProceduralTexture;
  11120. /**
  11121. * Set a int in the shader.
  11122. * @param name Define the name of the uniform as defined in the shader
  11123. * @param value Define the value to give to the uniform
  11124. * @return the texture itself allowing "fluent" like uniform updates
  11125. */
  11126. setInt(name: string, value: number): ProceduralTexture;
  11127. /**
  11128. * Set an array of floats in the shader.
  11129. * @param name Define the name of the uniform as defined in the shader
  11130. * @param value Define the value to give to the uniform
  11131. * @return the texture itself allowing "fluent" like uniform updates
  11132. */
  11133. setFloats(name: string, value: number[]): ProceduralTexture;
  11134. /**
  11135. * Set a vec3 in the shader from a Color3.
  11136. * @param name Define the name of the uniform as defined in the shader
  11137. * @param value Define the value to give to the uniform
  11138. * @return the texture itself allowing "fluent" like uniform updates
  11139. */
  11140. setColor3(name: string, value: Color3): ProceduralTexture;
  11141. /**
  11142. * Set a vec4 in the shader from a Color4.
  11143. * @param name Define the name of the uniform as defined in the shader
  11144. * @param value Define the value to give to the uniform
  11145. * @return the texture itself allowing "fluent" like uniform updates
  11146. */
  11147. setColor4(name: string, value: Color4): ProceduralTexture;
  11148. /**
  11149. * Set a vec2 in the shader from a Vector2.
  11150. * @param name Define the name of the uniform as defined in the shader
  11151. * @param value Define the value to give to the uniform
  11152. * @return the texture itself allowing "fluent" like uniform updates
  11153. */
  11154. setVector2(name: string, value: Vector2): ProceduralTexture;
  11155. /**
  11156. * Set a vec3 in the shader from a Vector3.
  11157. * @param name Define the name of the uniform as defined in the shader
  11158. * @param value Define the value to give to the uniform
  11159. * @return the texture itself allowing "fluent" like uniform updates
  11160. */
  11161. setVector3(name: string, value: Vector3): ProceduralTexture;
  11162. /**
  11163. * Set a mat4 in the shader from a MAtrix.
  11164. * @param name Define the name of the uniform as defined in the shader
  11165. * @param value Define the value to give to the uniform
  11166. * @return the texture itself allowing "fluent" like uniform updates
  11167. */
  11168. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11169. /**
  11170. * Render the texture to its associated render target.
  11171. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11172. */
  11173. render(useCameraPostProcess?: boolean): void;
  11174. /**
  11175. * Clone the texture.
  11176. * @returns the cloned texture
  11177. */
  11178. clone(): ProceduralTexture;
  11179. /**
  11180. * Dispose the texture and release its asoociated resources.
  11181. */
  11182. dispose(): void;
  11183. }
  11184. }
  11185. declare module "babylonjs/Particles/baseParticleSystem" {
  11186. import { Nullable } from "babylonjs/types";
  11187. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  11188. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11189. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  11190. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11191. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  11192. import { Scene } from "babylonjs/scene";
  11193. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  11194. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  11195. import { Texture } from "babylonjs/Materials/Textures/texture";
  11196. import { Color4 } from "babylonjs/Maths/math.color";
  11197. import { Animation } from "babylonjs/Animations/animation";
  11198. /**
  11199. * This represents the base class for particle system in Babylon.
  11200. * 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.
  11201. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11202. * @example https://doc.babylonjs.com/babylon101/particles
  11203. */
  11204. export class BaseParticleSystem {
  11205. /**
  11206. * Source color is added to the destination color without alpha affecting the result
  11207. */
  11208. static BLENDMODE_ONEONE: number;
  11209. /**
  11210. * Blend current color and particle color using particle’s alpha
  11211. */
  11212. static BLENDMODE_STANDARD: number;
  11213. /**
  11214. * Add current color and particle color multiplied by particle’s alpha
  11215. */
  11216. static BLENDMODE_ADD: number;
  11217. /**
  11218. * Multiply current color with particle color
  11219. */
  11220. static BLENDMODE_MULTIPLY: number;
  11221. /**
  11222. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11223. */
  11224. static BLENDMODE_MULTIPLYADD: number;
  11225. /**
  11226. * List of animations used by the particle system.
  11227. */
  11228. animations: Animation[];
  11229. /**
  11230. * The id of the Particle system.
  11231. */
  11232. id: string;
  11233. /**
  11234. * The friendly name of the Particle system.
  11235. */
  11236. name: string;
  11237. /**
  11238. * The rendering group used by the Particle system to chose when to render.
  11239. */
  11240. renderingGroupId: number;
  11241. /**
  11242. * The emitter represents the Mesh or position we are attaching the particle system to.
  11243. */
  11244. emitter: Nullable<AbstractMesh | Vector3>;
  11245. /**
  11246. * The maximum number of particles to emit per frame
  11247. */
  11248. emitRate: number;
  11249. /**
  11250. * If you want to launch only a few particles at once, that can be done, as well.
  11251. */
  11252. manualEmitCount: number;
  11253. /**
  11254. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11255. */
  11256. updateSpeed: number;
  11257. /**
  11258. * The amount of time the particle system is running (depends of the overall update speed).
  11259. */
  11260. targetStopDuration: number;
  11261. /**
  11262. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11263. */
  11264. disposeOnStop: boolean;
  11265. /**
  11266. * Minimum power of emitting particles.
  11267. */
  11268. minEmitPower: number;
  11269. /**
  11270. * Maximum power of emitting particles.
  11271. */
  11272. maxEmitPower: number;
  11273. /**
  11274. * Minimum life time of emitting particles.
  11275. */
  11276. minLifeTime: number;
  11277. /**
  11278. * Maximum life time of emitting particles.
  11279. */
  11280. maxLifeTime: number;
  11281. /**
  11282. * Minimum Size of emitting particles.
  11283. */
  11284. minSize: number;
  11285. /**
  11286. * Maximum Size of emitting particles.
  11287. */
  11288. maxSize: number;
  11289. /**
  11290. * Minimum scale of emitting particles on X axis.
  11291. */
  11292. minScaleX: number;
  11293. /**
  11294. * Maximum scale of emitting particles on X axis.
  11295. */
  11296. maxScaleX: number;
  11297. /**
  11298. * Minimum scale of emitting particles on Y axis.
  11299. */
  11300. minScaleY: number;
  11301. /**
  11302. * Maximum scale of emitting particles on Y axis.
  11303. */
  11304. maxScaleY: number;
  11305. /**
  11306. * Gets or sets the minimal initial rotation in radians.
  11307. */
  11308. minInitialRotation: number;
  11309. /**
  11310. * Gets or sets the maximal initial rotation in radians.
  11311. */
  11312. maxInitialRotation: number;
  11313. /**
  11314. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11315. */
  11316. minAngularSpeed: number;
  11317. /**
  11318. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11319. */
  11320. maxAngularSpeed: number;
  11321. /**
  11322. * The texture used to render each particle. (this can be a spritesheet)
  11323. */
  11324. particleTexture: Nullable<Texture>;
  11325. /**
  11326. * The layer mask we are rendering the particles through.
  11327. */
  11328. layerMask: number;
  11329. /**
  11330. * This can help using your own shader to render the particle system.
  11331. * The according effect will be created
  11332. */
  11333. customShader: any;
  11334. /**
  11335. * By default particle system starts as soon as they are created. This prevents the
  11336. * automatic start to happen and let you decide when to start emitting particles.
  11337. */
  11338. preventAutoStart: boolean;
  11339. private _noiseTexture;
  11340. /**
  11341. * Gets or sets a texture used to add random noise to particle positions
  11342. */
  11343. get noiseTexture(): Nullable<ProceduralTexture>;
  11344. set noiseTexture(value: Nullable<ProceduralTexture>);
  11345. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11346. noiseStrength: Vector3;
  11347. /**
  11348. * Callback triggered when the particle animation is ending.
  11349. */
  11350. onAnimationEnd: Nullable<() => void>;
  11351. /**
  11352. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11353. */
  11354. blendMode: number;
  11355. /**
  11356. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11357. * to override the particles.
  11358. */
  11359. forceDepthWrite: boolean;
  11360. /** 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 */
  11361. preWarmCycles: number;
  11362. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11363. preWarmStepOffset: number;
  11364. /**
  11365. * 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)
  11366. */
  11367. spriteCellChangeSpeed: number;
  11368. /**
  11369. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11370. */
  11371. startSpriteCellID: number;
  11372. /**
  11373. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11374. */
  11375. endSpriteCellID: number;
  11376. /**
  11377. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11378. */
  11379. spriteCellWidth: number;
  11380. /**
  11381. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11382. */
  11383. spriteCellHeight: number;
  11384. /**
  11385. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11386. */
  11387. spriteRandomStartCell: boolean;
  11388. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11389. translationPivot: Vector2;
  11390. /** @hidden */
  11391. protected _isAnimationSheetEnabled: boolean;
  11392. /**
  11393. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11394. */
  11395. beginAnimationOnStart: boolean;
  11396. /**
  11397. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11398. */
  11399. beginAnimationFrom: number;
  11400. /**
  11401. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11402. */
  11403. beginAnimationTo: number;
  11404. /**
  11405. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11406. */
  11407. beginAnimationLoop: boolean;
  11408. /**
  11409. * Gets or sets a world offset applied to all particles
  11410. */
  11411. worldOffset: Vector3;
  11412. /**
  11413. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11414. */
  11415. get isAnimationSheetEnabled(): boolean;
  11416. set isAnimationSheetEnabled(value: boolean);
  11417. /**
  11418. * Get hosting scene
  11419. * @returns the scene
  11420. */
  11421. getScene(): Scene;
  11422. /**
  11423. * You can use gravity if you want to give an orientation to your particles.
  11424. */
  11425. gravity: Vector3;
  11426. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11427. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11428. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11429. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11430. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11431. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11432. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11433. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11434. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11435. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11436. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11437. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11438. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11439. /**
  11440. * Defines the delay in milliseconds before starting the system (0 by default)
  11441. */
  11442. startDelay: number;
  11443. /**
  11444. * Gets the current list of drag gradients.
  11445. * You must use addDragGradient and removeDragGradient to udpate this list
  11446. * @returns the list of drag gradients
  11447. */
  11448. getDragGradients(): Nullable<Array<FactorGradient>>;
  11449. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11450. limitVelocityDamping: number;
  11451. /**
  11452. * Gets the current list of limit velocity gradients.
  11453. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11454. * @returns the list of limit velocity gradients
  11455. */
  11456. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11457. /**
  11458. * Gets the current list of color gradients.
  11459. * You must use addColorGradient and removeColorGradient to udpate this list
  11460. * @returns the list of color gradients
  11461. */
  11462. getColorGradients(): Nullable<Array<ColorGradient>>;
  11463. /**
  11464. * Gets the current list of size gradients.
  11465. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11466. * @returns the list of size gradients
  11467. */
  11468. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11469. /**
  11470. * Gets the current list of color remap gradients.
  11471. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11472. * @returns the list of color remap gradients
  11473. */
  11474. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11475. /**
  11476. * Gets the current list of alpha remap gradients.
  11477. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11478. * @returns the list of alpha remap gradients
  11479. */
  11480. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11481. /**
  11482. * Gets the current list of life time gradients.
  11483. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11484. * @returns the list of life time gradients
  11485. */
  11486. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11487. /**
  11488. * Gets the current list of angular speed gradients.
  11489. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11490. * @returns the list of angular speed gradients
  11491. */
  11492. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11493. /**
  11494. * Gets the current list of velocity gradients.
  11495. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11496. * @returns the list of velocity gradients
  11497. */
  11498. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11499. /**
  11500. * Gets the current list of start size gradients.
  11501. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11502. * @returns the list of start size gradients
  11503. */
  11504. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11505. /**
  11506. * Gets the current list of emit rate gradients.
  11507. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11508. * @returns the list of emit rate gradients
  11509. */
  11510. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11511. /**
  11512. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11513. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11514. */
  11515. get direction1(): Vector3;
  11516. set direction1(value: Vector3);
  11517. /**
  11518. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11519. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11520. */
  11521. get direction2(): Vector3;
  11522. set direction2(value: Vector3);
  11523. /**
  11524. * 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.
  11525. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11526. */
  11527. get minEmitBox(): Vector3;
  11528. set minEmitBox(value: Vector3);
  11529. /**
  11530. * 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.
  11531. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11532. */
  11533. get maxEmitBox(): Vector3;
  11534. set maxEmitBox(value: Vector3);
  11535. /**
  11536. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11537. */
  11538. color1: Color4;
  11539. /**
  11540. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11541. */
  11542. color2: Color4;
  11543. /**
  11544. * Color the particle will have at the end of its lifetime
  11545. */
  11546. colorDead: Color4;
  11547. /**
  11548. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11549. */
  11550. textureMask: Color4;
  11551. /**
  11552. * The particle emitter type defines the emitter used by the particle system.
  11553. * It can be for example box, sphere, or cone...
  11554. */
  11555. particleEmitterType: IParticleEmitterType;
  11556. /** @hidden */
  11557. _isSubEmitter: boolean;
  11558. /**
  11559. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11560. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11561. */
  11562. billboardMode: number;
  11563. protected _isBillboardBased: boolean;
  11564. /**
  11565. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11566. */
  11567. get isBillboardBased(): boolean;
  11568. set isBillboardBased(value: boolean);
  11569. /**
  11570. * The scene the particle system belongs to.
  11571. */
  11572. protected _scene: Scene;
  11573. /**
  11574. * Local cache of defines for image processing.
  11575. */
  11576. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11577. /**
  11578. * Default configuration related to image processing available in the standard Material.
  11579. */
  11580. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11581. /**
  11582. * Gets the image processing configuration used either in this material.
  11583. */
  11584. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11585. /**
  11586. * Sets the Default image processing configuration used either in the this material.
  11587. *
  11588. * If sets to null, the scene one is in use.
  11589. */
  11590. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11591. /**
  11592. * Attaches a new image processing configuration to the Standard Material.
  11593. * @param configuration
  11594. */
  11595. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11596. /** @hidden */
  11597. protected _reset(): void;
  11598. /** @hidden */
  11599. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11600. /**
  11601. * Instantiates a particle system.
  11602. * 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.
  11603. * @param name The name of the particle system
  11604. */
  11605. constructor(name: string);
  11606. /**
  11607. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11608. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11609. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11610. * @returns the emitter
  11611. */
  11612. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11613. /**
  11614. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11615. * @param radius The radius of the hemisphere to emit from
  11616. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11617. * @returns the emitter
  11618. */
  11619. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11620. /**
  11621. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11622. * @param radius The radius of the sphere to emit from
  11623. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11624. * @returns the emitter
  11625. */
  11626. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11627. /**
  11628. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11629. * @param radius The radius of the sphere to emit from
  11630. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11631. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11632. * @returns the emitter
  11633. */
  11634. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11635. /**
  11636. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11637. * @param radius The radius of the emission cylinder
  11638. * @param height The height of the emission cylinder
  11639. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11640. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11641. * @returns the emitter
  11642. */
  11643. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11644. /**
  11645. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11646. * @param radius The radius of the cylinder to emit from
  11647. * @param height The height of the emission cylinder
  11648. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11649. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11650. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11651. * @returns the emitter
  11652. */
  11653. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11654. /**
  11655. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11656. * @param radius The radius of the cone to emit from
  11657. * @param angle The base angle of the cone
  11658. * @returns the emitter
  11659. */
  11660. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11661. /**
  11662. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11663. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11664. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11665. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11666. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11667. * @returns the emitter
  11668. */
  11669. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11670. }
  11671. }
  11672. declare module "babylonjs/Particles/subEmitter" {
  11673. import { Scene } from "babylonjs/scene";
  11674. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  11675. /**
  11676. * Type of sub emitter
  11677. */
  11678. export enum SubEmitterType {
  11679. /**
  11680. * Attached to the particle over it's lifetime
  11681. */
  11682. ATTACHED = 0,
  11683. /**
  11684. * Created when the particle dies
  11685. */
  11686. END = 1
  11687. }
  11688. /**
  11689. * Sub emitter class used to emit particles from an existing particle
  11690. */
  11691. export class SubEmitter {
  11692. /**
  11693. * the particle system to be used by the sub emitter
  11694. */
  11695. particleSystem: ParticleSystem;
  11696. /**
  11697. * Type of the submitter (Default: END)
  11698. */
  11699. type: SubEmitterType;
  11700. /**
  11701. * 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)
  11702. * Note: This only is supported when using an emitter of type Mesh
  11703. */
  11704. inheritDirection: boolean;
  11705. /**
  11706. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11707. */
  11708. inheritedVelocityAmount: number;
  11709. /**
  11710. * Creates a sub emitter
  11711. * @param particleSystem the particle system to be used by the sub emitter
  11712. */
  11713. constructor(
  11714. /**
  11715. * the particle system to be used by the sub emitter
  11716. */
  11717. particleSystem: ParticleSystem);
  11718. /**
  11719. * Clones the sub emitter
  11720. * @returns the cloned sub emitter
  11721. */
  11722. clone(): SubEmitter;
  11723. /**
  11724. * Serialize current object to a JSON object
  11725. * @returns the serialized object
  11726. */
  11727. serialize(): any;
  11728. /** @hidden */
  11729. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11730. /**
  11731. * Creates a new SubEmitter from a serialized JSON version
  11732. * @param serializationObject defines the JSON object to read from
  11733. * @param scene defines the hosting scene
  11734. * @param rootUrl defines the rootUrl for data loading
  11735. * @returns a new SubEmitter
  11736. */
  11737. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11738. /** Release associated resources */
  11739. dispose(): void;
  11740. }
  11741. }
  11742. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  11743. /** @hidden */
  11744. export var imageProcessingDeclaration: {
  11745. name: string;
  11746. shader: string;
  11747. };
  11748. }
  11749. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  11750. /** @hidden */
  11751. export var imageProcessingFunctions: {
  11752. name: string;
  11753. shader: string;
  11754. };
  11755. }
  11756. declare module "babylonjs/Shaders/particles.fragment" {
  11757. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  11758. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  11759. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11760. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  11761. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  11762. /** @hidden */
  11763. export var particlesPixelShader: {
  11764. name: string;
  11765. shader: string;
  11766. };
  11767. }
  11768. declare module "babylonjs/Shaders/particles.vertex" {
  11769. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  11770. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  11771. /** @hidden */
  11772. export var particlesVertexShader: {
  11773. name: string;
  11774. shader: string;
  11775. };
  11776. }
  11777. declare module "babylonjs/Particles/particleSystem" {
  11778. import { Nullable } from "babylonjs/types";
  11779. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  11780. import { Observable } from "babylonjs/Misc/observable";
  11781. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  11782. import { Effect } from "babylonjs/Materials/effect";
  11783. import { Scene, IDisposable } from "babylonjs/scene";
  11784. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  11785. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  11786. import { Particle } from "babylonjs/Particles/particle";
  11787. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  11788. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  11789. import "babylonjs/Shaders/particles.fragment";
  11790. import "babylonjs/Shaders/particles.vertex";
  11791. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11792. /**
  11793. * This represents a particle system in Babylon.
  11794. * 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.
  11795. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11796. * @example https://doc.babylonjs.com/babylon101/particles
  11797. */
  11798. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11799. /**
  11800. * Billboard mode will only apply to Y axis
  11801. */
  11802. static readonly BILLBOARDMODE_Y: number;
  11803. /**
  11804. * Billboard mode will apply to all axes
  11805. */
  11806. static readonly BILLBOARDMODE_ALL: number;
  11807. /**
  11808. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11809. */
  11810. static readonly BILLBOARDMODE_STRETCHED: number;
  11811. /**
  11812. * This function can be defined to provide custom update for active particles.
  11813. * This function will be called instead of regular update (age, position, color, etc.).
  11814. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11815. */
  11816. updateFunction: (particles: Particle[]) => void;
  11817. private _emitterWorldMatrix;
  11818. /**
  11819. * This function can be defined to specify initial direction for every new particle.
  11820. * It by default use the emitterType defined function
  11821. */
  11822. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11823. /**
  11824. * This function can be defined to specify initial position for every new particle.
  11825. * It by default use the emitterType defined function
  11826. */
  11827. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11828. /**
  11829. * @hidden
  11830. */
  11831. _inheritedVelocityOffset: Vector3;
  11832. /**
  11833. * An event triggered when the system is disposed
  11834. */
  11835. onDisposeObservable: Observable<ParticleSystem>;
  11836. private _onDisposeObserver;
  11837. /**
  11838. * Sets a callback that will be triggered when the system is disposed
  11839. */
  11840. set onDispose(callback: () => void);
  11841. private _particles;
  11842. private _epsilon;
  11843. private _capacity;
  11844. private _stockParticles;
  11845. private _newPartsExcess;
  11846. private _vertexData;
  11847. private _vertexBuffer;
  11848. private _vertexBuffers;
  11849. private _spriteBuffer;
  11850. private _indexBuffer;
  11851. private _effect;
  11852. private _customEffect;
  11853. private _cachedDefines;
  11854. private _scaledColorStep;
  11855. private _colorDiff;
  11856. private _scaledDirection;
  11857. private _scaledGravity;
  11858. private _currentRenderId;
  11859. private _alive;
  11860. private _useInstancing;
  11861. private _started;
  11862. private _stopped;
  11863. private _actualFrame;
  11864. private _scaledUpdateSpeed;
  11865. private _vertexBufferSize;
  11866. /** @hidden */
  11867. _currentEmitRateGradient: Nullable<FactorGradient>;
  11868. /** @hidden */
  11869. _currentEmitRate1: number;
  11870. /** @hidden */
  11871. _currentEmitRate2: number;
  11872. /** @hidden */
  11873. _currentStartSizeGradient: Nullable<FactorGradient>;
  11874. /** @hidden */
  11875. _currentStartSize1: number;
  11876. /** @hidden */
  11877. _currentStartSize2: number;
  11878. private readonly _rawTextureWidth;
  11879. private _rampGradientsTexture;
  11880. private _useRampGradients;
  11881. /** Gets or sets a boolean indicating that ramp gradients must be used
  11882. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11883. */
  11884. get useRampGradients(): boolean;
  11885. set useRampGradients(value: boolean);
  11886. /**
  11887. * 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.
  11888. * 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: [])
  11889. */
  11890. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11891. private _subEmitters;
  11892. /**
  11893. * @hidden
  11894. * If the particle systems emitter should be disposed when the particle system is disposed
  11895. */
  11896. _disposeEmitterOnDispose: boolean;
  11897. /**
  11898. * The current active Sub-systems, this property is used by the root particle system only.
  11899. */
  11900. activeSubSystems: Array<ParticleSystem>;
  11901. /**
  11902. * Specifies if the particles are updated in emitter local space or world space
  11903. */
  11904. isLocal: boolean;
  11905. private _rootParticleSystem;
  11906. /**
  11907. * Gets the current list of active particles
  11908. */
  11909. get particles(): Particle[];
  11910. /**
  11911. * Returns the string "ParticleSystem"
  11912. * @returns a string containing the class name
  11913. */
  11914. getClassName(): string;
  11915. /**
  11916. * Instantiates a particle system.
  11917. * 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.
  11918. * @param name The name of the particle system
  11919. * @param capacity The max number of particles alive at the same time
  11920. * @param scene The scene the particle system belongs to
  11921. * @param customEffect a custom effect used to change the way particles are rendered by default
  11922. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11923. * @param epsilon Offset used to render the particles
  11924. */
  11925. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11926. private _addFactorGradient;
  11927. private _removeFactorGradient;
  11928. /**
  11929. * Adds a new life time gradient
  11930. * @param gradient defines the gradient to use (between 0 and 1)
  11931. * @param factor defines the life time factor to affect to the specified gradient
  11932. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11933. * @returns the current particle system
  11934. */
  11935. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11936. /**
  11937. * Remove a specific life time gradient
  11938. * @param gradient defines the gradient to remove
  11939. * @returns the current particle system
  11940. */
  11941. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11942. /**
  11943. * Adds a new size gradient
  11944. * @param gradient defines the gradient to use (between 0 and 1)
  11945. * @param factor defines the size factor to affect to the specified gradient
  11946. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11947. * @returns the current particle system
  11948. */
  11949. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11950. /**
  11951. * Remove a specific size gradient
  11952. * @param gradient defines the gradient to remove
  11953. * @returns the current particle system
  11954. */
  11955. removeSizeGradient(gradient: number): IParticleSystem;
  11956. /**
  11957. * Adds a new color remap gradient
  11958. * @param gradient defines the gradient to use (between 0 and 1)
  11959. * @param min defines the color remap minimal range
  11960. * @param max defines the color remap maximal range
  11961. * @returns the current particle system
  11962. */
  11963. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11964. /**
  11965. * Remove a specific color remap gradient
  11966. * @param gradient defines the gradient to remove
  11967. * @returns the current particle system
  11968. */
  11969. removeColorRemapGradient(gradient: number): IParticleSystem;
  11970. /**
  11971. * Adds a new alpha remap gradient
  11972. * @param gradient defines the gradient to use (between 0 and 1)
  11973. * @param min defines the alpha remap minimal range
  11974. * @param max defines the alpha remap maximal range
  11975. * @returns the current particle system
  11976. */
  11977. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11978. /**
  11979. * Remove a specific alpha remap gradient
  11980. * @param gradient defines the gradient to remove
  11981. * @returns the current particle system
  11982. */
  11983. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11984. /**
  11985. * Adds a new angular speed gradient
  11986. * @param gradient defines the gradient to use (between 0 and 1)
  11987. * @param factor defines the angular speed to affect to the specified gradient
  11988. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11989. * @returns the current particle system
  11990. */
  11991. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11992. /**
  11993. * Remove a specific angular speed gradient
  11994. * @param gradient defines the gradient to remove
  11995. * @returns the current particle system
  11996. */
  11997. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11998. /**
  11999. * Adds a new velocity gradient
  12000. * @param gradient defines the gradient to use (between 0 and 1)
  12001. * @param factor defines the velocity to affect to the specified gradient
  12002. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12003. * @returns the current particle system
  12004. */
  12005. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12006. /**
  12007. * Remove a specific velocity gradient
  12008. * @param gradient defines the gradient to remove
  12009. * @returns the current particle system
  12010. */
  12011. removeVelocityGradient(gradient: number): IParticleSystem;
  12012. /**
  12013. * Adds a new limit velocity gradient
  12014. * @param gradient defines the gradient to use (between 0 and 1)
  12015. * @param factor defines the limit velocity value to affect to the specified gradient
  12016. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12017. * @returns the current particle system
  12018. */
  12019. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12020. /**
  12021. * Remove a specific limit velocity gradient
  12022. * @param gradient defines the gradient to remove
  12023. * @returns the current particle system
  12024. */
  12025. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12026. /**
  12027. * Adds a new drag gradient
  12028. * @param gradient defines the gradient to use (between 0 and 1)
  12029. * @param factor defines the drag value to affect to the specified gradient
  12030. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12031. * @returns the current particle system
  12032. */
  12033. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12034. /**
  12035. * Remove a specific drag gradient
  12036. * @param gradient defines the gradient to remove
  12037. * @returns the current particle system
  12038. */
  12039. removeDragGradient(gradient: number): IParticleSystem;
  12040. /**
  12041. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12042. * @param gradient defines the gradient to use (between 0 and 1)
  12043. * @param factor defines the emit rate value to affect to the specified gradient
  12044. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12045. * @returns the current particle system
  12046. */
  12047. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12048. /**
  12049. * Remove a specific emit rate gradient
  12050. * @param gradient defines the gradient to remove
  12051. * @returns the current particle system
  12052. */
  12053. removeEmitRateGradient(gradient: number): IParticleSystem;
  12054. /**
  12055. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12056. * @param gradient defines the gradient to use (between 0 and 1)
  12057. * @param factor defines the start size value to affect to the specified gradient
  12058. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12059. * @returns the current particle system
  12060. */
  12061. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12062. /**
  12063. * Remove a specific start size gradient
  12064. * @param gradient defines the gradient to remove
  12065. * @returns the current particle system
  12066. */
  12067. removeStartSizeGradient(gradient: number): IParticleSystem;
  12068. private _createRampGradientTexture;
  12069. /**
  12070. * Gets the current list of ramp gradients.
  12071. * You must use addRampGradient and removeRampGradient to udpate this list
  12072. * @returns the list of ramp gradients
  12073. */
  12074. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12075. /**
  12076. * Adds a new ramp gradient used to remap particle colors
  12077. * @param gradient defines the gradient to use (between 0 and 1)
  12078. * @param color defines the color to affect to the specified gradient
  12079. * @returns the current particle system
  12080. */
  12081. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12082. /**
  12083. * Remove a specific ramp gradient
  12084. * @param gradient defines the gradient to remove
  12085. * @returns the current particle system
  12086. */
  12087. removeRampGradient(gradient: number): ParticleSystem;
  12088. /**
  12089. * Adds a new color gradient
  12090. * @param gradient defines the gradient to use (between 0 and 1)
  12091. * @param color1 defines the color to affect to the specified gradient
  12092. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12093. * @returns this particle system
  12094. */
  12095. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12096. /**
  12097. * Remove a specific color gradient
  12098. * @param gradient defines the gradient to remove
  12099. * @returns this particle system
  12100. */
  12101. removeColorGradient(gradient: number): IParticleSystem;
  12102. private _fetchR;
  12103. protected _reset(): void;
  12104. private _resetEffect;
  12105. private _createVertexBuffers;
  12106. private _createIndexBuffer;
  12107. /**
  12108. * Gets the maximum number of particles active at the same time.
  12109. * @returns The max number of active particles.
  12110. */
  12111. getCapacity(): number;
  12112. /**
  12113. * Gets whether there are still active particles in the system.
  12114. * @returns True if it is alive, otherwise false.
  12115. */
  12116. isAlive(): boolean;
  12117. /**
  12118. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12119. * @returns True if it has been started, otherwise false.
  12120. */
  12121. isStarted(): boolean;
  12122. private _prepareSubEmitterInternalArray;
  12123. /**
  12124. * Starts the particle system and begins to emit
  12125. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12126. */
  12127. start(delay?: number): void;
  12128. /**
  12129. * Stops the particle system.
  12130. * @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.
  12131. */
  12132. stop(stopSubEmitters?: boolean): void;
  12133. /**
  12134. * Remove all active particles
  12135. */
  12136. reset(): void;
  12137. /**
  12138. * @hidden (for internal use only)
  12139. */
  12140. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12141. /**
  12142. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12143. * Its lifetime will start back at 0.
  12144. */
  12145. recycleParticle: (particle: Particle) => void;
  12146. private _stopSubEmitters;
  12147. private _createParticle;
  12148. private _removeFromRoot;
  12149. private _emitFromParticle;
  12150. private _update;
  12151. /** @hidden */
  12152. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12153. /** @hidden */
  12154. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12155. /** @hidden */
  12156. private _getEffect;
  12157. /**
  12158. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12159. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12160. */
  12161. animate(preWarmOnly?: boolean): void;
  12162. private _appendParticleVertices;
  12163. /**
  12164. * Rebuilds the particle system.
  12165. */
  12166. rebuild(): void;
  12167. /**
  12168. * Is this system ready to be used/rendered
  12169. * @return true if the system is ready
  12170. */
  12171. isReady(): boolean;
  12172. private _render;
  12173. /**
  12174. * Renders the particle system in its current state.
  12175. * @returns the current number of particles
  12176. */
  12177. render(): number;
  12178. /**
  12179. * Disposes the particle system and free the associated resources
  12180. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12181. */
  12182. dispose(disposeTexture?: boolean): void;
  12183. /**
  12184. * Clones the particle system.
  12185. * @param name The name of the cloned object
  12186. * @param newEmitter The new emitter to use
  12187. * @returns the cloned particle system
  12188. */
  12189. clone(name: string, newEmitter: any): ParticleSystem;
  12190. /**
  12191. * Serializes the particle system to a JSON object.
  12192. * @returns the JSON object
  12193. */
  12194. serialize(): any;
  12195. /** @hidden */
  12196. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  12197. /** @hidden */
  12198. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12199. /**
  12200. * Parses a JSON object to create a particle system.
  12201. * @param parsedParticleSystem The JSON object to parse
  12202. * @param scene The scene to create the particle system in
  12203. * @param rootUrl The root url to use to load external dependencies like texture
  12204. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12205. * @returns the Parsed particle system
  12206. */
  12207. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12208. }
  12209. }
  12210. declare module "babylonjs/Particles/particle" {
  12211. import { Nullable } from "babylonjs/types";
  12212. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  12213. import { Color4 } from "babylonjs/Maths/math.color";
  12214. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12215. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12216. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  12217. /**
  12218. * A particle represents one of the element emitted by a particle system.
  12219. * This is mainly define by its coordinates, direction, velocity and age.
  12220. */
  12221. export class Particle {
  12222. /**
  12223. * The particle system the particle belongs to.
  12224. */
  12225. particleSystem: ParticleSystem;
  12226. private static _Count;
  12227. /**
  12228. * Unique ID of the particle
  12229. */
  12230. id: number;
  12231. /**
  12232. * The world position of the particle in the scene.
  12233. */
  12234. position: Vector3;
  12235. /**
  12236. * The world direction of the particle in the scene.
  12237. */
  12238. direction: Vector3;
  12239. /**
  12240. * The color of the particle.
  12241. */
  12242. color: Color4;
  12243. /**
  12244. * The color change of the particle per step.
  12245. */
  12246. colorStep: Color4;
  12247. /**
  12248. * Defines how long will the life of the particle be.
  12249. */
  12250. lifeTime: number;
  12251. /**
  12252. * The current age of the particle.
  12253. */
  12254. age: number;
  12255. /**
  12256. * The current size of the particle.
  12257. */
  12258. size: number;
  12259. /**
  12260. * The current scale of the particle.
  12261. */
  12262. scale: Vector2;
  12263. /**
  12264. * The current angle of the particle.
  12265. */
  12266. angle: number;
  12267. /**
  12268. * Defines how fast is the angle changing.
  12269. */
  12270. angularSpeed: number;
  12271. /**
  12272. * Defines the cell index used by the particle to be rendered from a sprite.
  12273. */
  12274. cellIndex: number;
  12275. /**
  12276. * The information required to support color remapping
  12277. */
  12278. remapData: Vector4;
  12279. /** @hidden */
  12280. _randomCellOffset?: number;
  12281. /** @hidden */
  12282. _initialDirection: Nullable<Vector3>;
  12283. /** @hidden */
  12284. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12285. /** @hidden */
  12286. _initialStartSpriteCellID: number;
  12287. /** @hidden */
  12288. _initialEndSpriteCellID: number;
  12289. /** @hidden */
  12290. _currentColorGradient: Nullable<ColorGradient>;
  12291. /** @hidden */
  12292. _currentColor1: Color4;
  12293. /** @hidden */
  12294. _currentColor2: Color4;
  12295. /** @hidden */
  12296. _currentSizeGradient: Nullable<FactorGradient>;
  12297. /** @hidden */
  12298. _currentSize1: number;
  12299. /** @hidden */
  12300. _currentSize2: number;
  12301. /** @hidden */
  12302. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12303. /** @hidden */
  12304. _currentAngularSpeed1: number;
  12305. /** @hidden */
  12306. _currentAngularSpeed2: number;
  12307. /** @hidden */
  12308. _currentVelocityGradient: Nullable<FactorGradient>;
  12309. /** @hidden */
  12310. _currentVelocity1: number;
  12311. /** @hidden */
  12312. _currentVelocity2: number;
  12313. /** @hidden */
  12314. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12315. /** @hidden */
  12316. _currentLimitVelocity1: number;
  12317. /** @hidden */
  12318. _currentLimitVelocity2: number;
  12319. /** @hidden */
  12320. _currentDragGradient: Nullable<FactorGradient>;
  12321. /** @hidden */
  12322. _currentDrag1: number;
  12323. /** @hidden */
  12324. _currentDrag2: number;
  12325. /** @hidden */
  12326. _randomNoiseCoordinates1: Vector3;
  12327. /** @hidden */
  12328. _randomNoiseCoordinates2: Vector3;
  12329. /** @hidden */
  12330. _localPosition?: Vector3;
  12331. /**
  12332. * Creates a new instance Particle
  12333. * @param particleSystem the particle system the particle belongs to
  12334. */
  12335. constructor(
  12336. /**
  12337. * The particle system the particle belongs to.
  12338. */
  12339. particleSystem: ParticleSystem);
  12340. private updateCellInfoFromSystem;
  12341. /**
  12342. * Defines how the sprite cell index is updated for the particle
  12343. */
  12344. updateCellIndex(): void;
  12345. /** @hidden */
  12346. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12347. /** @hidden */
  12348. _inheritParticleInfoToSubEmitters(): void;
  12349. /** @hidden */
  12350. _reset(): void;
  12351. /**
  12352. * Copy the properties of particle to another one.
  12353. * @param other the particle to copy the information to.
  12354. */
  12355. copyTo(other: Particle): void;
  12356. }
  12357. }
  12358. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  12359. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12360. import { Effect } from "babylonjs/Materials/effect";
  12361. import { Particle } from "babylonjs/Particles/particle";
  12362. import { Scene } from "babylonjs/scene";
  12363. /**
  12364. * Particle emitter represents a volume emitting particles.
  12365. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12366. */
  12367. export interface IParticleEmitterType {
  12368. /**
  12369. * Called by the particle System when the direction is computed for the created particle.
  12370. * @param worldMatrix is the world matrix of the particle system
  12371. * @param directionToUpdate is the direction vector to update with the result
  12372. * @param particle is the particle we are computed the direction for
  12373. * @param isLocal defines if the direction should be set in local space
  12374. */
  12375. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12376. /**
  12377. * Called by the particle System when the position is computed for the created particle.
  12378. * @param worldMatrix is the world matrix of the particle system
  12379. * @param positionToUpdate is the position vector to update with the result
  12380. * @param particle is the particle we are computed the position for
  12381. * @param isLocal defines if the position should be set in local space
  12382. */
  12383. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12384. /**
  12385. * Clones the current emitter and returns a copy of it
  12386. * @returns the new emitter
  12387. */
  12388. clone(): IParticleEmitterType;
  12389. /**
  12390. * Called by the GPUParticleSystem to setup the update shader
  12391. * @param effect defines the update shader
  12392. */
  12393. applyToShader(effect: Effect): void;
  12394. /**
  12395. * Returns a string to use to update the GPU particles update shader
  12396. * @returns the effect defines string
  12397. */
  12398. getEffectDefines(): string;
  12399. /**
  12400. * Returns a string representing the class name
  12401. * @returns a string containing the class name
  12402. */
  12403. getClassName(): string;
  12404. /**
  12405. * Serializes the particle system to a JSON object.
  12406. * @returns the JSON object
  12407. */
  12408. serialize(): any;
  12409. /**
  12410. * Parse properties from a JSON object
  12411. * @param serializationObject defines the JSON object
  12412. * @param scene defines the hosting scene
  12413. */
  12414. parse(serializationObject: any, scene: Scene): void;
  12415. }
  12416. }
  12417. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  12418. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12419. import { Effect } from "babylonjs/Materials/effect";
  12420. import { Particle } from "babylonjs/Particles/particle";
  12421. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12422. /**
  12423. * Particle emitter emitting particles from the inside of a box.
  12424. * It emits the particles randomly between 2 given directions.
  12425. */
  12426. export class BoxParticleEmitter implements IParticleEmitterType {
  12427. /**
  12428. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12429. */
  12430. direction1: Vector3;
  12431. /**
  12432. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12433. */
  12434. direction2: Vector3;
  12435. /**
  12436. * 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.
  12437. */
  12438. minEmitBox: Vector3;
  12439. /**
  12440. * 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.
  12441. */
  12442. maxEmitBox: Vector3;
  12443. /**
  12444. * Creates a new instance BoxParticleEmitter
  12445. */
  12446. constructor();
  12447. /**
  12448. * Called by the particle System when the direction is computed for the created particle.
  12449. * @param worldMatrix is the world matrix of the particle system
  12450. * @param directionToUpdate is the direction vector to update with the result
  12451. * @param particle is the particle we are computed the direction for
  12452. * @param isLocal defines if the direction should be set in local space
  12453. */
  12454. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12455. /**
  12456. * Called by the particle System when the position is computed for the created particle.
  12457. * @param worldMatrix is the world matrix of the particle system
  12458. * @param positionToUpdate is the position vector to update with the result
  12459. * @param particle is the particle we are computed the position for
  12460. * @param isLocal defines if the position should be set in local space
  12461. */
  12462. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12463. /**
  12464. * Clones the current emitter and returns a copy of it
  12465. * @returns the new emitter
  12466. */
  12467. clone(): BoxParticleEmitter;
  12468. /**
  12469. * Called by the GPUParticleSystem to setup the update shader
  12470. * @param effect defines the update shader
  12471. */
  12472. applyToShader(effect: Effect): void;
  12473. /**
  12474. * Returns a string to use to update the GPU particles update shader
  12475. * @returns a string containng the defines string
  12476. */
  12477. getEffectDefines(): string;
  12478. /**
  12479. * Returns the string "BoxParticleEmitter"
  12480. * @returns a string containing the class name
  12481. */
  12482. getClassName(): string;
  12483. /**
  12484. * Serializes the particle system to a JSON object.
  12485. * @returns the JSON object
  12486. */
  12487. serialize(): any;
  12488. /**
  12489. * Parse properties from a JSON object
  12490. * @param serializationObject defines the JSON object
  12491. */
  12492. parse(serializationObject: any): void;
  12493. }
  12494. }
  12495. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  12496. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12497. import { Effect } from "babylonjs/Materials/effect";
  12498. import { Particle } from "babylonjs/Particles/particle";
  12499. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12500. /**
  12501. * Particle emitter emitting particles from the inside of a cone.
  12502. * It emits the particles alongside the cone volume from the base to the particle.
  12503. * The emission direction might be randomized.
  12504. */
  12505. export class ConeParticleEmitter implements IParticleEmitterType {
  12506. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12507. directionRandomizer: number;
  12508. private _radius;
  12509. private _angle;
  12510. private _height;
  12511. /**
  12512. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12513. */
  12514. radiusRange: number;
  12515. /**
  12516. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12517. */
  12518. heightRange: number;
  12519. /**
  12520. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12521. */
  12522. emitFromSpawnPointOnly: boolean;
  12523. /**
  12524. * Gets or sets the radius of the emission cone
  12525. */
  12526. get radius(): number;
  12527. set radius(value: number);
  12528. /**
  12529. * Gets or sets the angle of the emission cone
  12530. */
  12531. get angle(): number;
  12532. set angle(value: number);
  12533. private _buildHeight;
  12534. /**
  12535. * Creates a new instance ConeParticleEmitter
  12536. * @param radius the radius of the emission cone (1 by default)
  12537. * @param angle the cone base angle (PI by default)
  12538. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12539. */
  12540. constructor(radius?: number, angle?: number,
  12541. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12542. directionRandomizer?: number);
  12543. /**
  12544. * Called by the particle System when the direction is computed for the created particle.
  12545. * @param worldMatrix is the world matrix of the particle system
  12546. * @param directionToUpdate is the direction vector to update with the result
  12547. * @param particle is the particle we are computed the direction for
  12548. * @param isLocal defines if the direction should be set in local space
  12549. */
  12550. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12551. /**
  12552. * Called by the particle System when the position is computed for the created particle.
  12553. * @param worldMatrix is the world matrix of the particle system
  12554. * @param positionToUpdate is the position vector to update with the result
  12555. * @param particle is the particle we are computed the position for
  12556. * @param isLocal defines if the position should be set in local space
  12557. */
  12558. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12559. /**
  12560. * Clones the current emitter and returns a copy of it
  12561. * @returns the new emitter
  12562. */
  12563. clone(): ConeParticleEmitter;
  12564. /**
  12565. * Called by the GPUParticleSystem to setup the update shader
  12566. * @param effect defines the update shader
  12567. */
  12568. applyToShader(effect: Effect): void;
  12569. /**
  12570. * Returns a string to use to update the GPU particles update shader
  12571. * @returns a string containng the defines string
  12572. */
  12573. getEffectDefines(): string;
  12574. /**
  12575. * Returns the string "ConeParticleEmitter"
  12576. * @returns a string containing the class name
  12577. */
  12578. getClassName(): string;
  12579. /**
  12580. * Serializes the particle system to a JSON object.
  12581. * @returns the JSON object
  12582. */
  12583. serialize(): any;
  12584. /**
  12585. * Parse properties from a JSON object
  12586. * @param serializationObject defines the JSON object
  12587. */
  12588. parse(serializationObject: any): void;
  12589. }
  12590. }
  12591. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  12592. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12593. import { Effect } from "babylonjs/Materials/effect";
  12594. import { Particle } from "babylonjs/Particles/particle";
  12595. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12596. /**
  12597. * Particle emitter emitting particles from the inside of a cylinder.
  12598. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12599. */
  12600. export class CylinderParticleEmitter implements IParticleEmitterType {
  12601. /**
  12602. * The radius of the emission cylinder.
  12603. */
  12604. radius: number;
  12605. /**
  12606. * The height of the emission cylinder.
  12607. */
  12608. height: number;
  12609. /**
  12610. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12611. */
  12612. radiusRange: number;
  12613. /**
  12614. * How much to randomize the particle direction [0-1].
  12615. */
  12616. directionRandomizer: number;
  12617. /**
  12618. * Creates a new instance CylinderParticleEmitter
  12619. * @param radius the radius of the emission cylinder (1 by default)
  12620. * @param height the height of the emission cylinder (1 by default)
  12621. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12622. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12623. */
  12624. constructor(
  12625. /**
  12626. * The radius of the emission cylinder.
  12627. */
  12628. radius?: number,
  12629. /**
  12630. * The height of the emission cylinder.
  12631. */
  12632. height?: number,
  12633. /**
  12634. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12635. */
  12636. radiusRange?: number,
  12637. /**
  12638. * How much to randomize the particle direction [0-1].
  12639. */
  12640. directionRandomizer?: number);
  12641. /**
  12642. * Called by the particle System when the direction is computed for the created particle.
  12643. * @param worldMatrix is the world matrix of the particle system
  12644. * @param directionToUpdate is the direction vector to update with the result
  12645. * @param particle is the particle we are computed the direction for
  12646. * @param isLocal defines if the direction should be set in local space
  12647. */
  12648. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12649. /**
  12650. * Called by the particle System when the position is computed for the created particle.
  12651. * @param worldMatrix is the world matrix of the particle system
  12652. * @param positionToUpdate is the position vector to update with the result
  12653. * @param particle is the particle we are computed the position for
  12654. * @param isLocal defines if the position should be set in local space
  12655. */
  12656. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12657. /**
  12658. * Clones the current emitter and returns a copy of it
  12659. * @returns the new emitter
  12660. */
  12661. clone(): CylinderParticleEmitter;
  12662. /**
  12663. * Called by the GPUParticleSystem to setup the update shader
  12664. * @param effect defines the update shader
  12665. */
  12666. applyToShader(effect: Effect): void;
  12667. /**
  12668. * Returns a string to use to update the GPU particles update shader
  12669. * @returns a string containng the defines string
  12670. */
  12671. getEffectDefines(): string;
  12672. /**
  12673. * Returns the string "CylinderParticleEmitter"
  12674. * @returns a string containing the class name
  12675. */
  12676. getClassName(): string;
  12677. /**
  12678. * Serializes the particle system to a JSON object.
  12679. * @returns the JSON object
  12680. */
  12681. serialize(): any;
  12682. /**
  12683. * Parse properties from a JSON object
  12684. * @param serializationObject defines the JSON object
  12685. */
  12686. parse(serializationObject: any): void;
  12687. }
  12688. /**
  12689. * Particle emitter emitting particles from the inside of a cylinder.
  12690. * It emits the particles randomly between two vectors.
  12691. */
  12692. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12693. /**
  12694. * The min limit of the emission direction.
  12695. */
  12696. direction1: Vector3;
  12697. /**
  12698. * The max limit of the emission direction.
  12699. */
  12700. direction2: Vector3;
  12701. /**
  12702. * Creates a new instance CylinderDirectedParticleEmitter
  12703. * @param radius the radius of the emission cylinder (1 by default)
  12704. * @param height the height of the emission cylinder (1 by default)
  12705. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12706. * @param direction1 the min limit of the emission direction (up vector by default)
  12707. * @param direction2 the max limit of the emission direction (up vector by default)
  12708. */
  12709. constructor(radius?: number, height?: number, radiusRange?: number,
  12710. /**
  12711. * The min limit of the emission direction.
  12712. */
  12713. direction1?: Vector3,
  12714. /**
  12715. * The max limit of the emission direction.
  12716. */
  12717. direction2?: Vector3);
  12718. /**
  12719. * Called by the particle System when the direction is computed for the created particle.
  12720. * @param worldMatrix is the world matrix of the particle system
  12721. * @param directionToUpdate is the direction vector to update with the result
  12722. * @param particle is the particle we are computed the direction for
  12723. */
  12724. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12725. /**
  12726. * Clones the current emitter and returns a copy of it
  12727. * @returns the new emitter
  12728. */
  12729. clone(): CylinderDirectedParticleEmitter;
  12730. /**
  12731. * Called by the GPUParticleSystem to setup the update shader
  12732. * @param effect defines the update shader
  12733. */
  12734. applyToShader(effect: Effect): void;
  12735. /**
  12736. * Returns a string to use to update the GPU particles update shader
  12737. * @returns a string containng the defines string
  12738. */
  12739. getEffectDefines(): string;
  12740. /**
  12741. * Returns the string "CylinderDirectedParticleEmitter"
  12742. * @returns a string containing the class name
  12743. */
  12744. getClassName(): string;
  12745. /**
  12746. * Serializes the particle system to a JSON object.
  12747. * @returns the JSON object
  12748. */
  12749. serialize(): any;
  12750. /**
  12751. * Parse properties from a JSON object
  12752. * @param serializationObject defines the JSON object
  12753. */
  12754. parse(serializationObject: any): void;
  12755. }
  12756. }
  12757. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  12758. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12759. import { Effect } from "babylonjs/Materials/effect";
  12760. import { Particle } from "babylonjs/Particles/particle";
  12761. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12762. /**
  12763. * Particle emitter emitting particles from the inside of a hemisphere.
  12764. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12765. */
  12766. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12767. /**
  12768. * The radius of the emission hemisphere.
  12769. */
  12770. radius: number;
  12771. /**
  12772. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12773. */
  12774. radiusRange: number;
  12775. /**
  12776. * How much to randomize the particle direction [0-1].
  12777. */
  12778. directionRandomizer: number;
  12779. /**
  12780. * Creates a new instance HemisphericParticleEmitter
  12781. * @param radius the radius of the emission hemisphere (1 by default)
  12782. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12783. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12784. */
  12785. constructor(
  12786. /**
  12787. * The radius of the emission hemisphere.
  12788. */
  12789. radius?: number,
  12790. /**
  12791. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12792. */
  12793. radiusRange?: number,
  12794. /**
  12795. * How much to randomize the particle direction [0-1].
  12796. */
  12797. directionRandomizer?: number);
  12798. /**
  12799. * Called by the particle System when the direction is computed for the created particle.
  12800. * @param worldMatrix is the world matrix of the particle system
  12801. * @param directionToUpdate is the direction vector to update with the result
  12802. * @param particle is the particle we are computed the direction for
  12803. * @param isLocal defines if the direction should be set in local space
  12804. */
  12805. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12806. /**
  12807. * Called by the particle System when the position is computed for the created particle.
  12808. * @param worldMatrix is the world matrix of the particle system
  12809. * @param positionToUpdate is the position vector to update with the result
  12810. * @param particle is the particle we are computed the position for
  12811. * @param isLocal defines if the position should be set in local space
  12812. */
  12813. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12814. /**
  12815. * Clones the current emitter and returns a copy of it
  12816. * @returns the new emitter
  12817. */
  12818. clone(): HemisphericParticleEmitter;
  12819. /**
  12820. * Called by the GPUParticleSystem to setup the update shader
  12821. * @param effect defines the update shader
  12822. */
  12823. applyToShader(effect: Effect): void;
  12824. /**
  12825. * Returns a string to use to update the GPU particles update shader
  12826. * @returns a string containng the defines string
  12827. */
  12828. getEffectDefines(): string;
  12829. /**
  12830. * Returns the string "HemisphericParticleEmitter"
  12831. * @returns a string containing the class name
  12832. */
  12833. getClassName(): string;
  12834. /**
  12835. * Serializes the particle system to a JSON object.
  12836. * @returns the JSON object
  12837. */
  12838. serialize(): any;
  12839. /**
  12840. * Parse properties from a JSON object
  12841. * @param serializationObject defines the JSON object
  12842. */
  12843. parse(serializationObject: any): void;
  12844. }
  12845. }
  12846. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  12847. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12848. import { Effect } from "babylonjs/Materials/effect";
  12849. import { Particle } from "babylonjs/Particles/particle";
  12850. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12851. /**
  12852. * Particle emitter emitting particles from a point.
  12853. * It emits the particles randomly between 2 given directions.
  12854. */
  12855. export class PointParticleEmitter implements IParticleEmitterType {
  12856. /**
  12857. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12858. */
  12859. direction1: Vector3;
  12860. /**
  12861. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12862. */
  12863. direction2: Vector3;
  12864. /**
  12865. * Creates a new instance PointParticleEmitter
  12866. */
  12867. constructor();
  12868. /**
  12869. * Called by the particle System when the direction is computed for the created particle.
  12870. * @param worldMatrix is the world matrix of the particle system
  12871. * @param directionToUpdate is the direction vector to update with the result
  12872. * @param particle is the particle we are computed the direction for
  12873. * @param isLocal defines if the direction should be set in local space
  12874. */
  12875. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12876. /**
  12877. * Called by the particle System when the position is computed for the created particle.
  12878. * @param worldMatrix is the world matrix of the particle system
  12879. * @param positionToUpdate is the position vector to update with the result
  12880. * @param particle is the particle we are computed the position for
  12881. * @param isLocal defines if the position should be set in local space
  12882. */
  12883. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12884. /**
  12885. * Clones the current emitter and returns a copy of it
  12886. * @returns the new emitter
  12887. */
  12888. clone(): PointParticleEmitter;
  12889. /**
  12890. * Called by the GPUParticleSystem to setup the update shader
  12891. * @param effect defines the update shader
  12892. */
  12893. applyToShader(effect: Effect): void;
  12894. /**
  12895. * Returns a string to use to update the GPU particles update shader
  12896. * @returns a string containng the defines string
  12897. */
  12898. getEffectDefines(): string;
  12899. /**
  12900. * Returns the string "PointParticleEmitter"
  12901. * @returns a string containing the class name
  12902. */
  12903. getClassName(): string;
  12904. /**
  12905. * Serializes the particle system to a JSON object.
  12906. * @returns the JSON object
  12907. */
  12908. serialize(): any;
  12909. /**
  12910. * Parse properties from a JSON object
  12911. * @param serializationObject defines the JSON object
  12912. */
  12913. parse(serializationObject: any): void;
  12914. }
  12915. }
  12916. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  12917. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12918. import { Effect } from "babylonjs/Materials/effect";
  12919. import { Particle } from "babylonjs/Particles/particle";
  12920. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12921. /**
  12922. * Particle emitter emitting particles from the inside of a sphere.
  12923. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12924. */
  12925. export class SphereParticleEmitter implements IParticleEmitterType {
  12926. /**
  12927. * The radius of the emission sphere.
  12928. */
  12929. radius: number;
  12930. /**
  12931. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12932. */
  12933. radiusRange: number;
  12934. /**
  12935. * How much to randomize the particle direction [0-1].
  12936. */
  12937. directionRandomizer: number;
  12938. /**
  12939. * Creates a new instance SphereParticleEmitter
  12940. * @param radius the radius of the emission sphere (1 by default)
  12941. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12942. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12943. */
  12944. constructor(
  12945. /**
  12946. * The radius of the emission sphere.
  12947. */
  12948. radius?: number,
  12949. /**
  12950. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12951. */
  12952. radiusRange?: number,
  12953. /**
  12954. * How much to randomize the particle direction [0-1].
  12955. */
  12956. directionRandomizer?: number);
  12957. /**
  12958. * Called by the particle System when the direction is computed for the created particle.
  12959. * @param worldMatrix is the world matrix of the particle system
  12960. * @param directionToUpdate is the direction vector to update with the result
  12961. * @param particle is the particle we are computed the direction for
  12962. * @param isLocal defines if the direction should be set in local space
  12963. */
  12964. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12965. /**
  12966. * Called by the particle System when the position is computed for the created particle.
  12967. * @param worldMatrix is the world matrix of the particle system
  12968. * @param positionToUpdate is the position vector to update with the result
  12969. * @param particle is the particle we are computed the position for
  12970. * @param isLocal defines if the position should be set in local space
  12971. */
  12972. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12973. /**
  12974. * Clones the current emitter and returns a copy of it
  12975. * @returns the new emitter
  12976. */
  12977. clone(): SphereParticleEmitter;
  12978. /**
  12979. * Called by the GPUParticleSystem to setup the update shader
  12980. * @param effect defines the update shader
  12981. */
  12982. applyToShader(effect: Effect): void;
  12983. /**
  12984. * Returns a string to use to update the GPU particles update shader
  12985. * @returns a string containng the defines string
  12986. */
  12987. getEffectDefines(): string;
  12988. /**
  12989. * Returns the string "SphereParticleEmitter"
  12990. * @returns a string containing the class name
  12991. */
  12992. getClassName(): string;
  12993. /**
  12994. * Serializes the particle system to a JSON object.
  12995. * @returns the JSON object
  12996. */
  12997. serialize(): any;
  12998. /**
  12999. * Parse properties from a JSON object
  13000. * @param serializationObject defines the JSON object
  13001. */
  13002. parse(serializationObject: any): void;
  13003. }
  13004. /**
  13005. * Particle emitter emitting particles from the inside of a sphere.
  13006. * It emits the particles randomly between two vectors.
  13007. */
  13008. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13009. /**
  13010. * The min limit of the emission direction.
  13011. */
  13012. direction1: Vector3;
  13013. /**
  13014. * The max limit of the emission direction.
  13015. */
  13016. direction2: Vector3;
  13017. /**
  13018. * Creates a new instance SphereDirectedParticleEmitter
  13019. * @param radius the radius of the emission sphere (1 by default)
  13020. * @param direction1 the min limit of the emission direction (up vector by default)
  13021. * @param direction2 the max limit of the emission direction (up vector by default)
  13022. */
  13023. constructor(radius?: number,
  13024. /**
  13025. * The min limit of the emission direction.
  13026. */
  13027. direction1?: Vector3,
  13028. /**
  13029. * The max limit of the emission direction.
  13030. */
  13031. direction2?: Vector3);
  13032. /**
  13033. * Called by the particle System when the direction is computed for the created particle.
  13034. * @param worldMatrix is the world matrix of the particle system
  13035. * @param directionToUpdate is the direction vector to update with the result
  13036. * @param particle is the particle we are computed the direction for
  13037. */
  13038. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13039. /**
  13040. * Clones the current emitter and returns a copy of it
  13041. * @returns the new emitter
  13042. */
  13043. clone(): SphereDirectedParticleEmitter;
  13044. /**
  13045. * Called by the GPUParticleSystem to setup the update shader
  13046. * @param effect defines the update shader
  13047. */
  13048. applyToShader(effect: Effect): void;
  13049. /**
  13050. * Returns a string to use to update the GPU particles update shader
  13051. * @returns a string containng the defines string
  13052. */
  13053. getEffectDefines(): string;
  13054. /**
  13055. * Returns the string "SphereDirectedParticleEmitter"
  13056. * @returns a string containing the class name
  13057. */
  13058. getClassName(): string;
  13059. /**
  13060. * Serializes the particle system to a JSON object.
  13061. * @returns the JSON object
  13062. */
  13063. serialize(): any;
  13064. /**
  13065. * Parse properties from a JSON object
  13066. * @param serializationObject defines the JSON object
  13067. */
  13068. parse(serializationObject: any): void;
  13069. }
  13070. }
  13071. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  13072. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13073. import { Effect } from "babylonjs/Materials/effect";
  13074. import { Particle } from "babylonjs/Particles/particle";
  13075. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13076. import { Nullable } from "babylonjs/types";
  13077. /**
  13078. * Particle emitter emitting particles from a custom list of positions.
  13079. */
  13080. export class CustomParticleEmitter implements IParticleEmitterType {
  13081. /**
  13082. * Gets or sets the position generator that will create the inital position of each particle.
  13083. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13084. */
  13085. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13086. /**
  13087. * Gets or sets the destination generator that will create the final destination of each particle.
  13088. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13089. */
  13090. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13091. /**
  13092. * Creates a new instance CustomParticleEmitter
  13093. */
  13094. constructor();
  13095. /**
  13096. * Called by the particle System when the direction is computed for the created particle.
  13097. * @param worldMatrix is the world matrix of the particle system
  13098. * @param directionToUpdate is the direction vector to update with the result
  13099. * @param particle is the particle we are computed the direction for
  13100. * @param isLocal defines if the direction should be set in local space
  13101. */
  13102. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13103. /**
  13104. * Called by the particle System when the position is computed for the created particle.
  13105. * @param worldMatrix is the world matrix of the particle system
  13106. * @param positionToUpdate is the position vector to update with the result
  13107. * @param particle is the particle we are computed the position for
  13108. * @param isLocal defines if the position should be set in local space
  13109. */
  13110. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13111. /**
  13112. * Clones the current emitter and returns a copy of it
  13113. * @returns the new emitter
  13114. */
  13115. clone(): CustomParticleEmitter;
  13116. /**
  13117. * Called by the GPUParticleSystem to setup the update shader
  13118. * @param effect defines the update shader
  13119. */
  13120. applyToShader(effect: Effect): void;
  13121. /**
  13122. * Returns a string to use to update the GPU particles update shader
  13123. * @returns a string containng the defines string
  13124. */
  13125. getEffectDefines(): string;
  13126. /**
  13127. * Returns the string "PointParticleEmitter"
  13128. * @returns a string containing the class name
  13129. */
  13130. getClassName(): string;
  13131. /**
  13132. * Serializes the particle system to a JSON object.
  13133. * @returns the JSON object
  13134. */
  13135. serialize(): any;
  13136. /**
  13137. * Parse properties from a JSON object
  13138. * @param serializationObject defines the JSON object
  13139. */
  13140. parse(serializationObject: any): void;
  13141. }
  13142. }
  13143. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  13144. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13145. import { Effect } from "babylonjs/Materials/effect";
  13146. import { Particle } from "babylonjs/Particles/particle";
  13147. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13148. import { Nullable } from "babylonjs/types";
  13149. import { Scene } from "babylonjs/scene";
  13150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13151. /**
  13152. * Particle emitter emitting particles from the inside of a box.
  13153. * It emits the particles randomly between 2 given directions.
  13154. */
  13155. export class MeshParticleEmitter implements IParticleEmitterType {
  13156. private _indices;
  13157. private _positions;
  13158. private _normals;
  13159. private _storedNormal;
  13160. private _mesh;
  13161. /**
  13162. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13163. */
  13164. direction1: Vector3;
  13165. /**
  13166. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13167. */
  13168. direction2: Vector3;
  13169. /**
  13170. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13171. */
  13172. useMeshNormalsForDirection: boolean;
  13173. /** Defines the mesh to use as source */
  13174. get mesh(): Nullable<AbstractMesh>;
  13175. set mesh(value: Nullable<AbstractMesh>);
  13176. /**
  13177. * Creates a new instance MeshParticleEmitter
  13178. * @param mesh defines the mesh to use as source
  13179. */
  13180. constructor(mesh?: Nullable<AbstractMesh>);
  13181. /**
  13182. * Called by the particle System when the direction is computed for the created particle.
  13183. * @param worldMatrix is the world matrix of the particle system
  13184. * @param directionToUpdate is the direction vector to update with the result
  13185. * @param particle is the particle we are computed the direction for
  13186. * @param isLocal defines if the direction should be set in local space
  13187. */
  13188. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13189. /**
  13190. * Called by the particle System when the position is computed for the created particle.
  13191. * @param worldMatrix is the world matrix of the particle system
  13192. * @param positionToUpdate is the position vector to update with the result
  13193. * @param particle is the particle we are computed the position for
  13194. * @param isLocal defines if the position should be set in local space
  13195. */
  13196. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13197. /**
  13198. * Clones the current emitter and returns a copy of it
  13199. * @returns the new emitter
  13200. */
  13201. clone(): MeshParticleEmitter;
  13202. /**
  13203. * Called by the GPUParticleSystem to setup the update shader
  13204. * @param effect defines the update shader
  13205. */
  13206. applyToShader(effect: Effect): void;
  13207. /**
  13208. * Returns a string to use to update the GPU particles update shader
  13209. * @returns a string containng the defines string
  13210. */
  13211. getEffectDefines(): string;
  13212. /**
  13213. * Returns the string "BoxParticleEmitter"
  13214. * @returns a string containing the class name
  13215. */
  13216. getClassName(): string;
  13217. /**
  13218. * Serializes the particle system to a JSON object.
  13219. * @returns the JSON object
  13220. */
  13221. serialize(): any;
  13222. /**
  13223. * Parse properties from a JSON object
  13224. * @param serializationObject defines the JSON object
  13225. * @param scene defines the hosting scene
  13226. */
  13227. parse(serializationObject: any, scene: Scene): void;
  13228. }
  13229. }
  13230. declare module "babylonjs/Particles/EmitterTypes/index" {
  13231. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  13232. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  13233. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  13234. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  13235. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13236. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  13237. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  13238. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  13239. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  13240. }
  13241. declare module "babylonjs/Particles/IParticleSystem" {
  13242. import { Nullable } from "babylonjs/types";
  13243. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  13244. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  13245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13246. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13247. import { Texture } from "babylonjs/Materials/Textures/texture";
  13248. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  13249. import { Scene } from "babylonjs/scene";
  13250. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  13251. import { Animation } from "babylonjs/Animations/animation";
  13252. /**
  13253. * Interface representing a particle system in Babylon.js.
  13254. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13255. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13256. */
  13257. export interface IParticleSystem {
  13258. /**
  13259. * List of animations used by the particle system.
  13260. */
  13261. animations: Animation[];
  13262. /**
  13263. * The id of the Particle system.
  13264. */
  13265. id: string;
  13266. /**
  13267. * The name of the Particle system.
  13268. */
  13269. name: string;
  13270. /**
  13271. * The emitter represents the Mesh or position we are attaching the particle system to.
  13272. */
  13273. emitter: Nullable<AbstractMesh | Vector3>;
  13274. /**
  13275. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13276. */
  13277. isBillboardBased: boolean;
  13278. /**
  13279. * The rendering group used by the Particle system to chose when to render.
  13280. */
  13281. renderingGroupId: number;
  13282. /**
  13283. * The layer mask we are rendering the particles through.
  13284. */
  13285. layerMask: number;
  13286. /**
  13287. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13288. */
  13289. updateSpeed: number;
  13290. /**
  13291. * The amount of time the particle system is running (depends of the overall update speed).
  13292. */
  13293. targetStopDuration: number;
  13294. /**
  13295. * The texture used to render each particle. (this can be a spritesheet)
  13296. */
  13297. particleTexture: Nullable<Texture>;
  13298. /**
  13299. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13300. */
  13301. blendMode: number;
  13302. /**
  13303. * Minimum life time of emitting particles.
  13304. */
  13305. minLifeTime: number;
  13306. /**
  13307. * Maximum life time of emitting particles.
  13308. */
  13309. maxLifeTime: number;
  13310. /**
  13311. * Minimum Size of emitting particles.
  13312. */
  13313. minSize: number;
  13314. /**
  13315. * Maximum Size of emitting particles.
  13316. */
  13317. maxSize: number;
  13318. /**
  13319. * Minimum scale of emitting particles on X axis.
  13320. */
  13321. minScaleX: number;
  13322. /**
  13323. * Maximum scale of emitting particles on X axis.
  13324. */
  13325. maxScaleX: number;
  13326. /**
  13327. * Minimum scale of emitting particles on Y axis.
  13328. */
  13329. minScaleY: number;
  13330. /**
  13331. * Maximum scale of emitting particles on Y axis.
  13332. */
  13333. maxScaleY: number;
  13334. /**
  13335. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13336. */
  13337. color1: Color4;
  13338. /**
  13339. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13340. */
  13341. color2: Color4;
  13342. /**
  13343. * Color the particle will have at the end of its lifetime.
  13344. */
  13345. colorDead: Color4;
  13346. /**
  13347. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13348. */
  13349. emitRate: number;
  13350. /**
  13351. * You can use gravity if you want to give an orientation to your particles.
  13352. */
  13353. gravity: Vector3;
  13354. /**
  13355. * Minimum power of emitting particles.
  13356. */
  13357. minEmitPower: number;
  13358. /**
  13359. * Maximum power of emitting particles.
  13360. */
  13361. maxEmitPower: number;
  13362. /**
  13363. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13364. */
  13365. minAngularSpeed: number;
  13366. /**
  13367. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13368. */
  13369. maxAngularSpeed: number;
  13370. /**
  13371. * Gets or sets the minimal initial rotation in radians.
  13372. */
  13373. minInitialRotation: number;
  13374. /**
  13375. * Gets or sets the maximal initial rotation in radians.
  13376. */
  13377. maxInitialRotation: number;
  13378. /**
  13379. * The particle emitter type defines the emitter used by the particle system.
  13380. * It can be for example box, sphere, or cone...
  13381. */
  13382. particleEmitterType: Nullable<IParticleEmitterType>;
  13383. /**
  13384. * Defines the delay in milliseconds before starting the system (0 by default)
  13385. */
  13386. startDelay: number;
  13387. /**
  13388. * 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
  13389. */
  13390. preWarmCycles: number;
  13391. /**
  13392. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13393. */
  13394. preWarmStepOffset: number;
  13395. /**
  13396. * 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)
  13397. */
  13398. spriteCellChangeSpeed: number;
  13399. /**
  13400. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13401. */
  13402. startSpriteCellID: number;
  13403. /**
  13404. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13405. */
  13406. endSpriteCellID: number;
  13407. /**
  13408. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13409. */
  13410. spriteCellWidth: number;
  13411. /**
  13412. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13413. */
  13414. spriteCellHeight: number;
  13415. /**
  13416. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13417. */
  13418. spriteRandomStartCell: boolean;
  13419. /**
  13420. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13421. */
  13422. isAnimationSheetEnabled: boolean;
  13423. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13424. translationPivot: Vector2;
  13425. /**
  13426. * Gets or sets a texture used to add random noise to particle positions
  13427. */
  13428. noiseTexture: Nullable<BaseTexture>;
  13429. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13430. noiseStrength: Vector3;
  13431. /**
  13432. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13433. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13434. */
  13435. billboardMode: number;
  13436. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13437. limitVelocityDamping: number;
  13438. /**
  13439. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13440. */
  13441. beginAnimationOnStart: boolean;
  13442. /**
  13443. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13444. */
  13445. beginAnimationFrom: number;
  13446. /**
  13447. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13448. */
  13449. beginAnimationTo: number;
  13450. /**
  13451. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13452. */
  13453. beginAnimationLoop: boolean;
  13454. /**
  13455. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13456. */
  13457. disposeOnStop: boolean;
  13458. /**
  13459. * Specifies if the particles are updated in emitter local space or world space
  13460. */
  13461. isLocal: boolean;
  13462. /**
  13463. * Gets the maximum number of particles active at the same time.
  13464. * @returns The max number of active particles.
  13465. */
  13466. getCapacity(): number;
  13467. /**
  13468. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13469. * @returns True if it has been started, otherwise false.
  13470. */
  13471. isStarted(): boolean;
  13472. /**
  13473. * Animates the particle system for this frame.
  13474. */
  13475. animate(): void;
  13476. /**
  13477. * Renders the particle system in its current state.
  13478. * @returns the current number of particles
  13479. */
  13480. render(): number;
  13481. /**
  13482. * Dispose the particle system and frees its associated resources.
  13483. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13484. */
  13485. dispose(disposeTexture?: boolean): void;
  13486. /**
  13487. * Clones the particle system.
  13488. * @param name The name of the cloned object
  13489. * @param newEmitter The new emitter to use
  13490. * @returns the cloned particle system
  13491. */
  13492. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13493. /**
  13494. * Serializes the particle system to a JSON object.
  13495. * @returns the JSON object
  13496. */
  13497. serialize(): any;
  13498. /**
  13499. * Rebuild the particle system
  13500. */
  13501. rebuild(): void;
  13502. /**
  13503. * Starts the particle system and begins to emit
  13504. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13505. */
  13506. start(delay?: number): void;
  13507. /**
  13508. * Stops the particle system.
  13509. */
  13510. stop(): void;
  13511. /**
  13512. * Remove all active particles
  13513. */
  13514. reset(): void;
  13515. /**
  13516. * Is this system ready to be used/rendered
  13517. * @return true if the system is ready
  13518. */
  13519. isReady(): boolean;
  13520. /**
  13521. * Returns the string "ParticleSystem"
  13522. * @returns a string containing the class name
  13523. */
  13524. getClassName(): string;
  13525. /**
  13526. * Adds a new color gradient
  13527. * @param gradient defines the gradient to use (between 0 and 1)
  13528. * @param color1 defines the color to affect to the specified gradient
  13529. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13530. * @returns the current particle system
  13531. */
  13532. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13533. /**
  13534. * Remove a specific color gradient
  13535. * @param gradient defines the gradient to remove
  13536. * @returns the current particle system
  13537. */
  13538. removeColorGradient(gradient: number): IParticleSystem;
  13539. /**
  13540. * Adds a new size gradient
  13541. * @param gradient defines the gradient to use (between 0 and 1)
  13542. * @param factor defines the size factor to affect to the specified gradient
  13543. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13544. * @returns the current particle system
  13545. */
  13546. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13547. /**
  13548. * Remove a specific size gradient
  13549. * @param gradient defines the gradient to remove
  13550. * @returns the current particle system
  13551. */
  13552. removeSizeGradient(gradient: number): IParticleSystem;
  13553. /**
  13554. * Gets the current list of color gradients.
  13555. * You must use addColorGradient and removeColorGradient to udpate this list
  13556. * @returns the list of color gradients
  13557. */
  13558. getColorGradients(): Nullable<Array<ColorGradient>>;
  13559. /**
  13560. * Gets the current list of size gradients.
  13561. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13562. * @returns the list of size gradients
  13563. */
  13564. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13565. /**
  13566. * Gets the current list of angular speed gradients.
  13567. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13568. * @returns the list of angular speed gradients
  13569. */
  13570. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13571. /**
  13572. * Adds a new angular speed gradient
  13573. * @param gradient defines the gradient to use (between 0 and 1)
  13574. * @param factor defines the angular speed to affect to the specified gradient
  13575. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13576. * @returns the current particle system
  13577. */
  13578. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13579. /**
  13580. * Remove a specific angular speed gradient
  13581. * @param gradient defines the gradient to remove
  13582. * @returns the current particle system
  13583. */
  13584. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13585. /**
  13586. * Gets the current list of velocity gradients.
  13587. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13588. * @returns the list of velocity gradients
  13589. */
  13590. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13591. /**
  13592. * Adds a new velocity gradient
  13593. * @param gradient defines the gradient to use (between 0 and 1)
  13594. * @param factor defines the velocity to affect to the specified gradient
  13595. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13596. * @returns the current particle system
  13597. */
  13598. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13599. /**
  13600. * Remove a specific velocity gradient
  13601. * @param gradient defines the gradient to remove
  13602. * @returns the current particle system
  13603. */
  13604. removeVelocityGradient(gradient: number): IParticleSystem;
  13605. /**
  13606. * Gets the current list of limit velocity gradients.
  13607. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13608. * @returns the list of limit velocity gradients
  13609. */
  13610. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13611. /**
  13612. * Adds a new limit velocity gradient
  13613. * @param gradient defines the gradient to use (between 0 and 1)
  13614. * @param factor defines the limit velocity to affect to the specified gradient
  13615. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13616. * @returns the current particle system
  13617. */
  13618. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13619. /**
  13620. * Remove a specific limit velocity gradient
  13621. * @param gradient defines the gradient to remove
  13622. * @returns the current particle system
  13623. */
  13624. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13625. /**
  13626. * Adds a new drag gradient
  13627. * @param gradient defines the gradient to use (between 0 and 1)
  13628. * @param factor defines the drag to affect to the specified gradient
  13629. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13630. * @returns the current particle system
  13631. */
  13632. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13633. /**
  13634. * Remove a specific drag gradient
  13635. * @param gradient defines the gradient to remove
  13636. * @returns the current particle system
  13637. */
  13638. removeDragGradient(gradient: number): IParticleSystem;
  13639. /**
  13640. * Gets the current list of drag gradients.
  13641. * You must use addDragGradient and removeDragGradient to udpate this list
  13642. * @returns the list of drag gradients
  13643. */
  13644. getDragGradients(): Nullable<Array<FactorGradient>>;
  13645. /**
  13646. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13647. * @param gradient defines the gradient to use (between 0 and 1)
  13648. * @param factor defines the emit rate to affect to the specified gradient
  13649. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13650. * @returns the current particle system
  13651. */
  13652. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13653. /**
  13654. * Remove a specific emit rate gradient
  13655. * @param gradient defines the gradient to remove
  13656. * @returns the current particle system
  13657. */
  13658. removeEmitRateGradient(gradient: number): IParticleSystem;
  13659. /**
  13660. * Gets the current list of emit rate gradients.
  13661. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13662. * @returns the list of emit rate gradients
  13663. */
  13664. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13665. /**
  13666. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13667. * @param gradient defines the gradient to use (between 0 and 1)
  13668. * @param factor defines the start size to affect to the specified gradient
  13669. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13670. * @returns the current particle system
  13671. */
  13672. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13673. /**
  13674. * Remove a specific start size gradient
  13675. * @param gradient defines the gradient to remove
  13676. * @returns the current particle system
  13677. */
  13678. removeStartSizeGradient(gradient: number): IParticleSystem;
  13679. /**
  13680. * Gets the current list of start size gradients.
  13681. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13682. * @returns the list of start size gradients
  13683. */
  13684. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13685. /**
  13686. * Adds a new life time gradient
  13687. * @param gradient defines the gradient to use (between 0 and 1)
  13688. * @param factor defines the life time factor to affect to the specified gradient
  13689. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13690. * @returns the current particle system
  13691. */
  13692. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13693. /**
  13694. * Remove a specific life time gradient
  13695. * @param gradient defines the gradient to remove
  13696. * @returns the current particle system
  13697. */
  13698. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13699. /**
  13700. * Gets the current list of life time gradients.
  13701. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13702. * @returns the list of life time gradients
  13703. */
  13704. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13705. /**
  13706. * Gets the current list of color gradients.
  13707. * You must use addColorGradient and removeColorGradient to udpate this list
  13708. * @returns the list of color gradients
  13709. */
  13710. getColorGradients(): Nullable<Array<ColorGradient>>;
  13711. /**
  13712. * Adds a new ramp gradient used to remap particle colors
  13713. * @param gradient defines the gradient to use (between 0 and 1)
  13714. * @param color defines the color to affect to the specified gradient
  13715. * @returns the current particle system
  13716. */
  13717. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13718. /**
  13719. * Gets the current list of ramp gradients.
  13720. * You must use addRampGradient and removeRampGradient to udpate this list
  13721. * @returns the list of ramp gradients
  13722. */
  13723. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13724. /** Gets or sets a boolean indicating that ramp gradients must be used
  13725. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13726. */
  13727. useRampGradients: boolean;
  13728. /**
  13729. * Adds a new color remap gradient
  13730. * @param gradient defines the gradient to use (between 0 and 1)
  13731. * @param min defines the color remap minimal range
  13732. * @param max defines the color remap maximal range
  13733. * @returns the current particle system
  13734. */
  13735. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13736. /**
  13737. * Gets the current list of color remap gradients.
  13738. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13739. * @returns the list of color remap gradients
  13740. */
  13741. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13742. /**
  13743. * Adds a new alpha remap gradient
  13744. * @param gradient defines the gradient to use (between 0 and 1)
  13745. * @param min defines the alpha remap minimal range
  13746. * @param max defines the alpha remap maximal range
  13747. * @returns the current particle system
  13748. */
  13749. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13750. /**
  13751. * Gets the current list of alpha remap gradients.
  13752. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13753. * @returns the list of alpha remap gradients
  13754. */
  13755. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13756. /**
  13757. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13758. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13759. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13760. * @returns the emitter
  13761. */
  13762. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13763. /**
  13764. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13765. * @param radius The radius of the hemisphere to emit from
  13766. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13767. * @returns the emitter
  13768. */
  13769. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13770. /**
  13771. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13772. * @param radius The radius of the sphere to emit from
  13773. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13774. * @returns the emitter
  13775. */
  13776. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13777. /**
  13778. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13779. * @param radius The radius of the sphere to emit from
  13780. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13781. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13782. * @returns the emitter
  13783. */
  13784. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13785. /**
  13786. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13787. * @param radius The radius of the emission cylinder
  13788. * @param height The height of the emission cylinder
  13789. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13790. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13791. * @returns the emitter
  13792. */
  13793. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13794. /**
  13795. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13796. * @param radius The radius of the cylinder to emit from
  13797. * @param height The height of the emission cylinder
  13798. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13799. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13800. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13801. * @returns the emitter
  13802. */
  13803. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13804. /**
  13805. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13806. * @param radius The radius of the cone to emit from
  13807. * @param angle The base angle of the cone
  13808. * @returns the emitter
  13809. */
  13810. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13811. /**
  13812. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13813. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13814. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13815. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13816. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13817. * @returns the emitter
  13818. */
  13819. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13820. /**
  13821. * Get hosting scene
  13822. * @returns the scene
  13823. */
  13824. getScene(): Scene;
  13825. }
  13826. }
  13827. declare module "babylonjs/Meshes/transformNode" {
  13828. import { DeepImmutable } from "babylonjs/types";
  13829. import { Observable } from "babylonjs/Misc/observable";
  13830. import { Nullable } from "babylonjs/types";
  13831. import { Camera } from "babylonjs/Cameras/camera";
  13832. import { Scene } from "babylonjs/scene";
  13833. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13834. import { Node } from "babylonjs/node";
  13835. import { Bone } from "babylonjs/Bones/bone";
  13836. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13837. import { Space } from "babylonjs/Maths/math.axis";
  13838. /**
  13839. * 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.
  13840. * @see https://doc.babylonjs.com/how_to/transformnode
  13841. */
  13842. export class TransformNode extends Node {
  13843. /**
  13844. * Object will not rotate to face the camera
  13845. */
  13846. static BILLBOARDMODE_NONE: number;
  13847. /**
  13848. * Object will rotate to face the camera but only on the x axis
  13849. */
  13850. static BILLBOARDMODE_X: number;
  13851. /**
  13852. * Object will rotate to face the camera but only on the y axis
  13853. */
  13854. static BILLBOARDMODE_Y: number;
  13855. /**
  13856. * Object will rotate to face the camera but only on the z axis
  13857. */
  13858. static BILLBOARDMODE_Z: number;
  13859. /**
  13860. * Object will rotate to face the camera
  13861. */
  13862. static BILLBOARDMODE_ALL: number;
  13863. /**
  13864. * Object will rotate to face the camera's position instead of orientation
  13865. */
  13866. static BILLBOARDMODE_USE_POSITION: number;
  13867. private _forward;
  13868. private _forwardInverted;
  13869. private _up;
  13870. private _right;
  13871. private _rightInverted;
  13872. private _position;
  13873. private _rotation;
  13874. private _rotationQuaternion;
  13875. protected _scaling: Vector3;
  13876. protected _isDirty: boolean;
  13877. private _transformToBoneReferal;
  13878. private _isAbsoluteSynced;
  13879. private _billboardMode;
  13880. /**
  13881. * Gets or sets the billboard mode. Default is 0.
  13882. *
  13883. * | Value | Type | Description |
  13884. * | --- | --- | --- |
  13885. * | 0 | BILLBOARDMODE_NONE | |
  13886. * | 1 | BILLBOARDMODE_X | |
  13887. * | 2 | BILLBOARDMODE_Y | |
  13888. * | 4 | BILLBOARDMODE_Z | |
  13889. * | 7 | BILLBOARDMODE_ALL | |
  13890. *
  13891. */
  13892. get billboardMode(): number;
  13893. set billboardMode(value: number);
  13894. private _preserveParentRotationForBillboard;
  13895. /**
  13896. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13897. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13898. */
  13899. get preserveParentRotationForBillboard(): boolean;
  13900. set preserveParentRotationForBillboard(value: boolean);
  13901. /**
  13902. * 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
  13903. */
  13904. scalingDeterminant: number;
  13905. private _infiniteDistance;
  13906. /**
  13907. * Gets or sets the distance of the object to max, often used by skybox
  13908. */
  13909. get infiniteDistance(): boolean;
  13910. set infiniteDistance(value: boolean);
  13911. /**
  13912. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13913. * By default the system will update normals to compensate
  13914. */
  13915. ignoreNonUniformScaling: boolean;
  13916. /**
  13917. * 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
  13918. */
  13919. reIntegrateRotationIntoRotationQuaternion: boolean;
  13920. /** @hidden */
  13921. _poseMatrix: Nullable<Matrix>;
  13922. /** @hidden */
  13923. _localMatrix: Matrix;
  13924. private _usePivotMatrix;
  13925. private _absolutePosition;
  13926. private _absoluteScaling;
  13927. private _absoluteRotationQuaternion;
  13928. private _pivotMatrix;
  13929. private _pivotMatrixInverse;
  13930. protected _postMultiplyPivotMatrix: boolean;
  13931. protected _isWorldMatrixFrozen: boolean;
  13932. /** @hidden */
  13933. _indexInSceneTransformNodesArray: number;
  13934. /**
  13935. * An event triggered after the world matrix is updated
  13936. */
  13937. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13938. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13939. /**
  13940. * Gets a string identifying the name of the class
  13941. * @returns "TransformNode" string
  13942. */
  13943. getClassName(): string;
  13944. /**
  13945. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13946. */
  13947. get position(): Vector3;
  13948. set position(newPosition: Vector3);
  13949. /**
  13950. * 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)).
  13951. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13952. */
  13953. get rotation(): Vector3;
  13954. set rotation(newRotation: Vector3);
  13955. /**
  13956. * 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)).
  13957. */
  13958. get scaling(): Vector3;
  13959. set scaling(newScaling: Vector3);
  13960. /**
  13961. * 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).
  13962. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13963. */
  13964. get rotationQuaternion(): Nullable<Quaternion>;
  13965. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13966. /**
  13967. * The forward direction of that transform in world space.
  13968. */
  13969. get forward(): Vector3;
  13970. /**
  13971. * The up direction of that transform in world space.
  13972. */
  13973. get up(): Vector3;
  13974. /**
  13975. * The right direction of that transform in world space.
  13976. */
  13977. get right(): Vector3;
  13978. /**
  13979. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13980. * @param matrix the matrix to copy the pose from
  13981. * @returns this TransformNode.
  13982. */
  13983. updatePoseMatrix(matrix: Matrix): TransformNode;
  13984. /**
  13985. * Returns the mesh Pose matrix.
  13986. * @returns the pose matrix
  13987. */
  13988. getPoseMatrix(): Matrix;
  13989. /** @hidden */
  13990. _isSynchronized(): boolean;
  13991. /** @hidden */
  13992. _initCache(): void;
  13993. /**
  13994. * Flag the transform node as dirty (Forcing it to update everything)
  13995. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13996. * @returns this transform node
  13997. */
  13998. markAsDirty(property: string): TransformNode;
  13999. /**
  14000. * Returns the current mesh absolute position.
  14001. * Returns a Vector3.
  14002. */
  14003. get absolutePosition(): Vector3;
  14004. /**
  14005. * Returns the current mesh absolute scaling.
  14006. * Returns a Vector3.
  14007. */
  14008. get absoluteScaling(): Vector3;
  14009. /**
  14010. * Returns the current mesh absolute rotation.
  14011. * Returns a Quaternion.
  14012. */
  14013. get absoluteRotationQuaternion(): Quaternion;
  14014. /**
  14015. * Sets a new matrix to apply before all other transformation
  14016. * @param matrix defines the transform matrix
  14017. * @returns the current TransformNode
  14018. */
  14019. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14020. /**
  14021. * Sets a new pivot matrix to the current node
  14022. * @param matrix defines the new pivot matrix to use
  14023. * @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
  14024. * @returns the current TransformNode
  14025. */
  14026. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14027. /**
  14028. * Returns the mesh pivot matrix.
  14029. * Default : Identity.
  14030. * @returns the matrix
  14031. */
  14032. getPivotMatrix(): Matrix;
  14033. /**
  14034. * Instantiate (when possible) or clone that node with its hierarchy
  14035. * @param newParent defines the new parent to use for the instance (or clone)
  14036. * @param options defines options to configure how copy is done
  14037. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14038. * @returns an instance (or a clone) of the current node with its hiearchy
  14039. */
  14040. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14041. doNotInstantiate: boolean;
  14042. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14043. /**
  14044. * Prevents the World matrix to be computed any longer
  14045. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14046. * @returns the TransformNode.
  14047. */
  14048. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14049. /**
  14050. * Allows back the World matrix computation.
  14051. * @returns the TransformNode.
  14052. */
  14053. unfreezeWorldMatrix(): this;
  14054. /**
  14055. * True if the World matrix has been frozen.
  14056. */
  14057. get isWorldMatrixFrozen(): boolean;
  14058. /**
  14059. * Retuns the mesh absolute position in the World.
  14060. * @returns a Vector3.
  14061. */
  14062. getAbsolutePosition(): Vector3;
  14063. /**
  14064. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14065. * @param absolutePosition the absolute position to set
  14066. * @returns the TransformNode.
  14067. */
  14068. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14069. /**
  14070. * Sets the mesh position in its local space.
  14071. * @param vector3 the position to set in localspace
  14072. * @returns the TransformNode.
  14073. */
  14074. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14075. /**
  14076. * Returns the mesh position in the local space from the current World matrix values.
  14077. * @returns a new Vector3.
  14078. */
  14079. getPositionExpressedInLocalSpace(): Vector3;
  14080. /**
  14081. * Translates the mesh along the passed Vector3 in its local space.
  14082. * @param vector3 the distance to translate in localspace
  14083. * @returns the TransformNode.
  14084. */
  14085. locallyTranslate(vector3: Vector3): TransformNode;
  14086. private static _lookAtVectorCache;
  14087. /**
  14088. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14089. * @param targetPoint the position (must be in same space as current mesh) to look at
  14090. * @param yawCor optional yaw (y-axis) correction in radians
  14091. * @param pitchCor optional pitch (x-axis) correction in radians
  14092. * @param rollCor optional roll (z-axis) correction in radians
  14093. * @param space the choosen space of the target
  14094. * @returns the TransformNode.
  14095. */
  14096. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14097. /**
  14098. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14099. * This Vector3 is expressed in the World space.
  14100. * @param localAxis axis to rotate
  14101. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14102. */
  14103. getDirection(localAxis: Vector3): Vector3;
  14104. /**
  14105. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14106. * localAxis is expressed in the mesh local space.
  14107. * result is computed in the Wordl space from the mesh World matrix.
  14108. * @param localAxis axis to rotate
  14109. * @param result the resulting transformnode
  14110. * @returns this TransformNode.
  14111. */
  14112. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14113. /**
  14114. * Sets this transform node rotation to the given local axis.
  14115. * @param localAxis the axis in local space
  14116. * @param yawCor optional yaw (y-axis) correction in radians
  14117. * @param pitchCor optional pitch (x-axis) correction in radians
  14118. * @param rollCor optional roll (z-axis) correction in radians
  14119. * @returns this TransformNode
  14120. */
  14121. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14122. /**
  14123. * Sets a new pivot point to the current node
  14124. * @param point defines the new pivot point to use
  14125. * @param space defines if the point is in world or local space (local by default)
  14126. * @returns the current TransformNode
  14127. */
  14128. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14129. /**
  14130. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14131. * @returns the pivot point
  14132. */
  14133. getPivotPoint(): Vector3;
  14134. /**
  14135. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14136. * @param result the vector3 to store the result
  14137. * @returns this TransformNode.
  14138. */
  14139. getPivotPointToRef(result: Vector3): TransformNode;
  14140. /**
  14141. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14142. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14143. */
  14144. getAbsolutePivotPoint(): Vector3;
  14145. /**
  14146. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14147. * @param result vector3 to store the result
  14148. * @returns this TransformNode.
  14149. */
  14150. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14151. /**
  14152. * Defines the passed node as the parent of the current node.
  14153. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14154. * @see https://doc.babylonjs.com/how_to/parenting
  14155. * @param node the node ot set as the parent
  14156. * @returns this TransformNode.
  14157. */
  14158. setParent(node: Nullable<Node>): TransformNode;
  14159. private _nonUniformScaling;
  14160. /**
  14161. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14162. */
  14163. get nonUniformScaling(): boolean;
  14164. /** @hidden */
  14165. _updateNonUniformScalingState(value: boolean): boolean;
  14166. /**
  14167. * Attach the current TransformNode to another TransformNode associated with a bone
  14168. * @param bone Bone affecting the TransformNode
  14169. * @param affectedTransformNode TransformNode associated with the bone
  14170. * @returns this object
  14171. */
  14172. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14173. /**
  14174. * Detach the transform node if its associated with a bone
  14175. * @returns this object
  14176. */
  14177. detachFromBone(): TransformNode;
  14178. private static _rotationAxisCache;
  14179. /**
  14180. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14181. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14182. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14183. * The passed axis is also normalized.
  14184. * @param axis the axis to rotate around
  14185. * @param amount the amount to rotate in radians
  14186. * @param space Space to rotate in (Default: local)
  14187. * @returns the TransformNode.
  14188. */
  14189. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14190. /**
  14191. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14192. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14193. * The passed axis is also normalized. .
  14194. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14195. * @param point the point to rotate around
  14196. * @param axis the axis to rotate around
  14197. * @param amount the amount to rotate in radians
  14198. * @returns the TransformNode
  14199. */
  14200. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14201. /**
  14202. * Translates the mesh along the axis vector for the passed distance in the given space.
  14203. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14204. * @param axis the axis to translate in
  14205. * @param distance the distance to translate
  14206. * @param space Space to rotate in (Default: local)
  14207. * @returns the TransformNode.
  14208. */
  14209. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14210. /**
  14211. * Adds a rotation step to the mesh current rotation.
  14212. * x, y, z are Euler angles expressed in radians.
  14213. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14214. * This means this rotation is made in the mesh local space only.
  14215. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14216. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14217. * ```javascript
  14218. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14219. * ```
  14220. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14221. * 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.
  14222. * @param x Rotation to add
  14223. * @param y Rotation to add
  14224. * @param z Rotation to add
  14225. * @returns the TransformNode.
  14226. */
  14227. addRotation(x: number, y: number, z: number): TransformNode;
  14228. /**
  14229. * @hidden
  14230. */
  14231. protected _getEffectiveParent(): Nullable<Node>;
  14232. /**
  14233. * Computes the world matrix of the node
  14234. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14235. * @returns the world matrix
  14236. */
  14237. computeWorldMatrix(force?: boolean): Matrix;
  14238. /**
  14239. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14240. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14241. */
  14242. resetLocalMatrix(independentOfChildren?: boolean): void;
  14243. protected _afterComputeWorldMatrix(): void;
  14244. /**
  14245. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14246. * @param func callback function to add
  14247. *
  14248. * @returns the TransformNode.
  14249. */
  14250. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14251. /**
  14252. * Removes a registered callback function.
  14253. * @param func callback function to remove
  14254. * @returns the TransformNode.
  14255. */
  14256. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14257. /**
  14258. * Gets the position of the current mesh in camera space
  14259. * @param camera defines the camera to use
  14260. * @returns a position
  14261. */
  14262. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14263. /**
  14264. * Returns the distance from the mesh to the active camera
  14265. * @param camera defines the camera to use
  14266. * @returns the distance
  14267. */
  14268. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14269. /**
  14270. * Clone the current transform node
  14271. * @param name Name of the new clone
  14272. * @param newParent New parent for the clone
  14273. * @param doNotCloneChildren Do not clone children hierarchy
  14274. * @returns the new transform node
  14275. */
  14276. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14277. /**
  14278. * Serializes the objects information.
  14279. * @param currentSerializationObject defines the object to serialize in
  14280. * @returns the serialized object
  14281. */
  14282. serialize(currentSerializationObject?: any): any;
  14283. /**
  14284. * Returns a new TransformNode object parsed from the source provided.
  14285. * @param parsedTransformNode is the source.
  14286. * @param scene the scne the object belongs to
  14287. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14288. * @returns a new TransformNode object parsed from the source provided.
  14289. */
  14290. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14291. /**
  14292. * Get all child-transformNodes of this node
  14293. * @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
  14294. * @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
  14295. * @returns an array of TransformNode
  14296. */
  14297. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14298. /**
  14299. * Releases resources associated with this transform node.
  14300. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14301. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14302. */
  14303. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14304. /**
  14305. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14306. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14307. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14308. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14309. * @returns the current mesh
  14310. */
  14311. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14312. private _syncAbsoluteScalingAndRotation;
  14313. }
  14314. }
  14315. declare module "babylonjs/Animations/animationPropertiesOverride" {
  14316. /**
  14317. * Class used to override all child animations of a given target
  14318. */
  14319. export class AnimationPropertiesOverride {
  14320. /**
  14321. * Gets or sets a value indicating if animation blending must be used
  14322. */
  14323. enableBlending: boolean;
  14324. /**
  14325. * Gets or sets the blending speed to use when enableBlending is true
  14326. */
  14327. blendingSpeed: number;
  14328. /**
  14329. * Gets or sets the default loop mode to use
  14330. */
  14331. loopMode: number;
  14332. }
  14333. }
  14334. declare module "babylonjs/Bones/bone" {
  14335. import { Skeleton } from "babylonjs/Bones/skeleton";
  14336. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  14337. import { Nullable } from "babylonjs/types";
  14338. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14339. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14340. import { Node } from "babylonjs/node";
  14341. import { Space } from "babylonjs/Maths/math.axis";
  14342. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  14343. /**
  14344. * Class used to store bone information
  14345. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14346. */
  14347. export class Bone extends Node {
  14348. /**
  14349. * defines the bone name
  14350. */
  14351. name: string;
  14352. private static _tmpVecs;
  14353. private static _tmpQuat;
  14354. private static _tmpMats;
  14355. /**
  14356. * Gets the list of child bones
  14357. */
  14358. children: Bone[];
  14359. /** Gets the animations associated with this bone */
  14360. animations: import("babylonjs/Animations/animation").Animation[];
  14361. /**
  14362. * Gets or sets bone length
  14363. */
  14364. length: number;
  14365. /**
  14366. * @hidden Internal only
  14367. * Set this value to map this bone to a different index in the transform matrices
  14368. * Set this value to -1 to exclude the bone from the transform matrices
  14369. */
  14370. _index: Nullable<number>;
  14371. private _skeleton;
  14372. private _localMatrix;
  14373. private _restPose;
  14374. private _baseMatrix;
  14375. private _absoluteTransform;
  14376. private _invertedAbsoluteTransform;
  14377. private _parent;
  14378. private _scalingDeterminant;
  14379. private _worldTransform;
  14380. private _localScaling;
  14381. private _localRotation;
  14382. private _localPosition;
  14383. private _needToDecompose;
  14384. private _needToCompose;
  14385. /** @hidden */
  14386. _linkedTransformNode: Nullable<TransformNode>;
  14387. /** @hidden */
  14388. _waitingTransformNodeId: Nullable<string>;
  14389. /** @hidden */
  14390. get _matrix(): Matrix;
  14391. /** @hidden */
  14392. set _matrix(value: Matrix);
  14393. /**
  14394. * Create a new bone
  14395. * @param name defines the bone name
  14396. * @param skeleton defines the parent skeleton
  14397. * @param parentBone defines the parent (can be null if the bone is the root)
  14398. * @param localMatrix defines the local matrix
  14399. * @param restPose defines the rest pose matrix
  14400. * @param baseMatrix defines the base matrix
  14401. * @param index defines index of the bone in the hiearchy
  14402. */
  14403. constructor(
  14404. /**
  14405. * defines the bone name
  14406. */
  14407. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14408. /**
  14409. * Gets the current object class name.
  14410. * @return the class name
  14411. */
  14412. getClassName(): string;
  14413. /**
  14414. * Gets the parent skeleton
  14415. * @returns a skeleton
  14416. */
  14417. getSkeleton(): Skeleton;
  14418. /**
  14419. * Gets parent bone
  14420. * @returns a bone or null if the bone is the root of the bone hierarchy
  14421. */
  14422. getParent(): Nullable<Bone>;
  14423. /**
  14424. * Returns an array containing the root bones
  14425. * @returns an array containing the root bones
  14426. */
  14427. getChildren(): Array<Bone>;
  14428. /**
  14429. * Gets the node index in matrix array generated for rendering
  14430. * @returns the node index
  14431. */
  14432. getIndex(): number;
  14433. /**
  14434. * Sets the parent bone
  14435. * @param parent defines the parent (can be null if the bone is the root)
  14436. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14437. */
  14438. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14439. /**
  14440. * Gets the local matrix
  14441. * @returns a matrix
  14442. */
  14443. getLocalMatrix(): Matrix;
  14444. /**
  14445. * Gets the base matrix (initial matrix which remains unchanged)
  14446. * @returns a matrix
  14447. */
  14448. getBaseMatrix(): Matrix;
  14449. /**
  14450. * Gets the rest pose matrix
  14451. * @returns a matrix
  14452. */
  14453. getRestPose(): Matrix;
  14454. /**
  14455. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14456. */
  14457. getWorldMatrix(): Matrix;
  14458. /**
  14459. * Sets the local matrix to rest pose matrix
  14460. */
  14461. returnToRest(): void;
  14462. /**
  14463. * Gets the inverse of the absolute transform matrix.
  14464. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14465. * @returns a matrix
  14466. */
  14467. getInvertedAbsoluteTransform(): Matrix;
  14468. /**
  14469. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14470. * @returns a matrix
  14471. */
  14472. getAbsoluteTransform(): Matrix;
  14473. /**
  14474. * Links with the given transform node.
  14475. * The local matrix of this bone is copied from the transform node every frame.
  14476. * @param transformNode defines the transform node to link to
  14477. */
  14478. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14479. /**
  14480. * Gets the node used to drive the bone's transformation
  14481. * @returns a transform node or null
  14482. */
  14483. getTransformNode(): Nullable<TransformNode>;
  14484. /** Gets or sets current position (in local space) */
  14485. get position(): Vector3;
  14486. set position(newPosition: Vector3);
  14487. /** Gets or sets current rotation (in local space) */
  14488. get rotation(): Vector3;
  14489. set rotation(newRotation: Vector3);
  14490. /** Gets or sets current rotation quaternion (in local space) */
  14491. get rotationQuaternion(): Quaternion;
  14492. set rotationQuaternion(newRotation: Quaternion);
  14493. /** Gets or sets current scaling (in local space) */
  14494. get scaling(): Vector3;
  14495. set scaling(newScaling: Vector3);
  14496. /**
  14497. * Gets the animation properties override
  14498. */
  14499. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14500. private _decompose;
  14501. private _compose;
  14502. /**
  14503. * Update the base and local matrices
  14504. * @param matrix defines the new base or local matrix
  14505. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14506. * @param updateLocalMatrix defines if the local matrix should be updated
  14507. */
  14508. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14509. /** @hidden */
  14510. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14511. /**
  14512. * Flag the bone as dirty (Forcing it to update everything)
  14513. */
  14514. markAsDirty(): void;
  14515. /** @hidden */
  14516. _markAsDirtyAndCompose(): void;
  14517. private _markAsDirtyAndDecompose;
  14518. /**
  14519. * Translate the bone in local or world space
  14520. * @param vec The amount to translate the bone
  14521. * @param space The space that the translation is in
  14522. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14523. */
  14524. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14525. /**
  14526. * Set the postion of the bone in local or world space
  14527. * @param position The position to set the bone
  14528. * @param space The space that the position is in
  14529. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14530. */
  14531. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14532. /**
  14533. * Set the absolute position of the bone (world space)
  14534. * @param position The position to set the bone
  14535. * @param mesh The mesh that this bone is attached to
  14536. */
  14537. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14538. /**
  14539. * Scale the bone on the x, y and z axes (in local space)
  14540. * @param x The amount to scale the bone on the x axis
  14541. * @param y The amount to scale the bone on the y axis
  14542. * @param z The amount to scale the bone on the z axis
  14543. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14544. */
  14545. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14546. /**
  14547. * Set the bone scaling in local space
  14548. * @param scale defines the scaling vector
  14549. */
  14550. setScale(scale: Vector3): void;
  14551. /**
  14552. * Gets the current scaling in local space
  14553. * @returns the current scaling vector
  14554. */
  14555. getScale(): Vector3;
  14556. /**
  14557. * Gets the current scaling in local space and stores it in a target vector
  14558. * @param result defines the target vector
  14559. */
  14560. getScaleToRef(result: Vector3): void;
  14561. /**
  14562. * Set the yaw, pitch, and roll of the bone in local or world space
  14563. * @param yaw The rotation of the bone on the y axis
  14564. * @param pitch The rotation of the bone on the x axis
  14565. * @param roll The rotation of the bone on the z axis
  14566. * @param space The space that the axes of rotation are in
  14567. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14568. */
  14569. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14570. /**
  14571. * Add a rotation to the bone on an axis in local or world space
  14572. * @param axis The axis to rotate the bone on
  14573. * @param amount The amount to rotate the bone
  14574. * @param space The space that the axis is in
  14575. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14576. */
  14577. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14578. /**
  14579. * Set the rotation of the bone to a particular axis angle in local or world space
  14580. * @param axis The axis to rotate the bone on
  14581. * @param angle The angle that the bone should be rotated to
  14582. * @param space The space that the axis is in
  14583. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14584. */
  14585. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14586. /**
  14587. * Set the euler rotation of the bone in local of world space
  14588. * @param rotation The euler rotation that the bone should be set to
  14589. * @param space The space that the rotation is in
  14590. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14591. */
  14592. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14593. /**
  14594. * Set the quaternion rotation of the bone in local of world space
  14595. * @param quat The quaternion rotation that the bone should be set to
  14596. * @param space The space that the rotation is in
  14597. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14598. */
  14599. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14600. /**
  14601. * Set the rotation matrix of the bone in local of world space
  14602. * @param rotMat The rotation matrix that the bone should be set to
  14603. * @param space The space that the rotation is in
  14604. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14605. */
  14606. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14607. private _rotateWithMatrix;
  14608. private _getNegativeRotationToRef;
  14609. /**
  14610. * Get the position of the bone in local or world space
  14611. * @param space The space that the returned position is in
  14612. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14613. * @returns The position of the bone
  14614. */
  14615. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14616. /**
  14617. * Copy the position of the bone to a vector3 in local or world space
  14618. * @param space The space that the returned position is in
  14619. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14620. * @param result The vector3 to copy the position to
  14621. */
  14622. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14623. /**
  14624. * Get the absolute position of the bone (world space)
  14625. * @param mesh The mesh that this bone is attached to
  14626. * @returns The absolute position of the bone
  14627. */
  14628. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14629. /**
  14630. * Copy the absolute position of the bone (world space) to the result param
  14631. * @param mesh The mesh that this bone is attached to
  14632. * @param result The vector3 to copy the absolute position to
  14633. */
  14634. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14635. /**
  14636. * Compute the absolute transforms of this bone and its children
  14637. */
  14638. computeAbsoluteTransforms(): void;
  14639. /**
  14640. * Get the world direction from an axis that is in the local space of the bone
  14641. * @param localAxis The local direction that is used to compute the world direction
  14642. * @param mesh The mesh that this bone is attached to
  14643. * @returns The world direction
  14644. */
  14645. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14646. /**
  14647. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14648. * @param localAxis The local direction that is used to compute the world direction
  14649. * @param mesh The mesh that this bone is attached to
  14650. * @param result The vector3 that the world direction will be copied to
  14651. */
  14652. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14653. /**
  14654. * Get the euler rotation of the bone in local or world space
  14655. * @param space The space that the rotation should be in
  14656. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14657. * @returns The euler rotation
  14658. */
  14659. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14660. /**
  14661. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14662. * @param space The space that the rotation should be in
  14663. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14664. * @param result The vector3 that the rotation should be copied to
  14665. */
  14666. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14667. /**
  14668. * Get the quaternion rotation of the bone in either local or world space
  14669. * @param space The space that the rotation should be in
  14670. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14671. * @returns The quaternion rotation
  14672. */
  14673. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14674. /**
  14675. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14676. * @param space The space that the rotation should be in
  14677. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14678. * @param result The quaternion that the rotation should be copied to
  14679. */
  14680. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14681. /**
  14682. * Get the rotation matrix of the bone in local or world space
  14683. * @param space The space that the rotation should be in
  14684. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14685. * @returns The rotation matrix
  14686. */
  14687. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14688. /**
  14689. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14690. * @param space The space that the rotation should be in
  14691. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14692. * @param result The quaternion that the rotation should be copied to
  14693. */
  14694. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14695. /**
  14696. * Get the world position of a point that is in the local space of the bone
  14697. * @param position The local position
  14698. * @param mesh The mesh that this bone is attached to
  14699. * @returns The world position
  14700. */
  14701. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14702. /**
  14703. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14704. * @param position The local position
  14705. * @param mesh The mesh that this bone is attached to
  14706. * @param result The vector3 that the world position should be copied to
  14707. */
  14708. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14709. /**
  14710. * Get the local position of a point that is in world space
  14711. * @param position The world position
  14712. * @param mesh The mesh that this bone is attached to
  14713. * @returns The local position
  14714. */
  14715. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14716. /**
  14717. * Get the local position of a point that is in world space and copy it to the result param
  14718. * @param position The world position
  14719. * @param mesh The mesh that this bone is attached to
  14720. * @param result The vector3 that the local position should be copied to
  14721. */
  14722. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14723. }
  14724. }
  14725. declare module "babylonjs/Animations/runtimeAnimation" {
  14726. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  14727. import { Animatable } from "babylonjs/Animations/animatable";
  14728. import { Scene } from "babylonjs/scene";
  14729. /**
  14730. * Defines a runtime animation
  14731. */
  14732. export class RuntimeAnimation {
  14733. private _events;
  14734. /**
  14735. * The current frame of the runtime animation
  14736. */
  14737. private _currentFrame;
  14738. /**
  14739. * The animation used by the runtime animation
  14740. */
  14741. private _animation;
  14742. /**
  14743. * The target of the runtime animation
  14744. */
  14745. private _target;
  14746. /**
  14747. * The initiating animatable
  14748. */
  14749. private _host;
  14750. /**
  14751. * The original value of the runtime animation
  14752. */
  14753. private _originalValue;
  14754. /**
  14755. * The original blend value of the runtime animation
  14756. */
  14757. private _originalBlendValue;
  14758. /**
  14759. * The offsets cache of the runtime animation
  14760. */
  14761. private _offsetsCache;
  14762. /**
  14763. * The high limits cache of the runtime animation
  14764. */
  14765. private _highLimitsCache;
  14766. /**
  14767. * Specifies if the runtime animation has been stopped
  14768. */
  14769. private _stopped;
  14770. /**
  14771. * The blending factor of the runtime animation
  14772. */
  14773. private _blendingFactor;
  14774. /**
  14775. * The BabylonJS scene
  14776. */
  14777. private _scene;
  14778. /**
  14779. * The current value of the runtime animation
  14780. */
  14781. private _currentValue;
  14782. /** @hidden */
  14783. _animationState: _IAnimationState;
  14784. /**
  14785. * The active target of the runtime animation
  14786. */
  14787. private _activeTargets;
  14788. private _currentActiveTarget;
  14789. private _directTarget;
  14790. /**
  14791. * The target path of the runtime animation
  14792. */
  14793. private _targetPath;
  14794. /**
  14795. * The weight of the runtime animation
  14796. */
  14797. private _weight;
  14798. /**
  14799. * The ratio offset of the runtime animation
  14800. */
  14801. private _ratioOffset;
  14802. /**
  14803. * The previous delay of the runtime animation
  14804. */
  14805. private _previousDelay;
  14806. /**
  14807. * The previous ratio of the runtime animation
  14808. */
  14809. private _previousRatio;
  14810. private _enableBlending;
  14811. private _keys;
  14812. private _minFrame;
  14813. private _maxFrame;
  14814. private _minValue;
  14815. private _maxValue;
  14816. private _targetIsArray;
  14817. /**
  14818. * Gets the current frame of the runtime animation
  14819. */
  14820. get currentFrame(): number;
  14821. /**
  14822. * Gets the weight of the runtime animation
  14823. */
  14824. get weight(): number;
  14825. /**
  14826. * Gets the current value of the runtime animation
  14827. */
  14828. get currentValue(): any;
  14829. /**
  14830. * Gets the target path of the runtime animation
  14831. */
  14832. get targetPath(): string;
  14833. /**
  14834. * Gets the actual target of the runtime animation
  14835. */
  14836. get target(): any;
  14837. /** @hidden */
  14838. _onLoop: () => void;
  14839. /**
  14840. * Create a new RuntimeAnimation object
  14841. * @param target defines the target of the animation
  14842. * @param animation defines the source animation object
  14843. * @param scene defines the hosting scene
  14844. * @param host defines the initiating Animatable
  14845. */
  14846. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14847. private _preparePath;
  14848. /**
  14849. * Gets the animation from the runtime animation
  14850. */
  14851. get animation(): Animation;
  14852. /**
  14853. * Resets the runtime animation to the beginning
  14854. * @param restoreOriginal defines whether to restore the target property to the original value
  14855. */
  14856. reset(restoreOriginal?: boolean): void;
  14857. /**
  14858. * Specifies if the runtime animation is stopped
  14859. * @returns Boolean specifying if the runtime animation is stopped
  14860. */
  14861. isStopped(): boolean;
  14862. /**
  14863. * Disposes of the runtime animation
  14864. */
  14865. dispose(): void;
  14866. /**
  14867. * Apply the interpolated value to the target
  14868. * @param currentValue defines the value computed by the animation
  14869. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14870. */
  14871. setValue(currentValue: any, weight: number): void;
  14872. private _getOriginalValues;
  14873. private _setValue;
  14874. /**
  14875. * Gets the loop pmode of the runtime animation
  14876. * @returns Loop Mode
  14877. */
  14878. private _getCorrectLoopMode;
  14879. /**
  14880. * Move the current animation to a given frame
  14881. * @param frame defines the frame to move to
  14882. */
  14883. goToFrame(frame: number): void;
  14884. /**
  14885. * @hidden Internal use only
  14886. */
  14887. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14888. /**
  14889. * Execute the current animation
  14890. * @param delay defines the delay to add to the current frame
  14891. * @param from defines the lower bound of the animation range
  14892. * @param to defines the upper bound of the animation range
  14893. * @param loop defines if the current animation must loop
  14894. * @param speedRatio defines the current speed ratio
  14895. * @param weight defines the weight of the animation (default is -1 so no weight)
  14896. * @param onLoop optional callback called when animation loops
  14897. * @returns a boolean indicating if the animation is running
  14898. */
  14899. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14900. }
  14901. }
  14902. declare module "babylonjs/Animations/animatable" {
  14903. import { Animation } from "babylonjs/Animations/animation";
  14904. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  14905. import { Nullable } from "babylonjs/types";
  14906. import { Observable } from "babylonjs/Misc/observable";
  14907. import { Scene } from "babylonjs/scene";
  14908. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  14909. import { Node } from "babylonjs/node";
  14910. /**
  14911. * Class used to store an actual running animation
  14912. */
  14913. export class Animatable {
  14914. /** defines the target object */
  14915. target: any;
  14916. /** defines the starting frame number (default is 0) */
  14917. fromFrame: number;
  14918. /** defines the ending frame number (default is 100) */
  14919. toFrame: number;
  14920. /** defines if the animation must loop (default is false) */
  14921. loopAnimation: boolean;
  14922. /** defines a callback to call when animation ends if it is not looping */
  14923. onAnimationEnd?: (() => void) | null | undefined;
  14924. /** defines a callback to call when animation loops */
  14925. onAnimationLoop?: (() => void) | null | undefined;
  14926. private _localDelayOffset;
  14927. private _pausedDelay;
  14928. private _runtimeAnimations;
  14929. private _paused;
  14930. private _scene;
  14931. private _speedRatio;
  14932. private _weight;
  14933. private _syncRoot;
  14934. /**
  14935. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14936. * This will only apply for non looping animation (default is true)
  14937. */
  14938. disposeOnEnd: boolean;
  14939. /**
  14940. * Gets a boolean indicating if the animation has started
  14941. */
  14942. animationStarted: boolean;
  14943. /**
  14944. * Observer raised when the animation ends
  14945. */
  14946. onAnimationEndObservable: Observable<Animatable>;
  14947. /**
  14948. * Observer raised when the animation loops
  14949. */
  14950. onAnimationLoopObservable: Observable<Animatable>;
  14951. /**
  14952. * Gets the root Animatable used to synchronize and normalize animations
  14953. */
  14954. get syncRoot(): Nullable<Animatable>;
  14955. /**
  14956. * Gets the current frame of the first RuntimeAnimation
  14957. * Used to synchronize Animatables
  14958. */
  14959. get masterFrame(): number;
  14960. /**
  14961. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14962. */
  14963. get weight(): number;
  14964. set weight(value: number);
  14965. /**
  14966. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14967. */
  14968. get speedRatio(): number;
  14969. set speedRatio(value: number);
  14970. /**
  14971. * Creates a new Animatable
  14972. * @param scene defines the hosting scene
  14973. * @param target defines the target object
  14974. * @param fromFrame defines the starting frame number (default is 0)
  14975. * @param toFrame defines the ending frame number (default is 100)
  14976. * @param loopAnimation defines if the animation must loop (default is false)
  14977. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14978. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14979. * @param animations defines a group of animation to add to the new Animatable
  14980. * @param onAnimationLoop defines a callback to call when animation loops
  14981. */
  14982. constructor(scene: Scene,
  14983. /** defines the target object */
  14984. target: any,
  14985. /** defines the starting frame number (default is 0) */
  14986. fromFrame?: number,
  14987. /** defines the ending frame number (default is 100) */
  14988. toFrame?: number,
  14989. /** defines if the animation must loop (default is false) */
  14990. loopAnimation?: boolean, speedRatio?: number,
  14991. /** defines a callback to call when animation ends if it is not looping */
  14992. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14993. /** defines a callback to call when animation loops */
  14994. onAnimationLoop?: (() => void) | null | undefined);
  14995. /**
  14996. * Synchronize and normalize current Animatable with a source Animatable
  14997. * This is useful when using animation weights and when animations are not of the same length
  14998. * @param root defines the root Animatable to synchronize with
  14999. * @returns the current Animatable
  15000. */
  15001. syncWith(root: Animatable): Animatable;
  15002. /**
  15003. * Gets the list of runtime animations
  15004. * @returns an array of RuntimeAnimation
  15005. */
  15006. getAnimations(): RuntimeAnimation[];
  15007. /**
  15008. * Adds more animations to the current animatable
  15009. * @param target defines the target of the animations
  15010. * @param animations defines the new animations to add
  15011. */
  15012. appendAnimations(target: any, animations: Animation[]): void;
  15013. /**
  15014. * Gets the source animation for a specific property
  15015. * @param property defines the propertyu to look for
  15016. * @returns null or the source animation for the given property
  15017. */
  15018. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15019. /**
  15020. * Gets the runtime animation for a specific property
  15021. * @param property defines the propertyu to look for
  15022. * @returns null or the runtime animation for the given property
  15023. */
  15024. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15025. /**
  15026. * Resets the animatable to its original state
  15027. */
  15028. reset(): void;
  15029. /**
  15030. * Allows the animatable to blend with current running animations
  15031. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15032. * @param blendingSpeed defines the blending speed to use
  15033. */
  15034. enableBlending(blendingSpeed: number): void;
  15035. /**
  15036. * Disable animation blending
  15037. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15038. */
  15039. disableBlending(): void;
  15040. /**
  15041. * Jump directly to a given frame
  15042. * @param frame defines the frame to jump to
  15043. */
  15044. goToFrame(frame: number): void;
  15045. /**
  15046. * Pause the animation
  15047. */
  15048. pause(): void;
  15049. /**
  15050. * Restart the animation
  15051. */
  15052. restart(): void;
  15053. private _raiseOnAnimationEnd;
  15054. /**
  15055. * Stop and delete the current animation
  15056. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15057. * @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)
  15058. */
  15059. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15060. /**
  15061. * Wait asynchronously for the animation to end
  15062. * @returns a promise which will be fullfilled when the animation ends
  15063. */
  15064. waitAsync(): Promise<Animatable>;
  15065. /** @hidden */
  15066. _animate(delay: number): boolean;
  15067. }
  15068. module "babylonjs/scene" {
  15069. interface Scene {
  15070. /** @hidden */
  15071. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15072. /** @hidden */
  15073. _processLateAnimationBindingsForMatrices(holder: {
  15074. totalWeight: number;
  15075. animations: RuntimeAnimation[];
  15076. originalValue: Matrix;
  15077. }): any;
  15078. /** @hidden */
  15079. _processLateAnimationBindingsForQuaternions(holder: {
  15080. totalWeight: number;
  15081. animations: RuntimeAnimation[];
  15082. originalValue: Quaternion;
  15083. }, refQuaternion: Quaternion): Quaternion;
  15084. /** @hidden */
  15085. _processLateAnimationBindings(): void;
  15086. /**
  15087. * Will start the animation sequence of a given target
  15088. * @param target defines the target
  15089. * @param from defines from which frame should animation start
  15090. * @param to defines until which frame should animation run.
  15091. * @param weight defines the weight to apply to the animation (1.0 by default)
  15092. * @param loop defines if the animation loops
  15093. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15094. * @param onAnimationEnd defines the function to be executed when the animation ends
  15095. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15096. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15097. * @param onAnimationLoop defines the callback to call when an animation loops
  15098. * @returns the animatable object created for this animation
  15099. */
  15100. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  15101. /**
  15102. * Will start the animation sequence of a given target
  15103. * @param target defines the target
  15104. * @param from defines from which frame should animation start
  15105. * @param to defines until which frame should animation run.
  15106. * @param loop defines if the animation loops
  15107. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15108. * @param onAnimationEnd defines the function to be executed when the animation ends
  15109. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15110. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15111. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15112. * @param onAnimationLoop defines the callback to call when an animation loops
  15113. * @returns the animatable object created for this animation
  15114. */
  15115. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  15116. /**
  15117. * Will start the animation sequence of a given target and its hierarchy
  15118. * @param target defines the target
  15119. * @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.
  15120. * @param from defines from which frame should animation start
  15121. * @param to defines until which frame should animation run.
  15122. * @param loop defines if the animation loops
  15123. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15124. * @param onAnimationEnd defines the function to be executed when the animation ends
  15125. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15126. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15127. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15128. * @param onAnimationLoop defines the callback to call when an animation loops
  15129. * @returns the list of created animatables
  15130. */
  15131. 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[];
  15132. /**
  15133. * Begin a new animation on a given node
  15134. * @param target defines the target where the animation will take place
  15135. * @param animations defines the list of animations to start
  15136. * @param from defines the initial value
  15137. * @param to defines the final value
  15138. * @param loop defines if you want animation to loop (off by default)
  15139. * @param speedRatio defines the speed ratio to apply to all animations
  15140. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15141. * @param onAnimationLoop defines the callback to call when an animation loops
  15142. * @returns the list of created animatables
  15143. */
  15144. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  15145. /**
  15146. * Begin a new animation on a given node and its hierarchy
  15147. * @param target defines the root node where the animation will take place
  15148. * @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.
  15149. * @param animations defines the list of animations to start
  15150. * @param from defines the initial value
  15151. * @param to defines the final value
  15152. * @param loop defines if you want animation to loop (off by default)
  15153. * @param speedRatio defines the speed ratio to apply to all animations
  15154. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15155. * @param onAnimationLoop defines the callback to call when an animation loops
  15156. * @returns the list of animatables created for all nodes
  15157. */
  15158. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  15159. /**
  15160. * Gets the animatable associated with a specific target
  15161. * @param target defines the target of the animatable
  15162. * @returns the required animatable if found
  15163. */
  15164. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15165. /**
  15166. * Gets all animatables associated with a given target
  15167. * @param target defines the target to look animatables for
  15168. * @returns an array of Animatables
  15169. */
  15170. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15171. /**
  15172. * Stops and removes all animations that have been applied to the scene
  15173. */
  15174. stopAllAnimations(): void;
  15175. /**
  15176. * Gets the current delta time used by animation engine
  15177. */
  15178. deltaTime: number;
  15179. }
  15180. }
  15181. module "babylonjs/Bones/bone" {
  15182. interface Bone {
  15183. /**
  15184. * Copy an animation range from another bone
  15185. * @param source defines the source bone
  15186. * @param rangeName defines the range name to copy
  15187. * @param frameOffset defines the frame offset
  15188. * @param rescaleAsRequired defines if rescaling must be applied if required
  15189. * @param skelDimensionsRatio defines the scaling ratio
  15190. * @returns true if operation was successful
  15191. */
  15192. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15193. }
  15194. }
  15195. }
  15196. declare module "babylonjs/Bones/skeleton" {
  15197. import { Bone } from "babylonjs/Bones/bone";
  15198. import { Observable } from "babylonjs/Misc/observable";
  15199. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15200. import { Scene } from "babylonjs/scene";
  15201. import { Nullable } from "babylonjs/types";
  15202. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15203. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  15204. import { Animatable } from "babylonjs/Animations/animatable";
  15205. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15206. import { Animation } from "babylonjs/Animations/animation";
  15207. import { AnimationRange } from "babylonjs/Animations/animationRange";
  15208. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15209. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  15210. /**
  15211. * Class used to handle skinning animations
  15212. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15213. */
  15214. export class Skeleton implements IAnimatable {
  15215. /** defines the skeleton name */
  15216. name: string;
  15217. /** defines the skeleton Id */
  15218. id: string;
  15219. /**
  15220. * Defines the list of child bones
  15221. */
  15222. bones: Bone[];
  15223. /**
  15224. * Defines an estimate of the dimension of the skeleton at rest
  15225. */
  15226. dimensionsAtRest: Vector3;
  15227. /**
  15228. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15229. */
  15230. needInitialSkinMatrix: boolean;
  15231. /**
  15232. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15233. */
  15234. overrideMesh: Nullable<AbstractMesh>;
  15235. /**
  15236. * Gets the list of animations attached to this skeleton
  15237. */
  15238. animations: Array<Animation>;
  15239. private _scene;
  15240. private _isDirty;
  15241. private _transformMatrices;
  15242. private _transformMatrixTexture;
  15243. private _meshesWithPoseMatrix;
  15244. private _animatables;
  15245. private _identity;
  15246. private _synchronizedWithMesh;
  15247. private _ranges;
  15248. private _lastAbsoluteTransformsUpdateId;
  15249. private _canUseTextureForBones;
  15250. private _uniqueId;
  15251. /** @hidden */
  15252. _numBonesWithLinkedTransformNode: number;
  15253. /** @hidden */
  15254. _hasWaitingData: Nullable<boolean>;
  15255. /**
  15256. * Specifies if the skeleton should be serialized
  15257. */
  15258. doNotSerialize: boolean;
  15259. private _useTextureToStoreBoneMatrices;
  15260. /**
  15261. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15262. * Please note that this option is not available if the hardware does not support it
  15263. */
  15264. get useTextureToStoreBoneMatrices(): boolean;
  15265. set useTextureToStoreBoneMatrices(value: boolean);
  15266. private _animationPropertiesOverride;
  15267. /**
  15268. * Gets or sets the animation properties override
  15269. */
  15270. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15271. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15272. /**
  15273. * List of inspectable custom properties (used by the Inspector)
  15274. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15275. */
  15276. inspectableCustomProperties: IInspectable[];
  15277. /**
  15278. * An observable triggered before computing the skeleton's matrices
  15279. */
  15280. onBeforeComputeObservable: Observable<Skeleton>;
  15281. /**
  15282. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15283. */
  15284. get isUsingTextureForMatrices(): boolean;
  15285. /**
  15286. * Gets the unique ID of this skeleton
  15287. */
  15288. get uniqueId(): number;
  15289. /**
  15290. * Creates a new skeleton
  15291. * @param name defines the skeleton name
  15292. * @param id defines the skeleton Id
  15293. * @param scene defines the hosting scene
  15294. */
  15295. constructor(
  15296. /** defines the skeleton name */
  15297. name: string,
  15298. /** defines the skeleton Id */
  15299. id: string, scene: Scene);
  15300. /**
  15301. * Gets the current object class name.
  15302. * @return the class name
  15303. */
  15304. getClassName(): string;
  15305. /**
  15306. * Returns an array containing the root bones
  15307. * @returns an array containing the root bones
  15308. */
  15309. getChildren(): Array<Bone>;
  15310. /**
  15311. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15312. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15313. * @returns a Float32Array containing matrices data
  15314. */
  15315. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15316. /**
  15317. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15318. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15319. * @returns a raw texture containing the data
  15320. */
  15321. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15322. /**
  15323. * Gets the current hosting scene
  15324. * @returns a scene object
  15325. */
  15326. getScene(): Scene;
  15327. /**
  15328. * Gets a string representing the current skeleton data
  15329. * @param fullDetails defines a boolean indicating if we want a verbose version
  15330. * @returns a string representing the current skeleton data
  15331. */
  15332. toString(fullDetails?: boolean): string;
  15333. /**
  15334. * Get bone's index searching by name
  15335. * @param name defines bone's name to search for
  15336. * @return the indice of the bone. Returns -1 if not found
  15337. */
  15338. getBoneIndexByName(name: string): number;
  15339. /**
  15340. * Creater a new animation range
  15341. * @param name defines the name of the range
  15342. * @param from defines the start key
  15343. * @param to defines the end key
  15344. */
  15345. createAnimationRange(name: string, from: number, to: number): void;
  15346. /**
  15347. * Delete a specific animation range
  15348. * @param name defines the name of the range
  15349. * @param deleteFrames defines if frames must be removed as well
  15350. */
  15351. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15352. /**
  15353. * Gets a specific animation range
  15354. * @param name defines the name of the range to look for
  15355. * @returns the requested animation range or null if not found
  15356. */
  15357. getAnimationRange(name: string): Nullable<AnimationRange>;
  15358. /**
  15359. * Gets the list of all animation ranges defined on this skeleton
  15360. * @returns an array
  15361. */
  15362. getAnimationRanges(): Nullable<AnimationRange>[];
  15363. /**
  15364. * Copy animation range from a source skeleton.
  15365. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15366. * @param source defines the source skeleton
  15367. * @param name defines the name of the range to copy
  15368. * @param rescaleAsRequired defines if rescaling must be applied if required
  15369. * @returns true if operation was successful
  15370. */
  15371. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15372. /**
  15373. * Forces the skeleton to go to rest pose
  15374. */
  15375. returnToRest(): void;
  15376. private _getHighestAnimationFrame;
  15377. /**
  15378. * Begin a specific animation range
  15379. * @param name defines the name of the range to start
  15380. * @param loop defines if looping must be turned on (false by default)
  15381. * @param speedRatio defines the speed ratio to apply (1 by default)
  15382. * @param onAnimationEnd defines a callback which will be called when animation will end
  15383. * @returns a new animatable
  15384. */
  15385. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15386. /** @hidden */
  15387. _markAsDirty(): void;
  15388. /** @hidden */
  15389. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15390. /** @hidden */
  15391. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15392. private _computeTransformMatrices;
  15393. /**
  15394. * Build all resources required to render a skeleton
  15395. */
  15396. prepare(): void;
  15397. /**
  15398. * Gets the list of animatables currently running for this skeleton
  15399. * @returns an array of animatables
  15400. */
  15401. getAnimatables(): IAnimatable[];
  15402. /**
  15403. * Clone the current skeleton
  15404. * @param name defines the name of the new skeleton
  15405. * @param id defines the id of the new skeleton
  15406. * @returns the new skeleton
  15407. */
  15408. clone(name: string, id?: string): Skeleton;
  15409. /**
  15410. * Enable animation blending for this skeleton
  15411. * @param blendingSpeed defines the blending speed to apply
  15412. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15413. */
  15414. enableBlending(blendingSpeed?: number): void;
  15415. /**
  15416. * Releases all resources associated with the current skeleton
  15417. */
  15418. dispose(): void;
  15419. /**
  15420. * Serialize the skeleton in a JSON object
  15421. * @returns a JSON object
  15422. */
  15423. serialize(): any;
  15424. /**
  15425. * Creates a new skeleton from serialized data
  15426. * @param parsedSkeleton defines the serialized data
  15427. * @param scene defines the hosting scene
  15428. * @returns a new skeleton
  15429. */
  15430. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15431. /**
  15432. * Compute all node absolute transforms
  15433. * @param forceUpdate defines if computation must be done even if cache is up to date
  15434. */
  15435. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15436. /**
  15437. * Gets the root pose matrix
  15438. * @returns a matrix
  15439. */
  15440. getPoseMatrix(): Nullable<Matrix>;
  15441. /**
  15442. * Sorts bones per internal index
  15443. */
  15444. sortBones(): void;
  15445. private _sortBones;
  15446. }
  15447. }
  15448. declare module "babylonjs/Meshes/instancedMesh" {
  15449. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  15450. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15451. import { Camera } from "babylonjs/Cameras/camera";
  15452. import { Node } from "babylonjs/node";
  15453. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15454. import { Mesh } from "babylonjs/Meshes/mesh";
  15455. import { Material } from "babylonjs/Materials/material";
  15456. import { Skeleton } from "babylonjs/Bones/skeleton";
  15457. import { Light } from "babylonjs/Lights/light";
  15458. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  15459. /**
  15460. * Creates an instance based on a source mesh.
  15461. */
  15462. export class InstancedMesh extends AbstractMesh {
  15463. private _sourceMesh;
  15464. private _currentLOD;
  15465. /** @hidden */
  15466. _indexInSourceMeshInstanceArray: number;
  15467. constructor(name: string, source: Mesh);
  15468. /**
  15469. * Returns the string "InstancedMesh".
  15470. */
  15471. getClassName(): string;
  15472. /** Gets the list of lights affecting that mesh */
  15473. get lightSources(): Light[];
  15474. _resyncLightSources(): void;
  15475. _resyncLightSource(light: Light): void;
  15476. _removeLightSource(light: Light, dispose: boolean): void;
  15477. /**
  15478. * If the source mesh receives shadows
  15479. */
  15480. get receiveShadows(): boolean;
  15481. /**
  15482. * The material of the source mesh
  15483. */
  15484. get material(): Nullable<Material>;
  15485. /**
  15486. * Visibility of the source mesh
  15487. */
  15488. get visibility(): number;
  15489. /**
  15490. * Skeleton of the source mesh
  15491. */
  15492. get skeleton(): Nullable<Skeleton>;
  15493. /**
  15494. * Rendering ground id of the source mesh
  15495. */
  15496. get renderingGroupId(): number;
  15497. set renderingGroupId(value: number);
  15498. /**
  15499. * Returns the total number of vertices (integer).
  15500. */
  15501. getTotalVertices(): number;
  15502. /**
  15503. * Returns a positive integer : the total number of indices in this mesh geometry.
  15504. * @returns the numner of indices or zero if the mesh has no geometry.
  15505. */
  15506. getTotalIndices(): number;
  15507. /**
  15508. * The source mesh of the instance
  15509. */
  15510. get sourceMesh(): Mesh;
  15511. /**
  15512. * Is this node ready to be used/rendered
  15513. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15514. * @return {boolean} is it ready
  15515. */
  15516. isReady(completeCheck?: boolean): boolean;
  15517. /**
  15518. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15519. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15520. * @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.
  15521. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15522. */
  15523. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15524. /**
  15525. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15526. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15527. * The `data` are either a numeric array either a Float32Array.
  15528. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15529. * 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).
  15530. * Note that a new underlying VertexBuffer object is created each call.
  15531. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15532. *
  15533. * Possible `kind` values :
  15534. * - VertexBuffer.PositionKind
  15535. * - VertexBuffer.UVKind
  15536. * - VertexBuffer.UV2Kind
  15537. * - VertexBuffer.UV3Kind
  15538. * - VertexBuffer.UV4Kind
  15539. * - VertexBuffer.UV5Kind
  15540. * - VertexBuffer.UV6Kind
  15541. * - VertexBuffer.ColorKind
  15542. * - VertexBuffer.MatricesIndicesKind
  15543. * - VertexBuffer.MatricesIndicesExtraKind
  15544. * - VertexBuffer.MatricesWeightsKind
  15545. * - VertexBuffer.MatricesWeightsExtraKind
  15546. *
  15547. * Returns the Mesh.
  15548. */
  15549. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15550. /**
  15551. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15552. * If the mesh has no geometry, it is simply returned as it is.
  15553. * The `data` are either a numeric array either a Float32Array.
  15554. * No new underlying VertexBuffer object is created.
  15555. * 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.
  15556. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15557. *
  15558. * Possible `kind` values :
  15559. * - VertexBuffer.PositionKind
  15560. * - VertexBuffer.UVKind
  15561. * - VertexBuffer.UV2Kind
  15562. * - VertexBuffer.UV3Kind
  15563. * - VertexBuffer.UV4Kind
  15564. * - VertexBuffer.UV5Kind
  15565. * - VertexBuffer.UV6Kind
  15566. * - VertexBuffer.ColorKind
  15567. * - VertexBuffer.MatricesIndicesKind
  15568. * - VertexBuffer.MatricesIndicesExtraKind
  15569. * - VertexBuffer.MatricesWeightsKind
  15570. * - VertexBuffer.MatricesWeightsExtraKind
  15571. *
  15572. * Returns the Mesh.
  15573. */
  15574. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15575. /**
  15576. * Sets the mesh indices.
  15577. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15578. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15579. * This method creates a new index buffer each call.
  15580. * Returns the Mesh.
  15581. */
  15582. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15583. /**
  15584. * Boolean : True if the mesh owns the requested kind of data.
  15585. */
  15586. isVerticesDataPresent(kind: string): boolean;
  15587. /**
  15588. * Returns an array of indices (IndicesArray).
  15589. */
  15590. getIndices(): Nullable<IndicesArray>;
  15591. get _positions(): Nullable<Vector3[]>;
  15592. /**
  15593. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15594. * This means the mesh underlying bounding box and sphere are recomputed.
  15595. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15596. * @returns the current mesh
  15597. */
  15598. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15599. /** @hidden */
  15600. _preActivate(): InstancedMesh;
  15601. /** @hidden */
  15602. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15603. /** @hidden */
  15604. _postActivate(): void;
  15605. getWorldMatrix(): Matrix;
  15606. get isAnInstance(): boolean;
  15607. /**
  15608. * Returns the current associated LOD AbstractMesh.
  15609. */
  15610. getLOD(camera: Camera): AbstractMesh;
  15611. /** @hidden */
  15612. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15613. /** @hidden */
  15614. _syncSubMeshes(): InstancedMesh;
  15615. /** @hidden */
  15616. _generatePointsArray(): boolean;
  15617. /**
  15618. * Creates a new InstancedMesh from the current mesh.
  15619. * - name (string) : the cloned mesh name
  15620. * - newParent (optional Node) : the optional Node to parent the clone to.
  15621. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15622. *
  15623. * Returns the clone.
  15624. */
  15625. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15626. /**
  15627. * Disposes the InstancedMesh.
  15628. * Returns nothing.
  15629. */
  15630. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15631. }
  15632. module "babylonjs/Meshes/mesh" {
  15633. interface Mesh {
  15634. /**
  15635. * Register a custom buffer that will be instanced
  15636. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15637. * @param kind defines the buffer kind
  15638. * @param stride defines the stride in floats
  15639. */
  15640. registerInstancedBuffer(kind: string, stride: number): void;
  15641. /** @hidden */
  15642. _userInstancedBuffersStorage: {
  15643. data: {
  15644. [key: string]: Float32Array;
  15645. };
  15646. sizes: {
  15647. [key: string]: number;
  15648. };
  15649. vertexBuffers: {
  15650. [key: string]: Nullable<VertexBuffer>;
  15651. };
  15652. strides: {
  15653. [key: string]: number;
  15654. };
  15655. };
  15656. }
  15657. }
  15658. module "babylonjs/Meshes/abstractMesh" {
  15659. interface AbstractMesh {
  15660. /**
  15661. * Object used to store instanced buffers defined by user
  15662. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15663. */
  15664. instancedBuffers: {
  15665. [key: string]: any;
  15666. };
  15667. }
  15668. }
  15669. }
  15670. declare module "babylonjs/Materials/shaderMaterial" {
  15671. import { Scene } from "babylonjs/scene";
  15672. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  15673. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15674. import { Mesh } from "babylonjs/Meshes/mesh";
  15675. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  15676. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15677. import { Texture } from "babylonjs/Materials/Textures/texture";
  15678. import { Material } from "babylonjs/Materials/material";
  15679. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  15680. /**
  15681. * Defines the options associated with the creation of a shader material.
  15682. */
  15683. export interface IShaderMaterialOptions {
  15684. /**
  15685. * Does the material work in alpha blend mode
  15686. */
  15687. needAlphaBlending: boolean;
  15688. /**
  15689. * Does the material work in alpha test mode
  15690. */
  15691. needAlphaTesting: boolean;
  15692. /**
  15693. * The list of attribute names used in the shader
  15694. */
  15695. attributes: string[];
  15696. /**
  15697. * The list of unifrom names used in the shader
  15698. */
  15699. uniforms: string[];
  15700. /**
  15701. * The list of UBO names used in the shader
  15702. */
  15703. uniformBuffers: string[];
  15704. /**
  15705. * The list of sampler names used in the shader
  15706. */
  15707. samplers: string[];
  15708. /**
  15709. * The list of defines used in the shader
  15710. */
  15711. defines: string[];
  15712. }
  15713. /**
  15714. * 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.
  15715. *
  15716. * This returned material effects how the mesh will look based on the code in the shaders.
  15717. *
  15718. * @see http://doc.babylonjs.com/how_to/shader_material
  15719. */
  15720. export class ShaderMaterial extends Material {
  15721. private _shaderPath;
  15722. private _options;
  15723. private _textures;
  15724. private _textureArrays;
  15725. private _floats;
  15726. private _ints;
  15727. private _floatsArrays;
  15728. private _colors3;
  15729. private _colors3Arrays;
  15730. private _colors4;
  15731. private _colors4Arrays;
  15732. private _vectors2;
  15733. private _vectors3;
  15734. private _vectors4;
  15735. private _matrices;
  15736. private _matrixArrays;
  15737. private _matrices3x3;
  15738. private _matrices2x2;
  15739. private _vectors2Arrays;
  15740. private _vectors3Arrays;
  15741. private _vectors4Arrays;
  15742. private _cachedWorldViewMatrix;
  15743. private _cachedWorldViewProjectionMatrix;
  15744. private _renderId;
  15745. private _multiview;
  15746. /**
  15747. * Instantiate a new shader material.
  15748. * 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.
  15749. * This returned material effects how the mesh will look based on the code in the shaders.
  15750. * @see http://doc.babylonjs.com/how_to/shader_material
  15751. * @param name Define the name of the material in the scene
  15752. * @param scene Define the scene the material belongs to
  15753. * @param shaderPath Defines the route to the shader code in one of three ways:
  15754. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15755. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15756. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15757. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15758. * @param options Define the options used to create the shader
  15759. */
  15760. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15761. /**
  15762. * Gets the shader path used to define the shader code
  15763. * It can be modified to trigger a new compilation
  15764. */
  15765. get shaderPath(): any;
  15766. /**
  15767. * Sets the shader path used to define the shader code
  15768. * It can be modified to trigger a new compilation
  15769. */
  15770. set shaderPath(shaderPath: any);
  15771. /**
  15772. * Gets the options used to compile the shader.
  15773. * They can be modified to trigger a new compilation
  15774. */
  15775. get options(): IShaderMaterialOptions;
  15776. /**
  15777. * Gets the current class name of the material e.g. "ShaderMaterial"
  15778. * Mainly use in serialization.
  15779. * @returns the class name
  15780. */
  15781. getClassName(): string;
  15782. /**
  15783. * Specifies if the material will require alpha blending
  15784. * @returns a boolean specifying if alpha blending is needed
  15785. */
  15786. needAlphaBlending(): boolean;
  15787. /**
  15788. * Specifies if this material should be rendered in alpha test mode
  15789. * @returns a boolean specifying if an alpha test is needed.
  15790. */
  15791. needAlphaTesting(): boolean;
  15792. private _checkUniform;
  15793. /**
  15794. * Set a texture in the shader.
  15795. * @param name Define the name of the uniform samplers as defined in the shader
  15796. * @param texture Define the texture to bind to this sampler
  15797. * @return the material itself allowing "fluent" like uniform updates
  15798. */
  15799. setTexture(name: string, texture: Texture): ShaderMaterial;
  15800. /**
  15801. * Set a texture array in the shader.
  15802. * @param name Define the name of the uniform sampler array as defined in the shader
  15803. * @param textures Define the list of textures to bind to this sampler
  15804. * @return the material itself allowing "fluent" like uniform updates
  15805. */
  15806. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  15807. /**
  15808. * Set a float in the shader.
  15809. * @param name Define the name of the uniform as defined in the shader
  15810. * @param value Define the value to give to the uniform
  15811. * @return the material itself allowing "fluent" like uniform updates
  15812. */
  15813. setFloat(name: string, value: number): ShaderMaterial;
  15814. /**
  15815. * Set a int in the shader.
  15816. * @param name Define the name of the uniform as defined in the shader
  15817. * @param value Define the value to give to the uniform
  15818. * @return the material itself allowing "fluent" like uniform updates
  15819. */
  15820. setInt(name: string, value: number): ShaderMaterial;
  15821. /**
  15822. * Set an array of floats in the shader.
  15823. * @param name Define the name of the uniform as defined in the shader
  15824. * @param value Define the value to give to the uniform
  15825. * @return the material itself allowing "fluent" like uniform updates
  15826. */
  15827. setFloats(name: string, value: number[]): ShaderMaterial;
  15828. /**
  15829. * Set a vec3 in the shader from a Color3.
  15830. * @param name Define the name of the uniform as defined in the shader
  15831. * @param value Define the value to give to the uniform
  15832. * @return the material itself allowing "fluent" like uniform updates
  15833. */
  15834. setColor3(name: string, value: Color3): ShaderMaterial;
  15835. /**
  15836. * Set a vec3 array in the shader from a Color3 array.
  15837. * @param name Define the name of the uniform as defined in the shader
  15838. * @param value Define the value to give to the uniform
  15839. * @return the material itself allowing "fluent" like uniform updates
  15840. */
  15841. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15842. /**
  15843. * Set a vec4 in the shader from a Color4.
  15844. * @param name Define the name of the uniform as defined in the shader
  15845. * @param value Define the value to give to the uniform
  15846. * @return the material itself allowing "fluent" like uniform updates
  15847. */
  15848. setColor4(name: string, value: Color4): ShaderMaterial;
  15849. /**
  15850. * Set a vec4 array in the shader from a Color4 array.
  15851. * @param name Define the name of the uniform as defined in the shader
  15852. * @param value Define the value to give to the uniform
  15853. * @return the material itself allowing "fluent" like uniform updates
  15854. */
  15855. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15856. /**
  15857. * Set a vec2 in the shader from a Vector2.
  15858. * @param name Define the name of the uniform as defined in the shader
  15859. * @param value Define the value to give to the uniform
  15860. * @return the material itself allowing "fluent" like uniform updates
  15861. */
  15862. setVector2(name: string, value: Vector2): ShaderMaterial;
  15863. /**
  15864. * Set a vec3 in the shader from a Vector3.
  15865. * @param name Define the name of the uniform as defined in the shader
  15866. * @param value Define the value to give to the uniform
  15867. * @return the material itself allowing "fluent" like uniform updates
  15868. */
  15869. setVector3(name: string, value: Vector3): ShaderMaterial;
  15870. /**
  15871. * Set a vec4 in the shader from a Vector4.
  15872. * @param name Define the name of the uniform as defined in the shader
  15873. * @param value Define the value to give to the uniform
  15874. * @return the material itself allowing "fluent" like uniform updates
  15875. */
  15876. setVector4(name: string, value: Vector4): ShaderMaterial;
  15877. /**
  15878. * Set a mat4 in the shader from a Matrix.
  15879. * @param name Define the name of the uniform as defined in the shader
  15880. * @param value Define the value to give to the uniform
  15881. * @return the material itself allowing "fluent" like uniform updates
  15882. */
  15883. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15884. /**
  15885. * Set a float32Array in the shader from a matrix array.
  15886. * @param name Define the name of the uniform as defined in the shader
  15887. * @param value Define the value to give to the uniform
  15888. * @return the material itself allowing "fluent" like uniform updates
  15889. */
  15890. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15891. /**
  15892. * Set a mat3 in the shader from a Float32Array.
  15893. * @param name Define the name of the uniform as defined in the shader
  15894. * @param value Define the value to give to the uniform
  15895. * @return the material itself allowing "fluent" like uniform updates
  15896. */
  15897. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15898. /**
  15899. * Set a mat2 in the shader from a Float32Array.
  15900. * @param name Define the name of the uniform as defined in the shader
  15901. * @param value Define the value to give to the uniform
  15902. * @return the material itself allowing "fluent" like uniform updates
  15903. */
  15904. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15905. /**
  15906. * Set a vec2 array in the shader from a number array.
  15907. * @param name Define the name of the uniform as defined in the shader
  15908. * @param value Define the value to give to the uniform
  15909. * @return the material itself allowing "fluent" like uniform updates
  15910. */
  15911. setArray2(name: string, value: number[]): ShaderMaterial;
  15912. /**
  15913. * Set a vec3 array in the shader from a number array.
  15914. * @param name Define the name of the uniform as defined in the shader
  15915. * @param value Define the value to give to the uniform
  15916. * @return the material itself allowing "fluent" like uniform updates
  15917. */
  15918. setArray3(name: string, value: number[]): ShaderMaterial;
  15919. /**
  15920. * Set a vec4 array in the shader from a number array.
  15921. * @param name Define the name of the uniform as defined in the shader
  15922. * @param value Define the value to give to the uniform
  15923. * @return the material itself allowing "fluent" like uniform updates
  15924. */
  15925. setArray4(name: string, value: number[]): ShaderMaterial;
  15926. private _checkCache;
  15927. /**
  15928. * Specifies that the submesh is ready to be used
  15929. * @param mesh defines the mesh to check
  15930. * @param subMesh defines which submesh to check
  15931. * @param useInstances specifies that instances should be used
  15932. * @returns a boolean indicating that the submesh is ready or not
  15933. */
  15934. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15935. /**
  15936. * Checks if the material is ready to render the requested mesh
  15937. * @param mesh Define the mesh to render
  15938. * @param useInstances Define whether or not the material is used with instances
  15939. * @returns true if ready, otherwise false
  15940. */
  15941. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15942. /**
  15943. * Binds the world matrix to the material
  15944. * @param world defines the world transformation matrix
  15945. */
  15946. bindOnlyWorldMatrix(world: Matrix): void;
  15947. /**
  15948. * Binds the material to the mesh
  15949. * @param world defines the world transformation matrix
  15950. * @param mesh defines the mesh to bind the material to
  15951. */
  15952. bind(world: Matrix, mesh?: Mesh): void;
  15953. /**
  15954. * Gets the active textures from the material
  15955. * @returns an array of textures
  15956. */
  15957. getActiveTextures(): BaseTexture[];
  15958. /**
  15959. * Specifies if the material uses a texture
  15960. * @param texture defines the texture to check against the material
  15961. * @returns a boolean specifying if the material uses the texture
  15962. */
  15963. hasTexture(texture: BaseTexture): boolean;
  15964. /**
  15965. * Makes a duplicate of the material, and gives it a new name
  15966. * @param name defines the new name for the duplicated material
  15967. * @returns the cloned material
  15968. */
  15969. clone(name: string): ShaderMaterial;
  15970. /**
  15971. * Disposes the material
  15972. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15973. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15974. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15975. */
  15976. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15977. /**
  15978. * Serializes this material in a JSON representation
  15979. * @returns the serialized material object
  15980. */
  15981. serialize(): any;
  15982. /**
  15983. * Creates a shader material from parsed shader material data
  15984. * @param source defines the JSON represnetation of the material
  15985. * @param scene defines the hosting scene
  15986. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15987. * @returns a new material
  15988. */
  15989. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15990. }
  15991. }
  15992. declare module "babylonjs/Shaders/color.fragment" {
  15993. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15994. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15995. /** @hidden */
  15996. export var colorPixelShader: {
  15997. name: string;
  15998. shader: string;
  15999. };
  16000. }
  16001. declare module "babylonjs/Shaders/color.vertex" {
  16002. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  16003. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  16004. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  16005. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  16006. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  16007. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  16008. /** @hidden */
  16009. export var colorVertexShader: {
  16010. name: string;
  16011. shader: string;
  16012. };
  16013. }
  16014. declare module "babylonjs/Meshes/linesMesh" {
  16015. import { Nullable } from "babylonjs/types";
  16016. import { Scene } from "babylonjs/scene";
  16017. import { Color3 } from "babylonjs/Maths/math.color";
  16018. import { Node } from "babylonjs/node";
  16019. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16020. import { Mesh } from "babylonjs/Meshes/mesh";
  16021. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  16022. import { Effect } from "babylonjs/Materials/effect";
  16023. import { Material } from "babylonjs/Materials/material";
  16024. import "babylonjs/Shaders/color.fragment";
  16025. import "babylonjs/Shaders/color.vertex";
  16026. /**
  16027. * Line mesh
  16028. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16029. */
  16030. export class LinesMesh extends Mesh {
  16031. /**
  16032. * If vertex color should be applied to the mesh
  16033. */
  16034. readonly useVertexColor?: boolean | undefined;
  16035. /**
  16036. * If vertex alpha should be applied to the mesh
  16037. */
  16038. readonly useVertexAlpha?: boolean | undefined;
  16039. /**
  16040. * Color of the line (Default: White)
  16041. */
  16042. color: Color3;
  16043. /**
  16044. * Alpha of the line (Default: 1)
  16045. */
  16046. alpha: number;
  16047. /**
  16048. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16049. * This margin is expressed in world space coordinates, so its value may vary.
  16050. * Default value is 0.1
  16051. */
  16052. intersectionThreshold: number;
  16053. private _colorShader;
  16054. private color4;
  16055. /**
  16056. * Creates a new LinesMesh
  16057. * @param name defines the name
  16058. * @param scene defines the hosting scene
  16059. * @param parent defines the parent mesh if any
  16060. * @param source defines the optional source LinesMesh used to clone data from
  16061. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16062. * When false, achieved by calling a clone(), also passing False.
  16063. * This will make creation of children, recursive.
  16064. * @param useVertexColor defines if this LinesMesh supports vertex color
  16065. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16066. */
  16067. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16068. /**
  16069. * If vertex color should be applied to the mesh
  16070. */
  16071. useVertexColor?: boolean | undefined,
  16072. /**
  16073. * If vertex alpha should be applied to the mesh
  16074. */
  16075. useVertexAlpha?: boolean | undefined);
  16076. private _addClipPlaneDefine;
  16077. private _removeClipPlaneDefine;
  16078. isReady(): boolean;
  16079. /**
  16080. * Returns the string "LineMesh"
  16081. */
  16082. getClassName(): string;
  16083. /**
  16084. * @hidden
  16085. */
  16086. get material(): Material;
  16087. /**
  16088. * @hidden
  16089. */
  16090. set material(value: Material);
  16091. /**
  16092. * @hidden
  16093. */
  16094. get checkCollisions(): boolean;
  16095. /** @hidden */
  16096. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16097. /** @hidden */
  16098. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16099. /**
  16100. * Disposes of the line mesh
  16101. * @param doNotRecurse If children should be disposed
  16102. */
  16103. dispose(doNotRecurse?: boolean): void;
  16104. /**
  16105. * Returns a new LineMesh object cloned from the current one.
  16106. */
  16107. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16108. /**
  16109. * Creates a new InstancedLinesMesh object from the mesh model.
  16110. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16111. * @param name defines the name of the new instance
  16112. * @returns a new InstancedLinesMesh
  16113. */
  16114. createInstance(name: string): InstancedLinesMesh;
  16115. }
  16116. /**
  16117. * Creates an instance based on a source LinesMesh
  16118. */
  16119. export class InstancedLinesMesh extends InstancedMesh {
  16120. /**
  16121. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16122. * This margin is expressed in world space coordinates, so its value may vary.
  16123. * Initilized with the intersectionThreshold value of the source LinesMesh
  16124. */
  16125. intersectionThreshold: number;
  16126. constructor(name: string, source: LinesMesh);
  16127. /**
  16128. * Returns the string "InstancedLinesMesh".
  16129. */
  16130. getClassName(): string;
  16131. }
  16132. }
  16133. declare module "babylonjs/Shaders/line.fragment" {
  16134. /** @hidden */
  16135. export var linePixelShader: {
  16136. name: string;
  16137. shader: string;
  16138. };
  16139. }
  16140. declare module "babylonjs/Shaders/line.vertex" {
  16141. /** @hidden */
  16142. export var lineVertexShader: {
  16143. name: string;
  16144. shader: string;
  16145. };
  16146. }
  16147. declare module "babylonjs/Rendering/edgesRenderer" {
  16148. import { Nullable } from "babylonjs/types";
  16149. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16151. import { Vector3 } from "babylonjs/Maths/math.vector";
  16152. import { IDisposable } from "babylonjs/scene";
  16153. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  16154. import "babylonjs/Shaders/line.fragment";
  16155. import "babylonjs/Shaders/line.vertex";
  16156. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  16157. module "babylonjs/Meshes/abstractMesh" {
  16158. interface AbstractMesh {
  16159. /**
  16160. * Gets the edgesRenderer associated with the mesh
  16161. */
  16162. edgesRenderer: Nullable<EdgesRenderer>;
  16163. }
  16164. }
  16165. module "babylonjs/Meshes/linesMesh" {
  16166. interface LinesMesh {
  16167. /**
  16168. * Enables the edge rendering mode on the mesh.
  16169. * This mode makes the mesh edges visible
  16170. * @param epsilon defines the maximal distance between two angles to detect a face
  16171. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16172. * @returns the currentAbstractMesh
  16173. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16174. */
  16175. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16176. }
  16177. }
  16178. module "babylonjs/Meshes/linesMesh" {
  16179. interface InstancedLinesMesh {
  16180. /**
  16181. * Enables the edge rendering mode on the mesh.
  16182. * This mode makes the mesh edges visible
  16183. * @param epsilon defines the maximal distance between two angles to detect a face
  16184. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16185. * @returns the current InstancedLinesMesh
  16186. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16187. */
  16188. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16189. }
  16190. }
  16191. /**
  16192. * Defines the minimum contract an Edges renderer should follow.
  16193. */
  16194. export interface IEdgesRenderer extends IDisposable {
  16195. /**
  16196. * Gets or sets a boolean indicating if the edgesRenderer is active
  16197. */
  16198. isEnabled: boolean;
  16199. /**
  16200. * Renders the edges of the attached mesh,
  16201. */
  16202. render(): void;
  16203. /**
  16204. * Checks wether or not the edges renderer is ready to render.
  16205. * @return true if ready, otherwise false.
  16206. */
  16207. isReady(): boolean;
  16208. }
  16209. /**
  16210. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16211. */
  16212. export class EdgesRenderer implements IEdgesRenderer {
  16213. /**
  16214. * Define the size of the edges with an orthographic camera
  16215. */
  16216. edgesWidthScalerForOrthographic: number;
  16217. /**
  16218. * Define the size of the edges with a perspective camera
  16219. */
  16220. edgesWidthScalerForPerspective: number;
  16221. protected _source: AbstractMesh;
  16222. protected _linesPositions: number[];
  16223. protected _linesNormals: number[];
  16224. protected _linesIndices: number[];
  16225. protected _epsilon: number;
  16226. protected _indicesCount: number;
  16227. protected _lineShader: ShaderMaterial;
  16228. protected _ib: DataBuffer;
  16229. protected _buffers: {
  16230. [key: string]: Nullable<VertexBuffer>;
  16231. };
  16232. protected _checkVerticesInsteadOfIndices: boolean;
  16233. private _meshRebuildObserver;
  16234. private _meshDisposeObserver;
  16235. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16236. isEnabled: boolean;
  16237. /**
  16238. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16239. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16240. * @param source Mesh used to create edges
  16241. * @param epsilon sum of angles in adjacency to check for edge
  16242. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16243. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16244. */
  16245. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16246. protected _prepareRessources(): void;
  16247. /** @hidden */
  16248. _rebuild(): void;
  16249. /**
  16250. * Releases the required resources for the edges renderer
  16251. */
  16252. dispose(): void;
  16253. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16254. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16255. /**
  16256. * Checks if the pair of p0 and p1 is en edge
  16257. * @param faceIndex
  16258. * @param edge
  16259. * @param faceNormals
  16260. * @param p0
  16261. * @param p1
  16262. * @private
  16263. */
  16264. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16265. /**
  16266. * push line into the position, normal and index buffer
  16267. * @protected
  16268. */
  16269. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16270. /**
  16271. * Generates lines edges from adjacencjes
  16272. * @private
  16273. */
  16274. _generateEdgesLines(): void;
  16275. /**
  16276. * Checks wether or not the edges renderer is ready to render.
  16277. * @return true if ready, otherwise false.
  16278. */
  16279. isReady(): boolean;
  16280. /**
  16281. * Renders the edges of the attached mesh,
  16282. */
  16283. render(): void;
  16284. }
  16285. /**
  16286. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16287. */
  16288. export class LineEdgesRenderer extends EdgesRenderer {
  16289. /**
  16290. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16291. * @param source LineMesh used to generate edges
  16292. * @param epsilon not important (specified angle for edge detection)
  16293. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16294. */
  16295. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16296. /**
  16297. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16298. */
  16299. _generateEdgesLines(): void;
  16300. }
  16301. }
  16302. declare module "babylonjs/Rendering/renderingGroup" {
  16303. import { SmartArray } from "babylonjs/Misc/smartArray";
  16304. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16305. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16306. import { Nullable } from "babylonjs/types";
  16307. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16308. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  16309. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16310. import { Material } from "babylonjs/Materials/material";
  16311. import { Scene } from "babylonjs/scene";
  16312. /**
  16313. * This represents the object necessary to create a rendering group.
  16314. * This is exclusively used and created by the rendering manager.
  16315. * To modify the behavior, you use the available helpers in your scene or meshes.
  16316. * @hidden
  16317. */
  16318. export class RenderingGroup {
  16319. index: number;
  16320. private static _zeroVector;
  16321. private _scene;
  16322. private _opaqueSubMeshes;
  16323. private _transparentSubMeshes;
  16324. private _alphaTestSubMeshes;
  16325. private _depthOnlySubMeshes;
  16326. private _particleSystems;
  16327. private _spriteManagers;
  16328. private _opaqueSortCompareFn;
  16329. private _alphaTestSortCompareFn;
  16330. private _transparentSortCompareFn;
  16331. private _renderOpaque;
  16332. private _renderAlphaTest;
  16333. private _renderTransparent;
  16334. /** @hidden */
  16335. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16336. onBeforeTransparentRendering: () => void;
  16337. /**
  16338. * Set the opaque sort comparison function.
  16339. * If null the sub meshes will be render in the order they were created
  16340. */
  16341. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16342. /**
  16343. * Set the alpha test sort comparison function.
  16344. * If null the sub meshes will be render in the order they were created
  16345. */
  16346. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16347. /**
  16348. * Set the transparent sort comparison function.
  16349. * If null the sub meshes will be render in the order they were created
  16350. */
  16351. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16352. /**
  16353. * Creates a new rendering group.
  16354. * @param index The rendering group index
  16355. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16356. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16357. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16358. */
  16359. 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>);
  16360. /**
  16361. * Render all the sub meshes contained in the group.
  16362. * @param customRenderFunction Used to override the default render behaviour of the group.
  16363. * @returns true if rendered some submeshes.
  16364. */
  16365. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16366. /**
  16367. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16368. * @param subMeshes The submeshes to render
  16369. */
  16370. private renderOpaqueSorted;
  16371. /**
  16372. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16373. * @param subMeshes The submeshes to render
  16374. */
  16375. private renderAlphaTestSorted;
  16376. /**
  16377. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16378. * @param subMeshes The submeshes to render
  16379. */
  16380. private renderTransparentSorted;
  16381. /**
  16382. * Renders the submeshes in a specified order.
  16383. * @param subMeshes The submeshes to sort before render
  16384. * @param sortCompareFn The comparison function use to sort
  16385. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16386. * @param transparent Specifies to activate blending if true
  16387. */
  16388. private static renderSorted;
  16389. /**
  16390. * Renders the submeshes in the order they were dispatched (no sort applied).
  16391. * @param subMeshes The submeshes to render
  16392. */
  16393. private static renderUnsorted;
  16394. /**
  16395. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16396. * are rendered back to front if in the same alpha index.
  16397. *
  16398. * @param a The first submesh
  16399. * @param b The second submesh
  16400. * @returns The result of the comparison
  16401. */
  16402. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16403. /**
  16404. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16405. * are rendered back to front.
  16406. *
  16407. * @param a The first submesh
  16408. * @param b The second submesh
  16409. * @returns The result of the comparison
  16410. */
  16411. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16412. /**
  16413. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16414. * are rendered front to back (prevent overdraw).
  16415. *
  16416. * @param a The first submesh
  16417. * @param b The second submesh
  16418. * @returns The result of the comparison
  16419. */
  16420. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16421. /**
  16422. * Resets the different lists of submeshes to prepare a new frame.
  16423. */
  16424. prepare(): void;
  16425. dispose(): void;
  16426. /**
  16427. * Inserts the submesh in its correct queue depending on its material.
  16428. * @param subMesh The submesh to dispatch
  16429. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16430. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16431. */
  16432. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16433. dispatchSprites(spriteManager: ISpriteManager): void;
  16434. dispatchParticles(particleSystem: IParticleSystem): void;
  16435. private _renderParticles;
  16436. private _renderSprites;
  16437. }
  16438. }
  16439. declare module "babylonjs/Rendering/renderingManager" {
  16440. import { Nullable } from "babylonjs/types";
  16441. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16442. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16443. import { SmartArray } from "babylonjs/Misc/smartArray";
  16444. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16445. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16446. import { Material } from "babylonjs/Materials/material";
  16447. import { Scene } from "babylonjs/scene";
  16448. import { Camera } from "babylonjs/Cameras/camera";
  16449. /**
  16450. * Interface describing the different options available in the rendering manager
  16451. * regarding Auto Clear between groups.
  16452. */
  16453. export interface IRenderingManagerAutoClearSetup {
  16454. /**
  16455. * Defines whether or not autoclear is enable.
  16456. */
  16457. autoClear: boolean;
  16458. /**
  16459. * Defines whether or not to autoclear the depth buffer.
  16460. */
  16461. depth: boolean;
  16462. /**
  16463. * Defines whether or not to autoclear the stencil buffer.
  16464. */
  16465. stencil: boolean;
  16466. }
  16467. /**
  16468. * This class is used by the onRenderingGroupObservable
  16469. */
  16470. export class RenderingGroupInfo {
  16471. /**
  16472. * The Scene that being rendered
  16473. */
  16474. scene: Scene;
  16475. /**
  16476. * The camera currently used for the rendering pass
  16477. */
  16478. camera: Nullable<Camera>;
  16479. /**
  16480. * The ID of the renderingGroup being processed
  16481. */
  16482. renderingGroupId: number;
  16483. }
  16484. /**
  16485. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16486. * It is enable to manage the different groups as well as the different necessary sort functions.
  16487. * This should not be used directly aside of the few static configurations
  16488. */
  16489. export class RenderingManager {
  16490. /**
  16491. * The max id used for rendering groups (not included)
  16492. */
  16493. static MAX_RENDERINGGROUPS: number;
  16494. /**
  16495. * The min id used for rendering groups (included)
  16496. */
  16497. static MIN_RENDERINGGROUPS: number;
  16498. /**
  16499. * Used to globally prevent autoclearing scenes.
  16500. */
  16501. static AUTOCLEAR: boolean;
  16502. /**
  16503. * @hidden
  16504. */
  16505. _useSceneAutoClearSetup: boolean;
  16506. private _scene;
  16507. private _renderingGroups;
  16508. private _depthStencilBufferAlreadyCleaned;
  16509. private _autoClearDepthStencil;
  16510. private _customOpaqueSortCompareFn;
  16511. private _customAlphaTestSortCompareFn;
  16512. private _customTransparentSortCompareFn;
  16513. private _renderingGroupInfo;
  16514. /**
  16515. * Instantiates a new rendering group for a particular scene
  16516. * @param scene Defines the scene the groups belongs to
  16517. */
  16518. constructor(scene: Scene);
  16519. private _clearDepthStencilBuffer;
  16520. /**
  16521. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16522. * @hidden
  16523. */
  16524. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16525. /**
  16526. * Resets the different information of the group to prepare a new frame
  16527. * @hidden
  16528. */
  16529. reset(): void;
  16530. /**
  16531. * Dispose and release the group and its associated resources.
  16532. * @hidden
  16533. */
  16534. dispose(): void;
  16535. /**
  16536. * Clear the info related to rendering groups preventing retention points during dispose.
  16537. */
  16538. freeRenderingGroups(): void;
  16539. private _prepareRenderingGroup;
  16540. /**
  16541. * Add a sprite manager to the rendering manager in order to render it this frame.
  16542. * @param spriteManager Define the sprite manager to render
  16543. */
  16544. dispatchSprites(spriteManager: ISpriteManager): void;
  16545. /**
  16546. * Add a particle system to the rendering manager in order to render it this frame.
  16547. * @param particleSystem Define the particle system to render
  16548. */
  16549. dispatchParticles(particleSystem: IParticleSystem): void;
  16550. /**
  16551. * Add a submesh to the manager in order to render it this frame
  16552. * @param subMesh The submesh to dispatch
  16553. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16554. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16555. */
  16556. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16557. /**
  16558. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16559. * This allowed control for front to back rendering or reversly depending of the special needs.
  16560. *
  16561. * @param renderingGroupId The rendering group id corresponding to its index
  16562. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16563. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16564. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16565. */
  16566. 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;
  16567. /**
  16568. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16569. *
  16570. * @param renderingGroupId The rendering group id corresponding to its index
  16571. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16572. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16573. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16574. */
  16575. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16576. /**
  16577. * Gets the current auto clear configuration for one rendering group of the rendering
  16578. * manager.
  16579. * @param index the rendering group index to get the information for
  16580. * @returns The auto clear setup for the requested rendering group
  16581. */
  16582. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16583. }
  16584. }
  16585. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  16586. import { SmartArray } from "babylonjs/Misc/smartArray";
  16587. import { Nullable } from "babylonjs/types";
  16588. import { Scene } from "babylonjs/scene";
  16589. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  16590. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16591. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16592. import { Mesh } from "babylonjs/Meshes/mesh";
  16593. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  16594. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  16595. import { Effect } from "babylonjs/Materials/effect";
  16596. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16597. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16598. import "babylonjs/Shaders/shadowMap.fragment";
  16599. import "babylonjs/Shaders/shadowMap.vertex";
  16600. import "babylonjs/Shaders/depthBoxBlur.fragment";
  16601. import { Observable } from "babylonjs/Misc/observable";
  16602. /**
  16603. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16604. */
  16605. export interface ICustomShaderOptions {
  16606. /**
  16607. * Gets or sets the custom shader name to use
  16608. */
  16609. shaderName: string;
  16610. /**
  16611. * The list of attribute names used in the shader
  16612. */
  16613. attributes?: string[];
  16614. /**
  16615. * The list of unifrom names used in the shader
  16616. */
  16617. uniforms?: string[];
  16618. /**
  16619. * The list of sampler names used in the shader
  16620. */
  16621. samplers?: string[];
  16622. /**
  16623. * The list of defines used in the shader
  16624. */
  16625. defines?: string[];
  16626. }
  16627. /**
  16628. * Interface to implement to create a shadow generator compatible with BJS.
  16629. */
  16630. export interface IShadowGenerator {
  16631. /**
  16632. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16633. * @returns The render target texture if present otherwise, null
  16634. */
  16635. getShadowMap(): Nullable<RenderTargetTexture>;
  16636. /**
  16637. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16638. * @param subMesh The submesh we want to render in the shadow map
  16639. * @param useInstances Defines wether will draw in the map using instances
  16640. * @returns true if ready otherwise, false
  16641. */
  16642. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16643. /**
  16644. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16645. * @param defines Defines of the material we want to update
  16646. * @param lightIndex Index of the light in the enabled light list of the material
  16647. */
  16648. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16649. /**
  16650. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16651. * defined in the generator but impacting the effect).
  16652. * It implies the unifroms available on the materials are the standard BJS ones.
  16653. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16654. * @param effect The effect we are binfing the information for
  16655. */
  16656. bindShadowLight(lightIndex: string, effect: Effect): void;
  16657. /**
  16658. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16659. * (eq to shadow prjection matrix * light transform matrix)
  16660. * @returns The transform matrix used to create the shadow map
  16661. */
  16662. getTransformMatrix(): Matrix;
  16663. /**
  16664. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16665. * Cube and 2D textures for instance.
  16666. */
  16667. recreateShadowMap(): void;
  16668. /**
  16669. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16670. * @param onCompiled Callback triggered at the and of the effects compilation
  16671. * @param options Sets of optional options forcing the compilation with different modes
  16672. */
  16673. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16674. useInstances: boolean;
  16675. }>): void;
  16676. /**
  16677. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16678. * @param options Sets of optional options forcing the compilation with different modes
  16679. * @returns A promise that resolves when the compilation completes
  16680. */
  16681. forceCompilationAsync(options?: Partial<{
  16682. useInstances: boolean;
  16683. }>): Promise<void>;
  16684. /**
  16685. * Serializes the shadow generator setup to a json object.
  16686. * @returns The serialized JSON object
  16687. */
  16688. serialize(): any;
  16689. /**
  16690. * Disposes the Shadow map and related Textures and effects.
  16691. */
  16692. dispose(): void;
  16693. }
  16694. /**
  16695. * Default implementation IShadowGenerator.
  16696. * This is the main object responsible of generating shadows in the framework.
  16697. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16698. */
  16699. export class ShadowGenerator implements IShadowGenerator {
  16700. /**
  16701. * Name of the shadow generator class
  16702. */
  16703. static CLASSNAME: string;
  16704. /**
  16705. * Shadow generator mode None: no filtering applied.
  16706. */
  16707. static readonly FILTER_NONE: number;
  16708. /**
  16709. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16710. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16711. */
  16712. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16713. /**
  16714. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16715. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16716. */
  16717. static readonly FILTER_POISSONSAMPLING: number;
  16718. /**
  16719. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16720. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16721. */
  16722. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16723. /**
  16724. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16725. * edge artifacts on steep falloff.
  16726. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16727. */
  16728. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16729. /**
  16730. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16731. * edge artifacts on steep falloff.
  16732. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16733. */
  16734. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16735. /**
  16736. * Shadow generator mode PCF: Percentage Closer Filtering
  16737. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16738. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16739. */
  16740. static readonly FILTER_PCF: number;
  16741. /**
  16742. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16743. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16744. * Contact Hardening
  16745. */
  16746. static readonly FILTER_PCSS: number;
  16747. /**
  16748. * Reserved for PCF and PCSS
  16749. * Highest Quality.
  16750. *
  16751. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16752. *
  16753. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16754. */
  16755. static readonly QUALITY_HIGH: number;
  16756. /**
  16757. * Reserved for PCF and PCSS
  16758. * Good tradeoff for quality/perf cross devices
  16759. *
  16760. * Execute PCF on a 3*3 kernel.
  16761. *
  16762. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16763. */
  16764. static readonly QUALITY_MEDIUM: number;
  16765. /**
  16766. * Reserved for PCF and PCSS
  16767. * The lowest quality but the fastest.
  16768. *
  16769. * Execute PCF on a 1*1 kernel.
  16770. *
  16771. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16772. */
  16773. static readonly QUALITY_LOW: number;
  16774. /** Gets or sets the custom shader name to use */
  16775. customShaderOptions: ICustomShaderOptions;
  16776. /**
  16777. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16778. */
  16779. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16780. /**
  16781. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16782. */
  16783. onAfterShadowMapRenderObservable: Observable<Effect>;
  16784. /**
  16785. * Observable triggered before a mesh is rendered in the shadow map.
  16786. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16787. */
  16788. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16789. /**
  16790. * Observable triggered after a mesh is rendered in the shadow map.
  16791. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16792. */
  16793. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16794. protected _bias: number;
  16795. /**
  16796. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16797. */
  16798. get bias(): number;
  16799. /**
  16800. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16801. */
  16802. set bias(bias: number);
  16803. protected _normalBias: number;
  16804. /**
  16805. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16806. */
  16807. get normalBias(): number;
  16808. /**
  16809. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16810. */
  16811. set normalBias(normalBias: number);
  16812. protected _blurBoxOffset: number;
  16813. /**
  16814. * Gets the blur box offset: offset applied during the blur pass.
  16815. * Only useful if useKernelBlur = false
  16816. */
  16817. get blurBoxOffset(): number;
  16818. /**
  16819. * Sets the blur box offset: offset applied during the blur pass.
  16820. * Only useful if useKernelBlur = false
  16821. */
  16822. set blurBoxOffset(value: number);
  16823. protected _blurScale: number;
  16824. /**
  16825. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16826. * 2 means half of the size.
  16827. */
  16828. get blurScale(): number;
  16829. /**
  16830. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16831. * 2 means half of the size.
  16832. */
  16833. set blurScale(value: number);
  16834. protected _blurKernel: number;
  16835. /**
  16836. * Gets the blur kernel: kernel size of the blur pass.
  16837. * Only useful if useKernelBlur = true
  16838. */
  16839. get blurKernel(): number;
  16840. /**
  16841. * Sets the blur kernel: kernel size of the blur pass.
  16842. * Only useful if useKernelBlur = true
  16843. */
  16844. set blurKernel(value: number);
  16845. protected _useKernelBlur: boolean;
  16846. /**
  16847. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16848. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16849. */
  16850. get useKernelBlur(): boolean;
  16851. /**
  16852. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16853. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16854. */
  16855. set useKernelBlur(value: boolean);
  16856. protected _depthScale: number;
  16857. /**
  16858. * Gets the depth scale used in ESM mode.
  16859. */
  16860. get depthScale(): number;
  16861. /**
  16862. * Sets the depth scale used in ESM mode.
  16863. * This can override the scale stored on the light.
  16864. */
  16865. set depthScale(value: number);
  16866. protected _validateFilter(filter: number): number;
  16867. protected _filter: number;
  16868. /**
  16869. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16870. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16871. */
  16872. get filter(): number;
  16873. /**
  16874. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16875. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16876. */
  16877. set filter(value: number);
  16878. /**
  16879. * Gets if the current filter is set to Poisson Sampling.
  16880. */
  16881. get usePoissonSampling(): boolean;
  16882. /**
  16883. * Sets the current filter to Poisson Sampling.
  16884. */
  16885. set usePoissonSampling(value: boolean);
  16886. /**
  16887. * Gets if the current filter is set to ESM.
  16888. */
  16889. get useExponentialShadowMap(): boolean;
  16890. /**
  16891. * Sets the current filter is to ESM.
  16892. */
  16893. set useExponentialShadowMap(value: boolean);
  16894. /**
  16895. * Gets if the current filter is set to filtered ESM.
  16896. */
  16897. get useBlurExponentialShadowMap(): boolean;
  16898. /**
  16899. * Gets if the current filter is set to filtered ESM.
  16900. */
  16901. set useBlurExponentialShadowMap(value: boolean);
  16902. /**
  16903. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16904. * exponential to prevent steep falloff artifacts).
  16905. */
  16906. get useCloseExponentialShadowMap(): boolean;
  16907. /**
  16908. * Sets the current filter to "close ESM" (using the inverse of the
  16909. * exponential to prevent steep falloff artifacts).
  16910. */
  16911. set useCloseExponentialShadowMap(value: boolean);
  16912. /**
  16913. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16914. * exponential to prevent steep falloff artifacts).
  16915. */
  16916. get useBlurCloseExponentialShadowMap(): boolean;
  16917. /**
  16918. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16919. * exponential to prevent steep falloff artifacts).
  16920. */
  16921. set useBlurCloseExponentialShadowMap(value: boolean);
  16922. /**
  16923. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16924. */
  16925. get usePercentageCloserFiltering(): boolean;
  16926. /**
  16927. * Sets the current filter to "PCF" (percentage closer filtering).
  16928. */
  16929. set usePercentageCloserFiltering(value: boolean);
  16930. protected _filteringQuality: number;
  16931. /**
  16932. * Gets the PCF or PCSS Quality.
  16933. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16934. */
  16935. get filteringQuality(): number;
  16936. /**
  16937. * Sets the PCF or PCSS Quality.
  16938. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16939. */
  16940. set filteringQuality(filteringQuality: number);
  16941. /**
  16942. * Gets if the current filter is set to "PCSS" (contact hardening).
  16943. */
  16944. get useContactHardeningShadow(): boolean;
  16945. /**
  16946. * Sets the current filter to "PCSS" (contact hardening).
  16947. */
  16948. set useContactHardeningShadow(value: boolean);
  16949. protected _contactHardeningLightSizeUVRatio: number;
  16950. /**
  16951. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16952. * Using a ratio helps keeping shape stability independently of the map size.
  16953. *
  16954. * It does not account for the light projection as it was having too much
  16955. * instability during the light setup or during light position changes.
  16956. *
  16957. * Only valid if useContactHardeningShadow is true.
  16958. */
  16959. get contactHardeningLightSizeUVRatio(): number;
  16960. /**
  16961. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16962. * Using a ratio helps keeping shape stability independently of the map size.
  16963. *
  16964. * It does not account for the light projection as it was having too much
  16965. * instability during the light setup or during light position changes.
  16966. *
  16967. * Only valid if useContactHardeningShadow is true.
  16968. */
  16969. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16970. protected _darkness: number;
  16971. /** Gets or sets the actual darkness of a shadow */
  16972. get darkness(): number;
  16973. set darkness(value: number);
  16974. /**
  16975. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16976. * 0 means strongest and 1 would means no shadow.
  16977. * @returns the darkness.
  16978. */
  16979. getDarkness(): number;
  16980. /**
  16981. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16982. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16983. * @returns the shadow generator allowing fluent coding.
  16984. */
  16985. setDarkness(darkness: number): ShadowGenerator;
  16986. protected _transparencyShadow: boolean;
  16987. /** Gets or sets the ability to have transparent shadow */
  16988. get transparencyShadow(): boolean;
  16989. set transparencyShadow(value: boolean);
  16990. /**
  16991. * Sets the ability to have transparent shadow (boolean).
  16992. * @param transparent True if transparent else False
  16993. * @returns the shadow generator allowing fluent coding
  16994. */
  16995. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16996. protected _shadowMap: Nullable<RenderTargetTexture>;
  16997. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16998. /**
  16999. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17000. * @returns The render target texture if present otherwise, null
  17001. */
  17002. getShadowMap(): Nullable<RenderTargetTexture>;
  17003. /**
  17004. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17005. * @returns The render target texture if the shadow map is present otherwise, null
  17006. */
  17007. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17008. /**
  17009. * Gets the class name of that object
  17010. * @returns "ShadowGenerator"
  17011. */
  17012. getClassName(): string;
  17013. /**
  17014. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17015. * @param mesh Mesh to add
  17016. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17017. * @returns the Shadow Generator itself
  17018. */
  17019. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17020. /**
  17021. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17022. * @param mesh Mesh to remove
  17023. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17024. * @returns the Shadow Generator itself
  17025. */
  17026. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17027. /**
  17028. * Controls the extent to which the shadows fade out at the edge of the frustum
  17029. */
  17030. frustumEdgeFalloff: number;
  17031. protected _light: IShadowLight;
  17032. /**
  17033. * Returns the associated light object.
  17034. * @returns the light generating the shadow
  17035. */
  17036. getLight(): IShadowLight;
  17037. /**
  17038. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17039. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17040. * It might on the other hand introduce peter panning.
  17041. */
  17042. forceBackFacesOnly: boolean;
  17043. protected _scene: Scene;
  17044. protected _lightDirection: Vector3;
  17045. protected _effect: Effect;
  17046. protected _viewMatrix: Matrix;
  17047. protected _projectionMatrix: Matrix;
  17048. protected _transformMatrix: Matrix;
  17049. protected _cachedPosition: Vector3;
  17050. protected _cachedDirection: Vector3;
  17051. protected _cachedDefines: string;
  17052. protected _currentRenderID: number;
  17053. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17054. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17055. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17056. protected _blurPostProcesses: PostProcess[];
  17057. protected _mapSize: number;
  17058. protected _currentFaceIndex: number;
  17059. protected _currentFaceIndexCache: number;
  17060. protected _textureType: number;
  17061. protected _defaultTextureMatrix: Matrix;
  17062. protected _storedUniqueId: Nullable<number>;
  17063. /** @hidden */
  17064. static _SceneComponentInitialization: (scene: Scene) => void;
  17065. /**
  17066. * Creates a ShadowGenerator object.
  17067. * A ShadowGenerator is the required tool to use the shadows.
  17068. * Each light casting shadows needs to use its own ShadowGenerator.
  17069. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17070. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17071. * @param light The light object generating the shadows.
  17072. * @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.
  17073. */
  17074. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17075. protected _initializeGenerator(): void;
  17076. protected _createTargetRenderTexture(): void;
  17077. protected _initializeShadowMap(): void;
  17078. protected _initializeBlurRTTAndPostProcesses(): void;
  17079. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17080. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  17081. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  17082. protected _applyFilterValues(): void;
  17083. /**
  17084. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17085. * @param onCompiled Callback triggered at the and of the effects compilation
  17086. * @param options Sets of optional options forcing the compilation with different modes
  17087. */
  17088. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17089. useInstances: boolean;
  17090. }>): void;
  17091. /**
  17092. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17093. * @param options Sets of optional options forcing the compilation with different modes
  17094. * @returns A promise that resolves when the compilation completes
  17095. */
  17096. forceCompilationAsync(options?: Partial<{
  17097. useInstances: boolean;
  17098. }>): Promise<void>;
  17099. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17100. /**
  17101. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17102. * @param subMesh The submesh we want to render in the shadow map
  17103. * @param useInstances Defines wether will draw in the map using instances
  17104. * @returns true if ready otherwise, false
  17105. */
  17106. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  17107. /**
  17108. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17109. * @param defines Defines of the material we want to update
  17110. * @param lightIndex Index of the light in the enabled light list of the material
  17111. */
  17112. prepareDefines(defines: any, lightIndex: number): void;
  17113. /**
  17114. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17115. * defined in the generator but impacting the effect).
  17116. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17117. * @param effect The effect we are binfing the information for
  17118. */
  17119. bindShadowLight(lightIndex: string, effect: Effect): void;
  17120. /**
  17121. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17122. * (eq to shadow prjection matrix * light transform matrix)
  17123. * @returns The transform matrix used to create the shadow map
  17124. */
  17125. getTransformMatrix(): Matrix;
  17126. /**
  17127. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17128. * Cube and 2D textures for instance.
  17129. */
  17130. recreateShadowMap(): void;
  17131. protected _disposeBlurPostProcesses(): void;
  17132. protected _disposeRTTandPostProcesses(): void;
  17133. /**
  17134. * Disposes the ShadowGenerator.
  17135. * Returns nothing.
  17136. */
  17137. dispose(): void;
  17138. /**
  17139. * Serializes the shadow generator setup to a json object.
  17140. * @returns The serialized JSON object
  17141. */
  17142. serialize(): any;
  17143. /**
  17144. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17145. * @param parsedShadowGenerator The JSON object to parse
  17146. * @param scene The scene to create the shadow map for
  17147. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17148. * @returns The parsed shadow generator
  17149. */
  17150. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17151. }
  17152. }
  17153. declare module "babylonjs/Lights/light" {
  17154. import { Nullable } from "babylonjs/types";
  17155. import { Scene } from "babylonjs/scene";
  17156. import { Vector3 } from "babylonjs/Maths/math.vector";
  17157. import { Color3 } from "babylonjs/Maths/math.color";
  17158. import { Node } from "babylonjs/node";
  17159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17160. import { Effect } from "babylonjs/Materials/effect";
  17161. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17162. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17163. /**
  17164. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17165. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17166. * 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.
  17167. */
  17168. export abstract class Light extends Node {
  17169. /**
  17170. * Falloff Default: light is falling off following the material specification:
  17171. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17172. */
  17173. static readonly FALLOFF_DEFAULT: number;
  17174. /**
  17175. * Falloff Physical: light is falling off following the inverse squared distance law.
  17176. */
  17177. static readonly FALLOFF_PHYSICAL: number;
  17178. /**
  17179. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17180. * to enhance interoperability with other engines.
  17181. */
  17182. static readonly FALLOFF_GLTF: number;
  17183. /**
  17184. * Falloff Standard: light is falling off like in the standard material
  17185. * to enhance interoperability with other materials.
  17186. */
  17187. static readonly FALLOFF_STANDARD: number;
  17188. /**
  17189. * If every light affecting the material is in this lightmapMode,
  17190. * material.lightmapTexture adds or multiplies
  17191. * (depends on material.useLightmapAsShadowmap)
  17192. * after every other light calculations.
  17193. */
  17194. static readonly LIGHTMAP_DEFAULT: number;
  17195. /**
  17196. * material.lightmapTexture as only diffuse lighting from this light
  17197. * adds only specular lighting from this light
  17198. * adds dynamic shadows
  17199. */
  17200. static readonly LIGHTMAP_SPECULAR: number;
  17201. /**
  17202. * material.lightmapTexture as only lighting
  17203. * no light calculation from this light
  17204. * only adds dynamic shadows from this light
  17205. */
  17206. static readonly LIGHTMAP_SHADOWSONLY: number;
  17207. /**
  17208. * Each light type uses the default quantity according to its type:
  17209. * point/spot lights use luminous intensity
  17210. * directional lights use illuminance
  17211. */
  17212. static readonly INTENSITYMODE_AUTOMATIC: number;
  17213. /**
  17214. * lumen (lm)
  17215. */
  17216. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17217. /**
  17218. * candela (lm/sr)
  17219. */
  17220. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17221. /**
  17222. * lux (lm/m^2)
  17223. */
  17224. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17225. /**
  17226. * nit (cd/m^2)
  17227. */
  17228. static readonly INTENSITYMODE_LUMINANCE: number;
  17229. /**
  17230. * Light type const id of the point light.
  17231. */
  17232. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17233. /**
  17234. * Light type const id of the directional light.
  17235. */
  17236. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17237. /**
  17238. * Light type const id of the spot light.
  17239. */
  17240. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17241. /**
  17242. * Light type const id of the hemispheric light.
  17243. */
  17244. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17245. /**
  17246. * Diffuse gives the basic color to an object.
  17247. */
  17248. diffuse: Color3;
  17249. /**
  17250. * Specular produces a highlight color on an object.
  17251. * Note: This is note affecting PBR materials.
  17252. */
  17253. specular: Color3;
  17254. /**
  17255. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17256. * falling off base on range or angle.
  17257. * This can be set to any values in Light.FALLOFF_x.
  17258. *
  17259. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17260. * other types of materials.
  17261. */
  17262. falloffType: number;
  17263. /**
  17264. * Strength of the light.
  17265. * Note: By default it is define in the framework own unit.
  17266. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17267. */
  17268. intensity: number;
  17269. private _range;
  17270. protected _inverseSquaredRange: number;
  17271. /**
  17272. * Defines how far from the source the light is impacting in scene units.
  17273. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17274. */
  17275. get range(): number;
  17276. /**
  17277. * Defines how far from the source the light is impacting in scene units.
  17278. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17279. */
  17280. set range(value: number);
  17281. /**
  17282. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17283. * of light.
  17284. */
  17285. private _photometricScale;
  17286. private _intensityMode;
  17287. /**
  17288. * Gets the photometric scale used to interpret the intensity.
  17289. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17290. */
  17291. get intensityMode(): number;
  17292. /**
  17293. * Sets the photometric scale used to interpret the intensity.
  17294. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17295. */
  17296. set intensityMode(value: number);
  17297. private _radius;
  17298. /**
  17299. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17300. */
  17301. get radius(): number;
  17302. /**
  17303. * sets the light radius used by PBR Materials to simulate soft area lights.
  17304. */
  17305. set radius(value: number);
  17306. private _renderPriority;
  17307. /**
  17308. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17309. * exceeding the number allowed of the materials.
  17310. */
  17311. renderPriority: number;
  17312. private _shadowEnabled;
  17313. /**
  17314. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17315. * the current shadow generator.
  17316. */
  17317. get shadowEnabled(): boolean;
  17318. /**
  17319. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17320. * the current shadow generator.
  17321. */
  17322. set shadowEnabled(value: boolean);
  17323. private _includedOnlyMeshes;
  17324. /**
  17325. * Gets the only meshes impacted by this light.
  17326. */
  17327. get includedOnlyMeshes(): AbstractMesh[];
  17328. /**
  17329. * Sets the only meshes impacted by this light.
  17330. */
  17331. set includedOnlyMeshes(value: AbstractMesh[]);
  17332. private _excludedMeshes;
  17333. /**
  17334. * Gets the meshes not impacted by this light.
  17335. */
  17336. get excludedMeshes(): AbstractMesh[];
  17337. /**
  17338. * Sets the meshes not impacted by this light.
  17339. */
  17340. set excludedMeshes(value: AbstractMesh[]);
  17341. private _excludeWithLayerMask;
  17342. /**
  17343. * Gets the layer id use to find what meshes are not impacted by the light.
  17344. * Inactive if 0
  17345. */
  17346. get excludeWithLayerMask(): number;
  17347. /**
  17348. * Sets the layer id use to find what meshes are not impacted by the light.
  17349. * Inactive if 0
  17350. */
  17351. set excludeWithLayerMask(value: number);
  17352. private _includeOnlyWithLayerMask;
  17353. /**
  17354. * Gets the layer id use to find what meshes are impacted by the light.
  17355. * Inactive if 0
  17356. */
  17357. get includeOnlyWithLayerMask(): number;
  17358. /**
  17359. * Sets the layer id use to find what meshes are impacted by the light.
  17360. * Inactive if 0
  17361. */
  17362. set includeOnlyWithLayerMask(value: number);
  17363. private _lightmapMode;
  17364. /**
  17365. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17366. */
  17367. get lightmapMode(): number;
  17368. /**
  17369. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17370. */
  17371. set lightmapMode(value: number);
  17372. /**
  17373. * Shadow generator associted to the light.
  17374. * @hidden Internal use only.
  17375. */
  17376. _shadowGenerator: Nullable<IShadowGenerator>;
  17377. /**
  17378. * @hidden Internal use only.
  17379. */
  17380. _excludedMeshesIds: string[];
  17381. /**
  17382. * @hidden Internal use only.
  17383. */
  17384. _includedOnlyMeshesIds: string[];
  17385. /**
  17386. * The current light unifom buffer.
  17387. * @hidden Internal use only.
  17388. */
  17389. _uniformBuffer: UniformBuffer;
  17390. /** @hidden */
  17391. _renderId: number;
  17392. /**
  17393. * Creates a Light object in the scene.
  17394. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17395. * @param name The firendly name of the light
  17396. * @param scene The scene the light belongs too
  17397. */
  17398. constructor(name: string, scene: Scene);
  17399. protected abstract _buildUniformLayout(): void;
  17400. /**
  17401. * Sets the passed Effect "effect" with the Light information.
  17402. * @param effect The effect to update
  17403. * @param lightIndex The index of the light in the effect to update
  17404. * @returns The light
  17405. */
  17406. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17407. /**
  17408. * Sets the passed Effect "effect" with the Light textures.
  17409. * @param effect The effect to update
  17410. * @param lightIndex The index of the light in the effect to update
  17411. * @returns The light
  17412. */
  17413. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17414. /**
  17415. * Binds the lights information from the scene to the effect for the given mesh.
  17416. * @param lightIndex Light index
  17417. * @param scene The scene where the light belongs to
  17418. * @param effect The effect we are binding the data to
  17419. * @param useSpecular Defines if specular is supported
  17420. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17421. */
  17422. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17423. /**
  17424. * Sets the passed Effect "effect" with the Light information.
  17425. * @param effect The effect to update
  17426. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17427. * @returns The light
  17428. */
  17429. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17430. /**
  17431. * Returns the string "Light".
  17432. * @returns the class name
  17433. */
  17434. getClassName(): string;
  17435. /** @hidden */
  17436. readonly _isLight: boolean;
  17437. /**
  17438. * Converts the light information to a readable string for debug purpose.
  17439. * @param fullDetails Supports for multiple levels of logging within scene loading
  17440. * @returns the human readable light info
  17441. */
  17442. toString(fullDetails?: boolean): string;
  17443. /** @hidden */
  17444. protected _syncParentEnabledState(): void;
  17445. /**
  17446. * Set the enabled state of this node.
  17447. * @param value - the new enabled state
  17448. */
  17449. setEnabled(value: boolean): void;
  17450. /**
  17451. * Returns the Light associated shadow generator if any.
  17452. * @return the associated shadow generator.
  17453. */
  17454. getShadowGenerator(): Nullable<IShadowGenerator>;
  17455. /**
  17456. * Returns a Vector3, the absolute light position in the World.
  17457. * @returns the world space position of the light
  17458. */
  17459. getAbsolutePosition(): Vector3;
  17460. /**
  17461. * Specifies if the light will affect the passed mesh.
  17462. * @param mesh The mesh to test against the light
  17463. * @return true the mesh is affected otherwise, false.
  17464. */
  17465. canAffectMesh(mesh: AbstractMesh): boolean;
  17466. /**
  17467. * Sort function to order lights for rendering.
  17468. * @param a First Light object to compare to second.
  17469. * @param b Second Light object to compare first.
  17470. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17471. */
  17472. static CompareLightsPriority(a: Light, b: Light): number;
  17473. /**
  17474. * Releases resources associated with this node.
  17475. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17476. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17477. */
  17478. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17479. /**
  17480. * Returns the light type ID (integer).
  17481. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17482. */
  17483. getTypeID(): number;
  17484. /**
  17485. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17486. * @returns the scaled intensity in intensity mode unit
  17487. */
  17488. getScaledIntensity(): number;
  17489. /**
  17490. * Returns a new Light object, named "name", from the current one.
  17491. * @param name The name of the cloned light
  17492. * @returns the new created light
  17493. */
  17494. clone(name: string): Nullable<Light>;
  17495. /**
  17496. * Serializes the current light into a Serialization object.
  17497. * @returns the serialized object.
  17498. */
  17499. serialize(): any;
  17500. /**
  17501. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17502. * This new light is named "name" and added to the passed scene.
  17503. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17504. * @param name The friendly name of the light
  17505. * @param scene The scene the new light will belong to
  17506. * @returns the constructor function
  17507. */
  17508. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17509. /**
  17510. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17511. * @param parsedLight The JSON representation of the light
  17512. * @param scene The scene to create the parsed light in
  17513. * @returns the created light after parsing
  17514. */
  17515. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17516. private _hookArrayForExcluded;
  17517. private _hookArrayForIncludedOnly;
  17518. private _resyncMeshes;
  17519. /**
  17520. * Forces the meshes to update their light related information in their rendering used effects
  17521. * @hidden Internal Use Only
  17522. */
  17523. _markMeshesAsLightDirty(): void;
  17524. /**
  17525. * Recomputes the cached photometric scale if needed.
  17526. */
  17527. private _computePhotometricScale;
  17528. /**
  17529. * Returns the Photometric Scale according to the light type and intensity mode.
  17530. */
  17531. private _getPhotometricScale;
  17532. /**
  17533. * Reorder the light in the scene according to their defined priority.
  17534. * @hidden Internal Use Only
  17535. */
  17536. _reorderLightsInScene(): void;
  17537. /**
  17538. * Prepares the list of defines specific to the light type.
  17539. * @param defines the list of defines
  17540. * @param lightIndex defines the index of the light for the effect
  17541. */
  17542. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17543. }
  17544. }
  17545. declare module "babylonjs/Actions/action" {
  17546. import { Observable } from "babylonjs/Misc/observable";
  17547. import { Condition } from "babylonjs/Actions/condition";
  17548. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  17549. import { ActionManager } from "babylonjs/Actions/actionManager";
  17550. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17551. /**
  17552. * Interface used to define Action
  17553. */
  17554. export interface IAction {
  17555. /**
  17556. * Trigger for the action
  17557. */
  17558. trigger: number;
  17559. /** Options of the trigger */
  17560. triggerOptions: any;
  17561. /**
  17562. * Gets the trigger parameters
  17563. * @returns the trigger parameters
  17564. */
  17565. getTriggerParameter(): any;
  17566. /**
  17567. * Internal only - executes current action event
  17568. * @hidden
  17569. */
  17570. _executeCurrent(evt?: ActionEvent): void;
  17571. /**
  17572. * Serialize placeholder for child classes
  17573. * @param parent of child
  17574. * @returns the serialized object
  17575. */
  17576. serialize(parent: any): any;
  17577. /**
  17578. * Internal only
  17579. * @hidden
  17580. */
  17581. _prepare(): void;
  17582. /**
  17583. * Internal only - manager for action
  17584. * @hidden
  17585. */
  17586. _actionManager: AbstractActionManager;
  17587. /**
  17588. * Adds action to chain of actions, may be a DoNothingAction
  17589. * @param action defines the next action to execute
  17590. * @returns The action passed in
  17591. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17592. */
  17593. then(action: IAction): IAction;
  17594. }
  17595. /**
  17596. * The action to be carried out following a trigger
  17597. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17598. */
  17599. export class Action implements IAction {
  17600. /** the trigger, with or without parameters, for the action */
  17601. triggerOptions: any;
  17602. /**
  17603. * Trigger for the action
  17604. */
  17605. trigger: number;
  17606. /**
  17607. * Internal only - manager for action
  17608. * @hidden
  17609. */
  17610. _actionManager: ActionManager;
  17611. private _nextActiveAction;
  17612. private _child;
  17613. private _condition?;
  17614. private _triggerParameter;
  17615. /**
  17616. * An event triggered prior to action being executed.
  17617. */
  17618. onBeforeExecuteObservable: Observable<Action>;
  17619. /**
  17620. * Creates a new Action
  17621. * @param triggerOptions the trigger, with or without parameters, for the action
  17622. * @param condition an optional determinant of action
  17623. */
  17624. constructor(
  17625. /** the trigger, with or without parameters, for the action */
  17626. triggerOptions: any, condition?: Condition);
  17627. /**
  17628. * Internal only
  17629. * @hidden
  17630. */
  17631. _prepare(): void;
  17632. /**
  17633. * Gets the trigger parameters
  17634. * @returns the trigger parameters
  17635. */
  17636. getTriggerParameter(): any;
  17637. /**
  17638. * Internal only - executes current action event
  17639. * @hidden
  17640. */
  17641. _executeCurrent(evt?: ActionEvent): void;
  17642. /**
  17643. * Execute placeholder for child classes
  17644. * @param evt optional action event
  17645. */
  17646. execute(evt?: ActionEvent): void;
  17647. /**
  17648. * Skips to next active action
  17649. */
  17650. skipToNextActiveAction(): void;
  17651. /**
  17652. * Adds action to chain of actions, may be a DoNothingAction
  17653. * @param action defines the next action to execute
  17654. * @returns The action passed in
  17655. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17656. */
  17657. then(action: Action): Action;
  17658. /**
  17659. * Internal only
  17660. * @hidden
  17661. */
  17662. _getProperty(propertyPath: string): string;
  17663. /**
  17664. * Internal only
  17665. * @hidden
  17666. */
  17667. _getEffectiveTarget(target: any, propertyPath: string): any;
  17668. /**
  17669. * Serialize placeholder for child classes
  17670. * @param parent of child
  17671. * @returns the serialized object
  17672. */
  17673. serialize(parent: any): any;
  17674. /**
  17675. * Internal only called by serialize
  17676. * @hidden
  17677. */
  17678. protected _serialize(serializedAction: any, parent?: any): any;
  17679. /**
  17680. * Internal only
  17681. * @hidden
  17682. */
  17683. static _SerializeValueAsString: (value: any) => string;
  17684. /**
  17685. * Internal only
  17686. * @hidden
  17687. */
  17688. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  17689. name: string;
  17690. targetType: string;
  17691. value: string;
  17692. };
  17693. }
  17694. }
  17695. declare module "babylonjs/Actions/condition" {
  17696. import { ActionManager } from "babylonjs/Actions/actionManager";
  17697. /**
  17698. * A Condition applied to an Action
  17699. */
  17700. export class Condition {
  17701. /**
  17702. * Internal only - manager for action
  17703. * @hidden
  17704. */
  17705. _actionManager: ActionManager;
  17706. /**
  17707. * Internal only
  17708. * @hidden
  17709. */
  17710. _evaluationId: number;
  17711. /**
  17712. * Internal only
  17713. * @hidden
  17714. */
  17715. _currentResult: boolean;
  17716. /**
  17717. * Creates a new Condition
  17718. * @param actionManager the manager of the action the condition is applied to
  17719. */
  17720. constructor(actionManager: ActionManager);
  17721. /**
  17722. * Check if the current condition is valid
  17723. * @returns a boolean
  17724. */
  17725. isValid(): boolean;
  17726. /**
  17727. * Internal only
  17728. * @hidden
  17729. */
  17730. _getProperty(propertyPath: string): string;
  17731. /**
  17732. * Internal only
  17733. * @hidden
  17734. */
  17735. _getEffectiveTarget(target: any, propertyPath: string): any;
  17736. /**
  17737. * Serialize placeholder for child classes
  17738. * @returns the serialized object
  17739. */
  17740. serialize(): any;
  17741. /**
  17742. * Internal only
  17743. * @hidden
  17744. */
  17745. protected _serialize(serializedCondition: any): any;
  17746. }
  17747. /**
  17748. * Defines specific conditional operators as extensions of Condition
  17749. */
  17750. export class ValueCondition extends Condition {
  17751. /** path to specify the property of the target the conditional operator uses */
  17752. propertyPath: string;
  17753. /** the value compared by the conditional operator against the current value of the property */
  17754. value: any;
  17755. /** the conditional operator, default ValueCondition.IsEqual */
  17756. operator: number;
  17757. /**
  17758. * Internal only
  17759. * @hidden
  17760. */
  17761. private static _IsEqual;
  17762. /**
  17763. * Internal only
  17764. * @hidden
  17765. */
  17766. private static _IsDifferent;
  17767. /**
  17768. * Internal only
  17769. * @hidden
  17770. */
  17771. private static _IsGreater;
  17772. /**
  17773. * Internal only
  17774. * @hidden
  17775. */
  17776. private static _IsLesser;
  17777. /**
  17778. * returns the number for IsEqual
  17779. */
  17780. static get IsEqual(): number;
  17781. /**
  17782. * Returns the number for IsDifferent
  17783. */
  17784. static get IsDifferent(): number;
  17785. /**
  17786. * Returns the number for IsGreater
  17787. */
  17788. static get IsGreater(): number;
  17789. /**
  17790. * Returns the number for IsLesser
  17791. */
  17792. static get IsLesser(): number;
  17793. /**
  17794. * Internal only The action manager for the condition
  17795. * @hidden
  17796. */
  17797. _actionManager: ActionManager;
  17798. /**
  17799. * Internal only
  17800. * @hidden
  17801. */
  17802. private _target;
  17803. /**
  17804. * Internal only
  17805. * @hidden
  17806. */
  17807. private _effectiveTarget;
  17808. /**
  17809. * Internal only
  17810. * @hidden
  17811. */
  17812. private _property;
  17813. /**
  17814. * Creates a new ValueCondition
  17815. * @param actionManager manager for the action the condition applies to
  17816. * @param target for the action
  17817. * @param propertyPath path to specify the property of the target the conditional operator uses
  17818. * @param value the value compared by the conditional operator against the current value of the property
  17819. * @param operator the conditional operator, default ValueCondition.IsEqual
  17820. */
  17821. constructor(actionManager: ActionManager, target: any,
  17822. /** path to specify the property of the target the conditional operator uses */
  17823. propertyPath: string,
  17824. /** the value compared by the conditional operator against the current value of the property */
  17825. value: any,
  17826. /** the conditional operator, default ValueCondition.IsEqual */
  17827. operator?: number);
  17828. /**
  17829. * Compares the given value with the property value for the specified conditional operator
  17830. * @returns the result of the comparison
  17831. */
  17832. isValid(): boolean;
  17833. /**
  17834. * Serialize the ValueCondition into a JSON compatible object
  17835. * @returns serialization object
  17836. */
  17837. serialize(): any;
  17838. /**
  17839. * Gets the name of the conditional operator for the ValueCondition
  17840. * @param operator the conditional operator
  17841. * @returns the name
  17842. */
  17843. static GetOperatorName(operator: number): string;
  17844. }
  17845. /**
  17846. * Defines a predicate condition as an extension of Condition
  17847. */
  17848. export class PredicateCondition extends Condition {
  17849. /** defines the predicate function used to validate the condition */
  17850. predicate: () => boolean;
  17851. /**
  17852. * Internal only - manager for action
  17853. * @hidden
  17854. */
  17855. _actionManager: ActionManager;
  17856. /**
  17857. * Creates a new PredicateCondition
  17858. * @param actionManager manager for the action the condition applies to
  17859. * @param predicate defines the predicate function used to validate the condition
  17860. */
  17861. constructor(actionManager: ActionManager,
  17862. /** defines the predicate function used to validate the condition */
  17863. predicate: () => boolean);
  17864. /**
  17865. * @returns the validity of the predicate condition
  17866. */
  17867. isValid(): boolean;
  17868. }
  17869. /**
  17870. * Defines a state condition as an extension of Condition
  17871. */
  17872. export class StateCondition extends Condition {
  17873. /** Value to compare with target state */
  17874. value: string;
  17875. /**
  17876. * Internal only - manager for action
  17877. * @hidden
  17878. */
  17879. _actionManager: ActionManager;
  17880. /**
  17881. * Internal only
  17882. * @hidden
  17883. */
  17884. private _target;
  17885. /**
  17886. * Creates a new StateCondition
  17887. * @param actionManager manager for the action the condition applies to
  17888. * @param target of the condition
  17889. * @param value to compare with target state
  17890. */
  17891. constructor(actionManager: ActionManager, target: any,
  17892. /** Value to compare with target state */
  17893. value: string);
  17894. /**
  17895. * Gets a boolean indicating if the current condition is met
  17896. * @returns the validity of the state
  17897. */
  17898. isValid(): boolean;
  17899. /**
  17900. * Serialize the StateCondition into a JSON compatible object
  17901. * @returns serialization object
  17902. */
  17903. serialize(): any;
  17904. }
  17905. }
  17906. declare module "babylonjs/Actions/directActions" {
  17907. import { Action } from "babylonjs/Actions/action";
  17908. import { Condition } from "babylonjs/Actions/condition";
  17909. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17910. /**
  17911. * This defines an action responsible to toggle a boolean once triggered.
  17912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17913. */
  17914. export class SwitchBooleanAction extends Action {
  17915. /**
  17916. * The path to the boolean property in the target object
  17917. */
  17918. propertyPath: string;
  17919. private _target;
  17920. private _effectiveTarget;
  17921. private _property;
  17922. /**
  17923. * Instantiate the action
  17924. * @param triggerOptions defines the trigger options
  17925. * @param target defines the object containing the boolean
  17926. * @param propertyPath defines the path to the boolean property in the target object
  17927. * @param condition defines the trigger related conditions
  17928. */
  17929. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17930. /** @hidden */
  17931. _prepare(): void;
  17932. /**
  17933. * Execute the action toggle the boolean value.
  17934. */
  17935. execute(): void;
  17936. /**
  17937. * Serializes the actions and its related information.
  17938. * @param parent defines the object to serialize in
  17939. * @returns the serialized object
  17940. */
  17941. serialize(parent: any): any;
  17942. }
  17943. /**
  17944. * This defines an action responsible to set a the state field of the target
  17945. * to a desired value once triggered.
  17946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17947. */
  17948. export class SetStateAction extends Action {
  17949. /**
  17950. * The value to store in the state field.
  17951. */
  17952. value: string;
  17953. private _target;
  17954. /**
  17955. * Instantiate the action
  17956. * @param triggerOptions defines the trigger options
  17957. * @param target defines the object containing the state property
  17958. * @param value defines the value to store in the state field
  17959. * @param condition defines the trigger related conditions
  17960. */
  17961. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17962. /**
  17963. * Execute the action and store the value on the target state property.
  17964. */
  17965. execute(): void;
  17966. /**
  17967. * Serializes the actions and its related information.
  17968. * @param parent defines the object to serialize in
  17969. * @returns the serialized object
  17970. */
  17971. serialize(parent: any): any;
  17972. }
  17973. /**
  17974. * This defines an action responsible to set a property of the target
  17975. * to a desired value once triggered.
  17976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17977. */
  17978. export class SetValueAction extends Action {
  17979. /**
  17980. * The path of the property to set in the target.
  17981. */
  17982. propertyPath: string;
  17983. /**
  17984. * The value to set in the property
  17985. */
  17986. value: any;
  17987. private _target;
  17988. private _effectiveTarget;
  17989. private _property;
  17990. /**
  17991. * Instantiate the action
  17992. * @param triggerOptions defines the trigger options
  17993. * @param target defines the object containing the property
  17994. * @param propertyPath defines the path of the property to set in the target
  17995. * @param value defines the value to set in the property
  17996. * @param condition defines the trigger related conditions
  17997. */
  17998. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17999. /** @hidden */
  18000. _prepare(): void;
  18001. /**
  18002. * Execute the action and set the targetted property to the desired value.
  18003. */
  18004. execute(): void;
  18005. /**
  18006. * Serializes the actions and its related information.
  18007. * @param parent defines the object to serialize in
  18008. * @returns the serialized object
  18009. */
  18010. serialize(parent: any): any;
  18011. }
  18012. /**
  18013. * This defines an action responsible to increment the target value
  18014. * to a desired value once triggered.
  18015. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18016. */
  18017. export class IncrementValueAction extends Action {
  18018. /**
  18019. * The path of the property to increment in the target.
  18020. */
  18021. propertyPath: string;
  18022. /**
  18023. * The value we should increment the property by.
  18024. */
  18025. value: any;
  18026. private _target;
  18027. private _effectiveTarget;
  18028. private _property;
  18029. /**
  18030. * Instantiate the action
  18031. * @param triggerOptions defines the trigger options
  18032. * @param target defines the object containing the property
  18033. * @param propertyPath defines the path of the property to increment in the target
  18034. * @param value defines the value value we should increment the property by
  18035. * @param condition defines the trigger related conditions
  18036. */
  18037. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  18038. /** @hidden */
  18039. _prepare(): void;
  18040. /**
  18041. * Execute the action and increment the target of the value amount.
  18042. */
  18043. execute(): void;
  18044. /**
  18045. * Serializes the actions and its related information.
  18046. * @param parent defines the object to serialize in
  18047. * @returns the serialized object
  18048. */
  18049. serialize(parent: any): any;
  18050. }
  18051. /**
  18052. * This defines an action responsible to start an animation once triggered.
  18053. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18054. */
  18055. export class PlayAnimationAction extends Action {
  18056. /**
  18057. * Where the animation should start (animation frame)
  18058. */
  18059. from: number;
  18060. /**
  18061. * Where the animation should stop (animation frame)
  18062. */
  18063. to: number;
  18064. /**
  18065. * Define if the animation should loop or stop after the first play.
  18066. */
  18067. loop?: boolean;
  18068. private _target;
  18069. /**
  18070. * Instantiate the action
  18071. * @param triggerOptions defines the trigger options
  18072. * @param target defines the target animation or animation name
  18073. * @param from defines from where the animation should start (animation frame)
  18074. * @param end defines where the animation should stop (animation frame)
  18075. * @param loop defines if the animation should loop or stop after the first play
  18076. * @param condition defines the trigger related conditions
  18077. */
  18078. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  18079. /** @hidden */
  18080. _prepare(): void;
  18081. /**
  18082. * Execute the action and play the animation.
  18083. */
  18084. execute(): void;
  18085. /**
  18086. * Serializes the actions and its related information.
  18087. * @param parent defines the object to serialize in
  18088. * @returns the serialized object
  18089. */
  18090. serialize(parent: any): any;
  18091. }
  18092. /**
  18093. * This defines an action responsible to stop an animation once triggered.
  18094. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18095. */
  18096. export class StopAnimationAction extends Action {
  18097. private _target;
  18098. /**
  18099. * Instantiate the action
  18100. * @param triggerOptions defines the trigger options
  18101. * @param target defines the target animation or animation name
  18102. * @param condition defines the trigger related conditions
  18103. */
  18104. constructor(triggerOptions: any, target: any, condition?: Condition);
  18105. /** @hidden */
  18106. _prepare(): void;
  18107. /**
  18108. * Execute the action and stop the animation.
  18109. */
  18110. execute(): void;
  18111. /**
  18112. * Serializes the actions and its related information.
  18113. * @param parent defines the object to serialize in
  18114. * @returns the serialized object
  18115. */
  18116. serialize(parent: any): any;
  18117. }
  18118. /**
  18119. * This defines an action responsible that does nothing once triggered.
  18120. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18121. */
  18122. export class DoNothingAction extends Action {
  18123. /**
  18124. * Instantiate the action
  18125. * @param triggerOptions defines the trigger options
  18126. * @param condition defines the trigger related conditions
  18127. */
  18128. constructor(triggerOptions?: any, condition?: Condition);
  18129. /**
  18130. * Execute the action and do nothing.
  18131. */
  18132. execute(): void;
  18133. /**
  18134. * Serializes the actions and its related information.
  18135. * @param parent defines the object to serialize in
  18136. * @returns the serialized object
  18137. */
  18138. serialize(parent: any): any;
  18139. }
  18140. /**
  18141. * This defines an action responsible to trigger several actions once triggered.
  18142. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18143. */
  18144. export class CombineAction extends Action {
  18145. /**
  18146. * The list of aggregated animations to run.
  18147. */
  18148. children: Action[];
  18149. /**
  18150. * Instantiate the action
  18151. * @param triggerOptions defines the trigger options
  18152. * @param children defines the list of aggregated animations to run
  18153. * @param condition defines the trigger related conditions
  18154. */
  18155. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  18156. /** @hidden */
  18157. _prepare(): void;
  18158. /**
  18159. * Execute the action and executes all the aggregated actions.
  18160. */
  18161. execute(evt: ActionEvent): void;
  18162. /**
  18163. * Serializes the actions and its related information.
  18164. * @param parent defines the object to serialize in
  18165. * @returns the serialized object
  18166. */
  18167. serialize(parent: any): any;
  18168. }
  18169. /**
  18170. * This defines an action responsible to run code (external event) once triggered.
  18171. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18172. */
  18173. export class ExecuteCodeAction extends Action {
  18174. /**
  18175. * The callback function to run.
  18176. */
  18177. func: (evt: ActionEvent) => void;
  18178. /**
  18179. * Instantiate the action
  18180. * @param triggerOptions defines the trigger options
  18181. * @param func defines the callback function to run
  18182. * @param condition defines the trigger related conditions
  18183. */
  18184. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  18185. /**
  18186. * Execute the action and run the attached code.
  18187. */
  18188. execute(evt: ActionEvent): void;
  18189. }
  18190. /**
  18191. * This defines an action responsible to set the parent property of the target once triggered.
  18192. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18193. */
  18194. export class SetParentAction extends Action {
  18195. private _parent;
  18196. private _target;
  18197. /**
  18198. * Instantiate the action
  18199. * @param triggerOptions defines the trigger options
  18200. * @param target defines the target containing the parent property
  18201. * @param parent defines from where the animation should start (animation frame)
  18202. * @param condition defines the trigger related conditions
  18203. */
  18204. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  18205. /** @hidden */
  18206. _prepare(): void;
  18207. /**
  18208. * Execute the action and set the parent property.
  18209. */
  18210. execute(): void;
  18211. /**
  18212. * Serializes the actions and its related information.
  18213. * @param parent defines the object to serialize in
  18214. * @returns the serialized object
  18215. */
  18216. serialize(parent: any): any;
  18217. }
  18218. }
  18219. declare module "babylonjs/Actions/actionManager" {
  18220. import { Nullable } from "babylonjs/types";
  18221. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18222. import { Scene } from "babylonjs/scene";
  18223. import { IAction } from "babylonjs/Actions/action";
  18224. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  18225. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  18226. /**
  18227. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  18228. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  18229. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18230. */
  18231. export class ActionManager extends AbstractActionManager {
  18232. /**
  18233. * Nothing
  18234. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18235. */
  18236. static readonly NothingTrigger: number;
  18237. /**
  18238. * On pick
  18239. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18240. */
  18241. static readonly OnPickTrigger: number;
  18242. /**
  18243. * On left pick
  18244. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18245. */
  18246. static readonly OnLeftPickTrigger: number;
  18247. /**
  18248. * On right pick
  18249. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18250. */
  18251. static readonly OnRightPickTrigger: number;
  18252. /**
  18253. * On center pick
  18254. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18255. */
  18256. static readonly OnCenterPickTrigger: number;
  18257. /**
  18258. * On pick down
  18259. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18260. */
  18261. static readonly OnPickDownTrigger: number;
  18262. /**
  18263. * On double pick
  18264. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18265. */
  18266. static readonly OnDoublePickTrigger: number;
  18267. /**
  18268. * On pick up
  18269. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18270. */
  18271. static readonly OnPickUpTrigger: number;
  18272. /**
  18273. * On pick out.
  18274. * This trigger will only be raised if you also declared a OnPickDown
  18275. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18276. */
  18277. static readonly OnPickOutTrigger: number;
  18278. /**
  18279. * On long press
  18280. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18281. */
  18282. static readonly OnLongPressTrigger: number;
  18283. /**
  18284. * On pointer over
  18285. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18286. */
  18287. static readonly OnPointerOverTrigger: number;
  18288. /**
  18289. * On pointer out
  18290. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18291. */
  18292. static readonly OnPointerOutTrigger: number;
  18293. /**
  18294. * On every frame
  18295. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18296. */
  18297. static readonly OnEveryFrameTrigger: number;
  18298. /**
  18299. * On intersection enter
  18300. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18301. */
  18302. static readonly OnIntersectionEnterTrigger: number;
  18303. /**
  18304. * On intersection exit
  18305. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18306. */
  18307. static readonly OnIntersectionExitTrigger: number;
  18308. /**
  18309. * On key down
  18310. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18311. */
  18312. static readonly OnKeyDownTrigger: number;
  18313. /**
  18314. * On key up
  18315. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18316. */
  18317. static readonly OnKeyUpTrigger: number;
  18318. private _scene;
  18319. /**
  18320. * Creates a new action manager
  18321. * @param scene defines the hosting scene
  18322. */
  18323. constructor(scene: Scene);
  18324. /**
  18325. * Releases all associated resources
  18326. */
  18327. dispose(): void;
  18328. /**
  18329. * Gets hosting scene
  18330. * @returns the hosting scene
  18331. */
  18332. getScene(): Scene;
  18333. /**
  18334. * Does this action manager handles actions of any of the given triggers
  18335. * @param triggers defines the triggers to be tested
  18336. * @return a boolean indicating whether one (or more) of the triggers is handled
  18337. */
  18338. hasSpecificTriggers(triggers: number[]): boolean;
  18339. /**
  18340. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  18341. * speed.
  18342. * @param triggerA defines the trigger to be tested
  18343. * @param triggerB defines the trigger to be tested
  18344. * @return a boolean indicating whether one (or more) of the triggers is handled
  18345. */
  18346. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  18347. /**
  18348. * Does this action manager handles actions of a given trigger
  18349. * @param trigger defines the trigger to be tested
  18350. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  18351. * @return whether the trigger is handled
  18352. */
  18353. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  18354. /**
  18355. * Does this action manager has pointer triggers
  18356. */
  18357. get hasPointerTriggers(): boolean;
  18358. /**
  18359. * Does this action manager has pick triggers
  18360. */
  18361. get hasPickTriggers(): boolean;
  18362. /**
  18363. * Registers an action to this action manager
  18364. * @param action defines the action to be registered
  18365. * @return the action amended (prepared) after registration
  18366. */
  18367. registerAction(action: IAction): Nullable<IAction>;
  18368. /**
  18369. * Unregisters an action to this action manager
  18370. * @param action defines the action to be unregistered
  18371. * @return a boolean indicating whether the action has been unregistered
  18372. */
  18373. unregisterAction(action: IAction): Boolean;
  18374. /**
  18375. * Process a specific trigger
  18376. * @param trigger defines the trigger to process
  18377. * @param evt defines the event details to be processed
  18378. */
  18379. processTrigger(trigger: number, evt?: IActionEvent): void;
  18380. /** @hidden */
  18381. _getEffectiveTarget(target: any, propertyPath: string): any;
  18382. /** @hidden */
  18383. _getProperty(propertyPath: string): string;
  18384. /**
  18385. * Serialize this manager to a JSON object
  18386. * @param name defines the property name to store this manager
  18387. * @returns a JSON representation of this manager
  18388. */
  18389. serialize(name: string): any;
  18390. /**
  18391. * Creates a new ActionManager from a JSON data
  18392. * @param parsedActions defines the JSON data to read from
  18393. * @param object defines the hosting mesh
  18394. * @param scene defines the hosting scene
  18395. */
  18396. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18397. /**
  18398. * Get a trigger name by index
  18399. * @param trigger defines the trigger index
  18400. * @returns a trigger name
  18401. */
  18402. static GetTriggerName(trigger: number): string;
  18403. }
  18404. }
  18405. declare module "babylonjs/Sprites/sprite" {
  18406. import { Vector3 } from "babylonjs/Maths/math.vector";
  18407. import { Nullable } from "babylonjs/types";
  18408. import { ActionManager } from "babylonjs/Actions/actionManager";
  18409. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18410. import { Color4 } from "babylonjs/Maths/math.color";
  18411. /**
  18412. * Class used to represent a sprite
  18413. * @see http://doc.babylonjs.com/babylon101/sprites
  18414. */
  18415. export class Sprite {
  18416. /** defines the name */
  18417. name: string;
  18418. /** Gets or sets the current world position */
  18419. position: Vector3;
  18420. /** Gets or sets the main color */
  18421. color: Color4;
  18422. /** Gets or sets the width */
  18423. width: number;
  18424. /** Gets or sets the height */
  18425. height: number;
  18426. /** Gets or sets rotation angle */
  18427. angle: number;
  18428. /** Gets or sets the cell index in the sprite sheet */
  18429. cellIndex: number;
  18430. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18431. cellRef: string;
  18432. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18433. invertU: number;
  18434. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18435. invertV: number;
  18436. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18437. disposeWhenFinishedAnimating: boolean;
  18438. /** Gets the list of attached animations */
  18439. animations: Animation[];
  18440. /** Gets or sets a boolean indicating if the sprite can be picked */
  18441. isPickable: boolean;
  18442. /**
  18443. * Gets or sets the associated action manager
  18444. */
  18445. actionManager: Nullable<ActionManager>;
  18446. private _animationStarted;
  18447. private _loopAnimation;
  18448. private _fromIndex;
  18449. private _toIndex;
  18450. private _delay;
  18451. private _direction;
  18452. private _manager;
  18453. private _time;
  18454. private _onAnimationEnd;
  18455. /**
  18456. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18457. */
  18458. isVisible: boolean;
  18459. /**
  18460. * Gets or sets the sprite size
  18461. */
  18462. get size(): number;
  18463. set size(value: number);
  18464. /**
  18465. * Creates a new Sprite
  18466. * @param name defines the name
  18467. * @param manager defines the manager
  18468. */
  18469. constructor(
  18470. /** defines the name */
  18471. name: string, manager: ISpriteManager);
  18472. /**
  18473. * Starts an animation
  18474. * @param from defines the initial key
  18475. * @param to defines the end key
  18476. * @param loop defines if the animation must loop
  18477. * @param delay defines the start delay (in ms)
  18478. * @param onAnimationEnd defines a callback to call when animation ends
  18479. */
  18480. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18481. /** Stops current animation (if any) */
  18482. stopAnimation(): void;
  18483. /** @hidden */
  18484. _animate(deltaTime: number): void;
  18485. /** Release associated resources */
  18486. dispose(): void;
  18487. }
  18488. }
  18489. declare module "babylonjs/Collisions/pickingInfo" {
  18490. import { Nullable } from "babylonjs/types";
  18491. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18492. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18493. import { Sprite } from "babylonjs/Sprites/sprite";
  18494. import { Ray } from "babylonjs/Culling/ray";
  18495. /**
  18496. * Information about the result of picking within a scene
  18497. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18498. */
  18499. export class PickingInfo {
  18500. /** @hidden */
  18501. _pickingUnavailable: boolean;
  18502. /**
  18503. * If the pick collided with an object
  18504. */
  18505. hit: boolean;
  18506. /**
  18507. * Distance away where the pick collided
  18508. */
  18509. distance: number;
  18510. /**
  18511. * The location of pick collision
  18512. */
  18513. pickedPoint: Nullable<Vector3>;
  18514. /**
  18515. * The mesh corresponding the the pick collision
  18516. */
  18517. pickedMesh: Nullable<AbstractMesh>;
  18518. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18519. bu: number;
  18520. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18521. bv: number;
  18522. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18523. faceId: number;
  18524. /** Id of the the submesh that was picked */
  18525. subMeshId: number;
  18526. /** If a sprite was picked, this will be the sprite the pick collided with */
  18527. pickedSprite: Nullable<Sprite>;
  18528. /**
  18529. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18530. */
  18531. originMesh: Nullable<AbstractMesh>;
  18532. /**
  18533. * The ray that was used to perform the picking.
  18534. */
  18535. ray: Nullable<Ray>;
  18536. /**
  18537. * Gets the normal correspodning to the face the pick collided with
  18538. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18539. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18540. * @returns The normal correspodning to the face the pick collided with
  18541. */
  18542. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18543. /**
  18544. * Gets the texture coordinates of where the pick occured
  18545. * @returns the vector containing the coordnates of the texture
  18546. */
  18547. getTextureCoordinates(): Nullable<Vector2>;
  18548. }
  18549. }
  18550. declare module "babylonjs/Events/pointerEvents" {
  18551. import { Nullable } from "babylonjs/types";
  18552. import { Vector2 } from "babylonjs/Maths/math.vector";
  18553. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18554. import { Ray } from "babylonjs/Culling/ray";
  18555. /**
  18556. * Gather the list of pointer event types as constants.
  18557. */
  18558. export class PointerEventTypes {
  18559. /**
  18560. * 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.
  18561. */
  18562. static readonly POINTERDOWN: number;
  18563. /**
  18564. * The pointerup event is fired when a pointer is no longer active.
  18565. */
  18566. static readonly POINTERUP: number;
  18567. /**
  18568. * The pointermove event is fired when a pointer changes coordinates.
  18569. */
  18570. static readonly POINTERMOVE: number;
  18571. /**
  18572. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18573. */
  18574. static readonly POINTERWHEEL: number;
  18575. /**
  18576. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18577. */
  18578. static readonly POINTERPICK: number;
  18579. /**
  18580. * The pointertap event is fired when a the object has been touched and released without drag.
  18581. */
  18582. static readonly POINTERTAP: number;
  18583. /**
  18584. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18585. */
  18586. static readonly POINTERDOUBLETAP: number;
  18587. }
  18588. /**
  18589. * Base class of pointer info types.
  18590. */
  18591. export class PointerInfoBase {
  18592. /**
  18593. * Defines the type of event (PointerEventTypes)
  18594. */
  18595. type: number;
  18596. /**
  18597. * Defines the related dom event
  18598. */
  18599. event: PointerEvent | MouseWheelEvent;
  18600. /**
  18601. * Instantiates the base class of pointers info.
  18602. * @param type Defines the type of event (PointerEventTypes)
  18603. * @param event Defines the related dom event
  18604. */
  18605. constructor(
  18606. /**
  18607. * Defines the type of event (PointerEventTypes)
  18608. */
  18609. type: number,
  18610. /**
  18611. * Defines the related dom event
  18612. */
  18613. event: PointerEvent | MouseWheelEvent);
  18614. }
  18615. /**
  18616. * This class is used to store pointer related info for the onPrePointerObservable event.
  18617. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18618. */
  18619. export class PointerInfoPre extends PointerInfoBase {
  18620. /**
  18621. * Ray from a pointer if availible (eg. 6dof controller)
  18622. */
  18623. ray: Nullable<Ray>;
  18624. /**
  18625. * Defines the local position of the pointer on the canvas.
  18626. */
  18627. localPosition: Vector2;
  18628. /**
  18629. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18630. */
  18631. skipOnPointerObservable: boolean;
  18632. /**
  18633. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18634. * @param type Defines the type of event (PointerEventTypes)
  18635. * @param event Defines the related dom event
  18636. * @param localX Defines the local x coordinates of the pointer when the event occured
  18637. * @param localY Defines the local y coordinates of the pointer when the event occured
  18638. */
  18639. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18640. }
  18641. /**
  18642. * This type contains all the data related to a pointer event in Babylon.js.
  18643. * 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.
  18644. */
  18645. export class PointerInfo extends PointerInfoBase {
  18646. /**
  18647. * Defines the picking info associated to the info (if any)\
  18648. */
  18649. pickInfo: Nullable<PickingInfo>;
  18650. /**
  18651. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18652. * @param type Defines the type of event (PointerEventTypes)
  18653. * @param event Defines the related dom event
  18654. * @param pickInfo Defines the picking info associated to the info (if any)\
  18655. */
  18656. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18657. /**
  18658. * Defines the picking info associated to the info (if any)\
  18659. */
  18660. pickInfo: Nullable<PickingInfo>);
  18661. }
  18662. /**
  18663. * Data relating to a touch event on the screen.
  18664. */
  18665. export interface PointerTouch {
  18666. /**
  18667. * X coordinate of touch.
  18668. */
  18669. x: number;
  18670. /**
  18671. * Y coordinate of touch.
  18672. */
  18673. y: number;
  18674. /**
  18675. * Id of touch. Unique for each finger.
  18676. */
  18677. pointerId: number;
  18678. /**
  18679. * Event type passed from DOM.
  18680. */
  18681. type: any;
  18682. }
  18683. }
  18684. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  18685. import { Observable } from "babylonjs/Misc/observable";
  18686. import { Nullable } from "babylonjs/types";
  18687. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18688. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18689. /**
  18690. * Manage the mouse inputs to control the movement of a free camera.
  18691. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18692. */
  18693. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18694. /**
  18695. * Define if touch is enabled in the mouse input
  18696. */
  18697. touchEnabled: boolean;
  18698. /**
  18699. * Defines the camera the input is attached to.
  18700. */
  18701. camera: FreeCamera;
  18702. /**
  18703. * Defines the buttons associated with the input to handle camera move.
  18704. */
  18705. buttons: number[];
  18706. /**
  18707. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18708. */
  18709. angularSensibility: number;
  18710. private _pointerInput;
  18711. private _onMouseMove;
  18712. private _observer;
  18713. private previousPosition;
  18714. /**
  18715. * Observable for when a pointer move event occurs containing the move offset
  18716. */
  18717. onPointerMovedObservable: Observable<{
  18718. offsetX: number;
  18719. offsetY: number;
  18720. }>;
  18721. /**
  18722. * @hidden
  18723. * If the camera should be rotated automatically based on pointer movement
  18724. */
  18725. _allowCameraRotation: boolean;
  18726. /**
  18727. * Manage the mouse inputs to control the movement of a free camera.
  18728. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18729. * @param touchEnabled Defines if touch is enabled or not
  18730. */
  18731. constructor(
  18732. /**
  18733. * Define if touch is enabled in the mouse input
  18734. */
  18735. touchEnabled?: boolean);
  18736. /**
  18737. * Attach the input controls to a specific dom element to get the input from.
  18738. * @param element Defines the element the controls should be listened from
  18739. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18740. */
  18741. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18742. /**
  18743. * Called on JS contextmenu event.
  18744. * Override this method to provide functionality.
  18745. */
  18746. protected onContextMenu(evt: PointerEvent): void;
  18747. /**
  18748. * Detach the current controls from the specified dom element.
  18749. * @param element Defines the element to stop listening the inputs from
  18750. */
  18751. detachControl(element: Nullable<HTMLElement>): void;
  18752. /**
  18753. * Gets the class name of the current intput.
  18754. * @returns the class name
  18755. */
  18756. getClassName(): string;
  18757. /**
  18758. * Get the friendly name associated with the input class.
  18759. * @returns the input friendly name
  18760. */
  18761. getSimpleName(): string;
  18762. }
  18763. }
  18764. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  18765. import { Nullable } from "babylonjs/types";
  18766. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18767. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18768. /**
  18769. * Manage the touch inputs to control the movement of a free camera.
  18770. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18771. */
  18772. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18773. /**
  18774. * Defines the camera the input is attached to.
  18775. */
  18776. camera: FreeCamera;
  18777. /**
  18778. * Defines the touch sensibility for rotation.
  18779. * The higher the faster.
  18780. */
  18781. touchAngularSensibility: number;
  18782. /**
  18783. * Defines the touch sensibility for move.
  18784. * The higher the faster.
  18785. */
  18786. touchMoveSensibility: number;
  18787. private _offsetX;
  18788. private _offsetY;
  18789. private _pointerPressed;
  18790. private _pointerInput;
  18791. private _observer;
  18792. private _onLostFocus;
  18793. /**
  18794. * Attach the input controls to a specific dom element to get the input from.
  18795. * @param element Defines the element the controls should be listened from
  18796. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18797. */
  18798. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18799. /**
  18800. * Detach the current controls from the specified dom element.
  18801. * @param element Defines the element to stop listening the inputs from
  18802. */
  18803. detachControl(element: Nullable<HTMLElement>): void;
  18804. /**
  18805. * Update the current camera state depending on the inputs that have been used this frame.
  18806. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18807. */
  18808. checkInputs(): void;
  18809. /**
  18810. * Gets the class name of the current intput.
  18811. * @returns the class name
  18812. */
  18813. getClassName(): string;
  18814. /**
  18815. * Get the friendly name associated with the input class.
  18816. * @returns the input friendly name
  18817. */
  18818. getSimpleName(): string;
  18819. }
  18820. }
  18821. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  18822. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18823. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  18824. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  18825. import { Nullable } from "babylonjs/types";
  18826. /**
  18827. * Default Inputs manager for the FreeCamera.
  18828. * It groups all the default supported inputs for ease of use.
  18829. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18830. */
  18831. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18832. /**
  18833. * @hidden
  18834. */
  18835. _mouseInput: Nullable<FreeCameraMouseInput>;
  18836. /**
  18837. * Instantiates a new FreeCameraInputsManager.
  18838. * @param camera Defines the camera the inputs belong to
  18839. */
  18840. constructor(camera: FreeCamera);
  18841. /**
  18842. * Add keyboard input support to the input manager.
  18843. * @returns the current input manager
  18844. */
  18845. addKeyboard(): FreeCameraInputsManager;
  18846. /**
  18847. * Add mouse input support to the input manager.
  18848. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18849. * @returns the current input manager
  18850. */
  18851. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18852. /**
  18853. * Removes the mouse input support from the manager
  18854. * @returns the current input manager
  18855. */
  18856. removeMouse(): FreeCameraInputsManager;
  18857. /**
  18858. * Add touch input support to the input manager.
  18859. * @returns the current input manager
  18860. */
  18861. addTouch(): FreeCameraInputsManager;
  18862. /**
  18863. * Remove all attached input methods from a camera
  18864. */
  18865. clear(): void;
  18866. }
  18867. }
  18868. declare module "babylonjs/Cameras/freeCamera" {
  18869. import { Vector3 } from "babylonjs/Maths/math.vector";
  18870. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18871. import { Scene } from "babylonjs/scene";
  18872. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  18873. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  18874. /**
  18875. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18876. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18877. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18878. */
  18879. export class FreeCamera extends TargetCamera {
  18880. /**
  18881. * Define the collision ellipsoid of the camera.
  18882. * This is helpful to simulate a camera body like the player body around the camera
  18883. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18884. */
  18885. ellipsoid: Vector3;
  18886. /**
  18887. * Define an offset for the position of the ellipsoid around the camera.
  18888. * This can be helpful to determine the center of the body near the gravity center of the body
  18889. * instead of its head.
  18890. */
  18891. ellipsoidOffset: Vector3;
  18892. /**
  18893. * Enable or disable collisions of the camera with the rest of the scene objects.
  18894. */
  18895. checkCollisions: boolean;
  18896. /**
  18897. * Enable or disable gravity on the camera.
  18898. */
  18899. applyGravity: boolean;
  18900. /**
  18901. * Define the input manager associated to the camera.
  18902. */
  18903. inputs: FreeCameraInputsManager;
  18904. /**
  18905. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18906. * Higher values reduce sensitivity.
  18907. */
  18908. get angularSensibility(): number;
  18909. /**
  18910. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18911. * Higher values reduce sensitivity.
  18912. */
  18913. set angularSensibility(value: number);
  18914. /**
  18915. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18916. */
  18917. get keysUp(): number[];
  18918. set keysUp(value: number[]);
  18919. /**
  18920. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18921. */
  18922. get keysUpward(): number[];
  18923. set keysUpward(value: number[]);
  18924. /**
  18925. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18926. */
  18927. get keysDown(): number[];
  18928. set keysDown(value: number[]);
  18929. /**
  18930. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18931. */
  18932. get keysDownward(): number[];
  18933. set keysDownward(value: number[]);
  18934. /**
  18935. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18936. */
  18937. get keysLeft(): number[];
  18938. set keysLeft(value: number[]);
  18939. /**
  18940. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18941. */
  18942. get keysRight(): number[];
  18943. set keysRight(value: number[]);
  18944. /**
  18945. * Event raised when the camera collide with a mesh in the scene.
  18946. */
  18947. onCollide: (collidedMesh: AbstractMesh) => void;
  18948. private _collider;
  18949. private _needMoveForGravity;
  18950. private _oldPosition;
  18951. private _diffPosition;
  18952. private _newPosition;
  18953. /** @hidden */
  18954. _localDirection: Vector3;
  18955. /** @hidden */
  18956. _transformedDirection: Vector3;
  18957. /**
  18958. * Instantiates a Free Camera.
  18959. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18960. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18961. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18962. * @param name Define the name of the camera in the scene
  18963. * @param position Define the start position of the camera in the scene
  18964. * @param scene Define the scene the camera belongs to
  18965. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18966. */
  18967. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18968. /**
  18969. * Attached controls to the current camera.
  18970. * @param element Defines the element the controls should be listened from
  18971. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18972. */
  18973. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18974. /**
  18975. * Detach the current controls from the camera.
  18976. * The camera will stop reacting to inputs.
  18977. * @param element Defines the element to stop listening the inputs from
  18978. */
  18979. detachControl(element: HTMLElement): void;
  18980. private _collisionMask;
  18981. /**
  18982. * Define a collision mask to limit the list of object the camera can collide with
  18983. */
  18984. get collisionMask(): number;
  18985. set collisionMask(mask: number);
  18986. /** @hidden */
  18987. _collideWithWorld(displacement: Vector3): void;
  18988. private _onCollisionPositionChange;
  18989. /** @hidden */
  18990. _checkInputs(): void;
  18991. /** @hidden */
  18992. _decideIfNeedsToMove(): boolean;
  18993. /** @hidden */
  18994. _updatePosition(): void;
  18995. /**
  18996. * Destroy the camera and release the current resources hold by it.
  18997. */
  18998. dispose(): void;
  18999. /**
  19000. * Gets the current object class name.
  19001. * @return the class name
  19002. */
  19003. getClassName(): string;
  19004. }
  19005. }
  19006. declare module "babylonjs/Gamepads/gamepad" {
  19007. import { Observable } from "babylonjs/Misc/observable";
  19008. /**
  19009. * Represents a gamepad control stick position
  19010. */
  19011. export class StickValues {
  19012. /**
  19013. * The x component of the control stick
  19014. */
  19015. x: number;
  19016. /**
  19017. * The y component of the control stick
  19018. */
  19019. y: number;
  19020. /**
  19021. * Initializes the gamepad x and y control stick values
  19022. * @param x The x component of the gamepad control stick value
  19023. * @param y The y component of the gamepad control stick value
  19024. */
  19025. constructor(
  19026. /**
  19027. * The x component of the control stick
  19028. */
  19029. x: number,
  19030. /**
  19031. * The y component of the control stick
  19032. */
  19033. y: number);
  19034. }
  19035. /**
  19036. * An interface which manages callbacks for gamepad button changes
  19037. */
  19038. export interface GamepadButtonChanges {
  19039. /**
  19040. * Called when a gamepad has been changed
  19041. */
  19042. changed: boolean;
  19043. /**
  19044. * Called when a gamepad press event has been triggered
  19045. */
  19046. pressChanged: boolean;
  19047. /**
  19048. * Called when a touch event has been triggered
  19049. */
  19050. touchChanged: boolean;
  19051. /**
  19052. * Called when a value has changed
  19053. */
  19054. valueChanged: boolean;
  19055. }
  19056. /**
  19057. * Represents a gamepad
  19058. */
  19059. export class Gamepad {
  19060. /**
  19061. * The id of the gamepad
  19062. */
  19063. id: string;
  19064. /**
  19065. * The index of the gamepad
  19066. */
  19067. index: number;
  19068. /**
  19069. * The browser gamepad
  19070. */
  19071. browserGamepad: any;
  19072. /**
  19073. * Specifies what type of gamepad this represents
  19074. */
  19075. type: number;
  19076. private _leftStick;
  19077. private _rightStick;
  19078. /** @hidden */
  19079. _isConnected: boolean;
  19080. private _leftStickAxisX;
  19081. private _leftStickAxisY;
  19082. private _rightStickAxisX;
  19083. private _rightStickAxisY;
  19084. /**
  19085. * Triggered when the left control stick has been changed
  19086. */
  19087. private _onleftstickchanged;
  19088. /**
  19089. * Triggered when the right control stick has been changed
  19090. */
  19091. private _onrightstickchanged;
  19092. /**
  19093. * Represents a gamepad controller
  19094. */
  19095. static GAMEPAD: number;
  19096. /**
  19097. * Represents a generic controller
  19098. */
  19099. static GENERIC: number;
  19100. /**
  19101. * Represents an XBox controller
  19102. */
  19103. static XBOX: number;
  19104. /**
  19105. * Represents a pose-enabled controller
  19106. */
  19107. static POSE_ENABLED: number;
  19108. /**
  19109. * Represents an Dual Shock controller
  19110. */
  19111. static DUALSHOCK: number;
  19112. /**
  19113. * Specifies whether the left control stick should be Y-inverted
  19114. */
  19115. protected _invertLeftStickY: boolean;
  19116. /**
  19117. * Specifies if the gamepad has been connected
  19118. */
  19119. get isConnected(): boolean;
  19120. /**
  19121. * Initializes the gamepad
  19122. * @param id The id of the gamepad
  19123. * @param index The index of the gamepad
  19124. * @param browserGamepad The browser gamepad
  19125. * @param leftStickX The x component of the left joystick
  19126. * @param leftStickY The y component of the left joystick
  19127. * @param rightStickX The x component of the right joystick
  19128. * @param rightStickY The y component of the right joystick
  19129. */
  19130. constructor(
  19131. /**
  19132. * The id of the gamepad
  19133. */
  19134. id: string,
  19135. /**
  19136. * The index of the gamepad
  19137. */
  19138. index: number,
  19139. /**
  19140. * The browser gamepad
  19141. */
  19142. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19143. /**
  19144. * Callback triggered when the left joystick has changed
  19145. * @param callback
  19146. */
  19147. onleftstickchanged(callback: (values: StickValues) => void): void;
  19148. /**
  19149. * Callback triggered when the right joystick has changed
  19150. * @param callback
  19151. */
  19152. onrightstickchanged(callback: (values: StickValues) => void): void;
  19153. /**
  19154. * Gets the left joystick
  19155. */
  19156. get leftStick(): StickValues;
  19157. /**
  19158. * Sets the left joystick values
  19159. */
  19160. set leftStick(newValues: StickValues);
  19161. /**
  19162. * Gets the right joystick
  19163. */
  19164. get rightStick(): StickValues;
  19165. /**
  19166. * Sets the right joystick value
  19167. */
  19168. set rightStick(newValues: StickValues);
  19169. /**
  19170. * Updates the gamepad joystick positions
  19171. */
  19172. update(): void;
  19173. /**
  19174. * Disposes the gamepad
  19175. */
  19176. dispose(): void;
  19177. }
  19178. /**
  19179. * Represents a generic gamepad
  19180. */
  19181. export class GenericPad extends Gamepad {
  19182. private _buttons;
  19183. private _onbuttondown;
  19184. private _onbuttonup;
  19185. /**
  19186. * Observable triggered when a button has been pressed
  19187. */
  19188. onButtonDownObservable: Observable<number>;
  19189. /**
  19190. * Observable triggered when a button has been released
  19191. */
  19192. onButtonUpObservable: Observable<number>;
  19193. /**
  19194. * Callback triggered when a button has been pressed
  19195. * @param callback Called when a button has been pressed
  19196. */
  19197. onbuttondown(callback: (buttonPressed: number) => void): void;
  19198. /**
  19199. * Callback triggered when a button has been released
  19200. * @param callback Called when a button has been released
  19201. */
  19202. onbuttonup(callback: (buttonReleased: number) => void): void;
  19203. /**
  19204. * Initializes the generic gamepad
  19205. * @param id The id of the generic gamepad
  19206. * @param index The index of the generic gamepad
  19207. * @param browserGamepad The browser gamepad
  19208. */
  19209. constructor(id: string, index: number, browserGamepad: any);
  19210. private _setButtonValue;
  19211. /**
  19212. * Updates the generic gamepad
  19213. */
  19214. update(): void;
  19215. /**
  19216. * Disposes the generic gamepad
  19217. */
  19218. dispose(): void;
  19219. }
  19220. }
  19221. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19222. import { Observable } from "babylonjs/Misc/observable";
  19223. import { Nullable } from "babylonjs/types";
  19224. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19225. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19226. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19227. import { Ray } from "babylonjs/Culling/ray";
  19228. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19229. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19230. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19231. /**
  19232. * Defines the types of pose enabled controllers that are supported
  19233. */
  19234. export enum PoseEnabledControllerType {
  19235. /**
  19236. * HTC Vive
  19237. */
  19238. VIVE = 0,
  19239. /**
  19240. * Oculus Rift
  19241. */
  19242. OCULUS = 1,
  19243. /**
  19244. * Windows mixed reality
  19245. */
  19246. WINDOWS = 2,
  19247. /**
  19248. * Samsung gear VR
  19249. */
  19250. GEAR_VR = 3,
  19251. /**
  19252. * Google Daydream
  19253. */
  19254. DAYDREAM = 4,
  19255. /**
  19256. * Generic
  19257. */
  19258. GENERIC = 5
  19259. }
  19260. /**
  19261. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19262. */
  19263. export interface MutableGamepadButton {
  19264. /**
  19265. * Value of the button/trigger
  19266. */
  19267. value: number;
  19268. /**
  19269. * If the button/trigger is currently touched
  19270. */
  19271. touched: boolean;
  19272. /**
  19273. * If the button/trigger is currently pressed
  19274. */
  19275. pressed: boolean;
  19276. }
  19277. /**
  19278. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19279. * @hidden
  19280. */
  19281. export interface ExtendedGamepadButton extends GamepadButton {
  19282. /**
  19283. * If the button/trigger is currently pressed
  19284. */
  19285. readonly pressed: boolean;
  19286. /**
  19287. * If the button/trigger is currently touched
  19288. */
  19289. readonly touched: boolean;
  19290. /**
  19291. * Value of the button/trigger
  19292. */
  19293. readonly value: number;
  19294. }
  19295. /** @hidden */
  19296. export interface _GamePadFactory {
  19297. /**
  19298. * Returns whether or not the current gamepad can be created for this type of controller.
  19299. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19300. * @returns true if it can be created, otherwise false
  19301. */
  19302. canCreate(gamepadInfo: any): boolean;
  19303. /**
  19304. * Creates a new instance of the Gamepad.
  19305. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19306. * @returns the new gamepad instance
  19307. */
  19308. create(gamepadInfo: any): Gamepad;
  19309. }
  19310. /**
  19311. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19312. */
  19313. export class PoseEnabledControllerHelper {
  19314. /** @hidden */
  19315. static _ControllerFactories: _GamePadFactory[];
  19316. /** @hidden */
  19317. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19318. /**
  19319. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19320. * @param vrGamepad the gamepad to initialized
  19321. * @returns a vr controller of the type the gamepad identified as
  19322. */
  19323. static InitiateController(vrGamepad: any): Gamepad;
  19324. }
  19325. /**
  19326. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19327. */
  19328. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19329. /**
  19330. * If the controller is used in a webXR session
  19331. */
  19332. isXR: boolean;
  19333. private _deviceRoomPosition;
  19334. private _deviceRoomRotationQuaternion;
  19335. /**
  19336. * The device position in babylon space
  19337. */
  19338. devicePosition: Vector3;
  19339. /**
  19340. * The device rotation in babylon space
  19341. */
  19342. deviceRotationQuaternion: Quaternion;
  19343. /**
  19344. * The scale factor of the device in babylon space
  19345. */
  19346. deviceScaleFactor: number;
  19347. /**
  19348. * (Likely devicePosition should be used instead) The device position in its room space
  19349. */
  19350. position: Vector3;
  19351. /**
  19352. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19353. */
  19354. rotationQuaternion: Quaternion;
  19355. /**
  19356. * The type of controller (Eg. Windows mixed reality)
  19357. */
  19358. controllerType: PoseEnabledControllerType;
  19359. protected _calculatedPosition: Vector3;
  19360. private _calculatedRotation;
  19361. /**
  19362. * The raw pose from the device
  19363. */
  19364. rawPose: DevicePose;
  19365. private _trackPosition;
  19366. private _maxRotationDistFromHeadset;
  19367. private _draggedRoomRotation;
  19368. /**
  19369. * @hidden
  19370. */
  19371. _disableTrackPosition(fixedPosition: Vector3): void;
  19372. /**
  19373. * Internal, the mesh attached to the controller
  19374. * @hidden
  19375. */
  19376. _mesh: Nullable<AbstractMesh>;
  19377. private _poseControlledCamera;
  19378. private _leftHandSystemQuaternion;
  19379. /**
  19380. * Internal, matrix used to convert room space to babylon space
  19381. * @hidden
  19382. */
  19383. _deviceToWorld: Matrix;
  19384. /**
  19385. * Node to be used when casting a ray from the controller
  19386. * @hidden
  19387. */
  19388. _pointingPoseNode: Nullable<TransformNode>;
  19389. /**
  19390. * Name of the child mesh that can be used to cast a ray from the controller
  19391. */
  19392. static readonly POINTING_POSE: string;
  19393. /**
  19394. * Creates a new PoseEnabledController from a gamepad
  19395. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19396. */
  19397. constructor(browserGamepad: any);
  19398. private _workingMatrix;
  19399. /**
  19400. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19401. */
  19402. update(): void;
  19403. /**
  19404. * Updates only the pose device and mesh without doing any button event checking
  19405. */
  19406. protected _updatePoseAndMesh(): void;
  19407. /**
  19408. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19409. * @param poseData raw pose fromthe device
  19410. */
  19411. updateFromDevice(poseData: DevicePose): void;
  19412. /**
  19413. * @hidden
  19414. */
  19415. _meshAttachedObservable: Observable<AbstractMesh>;
  19416. /**
  19417. * Attaches a mesh to the controller
  19418. * @param mesh the mesh to be attached
  19419. */
  19420. attachToMesh(mesh: AbstractMesh): void;
  19421. /**
  19422. * Attaches the controllers mesh to a camera
  19423. * @param camera the camera the mesh should be attached to
  19424. */
  19425. attachToPoseControlledCamera(camera: TargetCamera): void;
  19426. /**
  19427. * Disposes of the controller
  19428. */
  19429. dispose(): void;
  19430. /**
  19431. * The mesh that is attached to the controller
  19432. */
  19433. get mesh(): Nullable<AbstractMesh>;
  19434. /**
  19435. * Gets the ray of the controller in the direction the controller is pointing
  19436. * @param length the length the resulting ray should be
  19437. * @returns a ray in the direction the controller is pointing
  19438. */
  19439. getForwardRay(length?: number): Ray;
  19440. }
  19441. }
  19442. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19443. import { Observable } from "babylonjs/Misc/observable";
  19444. import { Scene } from "babylonjs/scene";
  19445. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19446. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19447. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19448. import { Nullable } from "babylonjs/types";
  19449. /**
  19450. * Defines the WebVRController object that represents controllers tracked in 3D space
  19451. */
  19452. export abstract class WebVRController extends PoseEnabledController {
  19453. /**
  19454. * Internal, the default controller model for the controller
  19455. */
  19456. protected _defaultModel: Nullable<AbstractMesh>;
  19457. /**
  19458. * Fired when the trigger state has changed
  19459. */
  19460. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19461. /**
  19462. * Fired when the main button state has changed
  19463. */
  19464. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19465. /**
  19466. * Fired when the secondary button state has changed
  19467. */
  19468. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19469. /**
  19470. * Fired when the pad state has changed
  19471. */
  19472. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19473. /**
  19474. * Fired when controllers stick values have changed
  19475. */
  19476. onPadValuesChangedObservable: Observable<StickValues>;
  19477. /**
  19478. * Array of button availible on the controller
  19479. */
  19480. protected _buttons: Array<MutableGamepadButton>;
  19481. private _onButtonStateChange;
  19482. /**
  19483. * Fired when a controller button's state has changed
  19484. * @param callback the callback containing the button that was modified
  19485. */
  19486. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19487. /**
  19488. * X and Y axis corresponding to the controllers joystick
  19489. */
  19490. pad: StickValues;
  19491. /**
  19492. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19493. */
  19494. hand: string;
  19495. /**
  19496. * The default controller model for the controller
  19497. */
  19498. get defaultModel(): Nullable<AbstractMesh>;
  19499. /**
  19500. * Creates a new WebVRController from a gamepad
  19501. * @param vrGamepad the gamepad that the WebVRController should be created from
  19502. */
  19503. constructor(vrGamepad: any);
  19504. /**
  19505. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19506. */
  19507. update(): void;
  19508. /**
  19509. * Function to be called when a button is modified
  19510. */
  19511. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19512. /**
  19513. * Loads a mesh and attaches it to the controller
  19514. * @param scene the scene the mesh should be added to
  19515. * @param meshLoaded callback for when the mesh has been loaded
  19516. */
  19517. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19518. private _setButtonValue;
  19519. private _changes;
  19520. private _checkChanges;
  19521. /**
  19522. * Disposes of th webVRCOntroller
  19523. */
  19524. dispose(): void;
  19525. }
  19526. }
  19527. declare module "babylonjs/Lights/hemisphericLight" {
  19528. import { Nullable } from "babylonjs/types";
  19529. import { Scene } from "babylonjs/scene";
  19530. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19531. import { Color3 } from "babylonjs/Maths/math.color";
  19532. import { Effect } from "babylonjs/Materials/effect";
  19533. import { Light } from "babylonjs/Lights/light";
  19534. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19535. /**
  19536. * The HemisphericLight simulates the ambient environment light,
  19537. * so the passed direction is the light reflection direction, not the incoming direction.
  19538. */
  19539. export class HemisphericLight extends Light {
  19540. /**
  19541. * The groundColor is the light in the opposite direction to the one specified during creation.
  19542. * 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.
  19543. */
  19544. groundColor: Color3;
  19545. /**
  19546. * The light reflection direction, not the incoming direction.
  19547. */
  19548. direction: Vector3;
  19549. /**
  19550. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19551. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19552. * The HemisphericLight can't cast shadows.
  19553. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19554. * @param name The friendly name of the light
  19555. * @param direction The direction of the light reflection
  19556. * @param scene The scene the light belongs to
  19557. */
  19558. constructor(name: string, direction: Vector3, scene: Scene);
  19559. protected _buildUniformLayout(): void;
  19560. /**
  19561. * Returns the string "HemisphericLight".
  19562. * @return The class name
  19563. */
  19564. getClassName(): string;
  19565. /**
  19566. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19567. * Returns the updated direction.
  19568. * @param target The target the direction should point to
  19569. * @return The computed direction
  19570. */
  19571. setDirectionToTarget(target: Vector3): Vector3;
  19572. /**
  19573. * Returns the shadow generator associated to the light.
  19574. * @returns Always null for hemispheric lights because it does not support shadows.
  19575. */
  19576. getShadowGenerator(): Nullable<IShadowGenerator>;
  19577. /**
  19578. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19579. * @param effect The effect to update
  19580. * @param lightIndex The index of the light in the effect to update
  19581. * @returns The hemispheric light
  19582. */
  19583. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19584. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19585. /**
  19586. * Computes the world matrix of the node
  19587. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19588. * @param useWasUpdatedFlag defines a reserved property
  19589. * @returns the world matrix
  19590. */
  19591. computeWorldMatrix(): Matrix;
  19592. /**
  19593. * Returns the integer 3.
  19594. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19595. */
  19596. getTypeID(): number;
  19597. /**
  19598. * Prepares the list of defines specific to the light type.
  19599. * @param defines the list of defines
  19600. * @param lightIndex defines the index of the light for the effect
  19601. */
  19602. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19603. }
  19604. }
  19605. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  19606. /** @hidden */
  19607. export var vrMultiviewToSingleviewPixelShader: {
  19608. name: string;
  19609. shader: string;
  19610. };
  19611. }
  19612. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  19613. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19614. import { Scene } from "babylonjs/scene";
  19615. /**
  19616. * Renders to multiple views with a single draw call
  19617. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19618. */
  19619. export class MultiviewRenderTarget extends RenderTargetTexture {
  19620. /**
  19621. * Creates a multiview render target
  19622. * @param scene scene used with the render target
  19623. * @param size the size of the render target (used for each view)
  19624. */
  19625. constructor(scene: Scene, size?: number | {
  19626. width: number;
  19627. height: number;
  19628. } | {
  19629. ratio: number;
  19630. });
  19631. /**
  19632. * @hidden
  19633. * @param faceIndex the face index, if its a cube texture
  19634. */
  19635. _bindFrameBuffer(faceIndex?: number): void;
  19636. /**
  19637. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19638. * @returns the view count
  19639. */
  19640. getViewCount(): number;
  19641. }
  19642. }
  19643. declare module "babylonjs/Maths/math.frustum" {
  19644. import { Matrix } from "babylonjs/Maths/math.vector";
  19645. import { DeepImmutable } from "babylonjs/types";
  19646. import { Plane } from "babylonjs/Maths/math.plane";
  19647. /**
  19648. * Represents a camera frustum
  19649. */
  19650. export class Frustum {
  19651. /**
  19652. * Gets the planes representing the frustum
  19653. * @param transform matrix to be applied to the returned planes
  19654. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19655. */
  19656. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19657. /**
  19658. * Gets the near frustum plane transformed by the transform matrix
  19659. * @param transform transformation matrix to be applied to the resulting frustum plane
  19660. * @param frustumPlane the resuling frustum plane
  19661. */
  19662. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19663. /**
  19664. * Gets the far frustum plane transformed by the transform matrix
  19665. * @param transform transformation matrix to be applied to the resulting frustum plane
  19666. * @param frustumPlane the resuling frustum plane
  19667. */
  19668. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19669. /**
  19670. * Gets the left frustum plane transformed by the transform matrix
  19671. * @param transform transformation matrix to be applied to the resulting frustum plane
  19672. * @param frustumPlane the resuling frustum plane
  19673. */
  19674. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19675. /**
  19676. * Gets the right frustum plane transformed by the transform matrix
  19677. * @param transform transformation matrix to be applied to the resulting frustum plane
  19678. * @param frustumPlane the resuling frustum plane
  19679. */
  19680. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19681. /**
  19682. * Gets the top frustum plane transformed by the transform matrix
  19683. * @param transform transformation matrix to be applied to the resulting frustum plane
  19684. * @param frustumPlane the resuling frustum plane
  19685. */
  19686. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19687. /**
  19688. * Gets the bottom frustum plane transformed by the transform matrix
  19689. * @param transform transformation matrix to be applied to the resulting frustum plane
  19690. * @param frustumPlane the resuling frustum plane
  19691. */
  19692. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19693. /**
  19694. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19695. * @param transform transformation matrix to be applied to the resulting frustum planes
  19696. * @param frustumPlanes the resuling frustum planes
  19697. */
  19698. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19699. }
  19700. }
  19701. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  19702. import { Camera } from "babylonjs/Cameras/camera";
  19703. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19704. import { Nullable } from "babylonjs/types";
  19705. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19706. import { Matrix } from "babylonjs/Maths/math.vector";
  19707. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19708. module "babylonjs/Engines/engine" {
  19709. interface Engine {
  19710. /**
  19711. * Creates a new multiview render target
  19712. * @param width defines the width of the texture
  19713. * @param height defines the height of the texture
  19714. * @returns the created multiview texture
  19715. */
  19716. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19717. /**
  19718. * Binds a multiview framebuffer to be drawn to
  19719. * @param multiviewTexture texture to bind
  19720. */
  19721. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19722. }
  19723. }
  19724. module "babylonjs/Cameras/camera" {
  19725. interface Camera {
  19726. /**
  19727. * @hidden
  19728. * 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)
  19729. */
  19730. _useMultiviewToSingleView: boolean;
  19731. /**
  19732. * @hidden
  19733. * 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)
  19734. */
  19735. _multiviewTexture: Nullable<RenderTargetTexture>;
  19736. /**
  19737. * @hidden
  19738. * ensures the multiview texture of the camera exists and has the specified width/height
  19739. * @param width height to set on the multiview texture
  19740. * @param height width to set on the multiview texture
  19741. */
  19742. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19743. }
  19744. }
  19745. module "babylonjs/scene" {
  19746. interface Scene {
  19747. /** @hidden */
  19748. _transformMatrixR: Matrix;
  19749. /** @hidden */
  19750. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19751. /** @hidden */
  19752. _createMultiviewUbo(): void;
  19753. /** @hidden */
  19754. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19755. /** @hidden */
  19756. _renderMultiviewToSingleView(camera: Camera): void;
  19757. }
  19758. }
  19759. }
  19760. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  19761. import { Camera } from "babylonjs/Cameras/camera";
  19762. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19763. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  19764. import "babylonjs/Engines/Extensions/engine.multiview";
  19765. /**
  19766. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19767. * This will not be used for webXR as it supports displaying texture arrays directly
  19768. */
  19769. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19770. /**
  19771. * Initializes a VRMultiviewToSingleview
  19772. * @param name name of the post process
  19773. * @param camera camera to be applied to
  19774. * @param scaleFactor scaling factor to the size of the output texture
  19775. */
  19776. constructor(name: string, camera: Camera, scaleFactor: number);
  19777. }
  19778. }
  19779. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  19780. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  19781. import { Nullable } from "babylonjs/types";
  19782. import { Size } from "babylonjs/Maths/math.size";
  19783. import { Observable } from "babylonjs/Misc/observable";
  19784. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  19785. /**
  19786. * Interface used to define additional presentation attributes
  19787. */
  19788. export interface IVRPresentationAttributes {
  19789. /**
  19790. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19791. */
  19792. highRefreshRate: boolean;
  19793. /**
  19794. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19795. */
  19796. foveationLevel: number;
  19797. }
  19798. module "babylonjs/Engines/engine" {
  19799. interface Engine {
  19800. /** @hidden */
  19801. _vrDisplay: any;
  19802. /** @hidden */
  19803. _vrSupported: boolean;
  19804. /** @hidden */
  19805. _oldSize: Size;
  19806. /** @hidden */
  19807. _oldHardwareScaleFactor: number;
  19808. /** @hidden */
  19809. _vrExclusivePointerMode: boolean;
  19810. /** @hidden */
  19811. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19812. /** @hidden */
  19813. _onVRDisplayPointerRestricted: () => void;
  19814. /** @hidden */
  19815. _onVRDisplayPointerUnrestricted: () => void;
  19816. /** @hidden */
  19817. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19818. /** @hidden */
  19819. _onVrDisplayDisconnect: Nullable<() => void>;
  19820. /** @hidden */
  19821. _onVrDisplayPresentChange: Nullable<() => void>;
  19822. /**
  19823. * Observable signaled when VR display mode changes
  19824. */
  19825. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19826. /**
  19827. * Observable signaled when VR request present is complete
  19828. */
  19829. onVRRequestPresentComplete: Observable<boolean>;
  19830. /**
  19831. * Observable signaled when VR request present starts
  19832. */
  19833. onVRRequestPresentStart: Observable<Engine>;
  19834. /**
  19835. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19836. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19837. */
  19838. isInVRExclusivePointerMode: boolean;
  19839. /**
  19840. * Gets a boolean indicating if a webVR device was detected
  19841. * @returns true if a webVR device was detected
  19842. */
  19843. isVRDevicePresent(): boolean;
  19844. /**
  19845. * Gets the current webVR device
  19846. * @returns the current webVR device (or null)
  19847. */
  19848. getVRDevice(): any;
  19849. /**
  19850. * Initializes a webVR display and starts listening to display change events
  19851. * The onVRDisplayChangedObservable will be notified upon these changes
  19852. * @returns A promise containing a VRDisplay and if vr is supported
  19853. */
  19854. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19855. /** @hidden */
  19856. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19857. /**
  19858. * Gets or sets the presentation attributes used to configure VR rendering
  19859. */
  19860. vrPresentationAttributes?: IVRPresentationAttributes;
  19861. /**
  19862. * Call this function to switch to webVR mode
  19863. * Will do nothing if webVR is not supported or if there is no webVR device
  19864. * @param options the webvr options provided to the camera. mainly used for multiview
  19865. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19866. */
  19867. enableVR(options: WebVROptions): void;
  19868. /** @hidden */
  19869. _onVRFullScreenTriggered(): void;
  19870. }
  19871. }
  19872. }
  19873. declare module "babylonjs/Cameras/VR/webVRCamera" {
  19874. import { Nullable } from "babylonjs/types";
  19875. import { Observable } from "babylonjs/Misc/observable";
  19876. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19877. import { Scene } from "babylonjs/scene";
  19878. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19879. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  19880. import { Node } from "babylonjs/node";
  19881. import { Ray } from "babylonjs/Culling/ray";
  19882. import "babylonjs/Cameras/RigModes/webVRRigMode";
  19883. import "babylonjs/Engines/Extensions/engine.webVR";
  19884. /**
  19885. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19886. * IMPORTANT!! The data is right-hand data.
  19887. * @export
  19888. * @interface DevicePose
  19889. */
  19890. export interface DevicePose {
  19891. /**
  19892. * The position of the device, values in array are [x,y,z].
  19893. */
  19894. readonly position: Nullable<Float32Array>;
  19895. /**
  19896. * The linearVelocity of the device, values in array are [x,y,z].
  19897. */
  19898. readonly linearVelocity: Nullable<Float32Array>;
  19899. /**
  19900. * The linearAcceleration of the device, values in array are [x,y,z].
  19901. */
  19902. readonly linearAcceleration: Nullable<Float32Array>;
  19903. /**
  19904. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19905. */
  19906. readonly orientation: Nullable<Float32Array>;
  19907. /**
  19908. * The angularVelocity of the device, values in array are [x,y,z].
  19909. */
  19910. readonly angularVelocity: Nullable<Float32Array>;
  19911. /**
  19912. * The angularAcceleration of the device, values in array are [x,y,z].
  19913. */
  19914. readonly angularAcceleration: Nullable<Float32Array>;
  19915. }
  19916. /**
  19917. * Interface representing a pose controlled object in Babylon.
  19918. * A pose controlled object has both regular pose values as well as pose values
  19919. * from an external device such as a VR head mounted display
  19920. */
  19921. export interface PoseControlled {
  19922. /**
  19923. * The position of the object in babylon space.
  19924. */
  19925. position: Vector3;
  19926. /**
  19927. * The rotation quaternion of the object in babylon space.
  19928. */
  19929. rotationQuaternion: Quaternion;
  19930. /**
  19931. * The position of the device in babylon space.
  19932. */
  19933. devicePosition?: Vector3;
  19934. /**
  19935. * The rotation quaternion of the device in babylon space.
  19936. */
  19937. deviceRotationQuaternion: Quaternion;
  19938. /**
  19939. * The raw pose coming from the device.
  19940. */
  19941. rawPose: Nullable<DevicePose>;
  19942. /**
  19943. * The scale of the device to be used when translating from device space to babylon space.
  19944. */
  19945. deviceScaleFactor: number;
  19946. /**
  19947. * Updates the poseControlled values based on the input device pose.
  19948. * @param poseData the pose data to update the object with
  19949. */
  19950. updateFromDevice(poseData: DevicePose): void;
  19951. }
  19952. /**
  19953. * Set of options to customize the webVRCamera
  19954. */
  19955. export interface WebVROptions {
  19956. /**
  19957. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19958. */
  19959. trackPosition?: boolean;
  19960. /**
  19961. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19962. */
  19963. positionScale?: number;
  19964. /**
  19965. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19966. */
  19967. displayName?: string;
  19968. /**
  19969. * Should the native controller meshes be initialized. (default: true)
  19970. */
  19971. controllerMeshes?: boolean;
  19972. /**
  19973. * Creating a default HemiLight only on controllers. (default: true)
  19974. */
  19975. defaultLightingOnControllers?: boolean;
  19976. /**
  19977. * If you don't want to use the default VR button of the helper. (default: false)
  19978. */
  19979. useCustomVRButton?: boolean;
  19980. /**
  19981. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19982. */
  19983. customVRButton?: HTMLButtonElement;
  19984. /**
  19985. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19986. */
  19987. rayLength?: number;
  19988. /**
  19989. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19990. */
  19991. defaultHeight?: number;
  19992. /**
  19993. * If multiview should be used if availible (default: false)
  19994. */
  19995. useMultiview?: boolean;
  19996. }
  19997. /**
  19998. * This represents a WebVR camera.
  19999. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20000. * @example http://doc.babylonjs.com/how_to/webvr_camera
  20001. */
  20002. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20003. private webVROptions;
  20004. /**
  20005. * @hidden
  20006. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20007. */
  20008. _vrDevice: any;
  20009. /**
  20010. * The rawPose of the vrDevice.
  20011. */
  20012. rawPose: Nullable<DevicePose>;
  20013. private _onVREnabled;
  20014. private _specsVersion;
  20015. private _attached;
  20016. private _frameData;
  20017. protected _descendants: Array<Node>;
  20018. private _deviceRoomPosition;
  20019. /** @hidden */
  20020. _deviceRoomRotationQuaternion: Quaternion;
  20021. private _standingMatrix;
  20022. /**
  20023. * Represents device position in babylon space.
  20024. */
  20025. devicePosition: Vector3;
  20026. /**
  20027. * Represents device rotation in babylon space.
  20028. */
  20029. deviceRotationQuaternion: Quaternion;
  20030. /**
  20031. * The scale of the device to be used when translating from device space to babylon space.
  20032. */
  20033. deviceScaleFactor: number;
  20034. private _deviceToWorld;
  20035. private _worldToDevice;
  20036. /**
  20037. * References to the webVR controllers for the vrDevice.
  20038. */
  20039. controllers: Array<WebVRController>;
  20040. /**
  20041. * Emits an event when a controller is attached.
  20042. */
  20043. onControllersAttachedObservable: Observable<WebVRController[]>;
  20044. /**
  20045. * Emits an event when a controller's mesh has been loaded;
  20046. */
  20047. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20048. /**
  20049. * Emits an event when the HMD's pose has been updated.
  20050. */
  20051. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20052. private _poseSet;
  20053. /**
  20054. * If the rig cameras be used as parent instead of this camera.
  20055. */
  20056. rigParenting: boolean;
  20057. private _lightOnControllers;
  20058. private _defaultHeight?;
  20059. /**
  20060. * Instantiates a WebVRFreeCamera.
  20061. * @param name The name of the WebVRFreeCamera
  20062. * @param position The starting anchor position for the camera
  20063. * @param scene The scene the camera belongs to
  20064. * @param webVROptions a set of customizable options for the webVRCamera
  20065. */
  20066. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20067. /**
  20068. * Gets the device distance from the ground in meters.
  20069. * @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.
  20070. */
  20071. deviceDistanceToRoomGround(): number;
  20072. /**
  20073. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20074. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20075. */
  20076. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20077. /**
  20078. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20079. * @returns A promise with a boolean set to if the standing matrix is supported.
  20080. */
  20081. useStandingMatrixAsync(): Promise<boolean>;
  20082. /**
  20083. * Disposes the camera
  20084. */
  20085. dispose(): void;
  20086. /**
  20087. * Gets a vrController by name.
  20088. * @param name The name of the controller to retreive
  20089. * @returns the controller matching the name specified or null if not found
  20090. */
  20091. getControllerByName(name: string): Nullable<WebVRController>;
  20092. private _leftController;
  20093. /**
  20094. * The controller corresponding to the users left hand.
  20095. */
  20096. get leftController(): Nullable<WebVRController>;
  20097. private _rightController;
  20098. /**
  20099. * The controller corresponding to the users right hand.
  20100. */
  20101. get rightController(): Nullable<WebVRController>;
  20102. /**
  20103. * Casts a ray forward from the vrCamera's gaze.
  20104. * @param length Length of the ray (default: 100)
  20105. * @returns the ray corresponding to the gaze
  20106. */
  20107. getForwardRay(length?: number): Ray;
  20108. /**
  20109. * @hidden
  20110. * Updates the camera based on device's frame data
  20111. */
  20112. _checkInputs(): void;
  20113. /**
  20114. * Updates the poseControlled values based on the input device pose.
  20115. * @param poseData Pose coming from the device
  20116. */
  20117. updateFromDevice(poseData: DevicePose): void;
  20118. private _htmlElementAttached;
  20119. private _detachIfAttached;
  20120. /**
  20121. * WebVR's attach control will start broadcasting frames to the device.
  20122. * Note that in certain browsers (chrome for example) this function must be called
  20123. * within a user-interaction callback. Example:
  20124. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20125. *
  20126. * @param element html element to attach the vrDevice to
  20127. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20128. */
  20129. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20130. /**
  20131. * Detaches the camera from the html element and disables VR
  20132. *
  20133. * @param element html element to detach from
  20134. */
  20135. detachControl(element: HTMLElement): void;
  20136. /**
  20137. * @returns the name of this class
  20138. */
  20139. getClassName(): string;
  20140. /**
  20141. * Calls resetPose on the vrDisplay
  20142. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20143. */
  20144. resetToCurrentRotation(): void;
  20145. /**
  20146. * @hidden
  20147. * Updates the rig cameras (left and right eye)
  20148. */
  20149. _updateRigCameras(): void;
  20150. private _workingVector;
  20151. private _oneVector;
  20152. private _workingMatrix;
  20153. private updateCacheCalled;
  20154. private _correctPositionIfNotTrackPosition;
  20155. /**
  20156. * @hidden
  20157. * Updates the cached values of the camera
  20158. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20159. */
  20160. _updateCache(ignoreParentClass?: boolean): void;
  20161. /**
  20162. * @hidden
  20163. * Get current device position in babylon world
  20164. */
  20165. _computeDevicePosition(): void;
  20166. /**
  20167. * Updates the current device position and rotation in the babylon world
  20168. */
  20169. update(): void;
  20170. /**
  20171. * @hidden
  20172. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20173. * @returns an identity matrix
  20174. */
  20175. _getViewMatrix(): Matrix;
  20176. private _tmpMatrix;
  20177. /**
  20178. * This function is called by the two RIG cameras.
  20179. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20180. * @hidden
  20181. */
  20182. _getWebVRViewMatrix(): Matrix;
  20183. /** @hidden */
  20184. _getWebVRProjectionMatrix(): Matrix;
  20185. private _onGamepadConnectedObserver;
  20186. private _onGamepadDisconnectedObserver;
  20187. private _updateCacheWhenTrackingDisabledObserver;
  20188. /**
  20189. * Initializes the controllers and their meshes
  20190. */
  20191. initControllers(): void;
  20192. }
  20193. }
  20194. declare module "babylonjs/PostProcesses/postProcess" {
  20195. import { Nullable } from "babylonjs/types";
  20196. import { SmartArray } from "babylonjs/Misc/smartArray";
  20197. import { Observable } from "babylonjs/Misc/observable";
  20198. import { Vector2 } from "babylonjs/Maths/math.vector";
  20199. import { Camera } from "babylonjs/Cameras/camera";
  20200. import { Effect } from "babylonjs/Materials/effect";
  20201. import "babylonjs/Shaders/postprocess.vertex";
  20202. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20203. import { Engine } from "babylonjs/Engines/engine";
  20204. import { Color4 } from "babylonjs/Maths/math.color";
  20205. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20206. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20207. /**
  20208. * Size options for a post process
  20209. */
  20210. export type PostProcessOptions = {
  20211. width: number;
  20212. height: number;
  20213. };
  20214. /**
  20215. * PostProcess can be used to apply a shader to a texture after it has been rendered
  20216. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20217. */
  20218. export class PostProcess {
  20219. /** Name of the PostProcess. */
  20220. name: string;
  20221. /**
  20222. * Gets or sets the unique id of the post process
  20223. */
  20224. uniqueId: number;
  20225. /**
  20226. * Width of the texture to apply the post process on
  20227. */
  20228. width: number;
  20229. /**
  20230. * Height of the texture to apply the post process on
  20231. */
  20232. height: number;
  20233. /**
  20234. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  20235. * @hidden
  20236. */
  20237. _outputTexture: Nullable<InternalTexture>;
  20238. /**
  20239. * Sampling mode used by the shader
  20240. * See https://doc.babylonjs.com/classes/3.1/texture
  20241. */
  20242. renderTargetSamplingMode: number;
  20243. /**
  20244. * Clear color to use when screen clearing
  20245. */
  20246. clearColor: Color4;
  20247. /**
  20248. * If the buffer needs to be cleared before applying the post process. (default: true)
  20249. * Should be set to false if shader will overwrite all previous pixels.
  20250. */
  20251. autoClear: boolean;
  20252. /**
  20253. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  20254. */
  20255. alphaMode: number;
  20256. /**
  20257. * Sets the setAlphaBlendConstants of the babylon engine
  20258. */
  20259. alphaConstants: Color4;
  20260. /**
  20261. * Animations to be used for the post processing
  20262. */
  20263. animations: import("babylonjs/Animations/animation").Animation[];
  20264. /**
  20265. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  20266. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  20267. */
  20268. enablePixelPerfectMode: boolean;
  20269. /**
  20270. * Force the postprocess to be applied without taking in account viewport
  20271. */
  20272. forceFullscreenViewport: boolean;
  20273. /**
  20274. * List of inspectable custom properties (used by the Inspector)
  20275. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20276. */
  20277. inspectableCustomProperties: IInspectable[];
  20278. /**
  20279. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  20280. *
  20281. * | Value | Type | Description |
  20282. * | ----- | ----------------------------------- | ----------- |
  20283. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  20284. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  20285. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  20286. *
  20287. */
  20288. scaleMode: number;
  20289. /**
  20290. * Force textures to be a power of two (default: false)
  20291. */
  20292. alwaysForcePOT: boolean;
  20293. private _samples;
  20294. /**
  20295. * Number of sample textures (default: 1)
  20296. */
  20297. get samples(): number;
  20298. set samples(n: number);
  20299. /**
  20300. * Modify the scale of the post process to be the same as the viewport (default: false)
  20301. */
  20302. adaptScaleToCurrentViewport: boolean;
  20303. private _camera;
  20304. private _scene;
  20305. private _engine;
  20306. private _options;
  20307. private _reusable;
  20308. private _textureType;
  20309. private _textureFormat;
  20310. /**
  20311. * Smart array of input and output textures for the post process.
  20312. * @hidden
  20313. */
  20314. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  20315. /**
  20316. * The index in _textures that corresponds to the output texture.
  20317. * @hidden
  20318. */
  20319. _currentRenderTextureInd: number;
  20320. private _effect;
  20321. private _samplers;
  20322. private _fragmentUrl;
  20323. private _vertexUrl;
  20324. private _parameters;
  20325. private _scaleRatio;
  20326. protected _indexParameters: any;
  20327. private _shareOutputWithPostProcess;
  20328. private _texelSize;
  20329. private _forcedOutputTexture;
  20330. /**
  20331. * Returns the fragment url or shader name used in the post process.
  20332. * @returns the fragment url or name in the shader store.
  20333. */
  20334. getEffectName(): string;
  20335. /**
  20336. * An event triggered when the postprocess is activated.
  20337. */
  20338. onActivateObservable: Observable<Camera>;
  20339. private _onActivateObserver;
  20340. /**
  20341. * A function that is added to the onActivateObservable
  20342. */
  20343. set onActivate(callback: Nullable<(camera: Camera) => void>);
  20344. /**
  20345. * An event triggered when the postprocess changes its size.
  20346. */
  20347. onSizeChangedObservable: Observable<PostProcess>;
  20348. private _onSizeChangedObserver;
  20349. /**
  20350. * A function that is added to the onSizeChangedObservable
  20351. */
  20352. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  20353. /**
  20354. * An event triggered when the postprocess applies its effect.
  20355. */
  20356. onApplyObservable: Observable<Effect>;
  20357. private _onApplyObserver;
  20358. /**
  20359. * A function that is added to the onApplyObservable
  20360. */
  20361. set onApply(callback: (effect: Effect) => void);
  20362. /**
  20363. * An event triggered before rendering the postprocess
  20364. */
  20365. onBeforeRenderObservable: Observable<Effect>;
  20366. private _onBeforeRenderObserver;
  20367. /**
  20368. * A function that is added to the onBeforeRenderObservable
  20369. */
  20370. set onBeforeRender(callback: (effect: Effect) => void);
  20371. /**
  20372. * An event triggered after rendering the postprocess
  20373. */
  20374. onAfterRenderObservable: Observable<Effect>;
  20375. private _onAfterRenderObserver;
  20376. /**
  20377. * A function that is added to the onAfterRenderObservable
  20378. */
  20379. set onAfterRender(callback: (efect: Effect) => void);
  20380. /**
  20381. * 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
  20382. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  20383. */
  20384. get inputTexture(): InternalTexture;
  20385. set inputTexture(value: InternalTexture);
  20386. /**
  20387. * Gets the camera which post process is applied to.
  20388. * @returns The camera the post process is applied to.
  20389. */
  20390. getCamera(): Camera;
  20391. /**
  20392. * Gets the texel size of the postprocess.
  20393. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  20394. */
  20395. get texelSize(): Vector2;
  20396. /**
  20397. * Creates a new instance PostProcess
  20398. * @param name The name of the PostProcess.
  20399. * @param fragmentUrl The url of the fragment shader to be used.
  20400. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20401. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20402. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20403. * @param camera The camera to apply the render pass to.
  20404. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20405. * @param engine The engine which the post process will be applied. (default: current engine)
  20406. * @param reusable If the post process can be reused on the same frame. (default: false)
  20407. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20408. * @param textureType Type of textures used when performing the post process. (default: 0)
  20409. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20410. * @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
  20411. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20412. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  20413. */
  20414. constructor(
  20415. /** Name of the PostProcess. */
  20416. 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);
  20417. /**
  20418. * Gets a string idenfifying the name of the class
  20419. * @returns "PostProcess" string
  20420. */
  20421. getClassName(): string;
  20422. /**
  20423. * Gets the engine which this post process belongs to.
  20424. * @returns The engine the post process was enabled with.
  20425. */
  20426. getEngine(): Engine;
  20427. /**
  20428. * The effect that is created when initializing the post process.
  20429. * @returns The created effect corresponding the the postprocess.
  20430. */
  20431. getEffect(): Effect;
  20432. /**
  20433. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20434. * @param postProcess The post process to share the output with.
  20435. * @returns This post process.
  20436. */
  20437. shareOutputWith(postProcess: PostProcess): PostProcess;
  20438. /**
  20439. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  20440. * This should be called if the post process that shares output with this post process is disabled/disposed.
  20441. */
  20442. useOwnOutput(): void;
  20443. /**
  20444. * Updates the effect with the current post process compile time values and recompiles the shader.
  20445. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20446. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20447. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20448. * @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
  20449. * @param onCompiled Called when the shader has been compiled.
  20450. * @param onError Called if there is an error when compiling a shader.
  20451. */
  20452. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20453. /**
  20454. * The post process is reusable if it can be used multiple times within one frame.
  20455. * @returns If the post process is reusable
  20456. */
  20457. isReusable(): boolean;
  20458. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20459. markTextureDirty(): void;
  20460. /**
  20461. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20462. * 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.
  20463. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20464. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20465. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20466. * @returns The target texture that was bound to be written to.
  20467. */
  20468. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20469. /**
  20470. * If the post process is supported.
  20471. */
  20472. get isSupported(): boolean;
  20473. /**
  20474. * The aspect ratio of the output texture.
  20475. */
  20476. get aspectRatio(): number;
  20477. /**
  20478. * Get a value indicating if the post-process is ready to be used
  20479. * @returns true if the post-process is ready (shader is compiled)
  20480. */
  20481. isReady(): boolean;
  20482. /**
  20483. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20484. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20485. */
  20486. apply(): Nullable<Effect>;
  20487. private _disposeTextures;
  20488. /**
  20489. * Disposes the post process.
  20490. * @param camera The camera to dispose the post process on.
  20491. */
  20492. dispose(camera?: Camera): void;
  20493. }
  20494. }
  20495. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  20496. /** @hidden */
  20497. export var kernelBlurVaryingDeclaration: {
  20498. name: string;
  20499. shader: string;
  20500. };
  20501. }
  20502. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  20503. /** @hidden */
  20504. export var kernelBlurFragment: {
  20505. name: string;
  20506. shader: string;
  20507. };
  20508. }
  20509. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  20510. /** @hidden */
  20511. export var kernelBlurFragment2: {
  20512. name: string;
  20513. shader: string;
  20514. };
  20515. }
  20516. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  20517. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20518. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  20519. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  20520. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  20521. /** @hidden */
  20522. export var kernelBlurPixelShader: {
  20523. name: string;
  20524. shader: string;
  20525. };
  20526. }
  20527. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  20528. /** @hidden */
  20529. export var kernelBlurVertex: {
  20530. name: string;
  20531. shader: string;
  20532. };
  20533. }
  20534. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  20535. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20536. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  20537. /** @hidden */
  20538. export var kernelBlurVertexShader: {
  20539. name: string;
  20540. shader: string;
  20541. };
  20542. }
  20543. declare module "babylonjs/PostProcesses/blurPostProcess" {
  20544. import { Vector2 } from "babylonjs/Maths/math.vector";
  20545. import { Nullable } from "babylonjs/types";
  20546. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  20547. import { Camera } from "babylonjs/Cameras/camera";
  20548. import { Effect } from "babylonjs/Materials/effect";
  20549. import { Engine } from "babylonjs/Engines/engine";
  20550. import "babylonjs/Shaders/kernelBlur.fragment";
  20551. import "babylonjs/Shaders/kernelBlur.vertex";
  20552. /**
  20553. * The Blur Post Process which blurs an image based on a kernel and direction.
  20554. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20555. */
  20556. export class BlurPostProcess extends PostProcess {
  20557. /** The direction in which to blur the image. */
  20558. direction: Vector2;
  20559. private blockCompilation;
  20560. protected _kernel: number;
  20561. protected _idealKernel: number;
  20562. protected _packedFloat: boolean;
  20563. private _staticDefines;
  20564. /**
  20565. * Sets the length in pixels of the blur sample region
  20566. */
  20567. set kernel(v: number);
  20568. /**
  20569. * Gets the length in pixels of the blur sample region
  20570. */
  20571. get kernel(): number;
  20572. /**
  20573. * Sets wether or not the blur needs to unpack/repack floats
  20574. */
  20575. set packedFloat(v: boolean);
  20576. /**
  20577. * Gets wether or not the blur is unpacking/repacking floats
  20578. */
  20579. get packedFloat(): boolean;
  20580. /**
  20581. * Creates a new instance BlurPostProcess
  20582. * @param name The name of the effect.
  20583. * @param direction The direction in which to blur the image.
  20584. * @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.
  20585. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20586. * @param camera The camera to apply the render pass to.
  20587. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20588. * @param engine The engine which the post process will be applied. (default: current engine)
  20589. * @param reusable If the post process can be reused on the same frame. (default: false)
  20590. * @param textureType Type of textures used when performing the post process. (default: 0)
  20591. * @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)
  20592. */
  20593. constructor(name: string,
  20594. /** The direction in which to blur the image. */
  20595. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20596. /**
  20597. * Updates the effect with the current post process compile time values and recompiles the shader.
  20598. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20599. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20600. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20601. * @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
  20602. * @param onCompiled Called when the shader has been compiled.
  20603. * @param onError Called if there is an error when compiling a shader.
  20604. */
  20605. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20606. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20607. /**
  20608. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20609. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20610. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20611. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20612. * The gaps between physical kernels are compensated for in the weighting of the samples
  20613. * @param idealKernel Ideal blur kernel.
  20614. * @return Nearest best kernel.
  20615. */
  20616. protected _nearestBestKernel(idealKernel: number): number;
  20617. /**
  20618. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20619. * @param x The point on the Gaussian distribution to sample.
  20620. * @return the value of the Gaussian function at x.
  20621. */
  20622. protected _gaussianWeight(x: number): number;
  20623. /**
  20624. * Generates a string that can be used as a floating point number in GLSL.
  20625. * @param x Value to print.
  20626. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20627. * @return GLSL float string.
  20628. */
  20629. protected _glslFloat(x: number, decimalFigures?: number): string;
  20630. }
  20631. }
  20632. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  20633. import { Scene } from "babylonjs/scene";
  20634. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20635. import { Plane } from "babylonjs/Maths/math.plane";
  20636. /**
  20637. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20638. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20639. * You can then easily use it as a reflectionTexture on a flat surface.
  20640. * In case the surface is not a plane, please consider relying on reflection probes.
  20641. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20642. */
  20643. export class MirrorTexture extends RenderTargetTexture {
  20644. private scene;
  20645. /**
  20646. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20647. * 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.
  20648. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20649. */
  20650. mirrorPlane: Plane;
  20651. /**
  20652. * Define the blur ratio used to blur the reflection if needed.
  20653. */
  20654. set blurRatio(value: number);
  20655. get blurRatio(): number;
  20656. /**
  20657. * Define the adaptive blur kernel used to blur the reflection if needed.
  20658. * This will autocompute the closest best match for the `blurKernel`
  20659. */
  20660. set adaptiveBlurKernel(value: number);
  20661. /**
  20662. * Define the blur kernel used to blur the reflection if needed.
  20663. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20664. */
  20665. set blurKernel(value: number);
  20666. /**
  20667. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20668. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20669. */
  20670. set blurKernelX(value: number);
  20671. get blurKernelX(): number;
  20672. /**
  20673. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20674. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20675. */
  20676. set blurKernelY(value: number);
  20677. get blurKernelY(): number;
  20678. private _autoComputeBlurKernel;
  20679. protected _onRatioRescale(): void;
  20680. private _updateGammaSpace;
  20681. private _imageProcessingConfigChangeObserver;
  20682. private _transformMatrix;
  20683. private _mirrorMatrix;
  20684. private _savedViewMatrix;
  20685. private _blurX;
  20686. private _blurY;
  20687. private _adaptiveBlurKernel;
  20688. private _blurKernelX;
  20689. private _blurKernelY;
  20690. private _blurRatio;
  20691. /**
  20692. * Instantiates a Mirror Texture.
  20693. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20694. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20695. * You can then easily use it as a reflectionTexture on a flat surface.
  20696. * In case the surface is not a plane, please consider relying on reflection probes.
  20697. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20698. * @param name
  20699. * @param size
  20700. * @param scene
  20701. * @param generateMipMaps
  20702. * @param type
  20703. * @param samplingMode
  20704. * @param generateDepthBuffer
  20705. */
  20706. constructor(name: string, size: number | {
  20707. width: number;
  20708. height: number;
  20709. } | {
  20710. ratio: number;
  20711. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20712. private _preparePostProcesses;
  20713. /**
  20714. * Clone the mirror texture.
  20715. * @returns the cloned texture
  20716. */
  20717. clone(): MirrorTexture;
  20718. /**
  20719. * Serialize the texture to a JSON representation you could use in Parse later on
  20720. * @returns the serialized JSON representation
  20721. */
  20722. serialize(): any;
  20723. /**
  20724. * Dispose the texture and release its associated resources.
  20725. */
  20726. dispose(): void;
  20727. }
  20728. }
  20729. declare module "babylonjs/Materials/Textures/texture" {
  20730. import { Observable } from "babylonjs/Misc/observable";
  20731. import { Nullable } from "babylonjs/types";
  20732. import { Matrix } from "babylonjs/Maths/math.vector";
  20733. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20734. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20735. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  20736. import { Scene } from "babylonjs/scene";
  20737. /**
  20738. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20739. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20740. */
  20741. export class Texture extends BaseTexture {
  20742. /**
  20743. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20744. */
  20745. static SerializeBuffers: boolean;
  20746. /** @hidden */
  20747. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  20748. /** @hidden */
  20749. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  20750. /** @hidden */
  20751. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  20752. /** nearest is mag = nearest and min = nearest and mip = linear */
  20753. static readonly NEAREST_SAMPLINGMODE: number;
  20754. /** nearest is mag = nearest and min = nearest and mip = linear */
  20755. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20756. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20757. static readonly BILINEAR_SAMPLINGMODE: number;
  20758. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20759. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20760. /** Trilinear is mag = linear and min = linear and mip = linear */
  20761. static readonly TRILINEAR_SAMPLINGMODE: number;
  20762. /** Trilinear is mag = linear and min = linear and mip = linear */
  20763. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20764. /** mag = nearest and min = nearest and mip = nearest */
  20765. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20766. /** mag = nearest and min = linear and mip = nearest */
  20767. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20768. /** mag = nearest and min = linear and mip = linear */
  20769. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20770. /** mag = nearest and min = linear and mip = none */
  20771. static readonly NEAREST_LINEAR: number;
  20772. /** mag = nearest and min = nearest and mip = none */
  20773. static readonly NEAREST_NEAREST: number;
  20774. /** mag = linear and min = nearest and mip = nearest */
  20775. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20776. /** mag = linear and min = nearest and mip = linear */
  20777. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20778. /** mag = linear and min = linear and mip = none */
  20779. static readonly LINEAR_LINEAR: number;
  20780. /** mag = linear and min = nearest and mip = none */
  20781. static readonly LINEAR_NEAREST: number;
  20782. /** Explicit coordinates mode */
  20783. static readonly EXPLICIT_MODE: number;
  20784. /** Spherical coordinates mode */
  20785. static readonly SPHERICAL_MODE: number;
  20786. /** Planar coordinates mode */
  20787. static readonly PLANAR_MODE: number;
  20788. /** Cubic coordinates mode */
  20789. static readonly CUBIC_MODE: number;
  20790. /** Projection coordinates mode */
  20791. static readonly PROJECTION_MODE: number;
  20792. /** Inverse Cubic coordinates mode */
  20793. static readonly SKYBOX_MODE: number;
  20794. /** Inverse Cubic coordinates mode */
  20795. static readonly INVCUBIC_MODE: number;
  20796. /** Equirectangular coordinates mode */
  20797. static readonly EQUIRECTANGULAR_MODE: number;
  20798. /** Equirectangular Fixed coordinates mode */
  20799. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20800. /** Equirectangular Fixed Mirrored coordinates mode */
  20801. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20802. /** Texture is not repeating outside of 0..1 UVs */
  20803. static readonly CLAMP_ADDRESSMODE: number;
  20804. /** Texture is repeating outside of 0..1 UVs */
  20805. static readonly WRAP_ADDRESSMODE: number;
  20806. /** Texture is repeating and mirrored */
  20807. static readonly MIRROR_ADDRESSMODE: number;
  20808. /**
  20809. * 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
  20810. */
  20811. static UseSerializedUrlIfAny: boolean;
  20812. /**
  20813. * Define the url of the texture.
  20814. */
  20815. url: Nullable<string>;
  20816. /**
  20817. * Define an offset on the texture to offset the u coordinates of the UVs
  20818. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20819. */
  20820. uOffset: number;
  20821. /**
  20822. * Define an offset on the texture to offset the v coordinates of the UVs
  20823. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20824. */
  20825. vOffset: number;
  20826. /**
  20827. * Define an offset on the texture to scale the u coordinates of the UVs
  20828. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20829. */
  20830. uScale: number;
  20831. /**
  20832. * Define an offset on the texture to scale the v coordinates of the UVs
  20833. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20834. */
  20835. vScale: number;
  20836. /**
  20837. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20838. * @see http://doc.babylonjs.com/how_to/more_materials
  20839. */
  20840. uAng: number;
  20841. /**
  20842. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20843. * @see http://doc.babylonjs.com/how_to/more_materials
  20844. */
  20845. vAng: number;
  20846. /**
  20847. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20848. * @see http://doc.babylonjs.com/how_to/more_materials
  20849. */
  20850. wAng: number;
  20851. /**
  20852. * Defines the center of rotation (U)
  20853. */
  20854. uRotationCenter: number;
  20855. /**
  20856. * Defines the center of rotation (V)
  20857. */
  20858. vRotationCenter: number;
  20859. /**
  20860. * Defines the center of rotation (W)
  20861. */
  20862. wRotationCenter: number;
  20863. /**
  20864. * Are mip maps generated for this texture or not.
  20865. */
  20866. get noMipmap(): boolean;
  20867. /**
  20868. * List of inspectable custom properties (used by the Inspector)
  20869. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20870. */
  20871. inspectableCustomProperties: Nullable<IInspectable[]>;
  20872. private _noMipmap;
  20873. /** @hidden */
  20874. _invertY: boolean;
  20875. private _rowGenerationMatrix;
  20876. private _cachedTextureMatrix;
  20877. private _projectionModeMatrix;
  20878. private _t0;
  20879. private _t1;
  20880. private _t2;
  20881. private _cachedUOffset;
  20882. private _cachedVOffset;
  20883. private _cachedUScale;
  20884. private _cachedVScale;
  20885. private _cachedUAng;
  20886. private _cachedVAng;
  20887. private _cachedWAng;
  20888. private _cachedProjectionMatrixId;
  20889. private _cachedCoordinatesMode;
  20890. /** @hidden */
  20891. protected _initialSamplingMode: number;
  20892. /** @hidden */
  20893. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20894. private _deleteBuffer;
  20895. protected _format: Nullable<number>;
  20896. private _delayedOnLoad;
  20897. private _delayedOnError;
  20898. private _mimeType?;
  20899. /**
  20900. * Observable triggered once the texture has been loaded.
  20901. */
  20902. onLoadObservable: Observable<Texture>;
  20903. protected _isBlocking: boolean;
  20904. /**
  20905. * Is the texture preventing material to render while loading.
  20906. * If false, a default texture will be used instead of the loading one during the preparation step.
  20907. */
  20908. set isBlocking(value: boolean);
  20909. get isBlocking(): boolean;
  20910. /**
  20911. * Get the current sampling mode associated with the texture.
  20912. */
  20913. get samplingMode(): number;
  20914. /**
  20915. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20916. */
  20917. get invertY(): boolean;
  20918. /**
  20919. * Instantiates a new texture.
  20920. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20921. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20922. * @param url defines the url of the picture to load as a texture
  20923. * @param scene defines the scene or engine the texture will belong to
  20924. * @param noMipmap defines if the texture will require mip maps or not
  20925. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20926. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20927. * @param onLoad defines a callback triggered when the texture has been loaded
  20928. * @param onError defines a callback triggered when an error occurred during the loading session
  20929. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20930. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20931. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20932. * @param mimeType defines an optional mime type information
  20933. */
  20934. 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);
  20935. /**
  20936. * Update the url (and optional buffer) of this texture if url was null during construction.
  20937. * @param url the url of the texture
  20938. * @param buffer the buffer of the texture (defaults to null)
  20939. * @param onLoad callback called when the texture is loaded (defaults to null)
  20940. */
  20941. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20942. /**
  20943. * Finish the loading sequence of a texture flagged as delayed load.
  20944. * @hidden
  20945. */
  20946. delayLoad(): void;
  20947. private _prepareRowForTextureGeneration;
  20948. /**
  20949. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20950. * @returns the transform matrix of the texture.
  20951. */
  20952. getTextureMatrix(uBase?: number): Matrix;
  20953. /**
  20954. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20955. * @returns The reflection texture transform
  20956. */
  20957. getReflectionTextureMatrix(): Matrix;
  20958. /**
  20959. * Clones the texture.
  20960. * @returns the cloned texture
  20961. */
  20962. clone(): Texture;
  20963. /**
  20964. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20965. * @returns The JSON representation of the texture
  20966. */
  20967. serialize(): any;
  20968. /**
  20969. * Get the current class name of the texture useful for serialization or dynamic coding.
  20970. * @returns "Texture"
  20971. */
  20972. getClassName(): string;
  20973. /**
  20974. * Dispose the texture and release its associated resources.
  20975. */
  20976. dispose(): void;
  20977. /**
  20978. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20979. * @param parsedTexture Define the JSON representation of the texture
  20980. * @param scene Define the scene the parsed texture should be instantiated in
  20981. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20982. * @returns The parsed texture if successful
  20983. */
  20984. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20985. /**
  20986. * Creates a texture from its base 64 representation.
  20987. * @param data Define the base64 payload without the data: prefix
  20988. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20989. * @param scene Define the scene the texture should belong to
  20990. * @param noMipmap Forces the texture to not create mip map information if true
  20991. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20992. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20993. * @param onLoad define a callback triggered when the texture has been loaded
  20994. * @param onError define a callback triggered when an error occurred during the loading session
  20995. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20996. * @returns the created texture
  20997. */
  20998. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20999. /**
  21000. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  21001. * @param data Define the base64 payload without the data: prefix
  21002. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  21003. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  21004. * @param scene Define the scene the texture should belong to
  21005. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  21006. * @param noMipmap Forces the texture to not create mip map information if true
  21007. * @param invertY define if the texture needs to be inverted on the y axis during loading
  21008. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  21009. * @param onLoad define a callback triggered when the texture has been loaded
  21010. * @param onError define a callback triggered when an error occurred during the loading session
  21011. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  21012. * @returns the created texture
  21013. */
  21014. 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;
  21015. }
  21016. }
  21017. declare module "babylonjs/PostProcesses/postProcessManager" {
  21018. import { Nullable } from "babylonjs/types";
  21019. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21020. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21021. import { Scene } from "babylonjs/scene";
  21022. /**
  21023. * PostProcessManager is used to manage one or more post processes or post process pipelines
  21024. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  21025. */
  21026. export class PostProcessManager {
  21027. private _scene;
  21028. private _indexBuffer;
  21029. private _vertexBuffers;
  21030. /**
  21031. * Creates a new instance PostProcess
  21032. * @param scene The scene that the post process is associated with.
  21033. */
  21034. constructor(scene: Scene);
  21035. private _prepareBuffers;
  21036. private _buildIndexBuffer;
  21037. /**
  21038. * Rebuilds the vertex buffers of the manager.
  21039. * @hidden
  21040. */
  21041. _rebuild(): void;
  21042. /**
  21043. * Prepares a frame to be run through a post process.
  21044. * @param sourceTexture The input texture to the post procesess. (default: null)
  21045. * @param postProcesses An array of post processes to be run. (default: null)
  21046. * @returns True if the post processes were able to be run.
  21047. * @hidden
  21048. */
  21049. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  21050. /**
  21051. * Manually render a set of post processes to a texture.
  21052. * @param postProcesses An array of post processes to be run.
  21053. * @param targetTexture The target texture to render to.
  21054. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  21055. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  21056. * @param lodLevel defines which lod of the texture to render to
  21057. */
  21058. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  21059. /**
  21060. * Finalize the result of the output of the postprocesses.
  21061. * @param doNotPresent If true the result will not be displayed to the screen.
  21062. * @param targetTexture The target texture to render to.
  21063. * @param faceIndex The index of the face to bind the target texture to.
  21064. * @param postProcesses The array of post processes to render.
  21065. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  21066. * @hidden
  21067. */
  21068. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  21069. /**
  21070. * Disposes of the post process manager.
  21071. */
  21072. dispose(): void;
  21073. }
  21074. }
  21075. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  21076. import { Observable } from "babylonjs/Misc/observable";
  21077. import { SmartArray } from "babylonjs/Misc/smartArray";
  21078. import { Nullable, Immutable } from "babylonjs/types";
  21079. import { Camera } from "babylonjs/Cameras/camera";
  21080. import { Scene } from "babylonjs/scene";
  21081. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21082. import { Color4 } from "babylonjs/Maths/math.color";
  21083. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  21084. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21085. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21086. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21087. import { Texture } from "babylonjs/Materials/Textures/texture";
  21088. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21089. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  21090. import "babylonjs/Engines/Extensions/engine.renderTarget";
  21091. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  21092. import { Engine } from "babylonjs/Engines/engine";
  21093. /**
  21094. * This Helps creating a texture that will be created from a camera in your scene.
  21095. * It is basically a dynamic texture that could be used to create special effects for instance.
  21096. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  21097. */
  21098. export class RenderTargetTexture extends Texture {
  21099. isCube: boolean;
  21100. /**
  21101. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  21102. */
  21103. static readonly REFRESHRATE_RENDER_ONCE: number;
  21104. /**
  21105. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  21106. */
  21107. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  21108. /**
  21109. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  21110. * the central point of your effect and can save a lot of performances.
  21111. */
  21112. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  21113. /**
  21114. * Use this predicate to dynamically define the list of mesh you want to render.
  21115. * If set, the renderList property will be overwritten.
  21116. */
  21117. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  21118. private _renderList;
  21119. /**
  21120. * Use this list to define the list of mesh you want to render.
  21121. */
  21122. get renderList(): Nullable<Array<AbstractMesh>>;
  21123. set renderList(value: Nullable<Array<AbstractMesh>>);
  21124. /**
  21125. * Use this function to overload the renderList array at rendering time.
  21126. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  21127. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  21128. * the cube (if the RTT is a cube, else layerOrFace=0).
  21129. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  21130. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  21131. * hold dummy elements!
  21132. */
  21133. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  21134. private _hookArray;
  21135. /**
  21136. * Define if particles should be rendered in your texture.
  21137. */
  21138. renderParticles: boolean;
  21139. /**
  21140. * Define if sprites should be rendered in your texture.
  21141. */
  21142. renderSprites: boolean;
  21143. /**
  21144. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  21145. */
  21146. coordinatesMode: number;
  21147. /**
  21148. * Define the camera used to render the texture.
  21149. */
  21150. activeCamera: Nullable<Camera>;
  21151. /**
  21152. * Override the render function of the texture with your own one.
  21153. */
  21154. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  21155. /**
  21156. * Define if camera post processes should be use while rendering the texture.
  21157. */
  21158. useCameraPostProcesses: boolean;
  21159. /**
  21160. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  21161. */
  21162. ignoreCameraViewport: boolean;
  21163. private _postProcessManager;
  21164. private _postProcesses;
  21165. private _resizeObserver;
  21166. /**
  21167. * An event triggered when the texture is unbind.
  21168. */
  21169. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21170. /**
  21171. * An event triggered when the texture is unbind.
  21172. */
  21173. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21174. private _onAfterUnbindObserver;
  21175. /**
  21176. * Set a after unbind callback in the texture.
  21177. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  21178. */
  21179. set onAfterUnbind(callback: () => void);
  21180. /**
  21181. * An event triggered before rendering the texture
  21182. */
  21183. onBeforeRenderObservable: Observable<number>;
  21184. private _onBeforeRenderObserver;
  21185. /**
  21186. * Set a before render callback in the texture.
  21187. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  21188. */
  21189. set onBeforeRender(callback: (faceIndex: number) => void);
  21190. /**
  21191. * An event triggered after rendering the texture
  21192. */
  21193. onAfterRenderObservable: Observable<number>;
  21194. private _onAfterRenderObserver;
  21195. /**
  21196. * Set a after render callback in the texture.
  21197. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21198. */
  21199. set onAfterRender(callback: (faceIndex: number) => void);
  21200. /**
  21201. * An event triggered after the texture clear
  21202. */
  21203. onClearObservable: Observable<Engine>;
  21204. private _onClearObserver;
  21205. /**
  21206. * Set a clear callback in the texture.
  21207. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21208. */
  21209. set onClear(callback: (Engine: Engine) => void);
  21210. /**
  21211. * An event triggered when the texture is resized.
  21212. */
  21213. onResizeObservable: Observable<RenderTargetTexture>;
  21214. /**
  21215. * Define the clear color of the Render Target if it should be different from the scene.
  21216. */
  21217. clearColor: Color4;
  21218. protected _size: number | {
  21219. width: number;
  21220. height: number;
  21221. layers?: number;
  21222. };
  21223. protected _initialSizeParameter: number | {
  21224. width: number;
  21225. height: number;
  21226. } | {
  21227. ratio: number;
  21228. };
  21229. protected _sizeRatio: Nullable<number>;
  21230. /** @hidden */
  21231. _generateMipMaps: boolean;
  21232. protected _renderingManager: RenderingManager;
  21233. /** @hidden */
  21234. _waitingRenderList: string[];
  21235. protected _doNotChangeAspectRatio: boolean;
  21236. protected _currentRefreshId: number;
  21237. protected _refreshRate: number;
  21238. protected _textureMatrix: Matrix;
  21239. protected _samples: number;
  21240. protected _renderTargetOptions: RenderTargetCreationOptions;
  21241. /**
  21242. * Gets render target creation options that were used.
  21243. */
  21244. get renderTargetOptions(): RenderTargetCreationOptions;
  21245. protected _engine: Engine;
  21246. protected _onRatioRescale(): void;
  21247. /**
  21248. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21249. * It must define where the camera used to render the texture is set
  21250. */
  21251. boundingBoxPosition: Vector3;
  21252. private _boundingBoxSize;
  21253. /**
  21254. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21255. * When defined, the cubemap will switch to local mode
  21256. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21257. * @example https://www.babylonjs-playground.com/#RNASML
  21258. */
  21259. set boundingBoxSize(value: Vector3);
  21260. get boundingBoxSize(): Vector3;
  21261. /**
  21262. * In case the RTT has been created with a depth texture, get the associated
  21263. * depth texture.
  21264. * Otherwise, return null.
  21265. */
  21266. get depthStencilTexture(): Nullable<InternalTexture>;
  21267. /**
  21268. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21269. * or used a shadow, depth texture...
  21270. * @param name The friendly name of the texture
  21271. * @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)
  21272. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21273. * @param generateMipMaps True if mip maps need to be generated after render.
  21274. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21275. * @param type The type of the buffer in the RTT (int, half float, float...)
  21276. * @param isCube True if a cube texture needs to be created
  21277. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21278. * @param generateDepthBuffer True to generate a depth buffer
  21279. * @param generateStencilBuffer True to generate a stencil buffer
  21280. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21281. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21282. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21283. */
  21284. constructor(name: string, size: number | {
  21285. width: number;
  21286. height: number;
  21287. layers?: number;
  21288. } | {
  21289. ratio: number;
  21290. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21291. /**
  21292. * Creates a depth stencil texture.
  21293. * This is only available in WebGL 2 or with the depth texture extension available.
  21294. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21295. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21296. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21297. */
  21298. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21299. private _processSizeParameter;
  21300. /**
  21301. * Define the number of samples to use in case of MSAA.
  21302. * It defaults to one meaning no MSAA has been enabled.
  21303. */
  21304. get samples(): number;
  21305. set samples(value: number);
  21306. /**
  21307. * Resets the refresh counter of the texture and start bak from scratch.
  21308. * Could be useful to regenerate the texture if it is setup to render only once.
  21309. */
  21310. resetRefreshCounter(): void;
  21311. /**
  21312. * Define the refresh rate of the texture or the rendering frequency.
  21313. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21314. */
  21315. get refreshRate(): number;
  21316. set refreshRate(value: number);
  21317. /**
  21318. * Adds a post process to the render target rendering passes.
  21319. * @param postProcess define the post process to add
  21320. */
  21321. addPostProcess(postProcess: PostProcess): void;
  21322. /**
  21323. * Clear all the post processes attached to the render target
  21324. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21325. */
  21326. clearPostProcesses(dispose?: boolean): void;
  21327. /**
  21328. * Remove one of the post process from the list of attached post processes to the texture
  21329. * @param postProcess define the post process to remove from the list
  21330. */
  21331. removePostProcess(postProcess: PostProcess): void;
  21332. /** @hidden */
  21333. _shouldRender(): boolean;
  21334. /**
  21335. * Gets the actual render size of the texture.
  21336. * @returns the width of the render size
  21337. */
  21338. getRenderSize(): number;
  21339. /**
  21340. * Gets the actual render width of the texture.
  21341. * @returns the width of the render size
  21342. */
  21343. getRenderWidth(): number;
  21344. /**
  21345. * Gets the actual render height of the texture.
  21346. * @returns the height of the render size
  21347. */
  21348. getRenderHeight(): number;
  21349. /**
  21350. * Gets the actual number of layers of the texture.
  21351. * @returns the number of layers
  21352. */
  21353. getRenderLayers(): number;
  21354. /**
  21355. * Get if the texture can be rescaled or not.
  21356. */
  21357. get canRescale(): boolean;
  21358. /**
  21359. * Resize the texture using a ratio.
  21360. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21361. */
  21362. scale(ratio: number): void;
  21363. /**
  21364. * Get the texture reflection matrix used to rotate/transform the reflection.
  21365. * @returns the reflection matrix
  21366. */
  21367. getReflectionTextureMatrix(): Matrix;
  21368. /**
  21369. * Resize the texture to a new desired size.
  21370. * Be carrefull as it will recreate all the data in the new texture.
  21371. * @param size Define the new size. It can be:
  21372. * - a number for squared texture,
  21373. * - an object containing { width: number, height: number }
  21374. * - or an object containing a ratio { ratio: number }
  21375. */
  21376. resize(size: number | {
  21377. width: number;
  21378. height: number;
  21379. } | {
  21380. ratio: number;
  21381. }): void;
  21382. private _defaultRenderListPrepared;
  21383. /**
  21384. * Renders all the objects from the render list into the texture.
  21385. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21386. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21387. */
  21388. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21389. private _bestReflectionRenderTargetDimension;
  21390. private _prepareRenderingManager;
  21391. /**
  21392. * @hidden
  21393. * @param faceIndex face index to bind to if this is a cubetexture
  21394. * @param layer defines the index of the texture to bind in the array
  21395. */
  21396. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  21397. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21398. private renderToTarget;
  21399. /**
  21400. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21401. * This allowed control for front to back rendering or reversly depending of the special needs.
  21402. *
  21403. * @param renderingGroupId The rendering group id corresponding to its index
  21404. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21405. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21406. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21407. */
  21408. 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;
  21409. /**
  21410. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21411. *
  21412. * @param renderingGroupId The rendering group id corresponding to its index
  21413. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21414. */
  21415. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21416. /**
  21417. * Clones the texture.
  21418. * @returns the cloned texture
  21419. */
  21420. clone(): RenderTargetTexture;
  21421. /**
  21422. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21423. * @returns The JSON representation of the texture
  21424. */
  21425. serialize(): any;
  21426. /**
  21427. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21428. */
  21429. disposeFramebufferObjects(): void;
  21430. /**
  21431. * Dispose the texture and release its associated resources.
  21432. */
  21433. dispose(): void;
  21434. /** @hidden */
  21435. _rebuild(): void;
  21436. /**
  21437. * Clear the info related to rendering groups preventing retention point in material dispose.
  21438. */
  21439. freeRenderingGroups(): void;
  21440. /**
  21441. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21442. * @returns the view count
  21443. */
  21444. getViewCount(): number;
  21445. }
  21446. }
  21447. declare module "babylonjs/Materials/material" {
  21448. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21449. import { SmartArray } from "babylonjs/Misc/smartArray";
  21450. import { Observable } from "babylonjs/Misc/observable";
  21451. import { Nullable } from "babylonjs/types";
  21452. import { Scene } from "babylonjs/scene";
  21453. import { Matrix } from "babylonjs/Maths/math.vector";
  21454. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21455. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21456. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21457. import { Effect } from "babylonjs/Materials/effect";
  21458. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21459. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21460. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21461. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21462. import { Mesh } from "babylonjs/Meshes/mesh";
  21463. import { Animation } from "babylonjs/Animations/animation";
  21464. /**
  21465. * Options for compiling materials.
  21466. */
  21467. export interface IMaterialCompilationOptions {
  21468. /**
  21469. * Defines whether clip planes are enabled.
  21470. */
  21471. clipPlane: boolean;
  21472. /**
  21473. * Defines whether instances are enabled.
  21474. */
  21475. useInstances: boolean;
  21476. }
  21477. /**
  21478. * Base class for the main features of a material in Babylon.js
  21479. */
  21480. export class Material implements IAnimatable {
  21481. /**
  21482. * Returns the triangle fill mode
  21483. */
  21484. static readonly TriangleFillMode: number;
  21485. /**
  21486. * Returns the wireframe mode
  21487. */
  21488. static readonly WireFrameFillMode: number;
  21489. /**
  21490. * Returns the point fill mode
  21491. */
  21492. static readonly PointFillMode: number;
  21493. /**
  21494. * Returns the point list draw mode
  21495. */
  21496. static readonly PointListDrawMode: number;
  21497. /**
  21498. * Returns the line list draw mode
  21499. */
  21500. static readonly LineListDrawMode: number;
  21501. /**
  21502. * Returns the line loop draw mode
  21503. */
  21504. static readonly LineLoopDrawMode: number;
  21505. /**
  21506. * Returns the line strip draw mode
  21507. */
  21508. static readonly LineStripDrawMode: number;
  21509. /**
  21510. * Returns the triangle strip draw mode
  21511. */
  21512. static readonly TriangleStripDrawMode: number;
  21513. /**
  21514. * Returns the triangle fan draw mode
  21515. */
  21516. static readonly TriangleFanDrawMode: number;
  21517. /**
  21518. * Stores the clock-wise side orientation
  21519. */
  21520. static readonly ClockWiseSideOrientation: number;
  21521. /**
  21522. * Stores the counter clock-wise side orientation
  21523. */
  21524. static readonly CounterClockWiseSideOrientation: number;
  21525. /**
  21526. * The dirty texture flag value
  21527. */
  21528. static readonly TextureDirtyFlag: number;
  21529. /**
  21530. * The dirty light flag value
  21531. */
  21532. static readonly LightDirtyFlag: number;
  21533. /**
  21534. * The dirty fresnel flag value
  21535. */
  21536. static readonly FresnelDirtyFlag: number;
  21537. /**
  21538. * The dirty attribute flag value
  21539. */
  21540. static readonly AttributesDirtyFlag: number;
  21541. /**
  21542. * The dirty misc flag value
  21543. */
  21544. static readonly MiscDirtyFlag: number;
  21545. /**
  21546. * The all dirty flag value
  21547. */
  21548. static readonly AllDirtyFlag: number;
  21549. /**
  21550. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21551. */
  21552. static readonly MATERIAL_OPAQUE: number;
  21553. /**
  21554. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21555. */
  21556. static readonly MATERIAL_ALPHATEST: number;
  21557. /**
  21558. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21559. */
  21560. static readonly MATERIAL_ALPHABLEND: number;
  21561. /**
  21562. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21563. * They are also discarded below the alpha cutoff threshold to improve performances.
  21564. */
  21565. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  21566. /**
  21567. * The ID of the material
  21568. */
  21569. id: string;
  21570. /**
  21571. * Gets or sets the unique id of the material
  21572. */
  21573. uniqueId: number;
  21574. /**
  21575. * The name of the material
  21576. */
  21577. name: string;
  21578. /**
  21579. * Gets or sets user defined metadata
  21580. */
  21581. metadata: any;
  21582. /**
  21583. * For internal use only. Please do not use.
  21584. */
  21585. reservedDataStore: any;
  21586. /**
  21587. * Specifies if the ready state should be checked on each call
  21588. */
  21589. checkReadyOnEveryCall: boolean;
  21590. /**
  21591. * Specifies if the ready state should be checked once
  21592. */
  21593. checkReadyOnlyOnce: boolean;
  21594. /**
  21595. * The state of the material
  21596. */
  21597. state: string;
  21598. /**
  21599. * The alpha value of the material
  21600. */
  21601. protected _alpha: number;
  21602. /**
  21603. * List of inspectable custom properties (used by the Inspector)
  21604. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21605. */
  21606. inspectableCustomProperties: IInspectable[];
  21607. /**
  21608. * Sets the alpha value of the material
  21609. */
  21610. set alpha(value: number);
  21611. /**
  21612. * Gets the alpha value of the material
  21613. */
  21614. get alpha(): number;
  21615. /**
  21616. * Specifies if back face culling is enabled
  21617. */
  21618. protected _backFaceCulling: boolean;
  21619. /**
  21620. * Sets the back-face culling state
  21621. */
  21622. set backFaceCulling(value: boolean);
  21623. /**
  21624. * Gets the back-face culling state
  21625. */
  21626. get backFaceCulling(): boolean;
  21627. /**
  21628. * Stores the value for side orientation
  21629. */
  21630. sideOrientation: number;
  21631. /**
  21632. * Callback triggered when the material is compiled
  21633. */
  21634. onCompiled: Nullable<(effect: Effect) => void>;
  21635. /**
  21636. * Callback triggered when an error occurs
  21637. */
  21638. onError: Nullable<(effect: Effect, errors: string) => void>;
  21639. /**
  21640. * Callback triggered to get the render target textures
  21641. */
  21642. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21643. /**
  21644. * Gets a boolean indicating that current material needs to register RTT
  21645. */
  21646. get hasRenderTargetTextures(): boolean;
  21647. /**
  21648. * Specifies if the material should be serialized
  21649. */
  21650. doNotSerialize: boolean;
  21651. /**
  21652. * @hidden
  21653. */
  21654. _storeEffectOnSubMeshes: boolean;
  21655. /**
  21656. * Stores the animations for the material
  21657. */
  21658. animations: Nullable<Array<Animation>>;
  21659. /**
  21660. * An event triggered when the material is disposed
  21661. */
  21662. onDisposeObservable: Observable<Material>;
  21663. /**
  21664. * An observer which watches for dispose events
  21665. */
  21666. private _onDisposeObserver;
  21667. private _onUnBindObservable;
  21668. /**
  21669. * Called during a dispose event
  21670. */
  21671. set onDispose(callback: () => void);
  21672. private _onBindObservable;
  21673. /**
  21674. * An event triggered when the material is bound
  21675. */
  21676. get onBindObservable(): Observable<AbstractMesh>;
  21677. /**
  21678. * An observer which watches for bind events
  21679. */
  21680. private _onBindObserver;
  21681. /**
  21682. * Called during a bind event
  21683. */
  21684. set onBind(callback: (Mesh: AbstractMesh) => void);
  21685. /**
  21686. * An event triggered when the material is unbound
  21687. */
  21688. get onUnBindObservable(): Observable<Material>;
  21689. /**
  21690. * Stores the value of the alpha mode
  21691. */
  21692. private _alphaMode;
  21693. /**
  21694. * Sets the value of the alpha mode.
  21695. *
  21696. * | Value | Type | Description |
  21697. * | --- | --- | --- |
  21698. * | 0 | ALPHA_DISABLE | |
  21699. * | 1 | ALPHA_ADD | |
  21700. * | 2 | ALPHA_COMBINE | |
  21701. * | 3 | ALPHA_SUBTRACT | |
  21702. * | 4 | ALPHA_MULTIPLY | |
  21703. * | 5 | ALPHA_MAXIMIZED | |
  21704. * | 6 | ALPHA_ONEONE | |
  21705. * | 7 | ALPHA_PREMULTIPLIED | |
  21706. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21707. * | 9 | ALPHA_INTERPOLATE | |
  21708. * | 10 | ALPHA_SCREENMODE | |
  21709. *
  21710. */
  21711. set alphaMode(value: number);
  21712. /**
  21713. * Gets the value of the alpha mode
  21714. */
  21715. get alphaMode(): number;
  21716. /**
  21717. * Stores the state of the need depth pre-pass value
  21718. */
  21719. private _needDepthPrePass;
  21720. /**
  21721. * Sets the need depth pre-pass value
  21722. */
  21723. set needDepthPrePass(value: boolean);
  21724. /**
  21725. * Gets the depth pre-pass value
  21726. */
  21727. get needDepthPrePass(): boolean;
  21728. /**
  21729. * Specifies if depth writing should be disabled
  21730. */
  21731. disableDepthWrite: boolean;
  21732. /**
  21733. * Specifies if depth writing should be forced
  21734. */
  21735. forceDepthWrite: boolean;
  21736. /**
  21737. * Specifies the depth function that should be used. 0 means the default engine function
  21738. */
  21739. depthFunction: number;
  21740. /**
  21741. * Specifies if there should be a separate pass for culling
  21742. */
  21743. separateCullingPass: boolean;
  21744. /**
  21745. * Stores the state specifing if fog should be enabled
  21746. */
  21747. private _fogEnabled;
  21748. /**
  21749. * Sets the state for enabling fog
  21750. */
  21751. set fogEnabled(value: boolean);
  21752. /**
  21753. * Gets the value of the fog enabled state
  21754. */
  21755. get fogEnabled(): boolean;
  21756. /**
  21757. * Stores the size of points
  21758. */
  21759. pointSize: number;
  21760. /**
  21761. * Stores the z offset value
  21762. */
  21763. zOffset: number;
  21764. /**
  21765. * Gets a value specifying if wireframe mode is enabled
  21766. */
  21767. get wireframe(): boolean;
  21768. /**
  21769. * Sets the state of wireframe mode
  21770. */
  21771. set wireframe(value: boolean);
  21772. /**
  21773. * Gets the value specifying if point clouds are enabled
  21774. */
  21775. get pointsCloud(): boolean;
  21776. /**
  21777. * Sets the state of point cloud mode
  21778. */
  21779. set pointsCloud(value: boolean);
  21780. /**
  21781. * Gets the material fill mode
  21782. */
  21783. get fillMode(): number;
  21784. /**
  21785. * Sets the material fill mode
  21786. */
  21787. set fillMode(value: number);
  21788. /**
  21789. * @hidden
  21790. * Stores the effects for the material
  21791. */
  21792. _effect: Nullable<Effect>;
  21793. /**
  21794. * Specifies if uniform buffers should be used
  21795. */
  21796. private _useUBO;
  21797. /**
  21798. * Stores a reference to the scene
  21799. */
  21800. private _scene;
  21801. /**
  21802. * Stores the fill mode state
  21803. */
  21804. private _fillMode;
  21805. /**
  21806. * Specifies if the depth write state should be cached
  21807. */
  21808. private _cachedDepthWriteState;
  21809. /**
  21810. * Specifies if the depth function state should be cached
  21811. */
  21812. private _cachedDepthFunctionState;
  21813. /**
  21814. * Stores the uniform buffer
  21815. */
  21816. protected _uniformBuffer: UniformBuffer;
  21817. /** @hidden */
  21818. _indexInSceneMaterialArray: number;
  21819. /** @hidden */
  21820. meshMap: Nullable<{
  21821. [id: string]: AbstractMesh | undefined;
  21822. }>;
  21823. /**
  21824. * Creates a material instance
  21825. * @param name defines the name of the material
  21826. * @param scene defines the scene to reference
  21827. * @param doNotAdd specifies if the material should be added to the scene
  21828. */
  21829. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21830. /**
  21831. * Returns a string representation of the current material
  21832. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21833. * @returns a string with material information
  21834. */
  21835. toString(fullDetails?: boolean): string;
  21836. /**
  21837. * Gets the class name of the material
  21838. * @returns a string with the class name of the material
  21839. */
  21840. getClassName(): string;
  21841. /**
  21842. * Specifies if updates for the material been locked
  21843. */
  21844. get isFrozen(): boolean;
  21845. /**
  21846. * Locks updates for the material
  21847. */
  21848. freeze(): void;
  21849. /**
  21850. * Unlocks updates for the material
  21851. */
  21852. unfreeze(): void;
  21853. /**
  21854. * Specifies if the material is ready to be used
  21855. * @param mesh defines the mesh to check
  21856. * @param useInstances specifies if instances should be used
  21857. * @returns a boolean indicating if the material is ready to be used
  21858. */
  21859. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21860. /**
  21861. * Specifies that the submesh is ready to be used
  21862. * @param mesh defines the mesh to check
  21863. * @param subMesh defines which submesh to check
  21864. * @param useInstances specifies that instances should be used
  21865. * @returns a boolean indicating that the submesh is ready or not
  21866. */
  21867. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21868. /**
  21869. * Returns the material effect
  21870. * @returns the effect associated with the material
  21871. */
  21872. getEffect(): Nullable<Effect>;
  21873. /**
  21874. * Returns the current scene
  21875. * @returns a Scene
  21876. */
  21877. getScene(): Scene;
  21878. /**
  21879. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21880. */
  21881. protected _forceAlphaTest: boolean;
  21882. /**
  21883. * The transparency mode of the material.
  21884. */
  21885. protected _transparencyMode: Nullable<number>;
  21886. /**
  21887. * Gets the current transparency mode.
  21888. */
  21889. get transparencyMode(): Nullable<number>;
  21890. /**
  21891. * Sets the transparency mode of the material.
  21892. *
  21893. * | Value | Type | Description |
  21894. * | ----- | ----------------------------------- | ----------- |
  21895. * | 0 | OPAQUE | |
  21896. * | 1 | ALPHATEST | |
  21897. * | 2 | ALPHABLEND | |
  21898. * | 3 | ALPHATESTANDBLEND | |
  21899. *
  21900. */
  21901. set transparencyMode(value: Nullable<number>);
  21902. /**
  21903. * Returns true if alpha blending should be disabled.
  21904. */
  21905. protected get _disableAlphaBlending(): boolean;
  21906. /**
  21907. * Specifies whether or not this material should be rendered in alpha blend mode.
  21908. * @returns a boolean specifying if alpha blending is needed
  21909. */
  21910. needAlphaBlending(): boolean;
  21911. /**
  21912. * Specifies if the mesh will require alpha blending
  21913. * @param mesh defines the mesh to check
  21914. * @returns a boolean specifying if alpha blending is needed for the mesh
  21915. */
  21916. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21917. /**
  21918. * Specifies whether or not this material should be rendered in alpha test mode.
  21919. * @returns a boolean specifying if an alpha test is needed.
  21920. */
  21921. needAlphaTesting(): boolean;
  21922. /**
  21923. * Specifies if material alpha testing should be turned on for the mesh
  21924. * @param mesh defines the mesh to check
  21925. */
  21926. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21927. /**
  21928. * Gets the texture used for the alpha test
  21929. * @returns the texture to use for alpha testing
  21930. */
  21931. getAlphaTestTexture(): Nullable<BaseTexture>;
  21932. /**
  21933. * Marks the material to indicate that it needs to be re-calculated
  21934. */
  21935. markDirty(): void;
  21936. /** @hidden */
  21937. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21938. /**
  21939. * Binds the material to the mesh
  21940. * @param world defines the world transformation matrix
  21941. * @param mesh defines the mesh to bind the material to
  21942. */
  21943. bind(world: Matrix, mesh?: Mesh): void;
  21944. /**
  21945. * Binds the submesh to the material
  21946. * @param world defines the world transformation matrix
  21947. * @param mesh defines the mesh containing the submesh
  21948. * @param subMesh defines the submesh to bind the material to
  21949. */
  21950. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21951. /**
  21952. * Binds the world matrix to the material
  21953. * @param world defines the world transformation matrix
  21954. */
  21955. bindOnlyWorldMatrix(world: Matrix): void;
  21956. /**
  21957. * Binds the scene's uniform buffer to the effect.
  21958. * @param effect defines the effect to bind to the scene uniform buffer
  21959. * @param sceneUbo defines the uniform buffer storing scene data
  21960. */
  21961. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21962. /**
  21963. * Binds the view matrix to the effect
  21964. * @param effect defines the effect to bind the view matrix to
  21965. */
  21966. bindView(effect: Effect): void;
  21967. /**
  21968. * Binds the view projection matrix to the effect
  21969. * @param effect defines the effect to bind the view projection matrix to
  21970. */
  21971. bindViewProjection(effect: Effect): void;
  21972. /**
  21973. * Processes to execute after binding the material to a mesh
  21974. * @param mesh defines the rendered mesh
  21975. */
  21976. protected _afterBind(mesh?: Mesh): void;
  21977. /**
  21978. * Unbinds the material from the mesh
  21979. */
  21980. unbind(): void;
  21981. /**
  21982. * Gets the active textures from the material
  21983. * @returns an array of textures
  21984. */
  21985. getActiveTextures(): BaseTexture[];
  21986. /**
  21987. * Specifies if the material uses a texture
  21988. * @param texture defines the texture to check against the material
  21989. * @returns a boolean specifying if the material uses the texture
  21990. */
  21991. hasTexture(texture: BaseTexture): boolean;
  21992. /**
  21993. * Makes a duplicate of the material, and gives it a new name
  21994. * @param name defines the new name for the duplicated material
  21995. * @returns the cloned material
  21996. */
  21997. clone(name: string): Nullable<Material>;
  21998. /**
  21999. * Gets the meshes bound to the material
  22000. * @returns an array of meshes bound to the material
  22001. */
  22002. getBindedMeshes(): AbstractMesh[];
  22003. /**
  22004. * Force shader compilation
  22005. * @param mesh defines the mesh associated with this material
  22006. * @param onCompiled defines a function to execute once the material is compiled
  22007. * @param options defines the options to configure the compilation
  22008. * @param onError defines a function to execute if the material fails compiling
  22009. */
  22010. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  22011. /**
  22012. * Force shader compilation
  22013. * @param mesh defines the mesh that will use this material
  22014. * @param options defines additional options for compiling the shaders
  22015. * @returns a promise that resolves when the compilation completes
  22016. */
  22017. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  22018. private static readonly _AllDirtyCallBack;
  22019. private static readonly _ImageProcessingDirtyCallBack;
  22020. private static readonly _TextureDirtyCallBack;
  22021. private static readonly _FresnelDirtyCallBack;
  22022. private static readonly _MiscDirtyCallBack;
  22023. private static readonly _LightsDirtyCallBack;
  22024. private static readonly _AttributeDirtyCallBack;
  22025. private static _FresnelAndMiscDirtyCallBack;
  22026. private static _TextureAndMiscDirtyCallBack;
  22027. private static readonly _DirtyCallbackArray;
  22028. private static readonly _RunDirtyCallBacks;
  22029. /**
  22030. * Marks a define in the material to indicate that it needs to be re-computed
  22031. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22032. */
  22033. markAsDirty(flag: number): void;
  22034. /**
  22035. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22036. * @param func defines a function which checks material defines against the submeshes
  22037. */
  22038. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22039. /**
  22040. * Indicates that we need to re-calculated for all submeshes
  22041. */
  22042. protected _markAllSubMeshesAsAllDirty(): void;
  22043. /**
  22044. * Indicates that image processing needs to be re-calculated for all submeshes
  22045. */
  22046. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22047. /**
  22048. * Indicates that textures need to be re-calculated for all submeshes
  22049. */
  22050. protected _markAllSubMeshesAsTexturesDirty(): void;
  22051. /**
  22052. * Indicates that fresnel needs to be re-calculated for all submeshes
  22053. */
  22054. protected _markAllSubMeshesAsFresnelDirty(): void;
  22055. /**
  22056. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22057. */
  22058. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22059. /**
  22060. * Indicates that lights need to be re-calculated for all submeshes
  22061. */
  22062. protected _markAllSubMeshesAsLightsDirty(): void;
  22063. /**
  22064. * Indicates that attributes need to be re-calculated for all submeshes
  22065. */
  22066. protected _markAllSubMeshesAsAttributesDirty(): void;
  22067. /**
  22068. * Indicates that misc needs to be re-calculated for all submeshes
  22069. */
  22070. protected _markAllSubMeshesAsMiscDirty(): void;
  22071. /**
  22072. * Indicates that textures and misc need to be re-calculated for all submeshes
  22073. */
  22074. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22075. /**
  22076. * Disposes the material
  22077. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22078. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22079. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22080. */
  22081. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22082. /** @hidden */
  22083. private releaseVertexArrayObject;
  22084. /**
  22085. * Serializes this material
  22086. * @returns the serialized material object
  22087. */
  22088. serialize(): any;
  22089. /**
  22090. * Creates a material from parsed material data
  22091. * @param parsedMaterial defines parsed material data
  22092. * @param scene defines the hosting scene
  22093. * @param rootUrl defines the root URL to use to load textures
  22094. * @returns a new material
  22095. */
  22096. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22097. }
  22098. }
  22099. declare module "babylonjs/Materials/multiMaterial" {
  22100. import { Nullable } from "babylonjs/types";
  22101. import { Scene } from "babylonjs/scene";
  22102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22103. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  22104. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22105. import { Material } from "babylonjs/Materials/material";
  22106. /**
  22107. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22108. * separate meshes. This can be use to improve performances.
  22109. * @see http://doc.babylonjs.com/how_to/multi_materials
  22110. */
  22111. export class MultiMaterial extends Material {
  22112. private _subMaterials;
  22113. /**
  22114. * Gets or Sets the list of Materials used within the multi material.
  22115. * They need to be ordered according to the submeshes order in the associated mesh
  22116. */
  22117. get subMaterials(): Nullable<Material>[];
  22118. set subMaterials(value: Nullable<Material>[]);
  22119. /**
  22120. * Function used to align with Node.getChildren()
  22121. * @returns the list of Materials used within the multi material
  22122. */
  22123. getChildren(): Nullable<Material>[];
  22124. /**
  22125. * Instantiates a new Multi Material
  22126. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22127. * separate meshes. This can be use to improve performances.
  22128. * @see http://doc.babylonjs.com/how_to/multi_materials
  22129. * @param name Define the name in the scene
  22130. * @param scene Define the scene the material belongs to
  22131. */
  22132. constructor(name: string, scene: Scene);
  22133. private _hookArray;
  22134. /**
  22135. * Get one of the submaterial by its index in the submaterials array
  22136. * @param index The index to look the sub material at
  22137. * @returns The Material if the index has been defined
  22138. */
  22139. getSubMaterial(index: number): Nullable<Material>;
  22140. /**
  22141. * Get the list of active textures for the whole sub materials list.
  22142. * @returns All the textures that will be used during the rendering
  22143. */
  22144. getActiveTextures(): BaseTexture[];
  22145. /**
  22146. * Gets the current class name of the material e.g. "MultiMaterial"
  22147. * Mainly use in serialization.
  22148. * @returns the class name
  22149. */
  22150. getClassName(): string;
  22151. /**
  22152. * Checks if the material is ready to render the requested sub mesh
  22153. * @param mesh Define the mesh the submesh belongs to
  22154. * @param subMesh Define the sub mesh to look readyness for
  22155. * @param useInstances Define whether or not the material is used with instances
  22156. * @returns true if ready, otherwise false
  22157. */
  22158. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22159. /**
  22160. * Clones the current material and its related sub materials
  22161. * @param name Define the name of the newly cloned material
  22162. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  22163. * @returns the cloned material
  22164. */
  22165. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  22166. /**
  22167. * Serializes the materials into a JSON representation.
  22168. * @returns the JSON representation
  22169. */
  22170. serialize(): any;
  22171. /**
  22172. * Dispose the material and release its associated resources
  22173. * @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)
  22174. * @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)
  22175. * @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)
  22176. */
  22177. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  22178. /**
  22179. * Creates a MultiMaterial from parsed MultiMaterial data.
  22180. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  22181. * @param scene defines the hosting scene
  22182. * @returns a new MultiMaterial
  22183. */
  22184. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  22185. }
  22186. }
  22187. declare module "babylonjs/Meshes/subMesh" {
  22188. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  22189. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  22190. import { Engine } from "babylonjs/Engines/engine";
  22191. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22192. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22193. import { Effect } from "babylonjs/Materials/effect";
  22194. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22195. import { Plane } from "babylonjs/Maths/math.plane";
  22196. import { Collider } from "babylonjs/Collisions/collider";
  22197. import { Material } from "babylonjs/Materials/material";
  22198. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22199. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22200. import { Mesh } from "babylonjs/Meshes/mesh";
  22201. import { Ray } from "babylonjs/Culling/ray";
  22202. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22203. /**
  22204. * Base class for submeshes
  22205. */
  22206. export class BaseSubMesh {
  22207. /** @hidden */
  22208. _materialDefines: Nullable<MaterialDefines>;
  22209. /** @hidden */
  22210. _materialEffect: Nullable<Effect>;
  22211. /**
  22212. * Gets material defines used by the effect associated to the sub mesh
  22213. */
  22214. get materialDefines(): Nullable<MaterialDefines>;
  22215. /**
  22216. * Sets material defines used by the effect associated to the sub mesh
  22217. */
  22218. set materialDefines(defines: Nullable<MaterialDefines>);
  22219. /**
  22220. * Gets associated effect
  22221. */
  22222. get effect(): Nullable<Effect>;
  22223. /**
  22224. * Sets associated effect (effect used to render this submesh)
  22225. * @param effect defines the effect to associate with
  22226. * @param defines defines the set of defines used to compile this effect
  22227. */
  22228. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22229. }
  22230. /**
  22231. * Defines a subdivision inside a mesh
  22232. */
  22233. export class SubMesh extends BaseSubMesh implements ICullable {
  22234. /** the material index to use */
  22235. materialIndex: number;
  22236. /** vertex index start */
  22237. verticesStart: number;
  22238. /** vertices count */
  22239. verticesCount: number;
  22240. /** index start */
  22241. indexStart: number;
  22242. /** indices count */
  22243. indexCount: number;
  22244. /** @hidden */
  22245. _linesIndexCount: number;
  22246. private _mesh;
  22247. private _renderingMesh;
  22248. private _boundingInfo;
  22249. private _linesIndexBuffer;
  22250. /** @hidden */
  22251. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22252. /** @hidden */
  22253. _trianglePlanes: Plane[];
  22254. /** @hidden */
  22255. _lastColliderTransformMatrix: Nullable<Matrix>;
  22256. /** @hidden */
  22257. _renderId: number;
  22258. /** @hidden */
  22259. _alphaIndex: number;
  22260. /** @hidden */
  22261. _distanceToCamera: number;
  22262. /** @hidden */
  22263. _id: number;
  22264. private _currentMaterial;
  22265. /**
  22266. * Add a new submesh to a mesh
  22267. * @param materialIndex defines the material index to use
  22268. * @param verticesStart defines vertex index start
  22269. * @param verticesCount defines vertices count
  22270. * @param indexStart defines index start
  22271. * @param indexCount defines indices count
  22272. * @param mesh defines the parent mesh
  22273. * @param renderingMesh defines an optional rendering mesh
  22274. * @param createBoundingBox defines if bounding box should be created for this submesh
  22275. * @returns the new submesh
  22276. */
  22277. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22278. /**
  22279. * Creates a new submesh
  22280. * @param materialIndex defines the material index to use
  22281. * @param verticesStart defines vertex index start
  22282. * @param verticesCount defines vertices count
  22283. * @param indexStart defines index start
  22284. * @param indexCount defines indices count
  22285. * @param mesh defines the parent mesh
  22286. * @param renderingMesh defines an optional rendering mesh
  22287. * @param createBoundingBox defines if bounding box should be created for this submesh
  22288. */
  22289. constructor(
  22290. /** the material index to use */
  22291. materialIndex: number,
  22292. /** vertex index start */
  22293. verticesStart: number,
  22294. /** vertices count */
  22295. verticesCount: number,
  22296. /** index start */
  22297. indexStart: number,
  22298. /** indices count */
  22299. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22300. /**
  22301. * Returns true if this submesh covers the entire parent mesh
  22302. * @ignorenaming
  22303. */
  22304. get IsGlobal(): boolean;
  22305. /**
  22306. * Returns the submesh BoudingInfo object
  22307. * @returns current bounding info (or mesh's one if the submesh is global)
  22308. */
  22309. getBoundingInfo(): BoundingInfo;
  22310. /**
  22311. * Sets the submesh BoundingInfo
  22312. * @param boundingInfo defines the new bounding info to use
  22313. * @returns the SubMesh
  22314. */
  22315. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22316. /**
  22317. * Returns the mesh of the current submesh
  22318. * @return the parent mesh
  22319. */
  22320. getMesh(): AbstractMesh;
  22321. /**
  22322. * Returns the rendering mesh of the submesh
  22323. * @returns the rendering mesh (could be different from parent mesh)
  22324. */
  22325. getRenderingMesh(): Mesh;
  22326. /**
  22327. * Returns the submesh material
  22328. * @returns null or the current material
  22329. */
  22330. getMaterial(): Nullable<Material>;
  22331. /**
  22332. * Sets a new updated BoundingInfo object to the submesh
  22333. * @param data defines an optional position array to use to determine the bounding info
  22334. * @returns the SubMesh
  22335. */
  22336. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22337. /** @hidden */
  22338. _checkCollision(collider: Collider): boolean;
  22339. /**
  22340. * Updates the submesh BoundingInfo
  22341. * @param world defines the world matrix to use to update the bounding info
  22342. * @returns the submesh
  22343. */
  22344. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22345. /**
  22346. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22347. * @param frustumPlanes defines the frustum planes
  22348. * @returns true if the submesh is intersecting with the frustum
  22349. */
  22350. isInFrustum(frustumPlanes: Plane[]): boolean;
  22351. /**
  22352. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22353. * @param frustumPlanes defines the frustum planes
  22354. * @returns true if the submesh is inside the frustum
  22355. */
  22356. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22357. /**
  22358. * Renders the submesh
  22359. * @param enableAlphaMode defines if alpha needs to be used
  22360. * @returns the submesh
  22361. */
  22362. render(enableAlphaMode: boolean): SubMesh;
  22363. /**
  22364. * @hidden
  22365. */
  22366. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22367. /**
  22368. * Checks if the submesh intersects with a ray
  22369. * @param ray defines the ray to test
  22370. * @returns true is the passed ray intersects the submesh bounding box
  22371. */
  22372. canIntersects(ray: Ray): boolean;
  22373. /**
  22374. * Intersects current submesh with a ray
  22375. * @param ray defines the ray to test
  22376. * @param positions defines mesh's positions array
  22377. * @param indices defines mesh's indices array
  22378. * @param fastCheck defines if only bounding info should be used
  22379. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22380. * @returns intersection info or null if no intersection
  22381. */
  22382. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22383. /** @hidden */
  22384. private _intersectLines;
  22385. /** @hidden */
  22386. private _intersectUnIndexedLines;
  22387. /** @hidden */
  22388. private _intersectTriangles;
  22389. /** @hidden */
  22390. private _intersectUnIndexedTriangles;
  22391. /** @hidden */
  22392. _rebuild(): void;
  22393. /**
  22394. * Creates a new submesh from the passed mesh
  22395. * @param newMesh defines the new hosting mesh
  22396. * @param newRenderingMesh defines an optional rendering mesh
  22397. * @returns the new submesh
  22398. */
  22399. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22400. /**
  22401. * Release associated resources
  22402. */
  22403. dispose(): void;
  22404. /**
  22405. * Gets the class name
  22406. * @returns the string "SubMesh".
  22407. */
  22408. getClassName(): string;
  22409. /**
  22410. * Creates a new submesh from indices data
  22411. * @param materialIndex the index of the main mesh material
  22412. * @param startIndex the index where to start the copy in the mesh indices array
  22413. * @param indexCount the number of indices to copy then from the startIndex
  22414. * @param mesh the main mesh to create the submesh from
  22415. * @param renderingMesh the optional rendering mesh
  22416. * @returns a new submesh
  22417. */
  22418. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22419. }
  22420. }
  22421. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22422. /**
  22423. * Class used to represent data loading progression
  22424. */
  22425. export class SceneLoaderFlags {
  22426. private static _ForceFullSceneLoadingForIncremental;
  22427. private static _ShowLoadingScreen;
  22428. private static _CleanBoneMatrixWeights;
  22429. private static _loggingLevel;
  22430. /**
  22431. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22432. */
  22433. static get ForceFullSceneLoadingForIncremental(): boolean;
  22434. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22435. /**
  22436. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22437. */
  22438. static get ShowLoadingScreen(): boolean;
  22439. static set ShowLoadingScreen(value: boolean);
  22440. /**
  22441. * Defines the current logging level (while loading the scene)
  22442. * @ignorenaming
  22443. */
  22444. static get loggingLevel(): number;
  22445. static set loggingLevel(value: number);
  22446. /**
  22447. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22448. */
  22449. static get CleanBoneMatrixWeights(): boolean;
  22450. static set CleanBoneMatrixWeights(value: boolean);
  22451. }
  22452. }
  22453. declare module "babylonjs/Meshes/geometry" {
  22454. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22455. import { Scene } from "babylonjs/scene";
  22456. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22457. import { Engine } from "babylonjs/Engines/engine";
  22458. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22459. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22460. import { Effect } from "babylonjs/Materials/effect";
  22461. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22462. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22463. import { Mesh } from "babylonjs/Meshes/mesh";
  22464. /**
  22465. * Class used to store geometry data (vertex buffers + index buffer)
  22466. */
  22467. export class Geometry implements IGetSetVerticesData {
  22468. /**
  22469. * Gets or sets the ID of the geometry
  22470. */
  22471. id: string;
  22472. /**
  22473. * Gets or sets the unique ID of the geometry
  22474. */
  22475. uniqueId: number;
  22476. /**
  22477. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22478. */
  22479. delayLoadState: number;
  22480. /**
  22481. * Gets the file containing the data to load when running in delay load state
  22482. */
  22483. delayLoadingFile: Nullable<string>;
  22484. /**
  22485. * Callback called when the geometry is updated
  22486. */
  22487. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22488. private _scene;
  22489. private _engine;
  22490. private _meshes;
  22491. private _totalVertices;
  22492. /** @hidden */
  22493. _indices: IndicesArray;
  22494. /** @hidden */
  22495. _vertexBuffers: {
  22496. [key: string]: VertexBuffer;
  22497. };
  22498. private _isDisposed;
  22499. private _extend;
  22500. private _boundingBias;
  22501. /** @hidden */
  22502. _delayInfo: Array<string>;
  22503. private _indexBuffer;
  22504. private _indexBufferIsUpdatable;
  22505. /** @hidden */
  22506. _boundingInfo: Nullable<BoundingInfo>;
  22507. /** @hidden */
  22508. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22509. /** @hidden */
  22510. _softwareSkinningFrameId: number;
  22511. private _vertexArrayObjects;
  22512. private _updatable;
  22513. /** @hidden */
  22514. _positions: Nullable<Vector3[]>;
  22515. /**
  22516. * 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
  22517. */
  22518. get boundingBias(): Vector2;
  22519. /**
  22520. * 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
  22521. */
  22522. set boundingBias(value: Vector2);
  22523. /**
  22524. * Static function used to attach a new empty geometry to a mesh
  22525. * @param mesh defines the mesh to attach the geometry to
  22526. * @returns the new Geometry
  22527. */
  22528. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22529. /**
  22530. * Creates a new geometry
  22531. * @param id defines the unique ID
  22532. * @param scene defines the hosting scene
  22533. * @param vertexData defines the VertexData used to get geometry data
  22534. * @param updatable defines if geometry must be updatable (false by default)
  22535. * @param mesh defines the mesh that will be associated with the geometry
  22536. */
  22537. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22538. /**
  22539. * Gets the current extend of the geometry
  22540. */
  22541. get extend(): {
  22542. minimum: Vector3;
  22543. maximum: Vector3;
  22544. };
  22545. /**
  22546. * Gets the hosting scene
  22547. * @returns the hosting Scene
  22548. */
  22549. getScene(): Scene;
  22550. /**
  22551. * Gets the hosting engine
  22552. * @returns the hosting Engine
  22553. */
  22554. getEngine(): Engine;
  22555. /**
  22556. * Defines if the geometry is ready to use
  22557. * @returns true if the geometry is ready to be used
  22558. */
  22559. isReady(): boolean;
  22560. /**
  22561. * Gets a value indicating that the geometry should not be serialized
  22562. */
  22563. get doNotSerialize(): boolean;
  22564. /** @hidden */
  22565. _rebuild(): void;
  22566. /**
  22567. * Affects all geometry data in one call
  22568. * @param vertexData defines the geometry data
  22569. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22570. */
  22571. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22572. /**
  22573. * Set specific vertex data
  22574. * @param kind defines the data kind (Position, normal, etc...)
  22575. * @param data defines the vertex data to use
  22576. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22577. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22578. */
  22579. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22580. /**
  22581. * Removes a specific vertex data
  22582. * @param kind defines the data kind (Position, normal, etc...)
  22583. */
  22584. removeVerticesData(kind: string): void;
  22585. /**
  22586. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22587. * @param buffer defines the vertex buffer to use
  22588. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22589. */
  22590. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22591. /**
  22592. * Update a specific vertex buffer
  22593. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22594. * It will do nothing if the buffer is not updatable
  22595. * @param kind defines the data kind (Position, normal, etc...)
  22596. * @param data defines the data to use
  22597. * @param offset defines the offset in the target buffer where to store the data
  22598. * @param useBytes set to true if the offset is in bytes
  22599. */
  22600. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22601. /**
  22602. * Update a specific vertex buffer
  22603. * This function will create a new buffer if the current one is not updatable
  22604. * @param kind defines the data kind (Position, normal, etc...)
  22605. * @param data defines the data to use
  22606. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22607. */
  22608. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22609. private _updateBoundingInfo;
  22610. /** @hidden */
  22611. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22612. /**
  22613. * Gets total number of vertices
  22614. * @returns the total number of vertices
  22615. */
  22616. getTotalVertices(): number;
  22617. /**
  22618. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22619. * @param kind defines the data kind (Position, normal, etc...)
  22620. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22621. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22622. * @returns a float array containing vertex data
  22623. */
  22624. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22625. /**
  22626. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22627. * @param kind defines the data kind (Position, normal, etc...)
  22628. * @returns true if the vertex buffer with the specified kind is updatable
  22629. */
  22630. isVertexBufferUpdatable(kind: string): boolean;
  22631. /**
  22632. * Gets a specific vertex buffer
  22633. * @param kind defines the data kind (Position, normal, etc...)
  22634. * @returns a VertexBuffer
  22635. */
  22636. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22637. /**
  22638. * Returns all vertex buffers
  22639. * @return an object holding all vertex buffers indexed by kind
  22640. */
  22641. getVertexBuffers(): Nullable<{
  22642. [key: string]: VertexBuffer;
  22643. }>;
  22644. /**
  22645. * Gets a boolean indicating if specific vertex buffer is present
  22646. * @param kind defines the data kind (Position, normal, etc...)
  22647. * @returns true if data is present
  22648. */
  22649. isVerticesDataPresent(kind: string): boolean;
  22650. /**
  22651. * Gets a list of all attached data kinds (Position, normal, etc...)
  22652. * @returns a list of string containing all kinds
  22653. */
  22654. getVerticesDataKinds(): string[];
  22655. /**
  22656. * Update index buffer
  22657. * @param indices defines the indices to store in the index buffer
  22658. * @param offset defines the offset in the target buffer where to store the data
  22659. * @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)
  22660. */
  22661. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22662. /**
  22663. * Creates a new index buffer
  22664. * @param indices defines the indices to store in the index buffer
  22665. * @param totalVertices defines the total number of vertices (could be null)
  22666. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22667. */
  22668. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22669. /**
  22670. * Return the total number of indices
  22671. * @returns the total number of indices
  22672. */
  22673. getTotalIndices(): number;
  22674. /**
  22675. * Gets the index buffer array
  22676. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22677. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22678. * @returns the index buffer array
  22679. */
  22680. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22681. /**
  22682. * Gets the index buffer
  22683. * @return the index buffer
  22684. */
  22685. getIndexBuffer(): Nullable<DataBuffer>;
  22686. /** @hidden */
  22687. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22688. /**
  22689. * Release the associated resources for a specific mesh
  22690. * @param mesh defines the source mesh
  22691. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22692. */
  22693. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22694. /**
  22695. * Apply current geometry to a given mesh
  22696. * @param mesh defines the mesh to apply geometry to
  22697. */
  22698. applyToMesh(mesh: Mesh): void;
  22699. private _updateExtend;
  22700. private _applyToMesh;
  22701. private notifyUpdate;
  22702. /**
  22703. * Load the geometry if it was flagged as delay loaded
  22704. * @param scene defines the hosting scene
  22705. * @param onLoaded defines a callback called when the geometry is loaded
  22706. */
  22707. load(scene: Scene, onLoaded?: () => void): void;
  22708. private _queueLoad;
  22709. /**
  22710. * Invert the geometry to move from a right handed system to a left handed one.
  22711. */
  22712. toLeftHanded(): void;
  22713. /** @hidden */
  22714. _resetPointsArrayCache(): void;
  22715. /** @hidden */
  22716. _generatePointsArray(): boolean;
  22717. /**
  22718. * Gets a value indicating if the geometry is disposed
  22719. * @returns true if the geometry was disposed
  22720. */
  22721. isDisposed(): boolean;
  22722. private _disposeVertexArrayObjects;
  22723. /**
  22724. * Free all associated resources
  22725. */
  22726. dispose(): void;
  22727. /**
  22728. * Clone the current geometry into a new geometry
  22729. * @param id defines the unique ID of the new geometry
  22730. * @returns a new geometry object
  22731. */
  22732. copy(id: string): Geometry;
  22733. /**
  22734. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22735. * @return a JSON representation of the current geometry data (without the vertices data)
  22736. */
  22737. serialize(): any;
  22738. private toNumberArray;
  22739. /**
  22740. * Serialize all vertices data into a JSON oject
  22741. * @returns a JSON representation of the current geometry data
  22742. */
  22743. serializeVerticeData(): any;
  22744. /**
  22745. * Extracts a clone of a mesh geometry
  22746. * @param mesh defines the source mesh
  22747. * @param id defines the unique ID of the new geometry object
  22748. * @returns the new geometry object
  22749. */
  22750. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22751. /**
  22752. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22753. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22754. * Be aware Math.random() could cause collisions, but:
  22755. * "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"
  22756. * @returns a string containing a new GUID
  22757. */
  22758. static RandomId(): string;
  22759. /** @hidden */
  22760. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22761. private static _CleanMatricesWeights;
  22762. /**
  22763. * Create a new geometry from persisted data (Using .babylon file format)
  22764. * @param parsedVertexData defines the persisted data
  22765. * @param scene defines the hosting scene
  22766. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22767. * @returns the new geometry object
  22768. */
  22769. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22770. }
  22771. }
  22772. declare module "babylonjs/Meshes/mesh.vertexData" {
  22773. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22774. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22775. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22776. import { Geometry } from "babylonjs/Meshes/geometry";
  22777. import { Mesh } from "babylonjs/Meshes/mesh";
  22778. /**
  22779. * Define an interface for all classes that will get and set the data on vertices
  22780. */
  22781. export interface IGetSetVerticesData {
  22782. /**
  22783. * Gets a boolean indicating if specific vertex data is present
  22784. * @param kind defines the vertex data kind to use
  22785. * @returns true is data kind is present
  22786. */
  22787. isVerticesDataPresent(kind: string): boolean;
  22788. /**
  22789. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22790. * @param kind defines the data kind (Position, normal, etc...)
  22791. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22792. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22793. * @returns a float array containing vertex data
  22794. */
  22795. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22796. /**
  22797. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22798. * @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.
  22799. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22800. * @returns the indices array or an empty array if the mesh has no geometry
  22801. */
  22802. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22803. /**
  22804. * Set specific vertex data
  22805. * @param kind defines the data kind (Position, normal, etc...)
  22806. * @param data defines the vertex data to use
  22807. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22808. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22809. */
  22810. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22811. /**
  22812. * Update a specific associated vertex buffer
  22813. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22814. * - VertexBuffer.PositionKind
  22815. * - VertexBuffer.UVKind
  22816. * - VertexBuffer.UV2Kind
  22817. * - VertexBuffer.UV3Kind
  22818. * - VertexBuffer.UV4Kind
  22819. * - VertexBuffer.UV5Kind
  22820. * - VertexBuffer.UV6Kind
  22821. * - VertexBuffer.ColorKind
  22822. * - VertexBuffer.MatricesIndicesKind
  22823. * - VertexBuffer.MatricesIndicesExtraKind
  22824. * - VertexBuffer.MatricesWeightsKind
  22825. * - VertexBuffer.MatricesWeightsExtraKind
  22826. * @param data defines the data source
  22827. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22828. * @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)
  22829. */
  22830. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22831. /**
  22832. * Creates a new index buffer
  22833. * @param indices defines the indices to store in the index buffer
  22834. * @param totalVertices defines the total number of vertices (could be null)
  22835. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22836. */
  22837. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22838. }
  22839. /**
  22840. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22841. */
  22842. export class VertexData {
  22843. /**
  22844. * Mesh side orientation : usually the external or front surface
  22845. */
  22846. static readonly FRONTSIDE: number;
  22847. /**
  22848. * Mesh side orientation : usually the internal or back surface
  22849. */
  22850. static readonly BACKSIDE: number;
  22851. /**
  22852. * Mesh side orientation : both internal and external or front and back surfaces
  22853. */
  22854. static readonly DOUBLESIDE: number;
  22855. /**
  22856. * Mesh side orientation : by default, `FRONTSIDE`
  22857. */
  22858. static readonly DEFAULTSIDE: number;
  22859. /**
  22860. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22861. */
  22862. positions: Nullable<FloatArray>;
  22863. /**
  22864. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22865. */
  22866. normals: Nullable<FloatArray>;
  22867. /**
  22868. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22869. */
  22870. tangents: Nullable<FloatArray>;
  22871. /**
  22872. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22873. */
  22874. uvs: Nullable<FloatArray>;
  22875. /**
  22876. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22877. */
  22878. uvs2: Nullable<FloatArray>;
  22879. /**
  22880. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22881. */
  22882. uvs3: Nullable<FloatArray>;
  22883. /**
  22884. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22885. */
  22886. uvs4: Nullable<FloatArray>;
  22887. /**
  22888. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22889. */
  22890. uvs5: Nullable<FloatArray>;
  22891. /**
  22892. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22893. */
  22894. uvs6: Nullable<FloatArray>;
  22895. /**
  22896. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22897. */
  22898. colors: Nullable<FloatArray>;
  22899. /**
  22900. * 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).
  22901. */
  22902. matricesIndices: Nullable<FloatArray>;
  22903. /**
  22904. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22905. */
  22906. matricesWeights: Nullable<FloatArray>;
  22907. /**
  22908. * An array extending the number of possible indices
  22909. */
  22910. matricesIndicesExtra: Nullable<FloatArray>;
  22911. /**
  22912. * An array extending the number of possible weights when the number of indices is extended
  22913. */
  22914. matricesWeightsExtra: Nullable<FloatArray>;
  22915. /**
  22916. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22917. */
  22918. indices: Nullable<IndicesArray>;
  22919. /**
  22920. * Uses the passed data array to set the set the values for the specified kind of data
  22921. * @param data a linear array of floating numbers
  22922. * @param kind the type of data that is being set, eg positions, colors etc
  22923. */
  22924. set(data: FloatArray, kind: string): void;
  22925. /**
  22926. * Associates the vertexData to the passed Mesh.
  22927. * Sets it as updatable or not (default `false`)
  22928. * @param mesh the mesh the vertexData is applied to
  22929. * @param updatable when used and having the value true allows new data to update the vertexData
  22930. * @returns the VertexData
  22931. */
  22932. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22933. /**
  22934. * Associates the vertexData to the passed Geometry.
  22935. * Sets it as updatable or not (default `false`)
  22936. * @param geometry the geometry the vertexData is applied to
  22937. * @param updatable when used and having the value true allows new data to update the vertexData
  22938. * @returns VertexData
  22939. */
  22940. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22941. /**
  22942. * Updates the associated mesh
  22943. * @param mesh the mesh to be updated
  22944. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22945. * @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
  22946. * @returns VertexData
  22947. */
  22948. updateMesh(mesh: Mesh): VertexData;
  22949. /**
  22950. * Updates the associated geometry
  22951. * @param geometry the geometry to be updated
  22952. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22953. * @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
  22954. * @returns VertexData.
  22955. */
  22956. updateGeometry(geometry: Geometry): VertexData;
  22957. private _applyTo;
  22958. private _update;
  22959. /**
  22960. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22961. * @param matrix the transforming matrix
  22962. * @returns the VertexData
  22963. */
  22964. transform(matrix: Matrix): VertexData;
  22965. /**
  22966. * Merges the passed VertexData into the current one
  22967. * @param other the VertexData to be merged into the current one
  22968. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22969. * @returns the modified VertexData
  22970. */
  22971. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22972. private _mergeElement;
  22973. private _validate;
  22974. /**
  22975. * Serializes the VertexData
  22976. * @returns a serialized object
  22977. */
  22978. serialize(): any;
  22979. /**
  22980. * Extracts the vertexData from a mesh
  22981. * @param mesh the mesh from which to extract the VertexData
  22982. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22983. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22984. * @returns the object VertexData associated to the passed mesh
  22985. */
  22986. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22987. /**
  22988. * Extracts the vertexData from the geometry
  22989. * @param geometry the geometry from which to extract the VertexData
  22990. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22991. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22992. * @returns the object VertexData associated to the passed mesh
  22993. */
  22994. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22995. private static _ExtractFrom;
  22996. /**
  22997. * Creates the VertexData for a Ribbon
  22998. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22999. * * pathArray array of paths, each of which an array of successive Vector3
  23000. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23001. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23002. * * 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
  23003. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23004. * * 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)
  23005. * * 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)
  23006. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23007. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23008. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23009. * @returns the VertexData of the ribbon
  23010. */
  23011. static CreateRibbon(options: {
  23012. pathArray: Vector3[][];
  23013. closeArray?: boolean;
  23014. closePath?: boolean;
  23015. offset?: number;
  23016. sideOrientation?: number;
  23017. frontUVs?: Vector4;
  23018. backUVs?: Vector4;
  23019. invertUV?: boolean;
  23020. uvs?: Vector2[];
  23021. colors?: Color4[];
  23022. }): VertexData;
  23023. /**
  23024. * Creates the VertexData for a box
  23025. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23026. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23027. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23028. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23029. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23030. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23031. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23032. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23033. * * 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)
  23034. * * 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)
  23035. * @returns the VertexData of the box
  23036. */
  23037. static CreateBox(options: {
  23038. size?: number;
  23039. width?: number;
  23040. height?: number;
  23041. depth?: number;
  23042. faceUV?: Vector4[];
  23043. faceColors?: Color4[];
  23044. sideOrientation?: number;
  23045. frontUVs?: Vector4;
  23046. backUVs?: Vector4;
  23047. }): VertexData;
  23048. /**
  23049. * Creates the VertexData for a tiled box
  23050. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23051. * * faceTiles sets the pattern, tile size and number of tiles for a face
  23052. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23053. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23054. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23055. * @returns the VertexData of the box
  23056. */
  23057. static CreateTiledBox(options: {
  23058. pattern?: number;
  23059. width?: number;
  23060. height?: number;
  23061. depth?: number;
  23062. tileSize?: number;
  23063. tileWidth?: number;
  23064. tileHeight?: number;
  23065. alignHorizontal?: number;
  23066. alignVertical?: number;
  23067. faceUV?: Vector4[];
  23068. faceColors?: Color4[];
  23069. sideOrientation?: number;
  23070. }): VertexData;
  23071. /**
  23072. * Creates the VertexData for a tiled plane
  23073. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23074. * * pattern a limited pattern arrangement depending on the number
  23075. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  23076. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  23077. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  23078. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23079. * * 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)
  23080. * * 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)
  23081. * @returns the VertexData of the tiled plane
  23082. */
  23083. static CreateTiledPlane(options: {
  23084. pattern?: number;
  23085. tileSize?: number;
  23086. tileWidth?: number;
  23087. tileHeight?: number;
  23088. size?: number;
  23089. width?: number;
  23090. height?: number;
  23091. alignHorizontal?: number;
  23092. alignVertical?: number;
  23093. sideOrientation?: number;
  23094. frontUVs?: Vector4;
  23095. backUVs?: Vector4;
  23096. }): VertexData;
  23097. /**
  23098. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23099. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23100. * * segments sets the number of horizontal strips optional, default 32
  23101. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23102. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23103. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23104. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23105. * * 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
  23106. * * 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
  23107. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23108. * * 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)
  23109. * * 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)
  23110. * @returns the VertexData of the ellipsoid
  23111. */
  23112. static CreateSphere(options: {
  23113. segments?: number;
  23114. diameter?: number;
  23115. diameterX?: number;
  23116. diameterY?: number;
  23117. diameterZ?: number;
  23118. arc?: number;
  23119. slice?: number;
  23120. sideOrientation?: number;
  23121. frontUVs?: Vector4;
  23122. backUVs?: Vector4;
  23123. }): VertexData;
  23124. /**
  23125. * Creates the VertexData for a cylinder, cone or prism
  23126. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23127. * * height sets the height (y direction) of the cylinder, optional, default 2
  23128. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23129. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23130. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23131. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23132. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23133. * * 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
  23134. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23135. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23136. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23137. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23138. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23139. * * 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)
  23140. * * 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)
  23141. * @returns the VertexData of the cylinder, cone or prism
  23142. */
  23143. static CreateCylinder(options: {
  23144. height?: number;
  23145. diameterTop?: number;
  23146. diameterBottom?: number;
  23147. diameter?: number;
  23148. tessellation?: number;
  23149. subdivisions?: number;
  23150. arc?: number;
  23151. faceColors?: Color4[];
  23152. faceUV?: Vector4[];
  23153. hasRings?: boolean;
  23154. enclose?: boolean;
  23155. sideOrientation?: number;
  23156. frontUVs?: Vector4;
  23157. backUVs?: Vector4;
  23158. }): VertexData;
  23159. /**
  23160. * Creates the VertexData for a torus
  23161. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23162. * * diameter the diameter of the torus, optional default 1
  23163. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23164. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23165. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23166. * * 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)
  23167. * * 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)
  23168. * @returns the VertexData of the torus
  23169. */
  23170. static CreateTorus(options: {
  23171. diameter?: number;
  23172. thickness?: number;
  23173. tessellation?: number;
  23174. sideOrientation?: number;
  23175. frontUVs?: Vector4;
  23176. backUVs?: Vector4;
  23177. }): VertexData;
  23178. /**
  23179. * Creates the VertexData of the LineSystem
  23180. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23181. * - lines an array of lines, each line being an array of successive Vector3
  23182. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23183. * @returns the VertexData of the LineSystem
  23184. */
  23185. static CreateLineSystem(options: {
  23186. lines: Vector3[][];
  23187. colors?: Nullable<Color4[][]>;
  23188. }): VertexData;
  23189. /**
  23190. * Create the VertexData for a DashedLines
  23191. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23192. * - points an array successive Vector3
  23193. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23194. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23195. * - dashNb the intended total number of dashes, optional, default 200
  23196. * @returns the VertexData for the DashedLines
  23197. */
  23198. static CreateDashedLines(options: {
  23199. points: Vector3[];
  23200. dashSize?: number;
  23201. gapSize?: number;
  23202. dashNb?: number;
  23203. }): VertexData;
  23204. /**
  23205. * Creates the VertexData for a Ground
  23206. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23207. * - width the width (x direction) of the ground, optional, default 1
  23208. * - height the height (z direction) of the ground, optional, default 1
  23209. * - subdivisions the number of subdivisions per side, optional, default 1
  23210. * @returns the VertexData of the Ground
  23211. */
  23212. static CreateGround(options: {
  23213. width?: number;
  23214. height?: number;
  23215. subdivisions?: number;
  23216. subdivisionsX?: number;
  23217. subdivisionsY?: number;
  23218. }): VertexData;
  23219. /**
  23220. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23221. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23222. * * xmin the ground minimum X coordinate, optional, default -1
  23223. * * zmin the ground minimum Z coordinate, optional, default -1
  23224. * * xmax the ground maximum X coordinate, optional, default 1
  23225. * * zmax the ground maximum Z coordinate, optional, default 1
  23226. * * 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}
  23227. * * 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}
  23228. * @returns the VertexData of the TiledGround
  23229. */
  23230. static CreateTiledGround(options: {
  23231. xmin: number;
  23232. zmin: number;
  23233. xmax: number;
  23234. zmax: number;
  23235. subdivisions?: {
  23236. w: number;
  23237. h: number;
  23238. };
  23239. precision?: {
  23240. w: number;
  23241. h: number;
  23242. };
  23243. }): VertexData;
  23244. /**
  23245. * Creates the VertexData of the Ground designed from a heightmap
  23246. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23247. * * width the width (x direction) of the ground
  23248. * * height the height (z direction) of the ground
  23249. * * subdivisions the number of subdivisions per side
  23250. * * minHeight the minimum altitude on the ground, optional, default 0
  23251. * * maxHeight the maximum altitude on the ground, optional default 1
  23252. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23253. * * buffer the array holding the image color data
  23254. * * bufferWidth the width of image
  23255. * * bufferHeight the height of image
  23256. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23257. * @returns the VertexData of the Ground designed from a heightmap
  23258. */
  23259. static CreateGroundFromHeightMap(options: {
  23260. width: number;
  23261. height: number;
  23262. subdivisions: number;
  23263. minHeight: number;
  23264. maxHeight: number;
  23265. colorFilter: Color3;
  23266. buffer: Uint8Array;
  23267. bufferWidth: number;
  23268. bufferHeight: number;
  23269. alphaFilter: number;
  23270. }): VertexData;
  23271. /**
  23272. * Creates the VertexData for a Plane
  23273. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23274. * * size sets the width and height of the plane to the value of size, optional default 1
  23275. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23276. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23277. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23278. * * 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)
  23279. * * 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)
  23280. * @returns the VertexData of the box
  23281. */
  23282. static CreatePlane(options: {
  23283. size?: number;
  23284. width?: number;
  23285. height?: number;
  23286. sideOrientation?: number;
  23287. frontUVs?: Vector4;
  23288. backUVs?: Vector4;
  23289. }): VertexData;
  23290. /**
  23291. * Creates the VertexData of the Disc or regular Polygon
  23292. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23293. * * radius the radius of the disc, optional default 0.5
  23294. * * tessellation the number of polygon sides, optional, default 64
  23295. * * 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
  23296. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23297. * * 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)
  23298. * * 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)
  23299. * @returns the VertexData of the box
  23300. */
  23301. static CreateDisc(options: {
  23302. radius?: number;
  23303. tessellation?: number;
  23304. arc?: number;
  23305. sideOrientation?: number;
  23306. frontUVs?: Vector4;
  23307. backUVs?: Vector4;
  23308. }): VertexData;
  23309. /**
  23310. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23311. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23312. * @param polygon a mesh built from polygonTriangulation.build()
  23313. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23314. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23315. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23316. * @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)
  23317. * @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)
  23318. * @returns the VertexData of the Polygon
  23319. */
  23320. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23321. /**
  23322. * Creates the VertexData of the IcoSphere
  23323. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23324. * * radius the radius of the IcoSphere, optional default 1
  23325. * * radiusX allows stretching in the x direction, optional, default radius
  23326. * * radiusY allows stretching in the y direction, optional, default radius
  23327. * * radiusZ allows stretching in the z direction, optional, default radius
  23328. * * flat when true creates a flat shaded mesh, optional, default true
  23329. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23330. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23331. * * 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)
  23332. * * 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)
  23333. * @returns the VertexData of the IcoSphere
  23334. */
  23335. static CreateIcoSphere(options: {
  23336. radius?: number;
  23337. radiusX?: number;
  23338. radiusY?: number;
  23339. radiusZ?: number;
  23340. flat?: boolean;
  23341. subdivisions?: number;
  23342. sideOrientation?: number;
  23343. frontUVs?: Vector4;
  23344. backUVs?: Vector4;
  23345. }): VertexData;
  23346. /**
  23347. * Creates the VertexData for a Polyhedron
  23348. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23349. * * type provided types are:
  23350. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23351. * * 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)
  23352. * * size the size of the IcoSphere, optional default 1
  23353. * * sizeX allows stretching in the x direction, optional, default size
  23354. * * sizeY allows stretching in the y direction, optional, default size
  23355. * * sizeZ allows stretching in the z direction, optional, default size
  23356. * * 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
  23357. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23358. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23359. * * flat when true creates a flat shaded mesh, optional, default true
  23360. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23361. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23362. * * 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)
  23363. * * 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)
  23364. * @returns the VertexData of the Polyhedron
  23365. */
  23366. static CreatePolyhedron(options: {
  23367. type?: number;
  23368. size?: number;
  23369. sizeX?: number;
  23370. sizeY?: number;
  23371. sizeZ?: number;
  23372. custom?: any;
  23373. faceUV?: Vector4[];
  23374. faceColors?: Color4[];
  23375. flat?: boolean;
  23376. sideOrientation?: number;
  23377. frontUVs?: Vector4;
  23378. backUVs?: Vector4;
  23379. }): VertexData;
  23380. /**
  23381. * Creates the VertexData for a TorusKnot
  23382. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23383. * * radius the radius of the torus knot, optional, default 2
  23384. * * tube the thickness of the tube, optional, default 0.5
  23385. * * radialSegments the number of sides on each tube segments, optional, default 32
  23386. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23387. * * p the number of windings around the z axis, optional, default 2
  23388. * * q the number of windings around the x axis, optional, default 3
  23389. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23390. * * 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)
  23391. * * 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)
  23392. * @returns the VertexData of the Torus Knot
  23393. */
  23394. static CreateTorusKnot(options: {
  23395. radius?: number;
  23396. tube?: number;
  23397. radialSegments?: number;
  23398. tubularSegments?: number;
  23399. p?: number;
  23400. q?: number;
  23401. sideOrientation?: number;
  23402. frontUVs?: Vector4;
  23403. backUVs?: Vector4;
  23404. }): VertexData;
  23405. /**
  23406. * Compute normals for given positions and indices
  23407. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23408. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23409. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23410. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23411. * * facetNormals : optional array of facet normals (vector3)
  23412. * * facetPositions : optional array of facet positions (vector3)
  23413. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23414. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23415. * * bInfo : optional bounding info, required for facetPartitioning computation
  23416. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23417. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23418. * * useRightHandedSystem: optional boolean to for right handed system computation
  23419. * * depthSort : optional boolean to enable the facet depth sort computation
  23420. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23421. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23422. */
  23423. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23424. facetNormals?: any;
  23425. facetPositions?: any;
  23426. facetPartitioning?: any;
  23427. ratio?: number;
  23428. bInfo?: any;
  23429. bbSize?: Vector3;
  23430. subDiv?: any;
  23431. useRightHandedSystem?: boolean;
  23432. depthSort?: boolean;
  23433. distanceTo?: Vector3;
  23434. depthSortedFacets?: any;
  23435. }): void;
  23436. /** @hidden */
  23437. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23438. /**
  23439. * Applies VertexData created from the imported parameters to the geometry
  23440. * @param parsedVertexData the parsed data from an imported file
  23441. * @param geometry the geometry to apply the VertexData to
  23442. */
  23443. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23444. }
  23445. }
  23446. declare module "babylonjs/Morph/morphTarget" {
  23447. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23448. import { Observable } from "babylonjs/Misc/observable";
  23449. import { Nullable, FloatArray } from "babylonjs/types";
  23450. import { Scene } from "babylonjs/scene";
  23451. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23452. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23453. /**
  23454. * Defines a target to use with MorphTargetManager
  23455. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23456. */
  23457. export class MorphTarget implements IAnimatable {
  23458. /** defines the name of the target */
  23459. name: string;
  23460. /**
  23461. * Gets or sets the list of animations
  23462. */
  23463. animations: import("babylonjs/Animations/animation").Animation[];
  23464. private _scene;
  23465. private _positions;
  23466. private _normals;
  23467. private _tangents;
  23468. private _uvs;
  23469. private _influence;
  23470. private _uniqueId;
  23471. /**
  23472. * Observable raised when the influence changes
  23473. */
  23474. onInfluenceChanged: Observable<boolean>;
  23475. /** @hidden */
  23476. _onDataLayoutChanged: Observable<void>;
  23477. /**
  23478. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23479. */
  23480. get influence(): number;
  23481. set influence(influence: number);
  23482. /**
  23483. * Gets or sets the id of the morph Target
  23484. */
  23485. id: string;
  23486. private _animationPropertiesOverride;
  23487. /**
  23488. * Gets or sets the animation properties override
  23489. */
  23490. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23491. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23492. /**
  23493. * Creates a new MorphTarget
  23494. * @param name defines the name of the target
  23495. * @param influence defines the influence to use
  23496. * @param scene defines the scene the morphtarget belongs to
  23497. */
  23498. constructor(
  23499. /** defines the name of the target */
  23500. name: string, influence?: number, scene?: Nullable<Scene>);
  23501. /**
  23502. * Gets the unique ID of this manager
  23503. */
  23504. get uniqueId(): number;
  23505. /**
  23506. * Gets a boolean defining if the target contains position data
  23507. */
  23508. get hasPositions(): boolean;
  23509. /**
  23510. * Gets a boolean defining if the target contains normal data
  23511. */
  23512. get hasNormals(): boolean;
  23513. /**
  23514. * Gets a boolean defining if the target contains tangent data
  23515. */
  23516. get hasTangents(): boolean;
  23517. /**
  23518. * Gets a boolean defining if the target contains texture coordinates data
  23519. */
  23520. get hasUVs(): boolean;
  23521. /**
  23522. * Affects position data to this target
  23523. * @param data defines the position data to use
  23524. */
  23525. setPositions(data: Nullable<FloatArray>): void;
  23526. /**
  23527. * Gets the position data stored in this target
  23528. * @returns a FloatArray containing the position data (or null if not present)
  23529. */
  23530. getPositions(): Nullable<FloatArray>;
  23531. /**
  23532. * Affects normal data to this target
  23533. * @param data defines the normal data to use
  23534. */
  23535. setNormals(data: Nullable<FloatArray>): void;
  23536. /**
  23537. * Gets the normal data stored in this target
  23538. * @returns a FloatArray containing the normal data (or null if not present)
  23539. */
  23540. getNormals(): Nullable<FloatArray>;
  23541. /**
  23542. * Affects tangent data to this target
  23543. * @param data defines the tangent data to use
  23544. */
  23545. setTangents(data: Nullable<FloatArray>): void;
  23546. /**
  23547. * Gets the tangent data stored in this target
  23548. * @returns a FloatArray containing the tangent data (or null if not present)
  23549. */
  23550. getTangents(): Nullable<FloatArray>;
  23551. /**
  23552. * Affects texture coordinates data to this target
  23553. * @param data defines the texture coordinates data to use
  23554. */
  23555. setUVs(data: Nullable<FloatArray>): void;
  23556. /**
  23557. * Gets the texture coordinates data stored in this target
  23558. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23559. */
  23560. getUVs(): Nullable<FloatArray>;
  23561. /**
  23562. * Clone the current target
  23563. * @returns a new MorphTarget
  23564. */
  23565. clone(): MorphTarget;
  23566. /**
  23567. * Serializes the current target into a Serialization object
  23568. * @returns the serialized object
  23569. */
  23570. serialize(): any;
  23571. /**
  23572. * Returns the string "MorphTarget"
  23573. * @returns "MorphTarget"
  23574. */
  23575. getClassName(): string;
  23576. /**
  23577. * Creates a new target from serialized data
  23578. * @param serializationObject defines the serialized data to use
  23579. * @returns a new MorphTarget
  23580. */
  23581. static Parse(serializationObject: any): MorphTarget;
  23582. /**
  23583. * Creates a MorphTarget from mesh data
  23584. * @param mesh defines the source mesh
  23585. * @param name defines the name to use for the new target
  23586. * @param influence defines the influence to attach to the target
  23587. * @returns a new MorphTarget
  23588. */
  23589. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23590. }
  23591. }
  23592. declare module "babylonjs/Morph/morphTargetManager" {
  23593. import { Nullable } from "babylonjs/types";
  23594. import { Scene } from "babylonjs/scene";
  23595. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23596. /**
  23597. * This class is used to deform meshes using morphing between different targets
  23598. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23599. */
  23600. export class MorphTargetManager {
  23601. private _targets;
  23602. private _targetInfluenceChangedObservers;
  23603. private _targetDataLayoutChangedObservers;
  23604. private _activeTargets;
  23605. private _scene;
  23606. private _influences;
  23607. private _supportsNormals;
  23608. private _supportsTangents;
  23609. private _supportsUVs;
  23610. private _vertexCount;
  23611. private _uniqueId;
  23612. private _tempInfluences;
  23613. /**
  23614. * Gets or sets a boolean indicating if normals must be morphed
  23615. */
  23616. enableNormalMorphing: boolean;
  23617. /**
  23618. * Gets or sets a boolean indicating if tangents must be morphed
  23619. */
  23620. enableTangentMorphing: boolean;
  23621. /**
  23622. * Gets or sets a boolean indicating if UV must be morphed
  23623. */
  23624. enableUVMorphing: boolean;
  23625. /**
  23626. * Creates a new MorphTargetManager
  23627. * @param scene defines the current scene
  23628. */
  23629. constructor(scene?: Nullable<Scene>);
  23630. /**
  23631. * Gets the unique ID of this manager
  23632. */
  23633. get uniqueId(): number;
  23634. /**
  23635. * Gets the number of vertices handled by this manager
  23636. */
  23637. get vertexCount(): number;
  23638. /**
  23639. * Gets a boolean indicating if this manager supports morphing of normals
  23640. */
  23641. get supportsNormals(): boolean;
  23642. /**
  23643. * Gets a boolean indicating if this manager supports morphing of tangents
  23644. */
  23645. get supportsTangents(): boolean;
  23646. /**
  23647. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23648. */
  23649. get supportsUVs(): boolean;
  23650. /**
  23651. * Gets the number of targets stored in this manager
  23652. */
  23653. get numTargets(): number;
  23654. /**
  23655. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23656. */
  23657. get numInfluencers(): number;
  23658. /**
  23659. * Gets the list of influences (one per target)
  23660. */
  23661. get influences(): Float32Array;
  23662. /**
  23663. * Gets the active target at specified index. An active target is a target with an influence > 0
  23664. * @param index defines the index to check
  23665. * @returns the requested target
  23666. */
  23667. getActiveTarget(index: number): MorphTarget;
  23668. /**
  23669. * Gets the target at specified index
  23670. * @param index defines the index to check
  23671. * @returns the requested target
  23672. */
  23673. getTarget(index: number): MorphTarget;
  23674. /**
  23675. * Add a new target to this manager
  23676. * @param target defines the target to add
  23677. */
  23678. addTarget(target: MorphTarget): void;
  23679. /**
  23680. * Removes a target from the manager
  23681. * @param target defines the target to remove
  23682. */
  23683. removeTarget(target: MorphTarget): void;
  23684. /**
  23685. * Clone the current manager
  23686. * @returns a new MorphTargetManager
  23687. */
  23688. clone(): MorphTargetManager;
  23689. /**
  23690. * Serializes the current manager into a Serialization object
  23691. * @returns the serialized object
  23692. */
  23693. serialize(): any;
  23694. private _syncActiveTargets;
  23695. /**
  23696. * Syncrhonize the targets with all the meshes using this morph target manager
  23697. */
  23698. synchronize(): void;
  23699. /**
  23700. * Creates a new MorphTargetManager from serialized data
  23701. * @param serializationObject defines the serialized data
  23702. * @param scene defines the hosting scene
  23703. * @returns the new MorphTargetManager
  23704. */
  23705. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23706. }
  23707. }
  23708. declare module "babylonjs/Meshes/meshLODLevel" {
  23709. import { Mesh } from "babylonjs/Meshes/mesh";
  23710. import { Nullable } from "babylonjs/types";
  23711. /**
  23712. * Class used to represent a specific level of detail of a mesh
  23713. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23714. */
  23715. export class MeshLODLevel {
  23716. /** Defines the distance where this level should start being displayed */
  23717. distance: number;
  23718. /** Defines the mesh to use to render this level */
  23719. mesh: Nullable<Mesh>;
  23720. /**
  23721. * Creates a new LOD level
  23722. * @param distance defines the distance where this level should star being displayed
  23723. * @param mesh defines the mesh to use to render this level
  23724. */
  23725. constructor(
  23726. /** Defines the distance where this level should start being displayed */
  23727. distance: number,
  23728. /** Defines the mesh to use to render this level */
  23729. mesh: Nullable<Mesh>);
  23730. }
  23731. }
  23732. declare module "babylonjs/Meshes/groundMesh" {
  23733. import { Scene } from "babylonjs/scene";
  23734. import { Vector3 } from "babylonjs/Maths/math.vector";
  23735. import { Mesh } from "babylonjs/Meshes/mesh";
  23736. /**
  23737. * Mesh representing the gorund
  23738. */
  23739. export class GroundMesh extends Mesh {
  23740. /** If octree should be generated */
  23741. generateOctree: boolean;
  23742. private _heightQuads;
  23743. /** @hidden */
  23744. _subdivisionsX: number;
  23745. /** @hidden */
  23746. _subdivisionsY: number;
  23747. /** @hidden */
  23748. _width: number;
  23749. /** @hidden */
  23750. _height: number;
  23751. /** @hidden */
  23752. _minX: number;
  23753. /** @hidden */
  23754. _maxX: number;
  23755. /** @hidden */
  23756. _minZ: number;
  23757. /** @hidden */
  23758. _maxZ: number;
  23759. constructor(name: string, scene: Scene);
  23760. /**
  23761. * "GroundMesh"
  23762. * @returns "GroundMesh"
  23763. */
  23764. getClassName(): string;
  23765. /**
  23766. * The minimum of x and y subdivisions
  23767. */
  23768. get subdivisions(): number;
  23769. /**
  23770. * X subdivisions
  23771. */
  23772. get subdivisionsX(): number;
  23773. /**
  23774. * Y subdivisions
  23775. */
  23776. get subdivisionsY(): number;
  23777. /**
  23778. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23779. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23780. * @param chunksCount the number of subdivisions for x and y
  23781. * @param octreeBlocksSize (Default: 32)
  23782. */
  23783. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23784. /**
  23785. * Returns a height (y) value in the Worl system :
  23786. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23787. * @param x x coordinate
  23788. * @param z z coordinate
  23789. * @returns the ground y position if (x, z) are outside the ground surface.
  23790. */
  23791. getHeightAtCoordinates(x: number, z: number): number;
  23792. /**
  23793. * Returns a normalized vector (Vector3) orthogonal to the ground
  23794. * at the ground coordinates (x, z) expressed in the World system.
  23795. * @param x x coordinate
  23796. * @param z z coordinate
  23797. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23798. */
  23799. getNormalAtCoordinates(x: number, z: number): Vector3;
  23800. /**
  23801. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23802. * at the ground coordinates (x, z) expressed in the World system.
  23803. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23804. * @param x x coordinate
  23805. * @param z z coordinate
  23806. * @param ref vector to store the result
  23807. * @returns the GroundMesh.
  23808. */
  23809. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23810. /**
  23811. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23812. * if the ground has been updated.
  23813. * This can be used in the render loop.
  23814. * @returns the GroundMesh.
  23815. */
  23816. updateCoordinateHeights(): GroundMesh;
  23817. private _getFacetAt;
  23818. private _initHeightQuads;
  23819. private _computeHeightQuads;
  23820. /**
  23821. * Serializes this ground mesh
  23822. * @param serializationObject object to write serialization to
  23823. */
  23824. serialize(serializationObject: any): void;
  23825. /**
  23826. * Parses a serialized ground mesh
  23827. * @param parsedMesh the serialized mesh
  23828. * @param scene the scene to create the ground mesh in
  23829. * @returns the created ground mesh
  23830. */
  23831. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23832. }
  23833. }
  23834. declare module "babylonjs/Physics/physicsJoint" {
  23835. import { Vector3 } from "babylonjs/Maths/math.vector";
  23836. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23837. /**
  23838. * Interface for Physics-Joint data
  23839. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23840. */
  23841. export interface PhysicsJointData {
  23842. /**
  23843. * The main pivot of the joint
  23844. */
  23845. mainPivot?: Vector3;
  23846. /**
  23847. * The connected pivot of the joint
  23848. */
  23849. connectedPivot?: Vector3;
  23850. /**
  23851. * The main axis of the joint
  23852. */
  23853. mainAxis?: Vector3;
  23854. /**
  23855. * The connected axis of the joint
  23856. */
  23857. connectedAxis?: Vector3;
  23858. /**
  23859. * The collision of the joint
  23860. */
  23861. collision?: boolean;
  23862. /**
  23863. * Native Oimo/Cannon/Energy data
  23864. */
  23865. nativeParams?: any;
  23866. }
  23867. /**
  23868. * This is a holder class for the physics joint created by the physics plugin
  23869. * It holds a set of functions to control the underlying joint
  23870. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23871. */
  23872. export class PhysicsJoint {
  23873. /**
  23874. * The type of the physics joint
  23875. */
  23876. type: number;
  23877. /**
  23878. * The data for the physics joint
  23879. */
  23880. jointData: PhysicsJointData;
  23881. private _physicsJoint;
  23882. protected _physicsPlugin: IPhysicsEnginePlugin;
  23883. /**
  23884. * Initializes the physics joint
  23885. * @param type The type of the physics joint
  23886. * @param jointData The data for the physics joint
  23887. */
  23888. constructor(
  23889. /**
  23890. * The type of the physics joint
  23891. */
  23892. type: number,
  23893. /**
  23894. * The data for the physics joint
  23895. */
  23896. jointData: PhysicsJointData);
  23897. /**
  23898. * Gets the physics joint
  23899. */
  23900. get physicsJoint(): any;
  23901. /**
  23902. * Sets the physics joint
  23903. */
  23904. set physicsJoint(newJoint: any);
  23905. /**
  23906. * Sets the physics plugin
  23907. */
  23908. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23909. /**
  23910. * Execute a function that is physics-plugin specific.
  23911. * @param {Function} func the function that will be executed.
  23912. * It accepts two parameters: the physics world and the physics joint
  23913. */
  23914. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23915. /**
  23916. * Distance-Joint type
  23917. */
  23918. static DistanceJoint: number;
  23919. /**
  23920. * Hinge-Joint type
  23921. */
  23922. static HingeJoint: number;
  23923. /**
  23924. * Ball-and-Socket joint type
  23925. */
  23926. static BallAndSocketJoint: number;
  23927. /**
  23928. * Wheel-Joint type
  23929. */
  23930. static WheelJoint: number;
  23931. /**
  23932. * Slider-Joint type
  23933. */
  23934. static SliderJoint: number;
  23935. /**
  23936. * Prismatic-Joint type
  23937. */
  23938. static PrismaticJoint: number;
  23939. /**
  23940. * Universal-Joint type
  23941. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23942. */
  23943. static UniversalJoint: number;
  23944. /**
  23945. * Hinge-Joint 2 type
  23946. */
  23947. static Hinge2Joint: number;
  23948. /**
  23949. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23950. */
  23951. static PointToPointJoint: number;
  23952. /**
  23953. * Spring-Joint type
  23954. */
  23955. static SpringJoint: number;
  23956. /**
  23957. * Lock-Joint type
  23958. */
  23959. static LockJoint: number;
  23960. }
  23961. /**
  23962. * A class representing a physics distance joint
  23963. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23964. */
  23965. export class DistanceJoint extends PhysicsJoint {
  23966. /**
  23967. *
  23968. * @param jointData The data for the Distance-Joint
  23969. */
  23970. constructor(jointData: DistanceJointData);
  23971. /**
  23972. * Update the predefined distance.
  23973. * @param maxDistance The maximum preferred distance
  23974. * @param minDistance The minimum preferred distance
  23975. */
  23976. updateDistance(maxDistance: number, minDistance?: number): void;
  23977. }
  23978. /**
  23979. * Represents a Motor-Enabled Joint
  23980. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23981. */
  23982. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23983. /**
  23984. * Initializes the Motor-Enabled Joint
  23985. * @param type The type of the joint
  23986. * @param jointData The physica joint data for the joint
  23987. */
  23988. constructor(type: number, jointData: PhysicsJointData);
  23989. /**
  23990. * Set the motor values.
  23991. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23992. * @param force the force to apply
  23993. * @param maxForce max force for this motor.
  23994. */
  23995. setMotor(force?: number, maxForce?: number): void;
  23996. /**
  23997. * Set the motor's limits.
  23998. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23999. * @param upperLimit The upper limit of the motor
  24000. * @param lowerLimit The lower limit of the motor
  24001. */
  24002. setLimit(upperLimit: number, lowerLimit?: number): void;
  24003. }
  24004. /**
  24005. * This class represents a single physics Hinge-Joint
  24006. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24007. */
  24008. export class HingeJoint extends MotorEnabledJoint {
  24009. /**
  24010. * Initializes the Hinge-Joint
  24011. * @param jointData The joint data for the Hinge-Joint
  24012. */
  24013. constructor(jointData: PhysicsJointData);
  24014. /**
  24015. * Set the motor values.
  24016. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24017. * @param {number} force the force to apply
  24018. * @param {number} maxForce max force for this motor.
  24019. */
  24020. setMotor(force?: number, maxForce?: number): void;
  24021. /**
  24022. * Set the motor's limits.
  24023. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24024. * @param upperLimit The upper limit of the motor
  24025. * @param lowerLimit The lower limit of the motor
  24026. */
  24027. setLimit(upperLimit: number, lowerLimit?: number): void;
  24028. }
  24029. /**
  24030. * This class represents a dual hinge physics joint (same as wheel joint)
  24031. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24032. */
  24033. export class Hinge2Joint extends MotorEnabledJoint {
  24034. /**
  24035. * Initializes the Hinge2-Joint
  24036. * @param jointData The joint data for the Hinge2-Joint
  24037. */
  24038. constructor(jointData: PhysicsJointData);
  24039. /**
  24040. * Set the motor values.
  24041. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24042. * @param {number} targetSpeed the speed the motor is to reach
  24043. * @param {number} maxForce max force for this motor.
  24044. * @param {motorIndex} the motor's index, 0 or 1.
  24045. */
  24046. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  24047. /**
  24048. * Set the motor limits.
  24049. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24050. * @param {number} upperLimit the upper limit
  24051. * @param {number} lowerLimit lower limit
  24052. * @param {motorIndex} the motor's index, 0 or 1.
  24053. */
  24054. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24055. }
  24056. /**
  24057. * Interface for a motor enabled joint
  24058. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24059. */
  24060. export interface IMotorEnabledJoint {
  24061. /**
  24062. * Physics joint
  24063. */
  24064. physicsJoint: any;
  24065. /**
  24066. * Sets the motor of the motor-enabled joint
  24067. * @param force The force of the motor
  24068. * @param maxForce The maximum force of the motor
  24069. * @param motorIndex The index of the motor
  24070. */
  24071. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  24072. /**
  24073. * Sets the limit of the motor
  24074. * @param upperLimit The upper limit of the motor
  24075. * @param lowerLimit The lower limit of the motor
  24076. * @param motorIndex The index of the motor
  24077. */
  24078. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24079. }
  24080. /**
  24081. * Joint data for a Distance-Joint
  24082. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24083. */
  24084. export interface DistanceJointData extends PhysicsJointData {
  24085. /**
  24086. * Max distance the 2 joint objects can be apart
  24087. */
  24088. maxDistance: number;
  24089. }
  24090. /**
  24091. * Joint data from a spring joint
  24092. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24093. */
  24094. export interface SpringJointData extends PhysicsJointData {
  24095. /**
  24096. * Length of the spring
  24097. */
  24098. length: number;
  24099. /**
  24100. * Stiffness of the spring
  24101. */
  24102. stiffness: number;
  24103. /**
  24104. * Damping of the spring
  24105. */
  24106. damping: number;
  24107. /** this callback will be called when applying the force to the impostors. */
  24108. forceApplicationCallback: () => void;
  24109. }
  24110. }
  24111. declare module "babylonjs/Physics/physicsRaycastResult" {
  24112. import { Vector3 } from "babylonjs/Maths/math.vector";
  24113. /**
  24114. * Holds the data for the raycast result
  24115. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24116. */
  24117. export class PhysicsRaycastResult {
  24118. private _hasHit;
  24119. private _hitDistance;
  24120. private _hitNormalWorld;
  24121. private _hitPointWorld;
  24122. private _rayFromWorld;
  24123. private _rayToWorld;
  24124. /**
  24125. * Gets if there was a hit
  24126. */
  24127. get hasHit(): boolean;
  24128. /**
  24129. * Gets the distance from the hit
  24130. */
  24131. get hitDistance(): number;
  24132. /**
  24133. * Gets the hit normal/direction in the world
  24134. */
  24135. get hitNormalWorld(): Vector3;
  24136. /**
  24137. * Gets the hit point in the world
  24138. */
  24139. get hitPointWorld(): Vector3;
  24140. /**
  24141. * Gets the ray "start point" of the ray in the world
  24142. */
  24143. get rayFromWorld(): Vector3;
  24144. /**
  24145. * Gets the ray "end point" of the ray in the world
  24146. */
  24147. get rayToWorld(): Vector3;
  24148. /**
  24149. * Sets the hit data (normal & point in world space)
  24150. * @param hitNormalWorld defines the normal in world space
  24151. * @param hitPointWorld defines the point in world space
  24152. */
  24153. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  24154. /**
  24155. * Sets the distance from the start point to the hit point
  24156. * @param distance
  24157. */
  24158. setHitDistance(distance: number): void;
  24159. /**
  24160. * Calculates the distance manually
  24161. */
  24162. calculateHitDistance(): void;
  24163. /**
  24164. * Resets all the values to default
  24165. * @param from The from point on world space
  24166. * @param to The to point on world space
  24167. */
  24168. reset(from?: Vector3, to?: Vector3): void;
  24169. }
  24170. /**
  24171. * Interface for the size containing width and height
  24172. */
  24173. interface IXYZ {
  24174. /**
  24175. * X
  24176. */
  24177. x: number;
  24178. /**
  24179. * Y
  24180. */
  24181. y: number;
  24182. /**
  24183. * Z
  24184. */
  24185. z: number;
  24186. }
  24187. }
  24188. declare module "babylonjs/Physics/IPhysicsEngine" {
  24189. import { Nullable } from "babylonjs/types";
  24190. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  24191. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24192. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24193. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  24194. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  24195. /**
  24196. * Interface used to describe a physics joint
  24197. */
  24198. export interface PhysicsImpostorJoint {
  24199. /** Defines the main impostor to which the joint is linked */
  24200. mainImpostor: PhysicsImpostor;
  24201. /** Defines the impostor that is connected to the main impostor using this joint */
  24202. connectedImpostor: PhysicsImpostor;
  24203. /** Defines the joint itself */
  24204. joint: PhysicsJoint;
  24205. }
  24206. /** @hidden */
  24207. export interface IPhysicsEnginePlugin {
  24208. world: any;
  24209. name: string;
  24210. setGravity(gravity: Vector3): void;
  24211. setTimeStep(timeStep: number): void;
  24212. getTimeStep(): number;
  24213. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24214. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24215. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24216. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24217. removePhysicsBody(impostor: PhysicsImpostor): void;
  24218. generateJoint(joint: PhysicsImpostorJoint): void;
  24219. removeJoint(joint: PhysicsImpostorJoint): void;
  24220. isSupported(): boolean;
  24221. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24222. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24223. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24224. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24225. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24226. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24227. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24228. getBodyMass(impostor: PhysicsImpostor): number;
  24229. getBodyFriction(impostor: PhysicsImpostor): number;
  24230. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24231. getBodyRestitution(impostor: PhysicsImpostor): number;
  24232. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24233. getBodyPressure?(impostor: PhysicsImpostor): number;
  24234. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  24235. getBodyStiffness?(impostor: PhysicsImpostor): number;
  24236. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  24237. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  24238. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  24239. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  24240. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  24241. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24242. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24243. sleepBody(impostor: PhysicsImpostor): void;
  24244. wakeUpBody(impostor: PhysicsImpostor): void;
  24245. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24246. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24247. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24248. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24249. getRadius(impostor: PhysicsImpostor): number;
  24250. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24251. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24252. dispose(): void;
  24253. }
  24254. /**
  24255. * Interface used to define a physics engine
  24256. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  24257. */
  24258. export interface IPhysicsEngine {
  24259. /**
  24260. * Gets the gravity vector used by the simulation
  24261. */
  24262. gravity: Vector3;
  24263. /**
  24264. * Sets the gravity vector used by the simulation
  24265. * @param gravity defines the gravity vector to use
  24266. */
  24267. setGravity(gravity: Vector3): void;
  24268. /**
  24269. * Set the time step of the physics engine.
  24270. * Default is 1/60.
  24271. * To slow it down, enter 1/600 for example.
  24272. * To speed it up, 1/30
  24273. * @param newTimeStep the new timestep to apply to this world.
  24274. */
  24275. setTimeStep(newTimeStep: number): void;
  24276. /**
  24277. * Get the time step of the physics engine.
  24278. * @returns the current time step
  24279. */
  24280. getTimeStep(): number;
  24281. /**
  24282. * Set the sub time step of the physics engine.
  24283. * Default is 0 meaning there is no sub steps
  24284. * To increase physics resolution precision, set a small value (like 1 ms)
  24285. * @param subTimeStep defines the new sub timestep used for physics resolution.
  24286. */
  24287. setSubTimeStep(subTimeStep: number): void;
  24288. /**
  24289. * Get the sub time step of the physics engine.
  24290. * @returns the current sub time step
  24291. */
  24292. getSubTimeStep(): number;
  24293. /**
  24294. * Release all resources
  24295. */
  24296. dispose(): void;
  24297. /**
  24298. * Gets the name of the current physics plugin
  24299. * @returns the name of the plugin
  24300. */
  24301. getPhysicsPluginName(): string;
  24302. /**
  24303. * Adding a new impostor for the impostor tracking.
  24304. * This will be done by the impostor itself.
  24305. * @param impostor the impostor to add
  24306. */
  24307. addImpostor(impostor: PhysicsImpostor): void;
  24308. /**
  24309. * Remove an impostor from the engine.
  24310. * This impostor and its mesh will not longer be updated by the physics engine.
  24311. * @param impostor the impostor to remove
  24312. */
  24313. removeImpostor(impostor: PhysicsImpostor): void;
  24314. /**
  24315. * Add a joint to the physics engine
  24316. * @param mainImpostor defines the main impostor to which the joint is added.
  24317. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  24318. * @param joint defines the joint that will connect both impostors.
  24319. */
  24320. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24321. /**
  24322. * Removes a joint from the simulation
  24323. * @param mainImpostor defines the impostor used with the joint
  24324. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  24325. * @param joint defines the joint to remove
  24326. */
  24327. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24328. /**
  24329. * Gets the current plugin used to run the simulation
  24330. * @returns current plugin
  24331. */
  24332. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24333. /**
  24334. * Gets the list of physic impostors
  24335. * @returns an array of PhysicsImpostor
  24336. */
  24337. getImpostors(): Array<PhysicsImpostor>;
  24338. /**
  24339. * Gets the impostor for a physics enabled object
  24340. * @param object defines the object impersonated by the impostor
  24341. * @returns the PhysicsImpostor or null if not found
  24342. */
  24343. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24344. /**
  24345. * Gets the impostor for a physics body object
  24346. * @param body defines physics body used by the impostor
  24347. * @returns the PhysicsImpostor or null if not found
  24348. */
  24349. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24350. /**
  24351. * Does a raycast in the physics world
  24352. * @param from when should the ray start?
  24353. * @param to when should the ray end?
  24354. * @returns PhysicsRaycastResult
  24355. */
  24356. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24357. /**
  24358. * Called by the scene. No need to call it.
  24359. * @param delta defines the timespam between frames
  24360. */
  24361. _step(delta: number): void;
  24362. }
  24363. }
  24364. declare module "babylonjs/Physics/physicsImpostor" {
  24365. import { Nullable, IndicesArray } from "babylonjs/types";
  24366. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24367. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24368. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24369. import { Scene } from "babylonjs/scene";
  24370. import { Bone } from "babylonjs/Bones/bone";
  24371. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24372. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24373. import { Space } from "babylonjs/Maths/math.axis";
  24374. /**
  24375. * The interface for the physics imposter parameters
  24376. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24377. */
  24378. export interface PhysicsImpostorParameters {
  24379. /**
  24380. * The mass of the physics imposter
  24381. */
  24382. mass: number;
  24383. /**
  24384. * The friction of the physics imposter
  24385. */
  24386. friction?: number;
  24387. /**
  24388. * The coefficient of restitution of the physics imposter
  24389. */
  24390. restitution?: number;
  24391. /**
  24392. * The native options of the physics imposter
  24393. */
  24394. nativeOptions?: any;
  24395. /**
  24396. * Specifies if the parent should be ignored
  24397. */
  24398. ignoreParent?: boolean;
  24399. /**
  24400. * Specifies if bi-directional transformations should be disabled
  24401. */
  24402. disableBidirectionalTransformation?: boolean;
  24403. /**
  24404. * The pressure inside the physics imposter, soft object only
  24405. */
  24406. pressure?: number;
  24407. /**
  24408. * The stiffness the physics imposter, soft object only
  24409. */
  24410. stiffness?: number;
  24411. /**
  24412. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24413. */
  24414. velocityIterations?: number;
  24415. /**
  24416. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24417. */
  24418. positionIterations?: number;
  24419. /**
  24420. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24421. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24422. * Add to fix multiple points
  24423. */
  24424. fixedPoints?: number;
  24425. /**
  24426. * The collision margin around a soft object
  24427. */
  24428. margin?: number;
  24429. /**
  24430. * The collision margin around a soft object
  24431. */
  24432. damping?: number;
  24433. /**
  24434. * The path for a rope based on an extrusion
  24435. */
  24436. path?: any;
  24437. /**
  24438. * The shape of an extrusion used for a rope based on an extrusion
  24439. */
  24440. shape?: any;
  24441. }
  24442. /**
  24443. * Interface for a physics-enabled object
  24444. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24445. */
  24446. export interface IPhysicsEnabledObject {
  24447. /**
  24448. * The position of the physics-enabled object
  24449. */
  24450. position: Vector3;
  24451. /**
  24452. * The rotation of the physics-enabled object
  24453. */
  24454. rotationQuaternion: Nullable<Quaternion>;
  24455. /**
  24456. * The scale of the physics-enabled object
  24457. */
  24458. scaling: Vector3;
  24459. /**
  24460. * The rotation of the physics-enabled object
  24461. */
  24462. rotation?: Vector3;
  24463. /**
  24464. * The parent of the physics-enabled object
  24465. */
  24466. parent?: any;
  24467. /**
  24468. * The bounding info of the physics-enabled object
  24469. * @returns The bounding info of the physics-enabled object
  24470. */
  24471. getBoundingInfo(): BoundingInfo;
  24472. /**
  24473. * Computes the world matrix
  24474. * @param force Specifies if the world matrix should be computed by force
  24475. * @returns A world matrix
  24476. */
  24477. computeWorldMatrix(force: boolean): Matrix;
  24478. /**
  24479. * Gets the world matrix
  24480. * @returns A world matrix
  24481. */
  24482. getWorldMatrix?(): Matrix;
  24483. /**
  24484. * Gets the child meshes
  24485. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24486. * @returns An array of abstract meshes
  24487. */
  24488. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24489. /**
  24490. * Gets the vertex data
  24491. * @param kind The type of vertex data
  24492. * @returns A nullable array of numbers, or a float32 array
  24493. */
  24494. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24495. /**
  24496. * Gets the indices from the mesh
  24497. * @returns A nullable array of index arrays
  24498. */
  24499. getIndices?(): Nullable<IndicesArray>;
  24500. /**
  24501. * Gets the scene from the mesh
  24502. * @returns the indices array or null
  24503. */
  24504. getScene?(): Scene;
  24505. /**
  24506. * Gets the absolute position from the mesh
  24507. * @returns the absolute position
  24508. */
  24509. getAbsolutePosition(): Vector3;
  24510. /**
  24511. * Gets the absolute pivot point from the mesh
  24512. * @returns the absolute pivot point
  24513. */
  24514. getAbsolutePivotPoint(): Vector3;
  24515. /**
  24516. * Rotates the mesh
  24517. * @param axis The axis of rotation
  24518. * @param amount The amount of rotation
  24519. * @param space The space of the rotation
  24520. * @returns The rotation transform node
  24521. */
  24522. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24523. /**
  24524. * Translates the mesh
  24525. * @param axis The axis of translation
  24526. * @param distance The distance of translation
  24527. * @param space The space of the translation
  24528. * @returns The transform node
  24529. */
  24530. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24531. /**
  24532. * Sets the absolute position of the mesh
  24533. * @param absolutePosition The absolute position of the mesh
  24534. * @returns The transform node
  24535. */
  24536. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24537. /**
  24538. * Gets the class name of the mesh
  24539. * @returns The class name
  24540. */
  24541. getClassName(): string;
  24542. }
  24543. /**
  24544. * Represents a physics imposter
  24545. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24546. */
  24547. export class PhysicsImpostor {
  24548. /**
  24549. * The physics-enabled object used as the physics imposter
  24550. */
  24551. object: IPhysicsEnabledObject;
  24552. /**
  24553. * The type of the physics imposter
  24554. */
  24555. type: number;
  24556. private _options;
  24557. private _scene?;
  24558. /**
  24559. * The default object size of the imposter
  24560. */
  24561. static DEFAULT_OBJECT_SIZE: Vector3;
  24562. /**
  24563. * The identity quaternion of the imposter
  24564. */
  24565. static IDENTITY_QUATERNION: Quaternion;
  24566. /** @hidden */
  24567. _pluginData: any;
  24568. private _physicsEngine;
  24569. private _physicsBody;
  24570. private _bodyUpdateRequired;
  24571. private _onBeforePhysicsStepCallbacks;
  24572. private _onAfterPhysicsStepCallbacks;
  24573. /** @hidden */
  24574. _onPhysicsCollideCallbacks: Array<{
  24575. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24576. otherImpostors: Array<PhysicsImpostor>;
  24577. }>;
  24578. private _deltaPosition;
  24579. private _deltaRotation;
  24580. private _deltaRotationConjugated;
  24581. /** @hidden */
  24582. _isFromLine: boolean;
  24583. private _parent;
  24584. private _isDisposed;
  24585. private static _tmpVecs;
  24586. private static _tmpQuat;
  24587. /**
  24588. * Specifies if the physics imposter is disposed
  24589. */
  24590. get isDisposed(): boolean;
  24591. /**
  24592. * Gets the mass of the physics imposter
  24593. */
  24594. get mass(): number;
  24595. set mass(value: number);
  24596. /**
  24597. * Gets the coefficient of friction
  24598. */
  24599. get friction(): number;
  24600. /**
  24601. * Sets the coefficient of friction
  24602. */
  24603. set friction(value: number);
  24604. /**
  24605. * Gets the coefficient of restitution
  24606. */
  24607. get restitution(): number;
  24608. /**
  24609. * Sets the coefficient of restitution
  24610. */
  24611. set restitution(value: number);
  24612. /**
  24613. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24614. */
  24615. get pressure(): number;
  24616. /**
  24617. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24618. */
  24619. set pressure(value: number);
  24620. /**
  24621. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24622. */
  24623. get stiffness(): number;
  24624. /**
  24625. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24626. */
  24627. set stiffness(value: number);
  24628. /**
  24629. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24630. */
  24631. get velocityIterations(): number;
  24632. /**
  24633. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24634. */
  24635. set velocityIterations(value: number);
  24636. /**
  24637. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24638. */
  24639. get positionIterations(): number;
  24640. /**
  24641. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24642. */
  24643. set positionIterations(value: number);
  24644. /**
  24645. * The unique id of the physics imposter
  24646. * set by the physics engine when adding this impostor to the array
  24647. */
  24648. uniqueId: number;
  24649. /**
  24650. * @hidden
  24651. */
  24652. soft: boolean;
  24653. /**
  24654. * @hidden
  24655. */
  24656. segments: number;
  24657. private _joints;
  24658. /**
  24659. * Initializes the physics imposter
  24660. * @param object The physics-enabled object used as the physics imposter
  24661. * @param type The type of the physics imposter
  24662. * @param _options The options for the physics imposter
  24663. * @param _scene The Babylon scene
  24664. */
  24665. constructor(
  24666. /**
  24667. * The physics-enabled object used as the physics imposter
  24668. */
  24669. object: IPhysicsEnabledObject,
  24670. /**
  24671. * The type of the physics imposter
  24672. */
  24673. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24674. /**
  24675. * This function will completly initialize this impostor.
  24676. * It will create a new body - but only if this mesh has no parent.
  24677. * If it has, this impostor will not be used other than to define the impostor
  24678. * of the child mesh.
  24679. * @hidden
  24680. */
  24681. _init(): void;
  24682. private _getPhysicsParent;
  24683. /**
  24684. * Should a new body be generated.
  24685. * @returns boolean specifying if body initialization is required
  24686. */
  24687. isBodyInitRequired(): boolean;
  24688. /**
  24689. * Sets the updated scaling
  24690. * @param updated Specifies if the scaling is updated
  24691. */
  24692. setScalingUpdated(): void;
  24693. /**
  24694. * Force a regeneration of this or the parent's impostor's body.
  24695. * Use under cautious - This will remove all joints already implemented.
  24696. */
  24697. forceUpdate(): void;
  24698. /**
  24699. * Gets the body that holds this impostor. Either its own, or its parent.
  24700. */
  24701. get physicsBody(): any;
  24702. /**
  24703. * Get the parent of the physics imposter
  24704. * @returns Physics imposter or null
  24705. */
  24706. get parent(): Nullable<PhysicsImpostor>;
  24707. /**
  24708. * Sets the parent of the physics imposter
  24709. */
  24710. set parent(value: Nullable<PhysicsImpostor>);
  24711. /**
  24712. * Set the physics body. Used mainly by the physics engine/plugin
  24713. */
  24714. set physicsBody(physicsBody: any);
  24715. /**
  24716. * Resets the update flags
  24717. */
  24718. resetUpdateFlags(): void;
  24719. /**
  24720. * Gets the object extend size
  24721. * @returns the object extend size
  24722. */
  24723. getObjectExtendSize(): Vector3;
  24724. /**
  24725. * Gets the object center
  24726. * @returns The object center
  24727. */
  24728. getObjectCenter(): Vector3;
  24729. /**
  24730. * Get a specific parameter from the options parameters
  24731. * @param paramName The object parameter name
  24732. * @returns The object parameter
  24733. */
  24734. getParam(paramName: string): any;
  24735. /**
  24736. * Sets a specific parameter in the options given to the physics plugin
  24737. * @param paramName The parameter name
  24738. * @param value The value of the parameter
  24739. */
  24740. setParam(paramName: string, value: number): void;
  24741. /**
  24742. * Specifically change the body's mass option. Won't recreate the physics body object
  24743. * @param mass The mass of the physics imposter
  24744. */
  24745. setMass(mass: number): void;
  24746. /**
  24747. * Gets the linear velocity
  24748. * @returns linear velocity or null
  24749. */
  24750. getLinearVelocity(): Nullable<Vector3>;
  24751. /**
  24752. * Sets the linear velocity
  24753. * @param velocity linear velocity or null
  24754. */
  24755. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24756. /**
  24757. * Gets the angular velocity
  24758. * @returns angular velocity or null
  24759. */
  24760. getAngularVelocity(): Nullable<Vector3>;
  24761. /**
  24762. * Sets the angular velocity
  24763. * @param velocity The velocity or null
  24764. */
  24765. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24766. /**
  24767. * Execute a function with the physics plugin native code
  24768. * Provide a function the will have two variables - the world object and the physics body object
  24769. * @param func The function to execute with the physics plugin native code
  24770. */
  24771. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24772. /**
  24773. * Register a function that will be executed before the physics world is stepping forward
  24774. * @param func The function to execute before the physics world is stepped forward
  24775. */
  24776. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24777. /**
  24778. * Unregister a function that will be executed before the physics world is stepping forward
  24779. * @param func The function to execute before the physics world is stepped forward
  24780. */
  24781. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24782. /**
  24783. * Register a function that will be executed after the physics step
  24784. * @param func The function to execute after physics step
  24785. */
  24786. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24787. /**
  24788. * Unregisters a function that will be executed after the physics step
  24789. * @param func The function to execute after physics step
  24790. */
  24791. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24792. /**
  24793. * register a function that will be executed when this impostor collides against a different body
  24794. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24795. * @param func Callback that is executed on collision
  24796. */
  24797. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24798. /**
  24799. * Unregisters the physics imposter on contact
  24800. * @param collideAgainst The physics object to collide against
  24801. * @param func Callback to execute on collision
  24802. */
  24803. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24804. private _tmpQuat;
  24805. private _tmpQuat2;
  24806. /**
  24807. * Get the parent rotation
  24808. * @returns The parent rotation
  24809. */
  24810. getParentsRotation(): Quaternion;
  24811. /**
  24812. * this function is executed by the physics engine.
  24813. */
  24814. beforeStep: () => void;
  24815. /**
  24816. * this function is executed by the physics engine
  24817. */
  24818. afterStep: () => void;
  24819. /**
  24820. * Legacy collision detection event support
  24821. */
  24822. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24823. /**
  24824. * event and body object due to cannon's event-based architecture.
  24825. */
  24826. onCollide: (e: {
  24827. body: any;
  24828. }) => void;
  24829. /**
  24830. * Apply a force
  24831. * @param force The force to apply
  24832. * @param contactPoint The contact point for the force
  24833. * @returns The physics imposter
  24834. */
  24835. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24836. /**
  24837. * Apply an impulse
  24838. * @param force The impulse force
  24839. * @param contactPoint The contact point for the impulse force
  24840. * @returns The physics imposter
  24841. */
  24842. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24843. /**
  24844. * A help function to create a joint
  24845. * @param otherImpostor A physics imposter used to create a joint
  24846. * @param jointType The type of joint
  24847. * @param jointData The data for the joint
  24848. * @returns The physics imposter
  24849. */
  24850. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24851. /**
  24852. * Add a joint to this impostor with a different impostor
  24853. * @param otherImpostor A physics imposter used to add a joint
  24854. * @param joint The joint to add
  24855. * @returns The physics imposter
  24856. */
  24857. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24858. /**
  24859. * Add an anchor to a cloth impostor
  24860. * @param otherImpostor rigid impostor to anchor to
  24861. * @param width ratio across width from 0 to 1
  24862. * @param height ratio up height from 0 to 1
  24863. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24864. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24865. * @returns impostor the soft imposter
  24866. */
  24867. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24868. /**
  24869. * Add a hook to a rope impostor
  24870. * @param otherImpostor rigid impostor to anchor to
  24871. * @param length ratio across rope from 0 to 1
  24872. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24873. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24874. * @returns impostor the rope imposter
  24875. */
  24876. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24877. /**
  24878. * Will keep this body still, in a sleep mode.
  24879. * @returns the physics imposter
  24880. */
  24881. sleep(): PhysicsImpostor;
  24882. /**
  24883. * Wake the body up.
  24884. * @returns The physics imposter
  24885. */
  24886. wakeUp(): PhysicsImpostor;
  24887. /**
  24888. * Clones the physics imposter
  24889. * @param newObject The physics imposter clones to this physics-enabled object
  24890. * @returns A nullable physics imposter
  24891. */
  24892. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24893. /**
  24894. * Disposes the physics imposter
  24895. */
  24896. dispose(): void;
  24897. /**
  24898. * Sets the delta position
  24899. * @param position The delta position amount
  24900. */
  24901. setDeltaPosition(position: Vector3): void;
  24902. /**
  24903. * Sets the delta rotation
  24904. * @param rotation The delta rotation amount
  24905. */
  24906. setDeltaRotation(rotation: Quaternion): void;
  24907. /**
  24908. * Gets the box size of the physics imposter and stores the result in the input parameter
  24909. * @param result Stores the box size
  24910. * @returns The physics imposter
  24911. */
  24912. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24913. /**
  24914. * Gets the radius of the physics imposter
  24915. * @returns Radius of the physics imposter
  24916. */
  24917. getRadius(): number;
  24918. /**
  24919. * Sync a bone with this impostor
  24920. * @param bone The bone to sync to the impostor.
  24921. * @param boneMesh The mesh that the bone is influencing.
  24922. * @param jointPivot The pivot of the joint / bone in local space.
  24923. * @param distToJoint Optional distance from the impostor to the joint.
  24924. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24925. */
  24926. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24927. /**
  24928. * Sync impostor to a bone
  24929. * @param bone The bone that the impostor will be synced to.
  24930. * @param boneMesh The mesh that the bone is influencing.
  24931. * @param jointPivot The pivot of the joint / bone in local space.
  24932. * @param distToJoint Optional distance from the impostor to the joint.
  24933. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24934. * @param boneAxis Optional vector3 axis the bone is aligned with
  24935. */
  24936. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24937. /**
  24938. * No-Imposter type
  24939. */
  24940. static NoImpostor: number;
  24941. /**
  24942. * Sphere-Imposter type
  24943. */
  24944. static SphereImpostor: number;
  24945. /**
  24946. * Box-Imposter type
  24947. */
  24948. static BoxImpostor: number;
  24949. /**
  24950. * Plane-Imposter type
  24951. */
  24952. static PlaneImpostor: number;
  24953. /**
  24954. * Mesh-imposter type
  24955. */
  24956. static MeshImpostor: number;
  24957. /**
  24958. * Capsule-Impostor type (Ammo.js plugin only)
  24959. */
  24960. static CapsuleImpostor: number;
  24961. /**
  24962. * Cylinder-Imposter type
  24963. */
  24964. static CylinderImpostor: number;
  24965. /**
  24966. * Particle-Imposter type
  24967. */
  24968. static ParticleImpostor: number;
  24969. /**
  24970. * Heightmap-Imposter type
  24971. */
  24972. static HeightmapImpostor: number;
  24973. /**
  24974. * ConvexHull-Impostor type (Ammo.js plugin only)
  24975. */
  24976. static ConvexHullImpostor: number;
  24977. /**
  24978. * Custom-Imposter type (Ammo.js plugin only)
  24979. */
  24980. static CustomImpostor: number;
  24981. /**
  24982. * Rope-Imposter type
  24983. */
  24984. static RopeImpostor: number;
  24985. /**
  24986. * Cloth-Imposter type
  24987. */
  24988. static ClothImpostor: number;
  24989. /**
  24990. * Softbody-Imposter type
  24991. */
  24992. static SoftbodyImpostor: number;
  24993. }
  24994. }
  24995. declare module "babylonjs/Meshes/mesh" {
  24996. import { Observable } from "babylonjs/Misc/observable";
  24997. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24998. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24999. import { Camera } from "babylonjs/Cameras/camera";
  25000. import { Scene } from "babylonjs/scene";
  25001. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  25002. import { Color4 } from "babylonjs/Maths/math.color";
  25003. import { Engine } from "babylonjs/Engines/engine";
  25004. import { Node } from "babylonjs/node";
  25005. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  25006. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  25007. import { Buffer } from "babylonjs/Meshes/buffer";
  25008. import { Geometry } from "babylonjs/Meshes/geometry";
  25009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25010. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25011. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  25012. import { Effect } from "babylonjs/Materials/effect";
  25013. import { Material } from "babylonjs/Materials/material";
  25014. import { Skeleton } from "babylonjs/Bones/skeleton";
  25015. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  25016. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  25017. import { Path3D } from "babylonjs/Maths/math.path";
  25018. import { Plane } from "babylonjs/Maths/math.plane";
  25019. import { TransformNode } from "babylonjs/Meshes/transformNode";
  25020. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  25021. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  25022. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  25023. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  25024. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  25025. /**
  25026. * @hidden
  25027. **/
  25028. export class _CreationDataStorage {
  25029. closePath?: boolean;
  25030. closeArray?: boolean;
  25031. idx: number[];
  25032. dashSize: number;
  25033. gapSize: number;
  25034. path3D: Path3D;
  25035. pathArray: Vector3[][];
  25036. arc: number;
  25037. radius: number;
  25038. cap: number;
  25039. tessellation: number;
  25040. }
  25041. /**
  25042. * @hidden
  25043. **/
  25044. class _InstanceDataStorage {
  25045. visibleInstances: any;
  25046. batchCache: _InstancesBatch;
  25047. instancesBufferSize: number;
  25048. instancesBuffer: Nullable<Buffer>;
  25049. instancesData: Float32Array;
  25050. overridenInstanceCount: number;
  25051. isFrozen: boolean;
  25052. previousBatch: Nullable<_InstancesBatch>;
  25053. hardwareInstancedRendering: boolean;
  25054. sideOrientation: number;
  25055. manualUpdate: boolean;
  25056. }
  25057. /**
  25058. * @hidden
  25059. **/
  25060. export class _InstancesBatch {
  25061. mustReturn: boolean;
  25062. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  25063. renderSelf: boolean[];
  25064. hardwareInstancedRendering: boolean[];
  25065. }
  25066. /**
  25067. * Class used to represent renderable models
  25068. */
  25069. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  25070. /**
  25071. * Mesh side orientation : usually the external or front surface
  25072. */
  25073. static readonly FRONTSIDE: number;
  25074. /**
  25075. * Mesh side orientation : usually the internal or back surface
  25076. */
  25077. static readonly BACKSIDE: number;
  25078. /**
  25079. * Mesh side orientation : both internal and external or front and back surfaces
  25080. */
  25081. static readonly DOUBLESIDE: number;
  25082. /**
  25083. * Mesh side orientation : by default, `FRONTSIDE`
  25084. */
  25085. static readonly DEFAULTSIDE: number;
  25086. /**
  25087. * Mesh cap setting : no cap
  25088. */
  25089. static readonly NO_CAP: number;
  25090. /**
  25091. * Mesh cap setting : one cap at the beginning of the mesh
  25092. */
  25093. static readonly CAP_START: number;
  25094. /**
  25095. * Mesh cap setting : one cap at the end of the mesh
  25096. */
  25097. static readonly CAP_END: number;
  25098. /**
  25099. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  25100. */
  25101. static readonly CAP_ALL: number;
  25102. /**
  25103. * Mesh pattern setting : no flip or rotate
  25104. */
  25105. static readonly NO_FLIP: number;
  25106. /**
  25107. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  25108. */
  25109. static readonly FLIP_TILE: number;
  25110. /**
  25111. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  25112. */
  25113. static readonly ROTATE_TILE: number;
  25114. /**
  25115. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  25116. */
  25117. static readonly FLIP_ROW: number;
  25118. /**
  25119. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  25120. */
  25121. static readonly ROTATE_ROW: number;
  25122. /**
  25123. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  25124. */
  25125. static readonly FLIP_N_ROTATE_TILE: number;
  25126. /**
  25127. * Mesh pattern setting : rotate pattern and rotate
  25128. */
  25129. static readonly FLIP_N_ROTATE_ROW: number;
  25130. /**
  25131. * Mesh tile positioning : part tiles same on left/right or top/bottom
  25132. */
  25133. static readonly CENTER: number;
  25134. /**
  25135. * Mesh tile positioning : part tiles on left
  25136. */
  25137. static readonly LEFT: number;
  25138. /**
  25139. * Mesh tile positioning : part tiles on right
  25140. */
  25141. static readonly RIGHT: number;
  25142. /**
  25143. * Mesh tile positioning : part tiles on top
  25144. */
  25145. static readonly TOP: number;
  25146. /**
  25147. * Mesh tile positioning : part tiles on bottom
  25148. */
  25149. static readonly BOTTOM: number;
  25150. /**
  25151. * Gets the default side orientation.
  25152. * @param orientation the orientation to value to attempt to get
  25153. * @returns the default orientation
  25154. * @hidden
  25155. */
  25156. static _GetDefaultSideOrientation(orientation?: number): number;
  25157. private _internalMeshDataInfo;
  25158. /**
  25159. * An event triggered before rendering the mesh
  25160. */
  25161. get onBeforeRenderObservable(): Observable<Mesh>;
  25162. /**
  25163. * An event triggered before binding the mesh
  25164. */
  25165. get onBeforeBindObservable(): Observable<Mesh>;
  25166. /**
  25167. * An event triggered after rendering the mesh
  25168. */
  25169. get onAfterRenderObservable(): Observable<Mesh>;
  25170. /**
  25171. * An event triggered before drawing the mesh
  25172. */
  25173. get onBeforeDrawObservable(): Observable<Mesh>;
  25174. private _onBeforeDrawObserver;
  25175. /**
  25176. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  25177. */
  25178. set onBeforeDraw(callback: () => void);
  25179. get hasInstances(): boolean;
  25180. /**
  25181. * Gets the delay loading state of the mesh (when delay loading is turned on)
  25182. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  25183. */
  25184. delayLoadState: number;
  25185. /**
  25186. * Gets the list of instances created from this mesh
  25187. * it is not supposed to be modified manually.
  25188. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  25189. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25190. */
  25191. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  25192. /**
  25193. * Gets the file containing delay loading data for this mesh
  25194. */
  25195. delayLoadingFile: string;
  25196. /** @hidden */
  25197. _binaryInfo: any;
  25198. /**
  25199. * User defined function used to change how LOD level selection is done
  25200. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25201. */
  25202. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  25203. /**
  25204. * Gets or sets the morph target manager
  25205. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25206. */
  25207. get morphTargetManager(): Nullable<MorphTargetManager>;
  25208. set morphTargetManager(value: Nullable<MorphTargetManager>);
  25209. /** @hidden */
  25210. _creationDataStorage: Nullable<_CreationDataStorage>;
  25211. /** @hidden */
  25212. _geometry: Nullable<Geometry>;
  25213. /** @hidden */
  25214. _delayInfo: Array<string>;
  25215. /** @hidden */
  25216. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  25217. /** @hidden */
  25218. _instanceDataStorage: _InstanceDataStorage;
  25219. private _effectiveMaterial;
  25220. /** @hidden */
  25221. _shouldGenerateFlatShading: boolean;
  25222. /** @hidden */
  25223. _originalBuilderSideOrientation: number;
  25224. /**
  25225. * Use this property to change the original side orientation defined at construction time
  25226. */
  25227. overrideMaterialSideOrientation: Nullable<number>;
  25228. /**
  25229. * Gets the source mesh (the one used to clone this one from)
  25230. */
  25231. get source(): Nullable<Mesh>;
  25232. /**
  25233. * Gets or sets a boolean indicating that this mesh does not use index buffer
  25234. */
  25235. get isUnIndexed(): boolean;
  25236. set isUnIndexed(value: boolean);
  25237. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  25238. get worldMatrixInstancedBuffer(): Float32Array;
  25239. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  25240. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  25241. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  25242. /**
  25243. * @constructor
  25244. * @param name The value used by scene.getMeshByName() to do a lookup.
  25245. * @param scene The scene to add this mesh to.
  25246. * @param parent The parent of this mesh, if it has one
  25247. * @param source An optional Mesh from which geometry is shared, cloned.
  25248. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  25249. * When false, achieved by calling a clone(), also passing False.
  25250. * This will make creation of children, recursive.
  25251. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  25252. */
  25253. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  25254. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  25255. doNotInstantiate: boolean;
  25256. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  25257. /**
  25258. * Gets the class name
  25259. * @returns the string "Mesh".
  25260. */
  25261. getClassName(): string;
  25262. /** @hidden */
  25263. get _isMesh(): boolean;
  25264. /**
  25265. * Returns a description of this mesh
  25266. * @param fullDetails define if full details about this mesh must be used
  25267. * @returns a descriptive string representing this mesh
  25268. */
  25269. toString(fullDetails?: boolean): string;
  25270. /** @hidden */
  25271. _unBindEffect(): void;
  25272. /**
  25273. * Gets a boolean indicating if this mesh has LOD
  25274. */
  25275. get hasLODLevels(): boolean;
  25276. /**
  25277. * Gets the list of MeshLODLevel associated with the current mesh
  25278. * @returns an array of MeshLODLevel
  25279. */
  25280. getLODLevels(): MeshLODLevel[];
  25281. private _sortLODLevels;
  25282. /**
  25283. * Add a mesh as LOD level triggered at the given distance.
  25284. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25285. * @param distance The distance from the center of the object to show this level
  25286. * @param mesh The mesh to be added as LOD level (can be null)
  25287. * @return This mesh (for chaining)
  25288. */
  25289. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  25290. /**
  25291. * Returns the LOD level mesh at the passed distance or null if not found.
  25292. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25293. * @param distance The distance from the center of the object to show this level
  25294. * @returns a Mesh or `null`
  25295. */
  25296. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  25297. /**
  25298. * Remove a mesh from the LOD array
  25299. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25300. * @param mesh defines the mesh to be removed
  25301. * @return This mesh (for chaining)
  25302. */
  25303. removeLODLevel(mesh: Mesh): Mesh;
  25304. /**
  25305. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  25306. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25307. * @param camera defines the camera to use to compute distance
  25308. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  25309. * @return This mesh (for chaining)
  25310. */
  25311. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  25312. /**
  25313. * Gets the mesh internal Geometry object
  25314. */
  25315. get geometry(): Nullable<Geometry>;
  25316. /**
  25317. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  25318. * @returns the total number of vertices
  25319. */
  25320. getTotalVertices(): number;
  25321. /**
  25322. * Returns the content of an associated vertex buffer
  25323. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25324. * - VertexBuffer.PositionKind
  25325. * - VertexBuffer.UVKind
  25326. * - VertexBuffer.UV2Kind
  25327. * - VertexBuffer.UV3Kind
  25328. * - VertexBuffer.UV4Kind
  25329. * - VertexBuffer.UV5Kind
  25330. * - VertexBuffer.UV6Kind
  25331. * - VertexBuffer.ColorKind
  25332. * - VertexBuffer.MatricesIndicesKind
  25333. * - VertexBuffer.MatricesIndicesExtraKind
  25334. * - VertexBuffer.MatricesWeightsKind
  25335. * - VertexBuffer.MatricesWeightsExtraKind
  25336. * @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
  25337. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25338. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25339. */
  25340. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25341. /**
  25342. * Returns the mesh VertexBuffer object from the requested `kind`
  25343. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25344. * - VertexBuffer.PositionKind
  25345. * - VertexBuffer.NormalKind
  25346. * - VertexBuffer.UVKind
  25347. * - VertexBuffer.UV2Kind
  25348. * - VertexBuffer.UV3Kind
  25349. * - VertexBuffer.UV4Kind
  25350. * - VertexBuffer.UV5Kind
  25351. * - VertexBuffer.UV6Kind
  25352. * - VertexBuffer.ColorKind
  25353. * - VertexBuffer.MatricesIndicesKind
  25354. * - VertexBuffer.MatricesIndicesExtraKind
  25355. * - VertexBuffer.MatricesWeightsKind
  25356. * - VertexBuffer.MatricesWeightsExtraKind
  25357. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25358. */
  25359. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25360. /**
  25361. * Tests if a specific vertex buffer is associated with this mesh
  25362. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25363. * - VertexBuffer.PositionKind
  25364. * - VertexBuffer.NormalKind
  25365. * - VertexBuffer.UVKind
  25366. * - VertexBuffer.UV2Kind
  25367. * - VertexBuffer.UV3Kind
  25368. * - VertexBuffer.UV4Kind
  25369. * - VertexBuffer.UV5Kind
  25370. * - VertexBuffer.UV6Kind
  25371. * - VertexBuffer.ColorKind
  25372. * - VertexBuffer.MatricesIndicesKind
  25373. * - VertexBuffer.MatricesIndicesExtraKind
  25374. * - VertexBuffer.MatricesWeightsKind
  25375. * - VertexBuffer.MatricesWeightsExtraKind
  25376. * @returns a boolean
  25377. */
  25378. isVerticesDataPresent(kind: string): boolean;
  25379. /**
  25380. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25381. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25382. * - VertexBuffer.PositionKind
  25383. * - VertexBuffer.UVKind
  25384. * - VertexBuffer.UV2Kind
  25385. * - VertexBuffer.UV3Kind
  25386. * - VertexBuffer.UV4Kind
  25387. * - VertexBuffer.UV5Kind
  25388. * - VertexBuffer.UV6Kind
  25389. * - VertexBuffer.ColorKind
  25390. * - VertexBuffer.MatricesIndicesKind
  25391. * - VertexBuffer.MatricesIndicesExtraKind
  25392. * - VertexBuffer.MatricesWeightsKind
  25393. * - VertexBuffer.MatricesWeightsExtraKind
  25394. * @returns a boolean
  25395. */
  25396. isVertexBufferUpdatable(kind: string): boolean;
  25397. /**
  25398. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25399. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25400. * - VertexBuffer.PositionKind
  25401. * - VertexBuffer.NormalKind
  25402. * - VertexBuffer.UVKind
  25403. * - VertexBuffer.UV2Kind
  25404. * - VertexBuffer.UV3Kind
  25405. * - VertexBuffer.UV4Kind
  25406. * - VertexBuffer.UV5Kind
  25407. * - VertexBuffer.UV6Kind
  25408. * - VertexBuffer.ColorKind
  25409. * - VertexBuffer.MatricesIndicesKind
  25410. * - VertexBuffer.MatricesIndicesExtraKind
  25411. * - VertexBuffer.MatricesWeightsKind
  25412. * - VertexBuffer.MatricesWeightsExtraKind
  25413. * @returns an array of strings
  25414. */
  25415. getVerticesDataKinds(): string[];
  25416. /**
  25417. * Returns a positive integer : the total number of indices in this mesh geometry.
  25418. * @returns the numner of indices or zero if the mesh has no geometry.
  25419. */
  25420. getTotalIndices(): number;
  25421. /**
  25422. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25423. * @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.
  25424. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25425. * @returns the indices array or an empty array if the mesh has no geometry
  25426. */
  25427. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25428. get isBlocked(): boolean;
  25429. /**
  25430. * Determine if the current mesh is ready to be rendered
  25431. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25432. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25433. * @returns true if all associated assets are ready (material, textures, shaders)
  25434. */
  25435. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25436. /**
  25437. * 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.
  25438. */
  25439. get areNormalsFrozen(): boolean;
  25440. /**
  25441. * 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.
  25442. * @returns the current mesh
  25443. */
  25444. freezeNormals(): Mesh;
  25445. /**
  25446. * 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
  25447. * @returns the current mesh
  25448. */
  25449. unfreezeNormals(): Mesh;
  25450. /**
  25451. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25452. */
  25453. set overridenInstanceCount(count: number);
  25454. /** @hidden */
  25455. _preActivate(): Mesh;
  25456. /** @hidden */
  25457. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25458. /** @hidden */
  25459. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25460. /**
  25461. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25462. * This means the mesh underlying bounding box and sphere are recomputed.
  25463. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25464. * @returns the current mesh
  25465. */
  25466. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25467. /** @hidden */
  25468. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25469. /**
  25470. * This function will subdivide the mesh into multiple submeshes
  25471. * @param count defines the expected number of submeshes
  25472. */
  25473. subdivide(count: number): void;
  25474. /**
  25475. * Copy a FloatArray into a specific associated vertex buffer
  25476. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25477. * - VertexBuffer.PositionKind
  25478. * - VertexBuffer.UVKind
  25479. * - VertexBuffer.UV2Kind
  25480. * - VertexBuffer.UV3Kind
  25481. * - VertexBuffer.UV4Kind
  25482. * - VertexBuffer.UV5Kind
  25483. * - VertexBuffer.UV6Kind
  25484. * - VertexBuffer.ColorKind
  25485. * - VertexBuffer.MatricesIndicesKind
  25486. * - VertexBuffer.MatricesIndicesExtraKind
  25487. * - VertexBuffer.MatricesWeightsKind
  25488. * - VertexBuffer.MatricesWeightsExtraKind
  25489. * @param data defines the data source
  25490. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25491. * @param stride defines the data stride size (can be null)
  25492. * @returns the current mesh
  25493. */
  25494. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25495. /**
  25496. * Delete a vertex buffer associated with this mesh
  25497. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25498. * - VertexBuffer.PositionKind
  25499. * - VertexBuffer.UVKind
  25500. * - VertexBuffer.UV2Kind
  25501. * - VertexBuffer.UV3Kind
  25502. * - VertexBuffer.UV4Kind
  25503. * - VertexBuffer.UV5Kind
  25504. * - VertexBuffer.UV6Kind
  25505. * - VertexBuffer.ColorKind
  25506. * - VertexBuffer.MatricesIndicesKind
  25507. * - VertexBuffer.MatricesIndicesExtraKind
  25508. * - VertexBuffer.MatricesWeightsKind
  25509. * - VertexBuffer.MatricesWeightsExtraKind
  25510. */
  25511. removeVerticesData(kind: string): void;
  25512. /**
  25513. * Flags an associated vertex buffer as updatable
  25514. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25515. * - VertexBuffer.PositionKind
  25516. * - VertexBuffer.UVKind
  25517. * - VertexBuffer.UV2Kind
  25518. * - VertexBuffer.UV3Kind
  25519. * - VertexBuffer.UV4Kind
  25520. * - VertexBuffer.UV5Kind
  25521. * - VertexBuffer.UV6Kind
  25522. * - VertexBuffer.ColorKind
  25523. * - VertexBuffer.MatricesIndicesKind
  25524. * - VertexBuffer.MatricesIndicesExtraKind
  25525. * - VertexBuffer.MatricesWeightsKind
  25526. * - VertexBuffer.MatricesWeightsExtraKind
  25527. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25528. */
  25529. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25530. /**
  25531. * Sets the mesh global Vertex Buffer
  25532. * @param buffer defines the buffer to use
  25533. * @returns the current mesh
  25534. */
  25535. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25536. /**
  25537. * Update a specific associated vertex buffer
  25538. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25539. * - VertexBuffer.PositionKind
  25540. * - VertexBuffer.UVKind
  25541. * - VertexBuffer.UV2Kind
  25542. * - VertexBuffer.UV3Kind
  25543. * - VertexBuffer.UV4Kind
  25544. * - VertexBuffer.UV5Kind
  25545. * - VertexBuffer.UV6Kind
  25546. * - VertexBuffer.ColorKind
  25547. * - VertexBuffer.MatricesIndicesKind
  25548. * - VertexBuffer.MatricesIndicesExtraKind
  25549. * - VertexBuffer.MatricesWeightsKind
  25550. * - VertexBuffer.MatricesWeightsExtraKind
  25551. * @param data defines the data source
  25552. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25553. * @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)
  25554. * @returns the current mesh
  25555. */
  25556. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25557. /**
  25558. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25559. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25560. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25561. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25562. * @returns the current mesh
  25563. */
  25564. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25565. /**
  25566. * Creates a un-shared specific occurence of the geometry for the mesh.
  25567. * @returns the current mesh
  25568. */
  25569. makeGeometryUnique(): Mesh;
  25570. /**
  25571. * Set the index buffer of this mesh
  25572. * @param indices defines the source data
  25573. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25574. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25575. * @returns the current mesh
  25576. */
  25577. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25578. /**
  25579. * Update the current index buffer
  25580. * @param indices defines the source data
  25581. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25582. * @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)
  25583. * @returns the current mesh
  25584. */
  25585. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25586. /**
  25587. * Invert the geometry to move from a right handed system to a left handed one.
  25588. * @returns the current mesh
  25589. */
  25590. toLeftHanded(): Mesh;
  25591. /** @hidden */
  25592. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25593. /** @hidden */
  25594. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25595. /**
  25596. * Registers for this mesh a javascript function called just before the rendering process
  25597. * @param func defines the function to call before rendering this mesh
  25598. * @returns the current mesh
  25599. */
  25600. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25601. /**
  25602. * Disposes a previously registered javascript function called before the rendering
  25603. * @param func defines the function to remove
  25604. * @returns the current mesh
  25605. */
  25606. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25607. /**
  25608. * Registers for this mesh a javascript function called just after the rendering is complete
  25609. * @param func defines the function to call after rendering this mesh
  25610. * @returns the current mesh
  25611. */
  25612. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25613. /**
  25614. * Disposes a previously registered javascript function called after the rendering.
  25615. * @param func defines the function to remove
  25616. * @returns the current mesh
  25617. */
  25618. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25619. /** @hidden */
  25620. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25621. /** @hidden */
  25622. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25623. /** @hidden */
  25624. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25625. /** @hidden */
  25626. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25627. /** @hidden */
  25628. _rebuild(): void;
  25629. /** @hidden */
  25630. _freeze(): void;
  25631. /** @hidden */
  25632. _unFreeze(): void;
  25633. /**
  25634. * 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
  25635. * @param subMesh defines the subMesh to render
  25636. * @param enableAlphaMode defines if alpha mode can be changed
  25637. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25638. * @returns the current mesh
  25639. */
  25640. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25641. private _onBeforeDraw;
  25642. /**
  25643. * Renormalize the mesh and patch it up if there are no weights
  25644. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25645. * However in the case of zero weights then we set just a single influence to 1.
  25646. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25647. */
  25648. cleanMatrixWeights(): void;
  25649. private normalizeSkinFourWeights;
  25650. private normalizeSkinWeightsAndExtra;
  25651. /**
  25652. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25653. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25654. * the user know there was an issue with importing the mesh
  25655. * @returns a validation object with skinned, valid and report string
  25656. */
  25657. validateSkinning(): {
  25658. skinned: boolean;
  25659. valid: boolean;
  25660. report: string;
  25661. };
  25662. /** @hidden */
  25663. _checkDelayState(): Mesh;
  25664. private _queueLoad;
  25665. /**
  25666. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25667. * A mesh is in the frustum if its bounding box intersects the frustum
  25668. * @param frustumPlanes defines the frustum to test
  25669. * @returns true if the mesh is in the frustum planes
  25670. */
  25671. isInFrustum(frustumPlanes: Plane[]): boolean;
  25672. /**
  25673. * Sets the mesh material by the material or multiMaterial `id` property
  25674. * @param id is a string identifying the material or the multiMaterial
  25675. * @returns the current mesh
  25676. */
  25677. setMaterialByID(id: string): Mesh;
  25678. /**
  25679. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25680. * @returns an array of IAnimatable
  25681. */
  25682. getAnimatables(): IAnimatable[];
  25683. /**
  25684. * Modifies the mesh geometry according to the passed transformation matrix.
  25685. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25686. * The mesh normals are modified using the same transformation.
  25687. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25688. * @param transform defines the transform matrix to use
  25689. * @see http://doc.babylonjs.com/resources/baking_transformations
  25690. * @returns the current mesh
  25691. */
  25692. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25693. /**
  25694. * Modifies the mesh geometry according to its own current World Matrix.
  25695. * The mesh World Matrix is then reset.
  25696. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25697. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25698. * @see http://doc.babylonjs.com/resources/baking_transformations
  25699. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25700. * @returns the current mesh
  25701. */
  25702. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25703. /** @hidden */
  25704. get _positions(): Nullable<Vector3[]>;
  25705. /** @hidden */
  25706. _resetPointsArrayCache(): Mesh;
  25707. /** @hidden */
  25708. _generatePointsArray(): boolean;
  25709. /**
  25710. * Returns a new Mesh object generated from the current mesh properties.
  25711. * This method must not get confused with createInstance()
  25712. * @param name is a string, the name given to the new mesh
  25713. * @param newParent can be any Node object (default `null`)
  25714. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25715. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25716. * @returns a new mesh
  25717. */
  25718. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25719. /**
  25720. * Releases resources associated with this mesh.
  25721. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25722. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25723. */
  25724. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25725. /** @hidden */
  25726. _disposeInstanceSpecificData(): void;
  25727. /**
  25728. * Modifies the mesh geometry according to a displacement map.
  25729. * 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.
  25730. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25731. * @param url is a string, the URL from the image file is to be downloaded.
  25732. * @param minHeight is the lower limit of the displacement.
  25733. * @param maxHeight is the upper limit of the displacement.
  25734. * @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.
  25735. * @param uvOffset is an optional vector2 used to offset UV.
  25736. * @param uvScale is an optional vector2 used to scale UV.
  25737. * @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.
  25738. * @returns the Mesh.
  25739. */
  25740. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25741. /**
  25742. * Modifies the mesh geometry according to a displacementMap buffer.
  25743. * 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.
  25744. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25745. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25746. * @param heightMapWidth is the width of the buffer image.
  25747. * @param heightMapHeight is the height of the buffer image.
  25748. * @param minHeight is the lower limit of the displacement.
  25749. * @param maxHeight is the upper limit of the displacement.
  25750. * @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.
  25751. * @param uvOffset is an optional vector2 used to offset UV.
  25752. * @param uvScale is an optional vector2 used to scale UV.
  25753. * @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.
  25754. * @returns the Mesh.
  25755. */
  25756. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25757. /**
  25758. * Modify the mesh to get a flat shading rendering.
  25759. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25760. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25761. * @returns current mesh
  25762. */
  25763. convertToFlatShadedMesh(): Mesh;
  25764. /**
  25765. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25766. * In other words, more vertices, no more indices and a single bigger VBO.
  25767. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25768. * @returns current mesh
  25769. */
  25770. convertToUnIndexedMesh(): Mesh;
  25771. /**
  25772. * Inverses facet orientations.
  25773. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25774. * @param flipNormals will also inverts the normals
  25775. * @returns current mesh
  25776. */
  25777. flipFaces(flipNormals?: boolean): Mesh;
  25778. /**
  25779. * Increase the number of facets and hence vertices in a mesh
  25780. * Vertex normals are interpolated from existing vertex normals
  25781. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25782. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25783. */
  25784. increaseVertices(numberPerEdge: number): void;
  25785. /**
  25786. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25787. * This will undo any application of covertToFlatShadedMesh
  25788. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25789. */
  25790. forceSharedVertices(): void;
  25791. /** @hidden */
  25792. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25793. /** @hidden */
  25794. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25795. /**
  25796. * Creates a new InstancedMesh object from the mesh model.
  25797. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25798. * @param name defines the name of the new instance
  25799. * @returns a new InstancedMesh
  25800. */
  25801. createInstance(name: string): InstancedMesh;
  25802. /**
  25803. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25804. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25805. * @returns the current mesh
  25806. */
  25807. synchronizeInstances(): Mesh;
  25808. /**
  25809. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25810. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25811. * This should be used together with the simplification to avoid disappearing triangles.
  25812. * @param successCallback an optional success callback to be called after the optimization finished.
  25813. * @returns the current mesh
  25814. */
  25815. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25816. /**
  25817. * Serialize current mesh
  25818. * @param serializationObject defines the object which will receive the serialization data
  25819. */
  25820. serialize(serializationObject: any): void;
  25821. /** @hidden */
  25822. _syncGeometryWithMorphTargetManager(): void;
  25823. /** @hidden */
  25824. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25825. /**
  25826. * Returns a new Mesh object parsed from the source provided.
  25827. * @param parsedMesh is the source
  25828. * @param scene defines the hosting scene
  25829. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25830. * @returns a new Mesh
  25831. */
  25832. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25833. /**
  25834. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25835. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25836. * @param name defines the name of the mesh to create
  25837. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25838. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25839. * @param closePath creates a seam between the first and the last points of each path of the path array
  25840. * @param offset is taken in account only if the `pathArray` is containing a single path
  25841. * @param scene defines the hosting scene
  25842. * @param updatable defines if the mesh must be flagged as updatable
  25843. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25844. * @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)
  25845. * @returns a new Mesh
  25846. */
  25847. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25848. /**
  25849. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25850. * @param name defines the name of the mesh to create
  25851. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25852. * @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
  25853. * @param scene defines the hosting scene
  25854. * @param updatable defines if the mesh must be flagged as updatable
  25855. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25856. * @returns a new Mesh
  25857. */
  25858. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25859. /**
  25860. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25861. * @param name defines the name of the mesh to create
  25862. * @param size sets the size (float) of each box side (default 1)
  25863. * @param scene defines the hosting scene
  25864. * @param updatable defines if the mesh must be flagged as updatable
  25865. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25866. * @returns a new Mesh
  25867. */
  25868. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25869. /**
  25870. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25871. * @param name defines the name of the mesh to create
  25872. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25873. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25874. * @param scene defines the hosting scene
  25875. * @param updatable defines if the mesh must be flagged as updatable
  25876. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25877. * @returns a new Mesh
  25878. */
  25879. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25880. /**
  25881. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25882. * @param name defines the name of the mesh to create
  25883. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25884. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25885. * @param scene defines the hosting scene
  25886. * @returns a new Mesh
  25887. */
  25888. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25889. /**
  25890. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25891. * @param name defines the name of the mesh to create
  25892. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25893. * @param diameterTop set the top cap diameter (floats, default 1)
  25894. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25895. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25896. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25897. * @param scene defines the hosting scene
  25898. * @param updatable defines if the mesh must be flagged as updatable
  25899. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25900. * @returns a new Mesh
  25901. */
  25902. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25903. /**
  25904. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25905. * @param name defines the name of the mesh to create
  25906. * @param diameter sets the diameter size (float) of the torus (default 1)
  25907. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25908. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25909. * @param scene defines the hosting scene
  25910. * @param updatable defines if the mesh must be flagged as updatable
  25911. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25912. * @returns a new Mesh
  25913. */
  25914. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25915. /**
  25916. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25917. * @param name defines the name of the mesh to create
  25918. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25919. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25920. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25921. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25922. * @param p the number of windings on X axis (positive integers, default 2)
  25923. * @param q the number of windings on Y axis (positive integers, default 3)
  25924. * @param scene defines the hosting scene
  25925. * @param updatable defines if the mesh must be flagged as updatable
  25926. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25927. * @returns a new Mesh
  25928. */
  25929. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25930. /**
  25931. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25932. * @param name defines the name of the mesh to create
  25933. * @param points is an array successive Vector3
  25934. * @param scene defines the hosting scene
  25935. * @param updatable defines if the mesh must be flagged as updatable
  25936. * @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).
  25937. * @returns a new Mesh
  25938. */
  25939. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25940. /**
  25941. * Creates a dashed line 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 points is an array successive Vector3
  25944. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25945. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25946. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25947. * @param scene defines the hosting scene
  25948. * @param updatable defines if the mesh must be flagged as updatable
  25949. * @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)
  25950. * @returns a new Mesh
  25951. */
  25952. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25953. /**
  25954. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25955. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25956. * 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.
  25957. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25958. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25959. * Remember you can only change the shape positions, not their number when updating a polygon.
  25960. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25961. * @param name defines the name of the mesh to create
  25962. * @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
  25963. * @param scene defines the hosting scene
  25964. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25965. * @param updatable defines if the mesh must be flagged as updatable
  25966. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25967. * @param earcutInjection can be used to inject your own earcut reference
  25968. * @returns a new Mesh
  25969. */
  25970. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25971. /**
  25972. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25973. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25974. * @param name defines the name of the mesh to create
  25975. * @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
  25976. * @param depth defines the height of extrusion
  25977. * @param scene defines the hosting scene
  25978. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25979. * @param updatable defines if the mesh must be flagged as updatable
  25980. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25981. * @param earcutInjection can be used to inject your own earcut reference
  25982. * @returns a new Mesh
  25983. */
  25984. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25985. /**
  25986. * Creates an extruded shape mesh.
  25987. * 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
  25988. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25989. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25990. * @param name defines the name of the mesh to create
  25991. * @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
  25992. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25993. * @param scale is the value to scale the shape
  25994. * @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
  25995. * @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
  25996. * @param scene defines the hosting scene
  25997. * @param updatable defines if the mesh must be flagged as updatable
  25998. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25999. * @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)
  26000. * @returns a new Mesh
  26001. */
  26002. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26003. /**
  26004. * Creates an custom extruded shape mesh.
  26005. * The custom extrusion is a parametric shape.
  26006. * It has no predefined shape. Its final shape will depend on the input parameters.
  26007. * Please consider using the same method from the MeshBuilder class instead
  26008. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26009. * @param name defines the name of the mesh to create
  26010. * @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
  26011. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  26012. * @param scaleFunction is a custom Javascript function called on each path point
  26013. * @param rotationFunction is a custom Javascript function called on each path point
  26014. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  26015. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  26016. * @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
  26017. * @param scene defines the hosting scene
  26018. * @param updatable defines if the mesh must be flagged as updatable
  26019. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26020. * @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)
  26021. * @returns a new Mesh
  26022. */
  26023. 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;
  26024. /**
  26025. * Creates lathe mesh.
  26026. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  26027. * Please consider using the same method from the MeshBuilder class instead
  26028. * @param name defines the name of the mesh to create
  26029. * @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
  26030. * @param radius is the radius value of the lathe
  26031. * @param tessellation is the side number of the lathe.
  26032. * @param scene defines the hosting scene
  26033. * @param updatable defines if the mesh must be flagged as updatable
  26034. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26035. * @returns a new Mesh
  26036. */
  26037. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26038. /**
  26039. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  26040. * @param name defines the name of the mesh to create
  26041. * @param size sets the size (float) of both sides of the plane at once (default 1)
  26042. * @param scene defines the hosting scene
  26043. * @param updatable defines if the mesh must be flagged as updatable
  26044. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26045. * @returns a new Mesh
  26046. */
  26047. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26048. /**
  26049. * Creates a ground mesh.
  26050. * Please consider using the same method from the MeshBuilder class instead
  26051. * @param name defines the name of the mesh to create
  26052. * @param width set the width of the ground
  26053. * @param height set the height of the ground
  26054. * @param subdivisions sets the number of subdivisions per side
  26055. * @param scene defines the hosting scene
  26056. * @param updatable defines if the mesh must be flagged as updatable
  26057. * @returns a new Mesh
  26058. */
  26059. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  26060. /**
  26061. * Creates a tiled ground mesh.
  26062. * Please consider using the same method from the MeshBuilder class instead
  26063. * @param name defines the name of the mesh to create
  26064. * @param xmin set the ground minimum X coordinate
  26065. * @param zmin set the ground minimum Y coordinate
  26066. * @param xmax set the ground maximum X coordinate
  26067. * @param zmax set the ground maximum Z coordinate
  26068. * @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
  26069. * @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
  26070. * @param scene defines the hosting scene
  26071. * @param updatable defines if the mesh must be flagged as updatable
  26072. * @returns a new Mesh
  26073. */
  26074. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  26075. w: number;
  26076. h: number;
  26077. }, precision: {
  26078. w: number;
  26079. h: number;
  26080. }, scene: Scene, updatable?: boolean): Mesh;
  26081. /**
  26082. * Creates a ground mesh from a height map.
  26083. * Please consider using the same method from the MeshBuilder class instead
  26084. * @see http://doc.babylonjs.com/babylon101/height_map
  26085. * @param name defines the name of the mesh to create
  26086. * @param url sets the URL of the height map image resource
  26087. * @param width set the ground width size
  26088. * @param height set the ground height size
  26089. * @param subdivisions sets the number of subdivision per side
  26090. * @param minHeight is the minimum altitude on the ground
  26091. * @param maxHeight is the maximum altitude on the ground
  26092. * @param scene defines the hosting scene
  26093. * @param updatable defines if the mesh must be flagged as updatable
  26094. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  26095. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  26096. * @returns a new Mesh
  26097. */
  26098. 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;
  26099. /**
  26100. * Creates a tube mesh.
  26101. * The tube is a parametric shape.
  26102. * It has no predefined shape. Its final shape will depend on the input parameters.
  26103. * Please consider using the same method from the MeshBuilder class instead
  26104. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26105. * @param name defines the name of the mesh to create
  26106. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  26107. * @param radius sets the tube radius size
  26108. * @param tessellation is the number of sides on the tubular surface
  26109. * @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
  26110. * @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
  26111. * @param scene defines the hosting scene
  26112. * @param updatable defines if the mesh must be flagged as updatable
  26113. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26114. * @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)
  26115. * @returns a new Mesh
  26116. */
  26117. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  26118. (i: number, distance: number): number;
  26119. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26120. /**
  26121. * Creates a polyhedron mesh.
  26122. * Please consider using the same method from the MeshBuilder class instead.
  26123. * * 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
  26124. * * The parameter `size` (positive float, default 1) sets the polygon size
  26125. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  26126. * * 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`
  26127. * * 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
  26128. * * 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)`)
  26129. * * 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
  26130. * * 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
  26131. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26132. * * If you create a double-sided mesh, you can choose what parts of 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
  26133. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26134. * @param name defines the name of the mesh to create
  26135. * @param options defines the options used to create the mesh
  26136. * @param scene defines the hosting scene
  26137. * @returns a new Mesh
  26138. */
  26139. static CreatePolyhedron(name: string, options: {
  26140. type?: number;
  26141. size?: number;
  26142. sizeX?: number;
  26143. sizeY?: number;
  26144. sizeZ?: number;
  26145. custom?: any;
  26146. faceUV?: Vector4[];
  26147. faceColors?: Color4[];
  26148. updatable?: boolean;
  26149. sideOrientation?: number;
  26150. }, scene: Scene): Mesh;
  26151. /**
  26152. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  26153. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  26154. * * 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`)
  26155. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  26156. * * 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
  26157. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26158. * * If you create a double-sided mesh, you can choose what parts of 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
  26159. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26160. * @param name defines the name of the mesh
  26161. * @param options defines the options used to create the mesh
  26162. * @param scene defines the hosting scene
  26163. * @returns a new Mesh
  26164. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  26165. */
  26166. static CreateIcoSphere(name: string, options: {
  26167. radius?: number;
  26168. flat?: boolean;
  26169. subdivisions?: number;
  26170. sideOrientation?: number;
  26171. updatable?: boolean;
  26172. }, scene: Scene): Mesh;
  26173. /**
  26174. * Creates a decal mesh.
  26175. * Please consider using the same method from the MeshBuilder class instead.
  26176. * A decal is a mesh usually applied as a model onto the surface of another mesh
  26177. * @param name defines the name of the mesh
  26178. * @param sourceMesh defines the mesh receiving the decal
  26179. * @param position sets the position of the decal in world coordinates
  26180. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  26181. * @param size sets the decal scaling
  26182. * @param angle sets the angle to rotate the decal
  26183. * @returns a new Mesh
  26184. */
  26185. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  26186. /**
  26187. * Prepare internal position array for software CPU skinning
  26188. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  26189. */
  26190. setPositionsForCPUSkinning(): Float32Array;
  26191. /**
  26192. * Prepare internal normal array for software CPU skinning
  26193. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  26194. */
  26195. setNormalsForCPUSkinning(): Float32Array;
  26196. /**
  26197. * Updates the vertex buffer by applying transformation from the bones
  26198. * @param skeleton defines the skeleton to apply to current mesh
  26199. * @returns the current mesh
  26200. */
  26201. applySkeleton(skeleton: Skeleton): Mesh;
  26202. /**
  26203. * 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
  26204. * @param meshes defines the list of meshes to scan
  26205. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  26206. */
  26207. static MinMax(meshes: AbstractMesh[]): {
  26208. min: Vector3;
  26209. max: Vector3;
  26210. };
  26211. /**
  26212. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  26213. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  26214. * @returns a vector3
  26215. */
  26216. static Center(meshesOrMinMaxVector: {
  26217. min: Vector3;
  26218. max: Vector3;
  26219. } | AbstractMesh[]): Vector3;
  26220. /**
  26221. * Merge the array of meshes into a single mesh for performance reasons.
  26222. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  26223. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  26224. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  26225. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  26226. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  26227. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  26228. * @returns a new mesh
  26229. */
  26230. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  26231. /** @hidden */
  26232. addInstance(instance: InstancedMesh): void;
  26233. /** @hidden */
  26234. removeInstance(instance: InstancedMesh): void;
  26235. }
  26236. }
  26237. declare module "babylonjs/Cameras/camera" {
  26238. import { SmartArray } from "babylonjs/Misc/smartArray";
  26239. import { Observable } from "babylonjs/Misc/observable";
  26240. import { Nullable } from "babylonjs/types";
  26241. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  26242. import { Scene } from "babylonjs/scene";
  26243. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  26244. import { Node } from "babylonjs/node";
  26245. import { Mesh } from "babylonjs/Meshes/mesh";
  26246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26247. import { ICullable } from "babylonjs/Culling/boundingInfo";
  26248. import { Viewport } from "babylonjs/Maths/math.viewport";
  26249. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26250. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26251. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  26252. import { Ray } from "babylonjs/Culling/ray";
  26253. /**
  26254. * This is the base class of all the camera used in the application.
  26255. * @see http://doc.babylonjs.com/features/cameras
  26256. */
  26257. export class Camera extends Node {
  26258. /** @hidden */
  26259. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  26260. /**
  26261. * This is the default projection mode used by the cameras.
  26262. * It helps recreating a feeling of perspective and better appreciate depth.
  26263. * This is the best way to simulate real life cameras.
  26264. */
  26265. static readonly PERSPECTIVE_CAMERA: number;
  26266. /**
  26267. * This helps creating camera with an orthographic mode.
  26268. * 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.
  26269. */
  26270. static readonly ORTHOGRAPHIC_CAMERA: number;
  26271. /**
  26272. * This is the default FOV mode for perspective cameras.
  26273. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  26274. */
  26275. static readonly FOVMODE_VERTICAL_FIXED: number;
  26276. /**
  26277. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  26278. */
  26279. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  26280. /**
  26281. * This specifies ther is no need for a camera rig.
  26282. * Basically only one eye is rendered corresponding to the camera.
  26283. */
  26284. static readonly RIG_MODE_NONE: number;
  26285. /**
  26286. * Simulates a camera Rig with one blue eye and one red eye.
  26287. * This can be use with 3d blue and red glasses.
  26288. */
  26289. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  26290. /**
  26291. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  26292. */
  26293. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  26294. /**
  26295. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  26296. */
  26297. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  26298. /**
  26299. * Defines that both eyes of the camera will be rendered over under each other.
  26300. */
  26301. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  26302. /**
  26303. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  26304. */
  26305. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  26306. /**
  26307. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  26308. */
  26309. static readonly RIG_MODE_VR: number;
  26310. /**
  26311. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  26312. */
  26313. static readonly RIG_MODE_WEBVR: number;
  26314. /**
  26315. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  26316. */
  26317. static readonly RIG_MODE_CUSTOM: number;
  26318. /**
  26319. * Defines if by default attaching controls should prevent the default javascript event to continue.
  26320. */
  26321. static ForceAttachControlToAlwaysPreventDefault: boolean;
  26322. /**
  26323. * Define the input manager associated with the camera.
  26324. */
  26325. inputs: CameraInputsManager<Camera>;
  26326. /** @hidden */
  26327. _position: Vector3;
  26328. /**
  26329. * Define the current local position of the camera in the scene
  26330. */
  26331. get position(): Vector3;
  26332. set position(newPosition: Vector3);
  26333. /**
  26334. * The vector the camera should consider as up.
  26335. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  26336. */
  26337. upVector: Vector3;
  26338. /**
  26339. * Define the current limit on the left side for an orthographic camera
  26340. * In scene unit
  26341. */
  26342. orthoLeft: Nullable<number>;
  26343. /**
  26344. * Define the current limit on the right side for an orthographic camera
  26345. * In scene unit
  26346. */
  26347. orthoRight: Nullable<number>;
  26348. /**
  26349. * Define the current limit on the bottom side for an orthographic camera
  26350. * In scene unit
  26351. */
  26352. orthoBottom: Nullable<number>;
  26353. /**
  26354. * Define the current limit on the top side for an orthographic camera
  26355. * In scene unit
  26356. */
  26357. orthoTop: Nullable<number>;
  26358. /**
  26359. * Field Of View is set in Radians. (default is 0.8)
  26360. */
  26361. fov: number;
  26362. /**
  26363. * Define the minimum distance the camera can see from.
  26364. * This is important to note that the depth buffer are not infinite and the closer it starts
  26365. * the more your scene might encounter depth fighting issue.
  26366. */
  26367. minZ: number;
  26368. /**
  26369. * Define the maximum distance the camera can see to.
  26370. * This is important to note that the depth buffer are not infinite and the further it end
  26371. * the more your scene might encounter depth fighting issue.
  26372. */
  26373. maxZ: number;
  26374. /**
  26375. * Define the default inertia of the camera.
  26376. * This helps giving a smooth feeling to the camera movement.
  26377. */
  26378. inertia: number;
  26379. /**
  26380. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26381. */
  26382. mode: number;
  26383. /**
  26384. * Define whether the camera is intermediate.
  26385. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26386. */
  26387. isIntermediate: boolean;
  26388. /**
  26389. * Define the viewport of the camera.
  26390. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26391. */
  26392. viewport: Viewport;
  26393. /**
  26394. * Restricts the camera to viewing objects with the same layerMask.
  26395. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26396. */
  26397. layerMask: number;
  26398. /**
  26399. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26400. */
  26401. fovMode: number;
  26402. /**
  26403. * Rig mode of the camera.
  26404. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26405. * This is normally controlled byt the camera themselves as internal use.
  26406. */
  26407. cameraRigMode: number;
  26408. /**
  26409. * Defines the distance between both "eyes" in case of a RIG
  26410. */
  26411. interaxialDistance: number;
  26412. /**
  26413. * Defines if stereoscopic rendering is done side by side or over under.
  26414. */
  26415. isStereoscopicSideBySide: boolean;
  26416. /**
  26417. * 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
  26418. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26419. * else in the scene. (Eg. security camera)
  26420. *
  26421. * 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)
  26422. */
  26423. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26424. /**
  26425. * When set, the camera will render to this render target instead of the default canvas
  26426. *
  26427. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26428. */
  26429. outputRenderTarget: Nullable<RenderTargetTexture>;
  26430. /**
  26431. * Observable triggered when the camera view matrix has changed.
  26432. */
  26433. onViewMatrixChangedObservable: Observable<Camera>;
  26434. /**
  26435. * Observable triggered when the camera Projection matrix has changed.
  26436. */
  26437. onProjectionMatrixChangedObservable: Observable<Camera>;
  26438. /**
  26439. * Observable triggered when the inputs have been processed.
  26440. */
  26441. onAfterCheckInputsObservable: Observable<Camera>;
  26442. /**
  26443. * Observable triggered when reset has been called and applied to the camera.
  26444. */
  26445. onRestoreStateObservable: Observable<Camera>;
  26446. /**
  26447. * Is this camera a part of a rig system?
  26448. */
  26449. isRigCamera: boolean;
  26450. /**
  26451. * If isRigCamera set to true this will be set with the parent camera.
  26452. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  26453. */
  26454. rigParent?: Camera;
  26455. /** @hidden */
  26456. _cameraRigParams: any;
  26457. /** @hidden */
  26458. _rigCameras: Camera[];
  26459. /** @hidden */
  26460. _rigPostProcess: Nullable<PostProcess>;
  26461. protected _webvrViewMatrix: Matrix;
  26462. /** @hidden */
  26463. _skipRendering: boolean;
  26464. /** @hidden */
  26465. _projectionMatrix: Matrix;
  26466. /** @hidden */
  26467. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26468. /** @hidden */
  26469. _activeMeshes: SmartArray<AbstractMesh>;
  26470. protected _globalPosition: Vector3;
  26471. /** @hidden */
  26472. _computedViewMatrix: Matrix;
  26473. private _doNotComputeProjectionMatrix;
  26474. private _transformMatrix;
  26475. private _frustumPlanes;
  26476. private _refreshFrustumPlanes;
  26477. private _storedFov;
  26478. private _stateStored;
  26479. /**
  26480. * Instantiates a new camera object.
  26481. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26482. * @see http://doc.babylonjs.com/features/cameras
  26483. * @param name Defines the name of the camera in the scene
  26484. * @param position Defines the position of the camera
  26485. * @param scene Defines the scene the camera belongs too
  26486. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26487. */
  26488. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26489. /**
  26490. * Store current camera state (fov, position, etc..)
  26491. * @returns the camera
  26492. */
  26493. storeState(): Camera;
  26494. /**
  26495. * Restores the camera state values if it has been stored. You must call storeState() first
  26496. */
  26497. protected _restoreStateValues(): boolean;
  26498. /**
  26499. * Restored camera state. You must call storeState() first.
  26500. * @returns true if restored and false otherwise
  26501. */
  26502. restoreState(): boolean;
  26503. /**
  26504. * Gets the class name of the camera.
  26505. * @returns the class name
  26506. */
  26507. getClassName(): string;
  26508. /** @hidden */
  26509. readonly _isCamera: boolean;
  26510. /**
  26511. * Gets a string representation of the camera useful for debug purpose.
  26512. * @param fullDetails Defines that a more verboe level of logging is required
  26513. * @returns the string representation
  26514. */
  26515. toString(fullDetails?: boolean): string;
  26516. /**
  26517. * Gets the current world space position of the camera.
  26518. */
  26519. get globalPosition(): Vector3;
  26520. /**
  26521. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26522. * @returns the active meshe list
  26523. */
  26524. getActiveMeshes(): SmartArray<AbstractMesh>;
  26525. /**
  26526. * Check whether a mesh is part of the current active mesh list of the camera
  26527. * @param mesh Defines the mesh to check
  26528. * @returns true if active, false otherwise
  26529. */
  26530. isActiveMesh(mesh: Mesh): boolean;
  26531. /**
  26532. * Is this camera ready to be used/rendered
  26533. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26534. * @return true if the camera is ready
  26535. */
  26536. isReady(completeCheck?: boolean): boolean;
  26537. /** @hidden */
  26538. _initCache(): void;
  26539. /** @hidden */
  26540. _updateCache(ignoreParentClass?: boolean): void;
  26541. /** @hidden */
  26542. _isSynchronized(): boolean;
  26543. /** @hidden */
  26544. _isSynchronizedViewMatrix(): boolean;
  26545. /** @hidden */
  26546. _isSynchronizedProjectionMatrix(): boolean;
  26547. /**
  26548. * Attach the input controls to a specific dom element to get the input from.
  26549. * @param element Defines the element the controls should be listened from
  26550. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26551. */
  26552. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26553. /**
  26554. * Detach the current controls from the specified dom element.
  26555. * @param element Defines the element to stop listening the inputs from
  26556. */
  26557. detachControl(element: HTMLElement): void;
  26558. /**
  26559. * Update the camera state according to the different inputs gathered during the frame.
  26560. */
  26561. update(): void;
  26562. /** @hidden */
  26563. _checkInputs(): void;
  26564. /** @hidden */
  26565. get rigCameras(): Camera[];
  26566. /**
  26567. * Gets the post process used by the rig cameras
  26568. */
  26569. get rigPostProcess(): Nullable<PostProcess>;
  26570. /**
  26571. * Internal, gets the first post proces.
  26572. * @returns the first post process to be run on this camera.
  26573. */
  26574. _getFirstPostProcess(): Nullable<PostProcess>;
  26575. private _cascadePostProcessesToRigCams;
  26576. /**
  26577. * Attach a post process to the camera.
  26578. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26579. * @param postProcess The post process to attach to the camera
  26580. * @param insertAt The position of the post process in case several of them are in use in the scene
  26581. * @returns the position the post process has been inserted at
  26582. */
  26583. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26584. /**
  26585. * Detach a post process to the camera.
  26586. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26587. * @param postProcess The post process to detach from the camera
  26588. */
  26589. detachPostProcess(postProcess: PostProcess): void;
  26590. /**
  26591. * Gets the current world matrix of the camera
  26592. */
  26593. getWorldMatrix(): Matrix;
  26594. /** @hidden */
  26595. _getViewMatrix(): Matrix;
  26596. /**
  26597. * Gets the current view matrix of the camera.
  26598. * @param force forces the camera to recompute the matrix without looking at the cached state
  26599. * @returns the view matrix
  26600. */
  26601. getViewMatrix(force?: boolean): Matrix;
  26602. /**
  26603. * Freeze the projection matrix.
  26604. * It will prevent the cache check of the camera projection compute and can speed up perf
  26605. * if no parameter of the camera are meant to change
  26606. * @param projection Defines manually a projection if necessary
  26607. */
  26608. freezeProjectionMatrix(projection?: Matrix): void;
  26609. /**
  26610. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26611. */
  26612. unfreezeProjectionMatrix(): void;
  26613. /**
  26614. * Gets the current projection matrix of the camera.
  26615. * @param force forces the camera to recompute the matrix without looking at the cached state
  26616. * @returns the projection matrix
  26617. */
  26618. getProjectionMatrix(force?: boolean): Matrix;
  26619. /**
  26620. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26621. * @returns a Matrix
  26622. */
  26623. getTransformationMatrix(): Matrix;
  26624. private _updateFrustumPlanes;
  26625. /**
  26626. * Checks if a cullable object (mesh...) is in the camera frustum
  26627. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26628. * @param target The object to check
  26629. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26630. * @returns true if the object is in frustum otherwise false
  26631. */
  26632. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26633. /**
  26634. * Checks if a cullable object (mesh...) is in the camera frustum
  26635. * Unlike isInFrustum this cheks the full bounding box
  26636. * @param target The object to check
  26637. * @returns true if the object is in frustum otherwise false
  26638. */
  26639. isCompletelyInFrustum(target: ICullable): boolean;
  26640. /**
  26641. * Gets a ray in the forward direction from the camera.
  26642. * @param length Defines the length of the ray to create
  26643. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26644. * @param origin Defines the start point of the ray which defaults to the camera position
  26645. * @returns the forward ray
  26646. */
  26647. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26648. /**
  26649. * Releases resources associated with this node.
  26650. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26651. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26652. */
  26653. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26654. /** @hidden */
  26655. _isLeftCamera: boolean;
  26656. /**
  26657. * Gets the left camera of a rig setup in case of Rigged Camera
  26658. */
  26659. get isLeftCamera(): boolean;
  26660. /** @hidden */
  26661. _isRightCamera: boolean;
  26662. /**
  26663. * Gets the right camera of a rig setup in case of Rigged Camera
  26664. */
  26665. get isRightCamera(): boolean;
  26666. /**
  26667. * Gets the left camera of a rig setup in case of Rigged Camera
  26668. */
  26669. get leftCamera(): Nullable<FreeCamera>;
  26670. /**
  26671. * Gets the right camera of a rig setup in case of Rigged Camera
  26672. */
  26673. get rightCamera(): Nullable<FreeCamera>;
  26674. /**
  26675. * Gets the left camera target of a rig setup in case of Rigged Camera
  26676. * @returns the target position
  26677. */
  26678. getLeftTarget(): Nullable<Vector3>;
  26679. /**
  26680. * Gets the right camera target of a rig setup in case of Rigged Camera
  26681. * @returns the target position
  26682. */
  26683. getRightTarget(): Nullable<Vector3>;
  26684. /**
  26685. * @hidden
  26686. */
  26687. setCameraRigMode(mode: number, rigParams: any): void;
  26688. /** @hidden */
  26689. static _setStereoscopicRigMode(camera: Camera): void;
  26690. /** @hidden */
  26691. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26692. /** @hidden */
  26693. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26694. /** @hidden */
  26695. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26696. /** @hidden */
  26697. _getVRProjectionMatrix(): Matrix;
  26698. protected _updateCameraRotationMatrix(): void;
  26699. protected _updateWebVRCameraRotationMatrix(): void;
  26700. /**
  26701. * This function MUST be overwritten by the different WebVR cameras available.
  26702. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26703. * @hidden
  26704. */
  26705. _getWebVRProjectionMatrix(): Matrix;
  26706. /**
  26707. * This function MUST be overwritten by the different WebVR cameras available.
  26708. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26709. * @hidden
  26710. */
  26711. _getWebVRViewMatrix(): Matrix;
  26712. /** @hidden */
  26713. setCameraRigParameter(name: string, value: any): void;
  26714. /**
  26715. * needs to be overridden by children so sub has required properties to be copied
  26716. * @hidden
  26717. */
  26718. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26719. /**
  26720. * May need to be overridden by children
  26721. * @hidden
  26722. */
  26723. _updateRigCameras(): void;
  26724. /** @hidden */
  26725. _setupInputs(): void;
  26726. /**
  26727. * Serialiaze the camera setup to a json represention
  26728. * @returns the JSON representation
  26729. */
  26730. serialize(): any;
  26731. /**
  26732. * Clones the current camera.
  26733. * @param name The cloned camera name
  26734. * @returns the cloned camera
  26735. */
  26736. clone(name: string): Camera;
  26737. /**
  26738. * Gets the direction of the camera relative to a given local axis.
  26739. * @param localAxis Defines the reference axis to provide a relative direction.
  26740. * @return the direction
  26741. */
  26742. getDirection(localAxis: Vector3): Vector3;
  26743. /**
  26744. * Returns the current camera absolute rotation
  26745. */
  26746. get absoluteRotation(): Quaternion;
  26747. /**
  26748. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26749. * @param localAxis Defines the reference axis to provide a relative direction.
  26750. * @param result Defines the vector to store the result in
  26751. */
  26752. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26753. /**
  26754. * Gets a camera constructor for a given camera type
  26755. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26756. * @param name The name of the camera the result will be able to instantiate
  26757. * @param scene The scene the result will construct the camera in
  26758. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26759. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26760. * @returns a factory method to construc the camera
  26761. */
  26762. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26763. /**
  26764. * Compute the world matrix of the camera.
  26765. * @returns the camera world matrix
  26766. */
  26767. computeWorldMatrix(): Matrix;
  26768. /**
  26769. * Parse a JSON and creates the camera from the parsed information
  26770. * @param parsedCamera The JSON to parse
  26771. * @param scene The scene to instantiate the camera in
  26772. * @returns the newly constructed camera
  26773. */
  26774. static Parse(parsedCamera: any, scene: Scene): Camera;
  26775. }
  26776. }
  26777. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26778. import { Nullable } from "babylonjs/types";
  26779. import { Scene } from "babylonjs/scene";
  26780. import { Vector4 } from "babylonjs/Maths/math.vector";
  26781. import { Mesh } from "babylonjs/Meshes/mesh";
  26782. /**
  26783. * Class containing static functions to help procedurally build meshes
  26784. */
  26785. export class DiscBuilder {
  26786. /**
  26787. * Creates a plane polygonal mesh. By default, this is a disc
  26788. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26789. * * 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
  26790. * * 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
  26791. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26792. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26794. * @param name defines the name of the mesh
  26795. * @param options defines the options used to create the mesh
  26796. * @param scene defines the hosting scene
  26797. * @returns the plane polygonal mesh
  26798. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26799. */
  26800. static CreateDisc(name: string, options: {
  26801. radius?: number;
  26802. tessellation?: number;
  26803. arc?: number;
  26804. updatable?: boolean;
  26805. sideOrientation?: number;
  26806. frontUVs?: Vector4;
  26807. backUVs?: Vector4;
  26808. }, scene?: Nullable<Scene>): Mesh;
  26809. }
  26810. }
  26811. declare module "babylonjs/Materials/fresnelParameters" {
  26812. import { Color3 } from "babylonjs/Maths/math.color";
  26813. /**
  26814. * This represents all the required information to add a fresnel effect on a material:
  26815. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26816. */
  26817. export class FresnelParameters {
  26818. private _isEnabled;
  26819. /**
  26820. * Define if the fresnel effect is enable or not.
  26821. */
  26822. get isEnabled(): boolean;
  26823. set isEnabled(value: boolean);
  26824. /**
  26825. * Define the color used on edges (grazing angle)
  26826. */
  26827. leftColor: Color3;
  26828. /**
  26829. * Define the color used on center
  26830. */
  26831. rightColor: Color3;
  26832. /**
  26833. * Define bias applied to computed fresnel term
  26834. */
  26835. bias: number;
  26836. /**
  26837. * Defined the power exponent applied to fresnel term
  26838. */
  26839. power: number;
  26840. /**
  26841. * Clones the current fresnel and its valuues
  26842. * @returns a clone fresnel configuration
  26843. */
  26844. clone(): FresnelParameters;
  26845. /**
  26846. * Serializes the current fresnel parameters to a JSON representation.
  26847. * @return the JSON serialization
  26848. */
  26849. serialize(): any;
  26850. /**
  26851. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26852. * @param parsedFresnelParameters Define the JSON representation
  26853. * @returns the parsed parameters
  26854. */
  26855. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26856. }
  26857. }
  26858. declare module "babylonjs/Materials/pushMaterial" {
  26859. import { Nullable } from "babylonjs/types";
  26860. import { Scene } from "babylonjs/scene";
  26861. import { Matrix } from "babylonjs/Maths/math.vector";
  26862. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26863. import { Mesh } from "babylonjs/Meshes/mesh";
  26864. import { Material } from "babylonjs/Materials/material";
  26865. import { Effect } from "babylonjs/Materials/effect";
  26866. /**
  26867. * Base class of materials working in push mode in babylon JS
  26868. * @hidden
  26869. */
  26870. export class PushMaterial extends Material {
  26871. protected _activeEffect: Effect;
  26872. protected _normalMatrix: Matrix;
  26873. /**
  26874. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26875. * This means that the material can keep using a previous shader while a new one is being compiled.
  26876. * This is mostly used when shader parallel compilation is supported (true by default)
  26877. */
  26878. allowShaderHotSwapping: boolean;
  26879. constructor(name: string, scene: Scene);
  26880. getEffect(): Effect;
  26881. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26882. /**
  26883. * Binds the given world matrix to the active effect
  26884. *
  26885. * @param world the matrix to bind
  26886. */
  26887. bindOnlyWorldMatrix(world: Matrix): void;
  26888. /**
  26889. * Binds the given normal matrix to the active effect
  26890. *
  26891. * @param normalMatrix the matrix to bind
  26892. */
  26893. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26894. bind(world: Matrix, mesh?: Mesh): void;
  26895. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26896. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26897. }
  26898. }
  26899. declare module "babylonjs/Materials/materialFlags" {
  26900. /**
  26901. * This groups all the flags used to control the materials channel.
  26902. */
  26903. export class MaterialFlags {
  26904. private static _DiffuseTextureEnabled;
  26905. /**
  26906. * Are diffuse textures enabled in the application.
  26907. */
  26908. static get DiffuseTextureEnabled(): boolean;
  26909. static set DiffuseTextureEnabled(value: boolean);
  26910. private static _AmbientTextureEnabled;
  26911. /**
  26912. * Are ambient textures enabled in the application.
  26913. */
  26914. static get AmbientTextureEnabled(): boolean;
  26915. static set AmbientTextureEnabled(value: boolean);
  26916. private static _OpacityTextureEnabled;
  26917. /**
  26918. * Are opacity textures enabled in the application.
  26919. */
  26920. static get OpacityTextureEnabled(): boolean;
  26921. static set OpacityTextureEnabled(value: boolean);
  26922. private static _ReflectionTextureEnabled;
  26923. /**
  26924. * Are reflection textures enabled in the application.
  26925. */
  26926. static get ReflectionTextureEnabled(): boolean;
  26927. static set ReflectionTextureEnabled(value: boolean);
  26928. private static _EmissiveTextureEnabled;
  26929. /**
  26930. * Are emissive textures enabled in the application.
  26931. */
  26932. static get EmissiveTextureEnabled(): boolean;
  26933. static set EmissiveTextureEnabled(value: boolean);
  26934. private static _SpecularTextureEnabled;
  26935. /**
  26936. * Are specular textures enabled in the application.
  26937. */
  26938. static get SpecularTextureEnabled(): boolean;
  26939. static set SpecularTextureEnabled(value: boolean);
  26940. private static _BumpTextureEnabled;
  26941. /**
  26942. * Are bump textures enabled in the application.
  26943. */
  26944. static get BumpTextureEnabled(): boolean;
  26945. static set BumpTextureEnabled(value: boolean);
  26946. private static _LightmapTextureEnabled;
  26947. /**
  26948. * Are lightmap textures enabled in the application.
  26949. */
  26950. static get LightmapTextureEnabled(): boolean;
  26951. static set LightmapTextureEnabled(value: boolean);
  26952. private static _RefractionTextureEnabled;
  26953. /**
  26954. * Are refraction textures enabled in the application.
  26955. */
  26956. static get RefractionTextureEnabled(): boolean;
  26957. static set RefractionTextureEnabled(value: boolean);
  26958. private static _ColorGradingTextureEnabled;
  26959. /**
  26960. * Are color grading textures enabled in the application.
  26961. */
  26962. static get ColorGradingTextureEnabled(): boolean;
  26963. static set ColorGradingTextureEnabled(value: boolean);
  26964. private static _FresnelEnabled;
  26965. /**
  26966. * Are fresnels enabled in the application.
  26967. */
  26968. static get FresnelEnabled(): boolean;
  26969. static set FresnelEnabled(value: boolean);
  26970. private static _ClearCoatTextureEnabled;
  26971. /**
  26972. * Are clear coat textures enabled in the application.
  26973. */
  26974. static get ClearCoatTextureEnabled(): boolean;
  26975. static set ClearCoatTextureEnabled(value: boolean);
  26976. private static _ClearCoatBumpTextureEnabled;
  26977. /**
  26978. * Are clear coat bump textures enabled in the application.
  26979. */
  26980. static get ClearCoatBumpTextureEnabled(): boolean;
  26981. static set ClearCoatBumpTextureEnabled(value: boolean);
  26982. private static _ClearCoatTintTextureEnabled;
  26983. /**
  26984. * Are clear coat tint textures enabled in the application.
  26985. */
  26986. static get ClearCoatTintTextureEnabled(): boolean;
  26987. static set ClearCoatTintTextureEnabled(value: boolean);
  26988. private static _SheenTextureEnabled;
  26989. /**
  26990. * Are sheen textures enabled in the application.
  26991. */
  26992. static get SheenTextureEnabled(): boolean;
  26993. static set SheenTextureEnabled(value: boolean);
  26994. private static _AnisotropicTextureEnabled;
  26995. /**
  26996. * Are anisotropic textures enabled in the application.
  26997. */
  26998. static get AnisotropicTextureEnabled(): boolean;
  26999. static set AnisotropicTextureEnabled(value: boolean);
  27000. private static _ThicknessTextureEnabled;
  27001. /**
  27002. * Are thickness textures enabled in the application.
  27003. */
  27004. static get ThicknessTextureEnabled(): boolean;
  27005. static set ThicknessTextureEnabled(value: boolean);
  27006. }
  27007. }
  27008. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  27009. /** @hidden */
  27010. export var defaultFragmentDeclaration: {
  27011. name: string;
  27012. shader: string;
  27013. };
  27014. }
  27015. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  27016. /** @hidden */
  27017. export var defaultUboDeclaration: {
  27018. name: string;
  27019. shader: string;
  27020. };
  27021. }
  27022. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  27023. /** @hidden */
  27024. export var lightFragmentDeclaration: {
  27025. name: string;
  27026. shader: string;
  27027. };
  27028. }
  27029. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  27030. /** @hidden */
  27031. export var lightUboDeclaration: {
  27032. name: string;
  27033. shader: string;
  27034. };
  27035. }
  27036. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  27037. /** @hidden */
  27038. export var lightsFragmentFunctions: {
  27039. name: string;
  27040. shader: string;
  27041. };
  27042. }
  27043. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  27044. /** @hidden */
  27045. export var shadowsFragmentFunctions: {
  27046. name: string;
  27047. shader: string;
  27048. };
  27049. }
  27050. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  27051. /** @hidden */
  27052. export var fresnelFunction: {
  27053. name: string;
  27054. shader: string;
  27055. };
  27056. }
  27057. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  27058. /** @hidden */
  27059. export var reflectionFunction: {
  27060. name: string;
  27061. shader: string;
  27062. };
  27063. }
  27064. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  27065. /** @hidden */
  27066. export var bumpFragmentFunctions: {
  27067. name: string;
  27068. shader: string;
  27069. };
  27070. }
  27071. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  27072. /** @hidden */
  27073. export var logDepthDeclaration: {
  27074. name: string;
  27075. shader: string;
  27076. };
  27077. }
  27078. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  27079. /** @hidden */
  27080. export var bumpFragment: {
  27081. name: string;
  27082. shader: string;
  27083. };
  27084. }
  27085. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  27086. /** @hidden */
  27087. export var depthPrePass: {
  27088. name: string;
  27089. shader: string;
  27090. };
  27091. }
  27092. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  27093. /** @hidden */
  27094. export var lightFragment: {
  27095. name: string;
  27096. shader: string;
  27097. };
  27098. }
  27099. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  27100. /** @hidden */
  27101. export var logDepthFragment: {
  27102. name: string;
  27103. shader: string;
  27104. };
  27105. }
  27106. declare module "babylonjs/Shaders/default.fragment" {
  27107. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  27108. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27109. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27110. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27111. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27112. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  27113. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  27114. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  27115. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  27116. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  27117. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  27118. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  27119. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  27120. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27121. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  27122. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  27123. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  27124. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  27125. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  27126. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  27127. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  27128. /** @hidden */
  27129. export var defaultPixelShader: {
  27130. name: string;
  27131. shader: string;
  27132. };
  27133. }
  27134. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  27135. /** @hidden */
  27136. export var defaultVertexDeclaration: {
  27137. name: string;
  27138. shader: string;
  27139. };
  27140. }
  27141. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  27142. /** @hidden */
  27143. export var bumpVertexDeclaration: {
  27144. name: string;
  27145. shader: string;
  27146. };
  27147. }
  27148. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  27149. /** @hidden */
  27150. export var bumpVertex: {
  27151. name: string;
  27152. shader: string;
  27153. };
  27154. }
  27155. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  27156. /** @hidden */
  27157. export var fogVertex: {
  27158. name: string;
  27159. shader: string;
  27160. };
  27161. }
  27162. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  27163. /** @hidden */
  27164. export var shadowsVertex: {
  27165. name: string;
  27166. shader: string;
  27167. };
  27168. }
  27169. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  27170. /** @hidden */
  27171. export var pointCloudVertex: {
  27172. name: string;
  27173. shader: string;
  27174. };
  27175. }
  27176. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  27177. /** @hidden */
  27178. export var logDepthVertex: {
  27179. name: string;
  27180. shader: string;
  27181. };
  27182. }
  27183. declare module "babylonjs/Shaders/default.vertex" {
  27184. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  27185. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27186. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27187. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  27188. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  27189. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  27190. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  27191. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  27192. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27193. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27194. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  27195. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  27196. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27197. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  27198. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  27199. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  27200. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  27201. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  27202. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  27203. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  27204. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  27205. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  27206. /** @hidden */
  27207. export var defaultVertexShader: {
  27208. name: string;
  27209. shader: string;
  27210. };
  27211. }
  27212. declare module "babylonjs/Materials/standardMaterial" {
  27213. import { SmartArray } from "babylonjs/Misc/smartArray";
  27214. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27215. import { Nullable } from "babylonjs/types";
  27216. import { Scene } from "babylonjs/scene";
  27217. import { Matrix } from "babylonjs/Maths/math.vector";
  27218. import { Color3 } from "babylonjs/Maths/math.color";
  27219. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27220. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27221. import { Mesh } from "babylonjs/Meshes/mesh";
  27222. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  27223. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  27224. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  27225. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  27226. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  27227. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27228. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27229. import "babylonjs/Shaders/default.fragment";
  27230. import "babylonjs/Shaders/default.vertex";
  27231. /** @hidden */
  27232. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  27233. MAINUV1: boolean;
  27234. MAINUV2: boolean;
  27235. DIFFUSE: boolean;
  27236. DIFFUSEDIRECTUV: number;
  27237. AMBIENT: boolean;
  27238. AMBIENTDIRECTUV: number;
  27239. OPACITY: boolean;
  27240. OPACITYDIRECTUV: number;
  27241. OPACITYRGB: boolean;
  27242. REFLECTION: boolean;
  27243. EMISSIVE: boolean;
  27244. EMISSIVEDIRECTUV: number;
  27245. SPECULAR: boolean;
  27246. SPECULARDIRECTUV: number;
  27247. BUMP: boolean;
  27248. BUMPDIRECTUV: number;
  27249. PARALLAX: boolean;
  27250. PARALLAXOCCLUSION: boolean;
  27251. SPECULAROVERALPHA: boolean;
  27252. CLIPPLANE: boolean;
  27253. CLIPPLANE2: boolean;
  27254. CLIPPLANE3: boolean;
  27255. CLIPPLANE4: boolean;
  27256. CLIPPLANE5: boolean;
  27257. CLIPPLANE6: boolean;
  27258. ALPHATEST: boolean;
  27259. DEPTHPREPASS: boolean;
  27260. ALPHAFROMDIFFUSE: boolean;
  27261. POINTSIZE: boolean;
  27262. FOG: boolean;
  27263. SPECULARTERM: boolean;
  27264. DIFFUSEFRESNEL: boolean;
  27265. OPACITYFRESNEL: boolean;
  27266. REFLECTIONFRESNEL: boolean;
  27267. REFRACTIONFRESNEL: boolean;
  27268. EMISSIVEFRESNEL: boolean;
  27269. FRESNEL: boolean;
  27270. NORMAL: boolean;
  27271. UV1: boolean;
  27272. UV2: boolean;
  27273. VERTEXCOLOR: boolean;
  27274. VERTEXALPHA: boolean;
  27275. NUM_BONE_INFLUENCERS: number;
  27276. BonesPerMesh: number;
  27277. BONETEXTURE: boolean;
  27278. INSTANCES: boolean;
  27279. GLOSSINESS: boolean;
  27280. ROUGHNESS: boolean;
  27281. EMISSIVEASILLUMINATION: boolean;
  27282. LINKEMISSIVEWITHDIFFUSE: boolean;
  27283. REFLECTIONFRESNELFROMSPECULAR: boolean;
  27284. LIGHTMAP: boolean;
  27285. LIGHTMAPDIRECTUV: number;
  27286. OBJECTSPACE_NORMALMAP: boolean;
  27287. USELIGHTMAPASSHADOWMAP: boolean;
  27288. REFLECTIONMAP_3D: boolean;
  27289. REFLECTIONMAP_SPHERICAL: boolean;
  27290. REFLECTIONMAP_PLANAR: boolean;
  27291. REFLECTIONMAP_CUBIC: boolean;
  27292. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27293. REFLECTIONMAP_PROJECTION: boolean;
  27294. REFLECTIONMAP_SKYBOX: boolean;
  27295. REFLECTIONMAP_EXPLICIT: boolean;
  27296. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27297. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27298. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27299. INVERTCUBICMAP: boolean;
  27300. LOGARITHMICDEPTH: boolean;
  27301. REFRACTION: boolean;
  27302. REFRACTIONMAP_3D: boolean;
  27303. REFLECTIONOVERALPHA: boolean;
  27304. TWOSIDEDLIGHTING: boolean;
  27305. SHADOWFLOAT: boolean;
  27306. MORPHTARGETS: boolean;
  27307. MORPHTARGETS_NORMAL: boolean;
  27308. MORPHTARGETS_TANGENT: boolean;
  27309. MORPHTARGETS_UV: boolean;
  27310. NUM_MORPH_INFLUENCERS: number;
  27311. NONUNIFORMSCALING: boolean;
  27312. PREMULTIPLYALPHA: boolean;
  27313. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  27314. ALPHABLEND: boolean;
  27315. IMAGEPROCESSING: boolean;
  27316. VIGNETTE: boolean;
  27317. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27318. VIGNETTEBLENDMODEOPAQUE: boolean;
  27319. TONEMAPPING: boolean;
  27320. TONEMAPPING_ACES: boolean;
  27321. CONTRAST: boolean;
  27322. COLORCURVES: boolean;
  27323. COLORGRADING: boolean;
  27324. COLORGRADING3D: boolean;
  27325. SAMPLER3DGREENDEPTH: boolean;
  27326. SAMPLER3DBGRMAP: boolean;
  27327. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27328. MULTIVIEW: boolean;
  27329. /**
  27330. * If the reflection texture on this material is in linear color space
  27331. * @hidden
  27332. */
  27333. IS_REFLECTION_LINEAR: boolean;
  27334. /**
  27335. * If the refraction texture on this material is in linear color space
  27336. * @hidden
  27337. */
  27338. IS_REFRACTION_LINEAR: boolean;
  27339. EXPOSURE: boolean;
  27340. constructor();
  27341. setReflectionMode(modeToEnable: string): void;
  27342. }
  27343. /**
  27344. * This is the default material used in Babylon. It is the best trade off between quality
  27345. * and performances.
  27346. * @see http://doc.babylonjs.com/babylon101/materials
  27347. */
  27348. export class StandardMaterial extends PushMaterial {
  27349. private _diffuseTexture;
  27350. /**
  27351. * The basic texture of the material as viewed under a light.
  27352. */
  27353. diffuseTexture: Nullable<BaseTexture>;
  27354. private _ambientTexture;
  27355. /**
  27356. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27357. */
  27358. ambientTexture: Nullable<BaseTexture>;
  27359. private _opacityTexture;
  27360. /**
  27361. * Define the transparency of the material from a texture.
  27362. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27363. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27364. */
  27365. opacityTexture: Nullable<BaseTexture>;
  27366. private _reflectionTexture;
  27367. /**
  27368. * Define the texture used to display the reflection.
  27369. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27370. */
  27371. reflectionTexture: Nullable<BaseTexture>;
  27372. private _emissiveTexture;
  27373. /**
  27374. * Define texture of the material as if self lit.
  27375. * This will be mixed in the final result even in the absence of light.
  27376. */
  27377. emissiveTexture: Nullable<BaseTexture>;
  27378. private _specularTexture;
  27379. /**
  27380. * Define how the color and intensity of the highlight given by the light in the material.
  27381. */
  27382. specularTexture: Nullable<BaseTexture>;
  27383. private _bumpTexture;
  27384. /**
  27385. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27386. * 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.
  27387. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27388. */
  27389. bumpTexture: Nullable<BaseTexture>;
  27390. private _lightmapTexture;
  27391. /**
  27392. * Complex lighting can be computationally expensive to compute at runtime.
  27393. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27394. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27395. */
  27396. lightmapTexture: Nullable<BaseTexture>;
  27397. private _refractionTexture;
  27398. /**
  27399. * Define the texture used to display the refraction.
  27400. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27401. */
  27402. refractionTexture: Nullable<BaseTexture>;
  27403. /**
  27404. * The color of the material lit by the environmental background lighting.
  27405. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27406. */
  27407. ambientColor: Color3;
  27408. /**
  27409. * The basic color of the material as viewed under a light.
  27410. */
  27411. diffuseColor: Color3;
  27412. /**
  27413. * Define how the color and intensity of the highlight given by the light in the material.
  27414. */
  27415. specularColor: Color3;
  27416. /**
  27417. * Define the color of the material as if self lit.
  27418. * This will be mixed in the final result even in the absence of light.
  27419. */
  27420. emissiveColor: Color3;
  27421. /**
  27422. * Defines how sharp are the highlights in the material.
  27423. * The bigger the value the sharper giving a more glossy feeling to the result.
  27424. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27425. */
  27426. specularPower: number;
  27427. private _useAlphaFromDiffuseTexture;
  27428. /**
  27429. * Does the transparency come from the diffuse texture alpha channel.
  27430. */
  27431. useAlphaFromDiffuseTexture: boolean;
  27432. private _useEmissiveAsIllumination;
  27433. /**
  27434. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27435. */
  27436. useEmissiveAsIllumination: boolean;
  27437. private _linkEmissiveWithDiffuse;
  27438. /**
  27439. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27440. * the emissive level when the final color is close to one.
  27441. */
  27442. linkEmissiveWithDiffuse: boolean;
  27443. private _useSpecularOverAlpha;
  27444. /**
  27445. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27446. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27447. */
  27448. useSpecularOverAlpha: boolean;
  27449. private _useReflectionOverAlpha;
  27450. /**
  27451. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27452. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27453. */
  27454. useReflectionOverAlpha: boolean;
  27455. private _disableLighting;
  27456. /**
  27457. * Does lights from the scene impacts this material.
  27458. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27459. */
  27460. disableLighting: boolean;
  27461. private _useObjectSpaceNormalMap;
  27462. /**
  27463. * Allows using an object space normal map (instead of tangent space).
  27464. */
  27465. useObjectSpaceNormalMap: boolean;
  27466. private _useParallax;
  27467. /**
  27468. * Is parallax enabled or not.
  27469. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27470. */
  27471. useParallax: boolean;
  27472. private _useParallaxOcclusion;
  27473. /**
  27474. * Is parallax occlusion enabled or not.
  27475. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27476. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27477. */
  27478. useParallaxOcclusion: boolean;
  27479. /**
  27480. * 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.
  27481. */
  27482. parallaxScaleBias: number;
  27483. private _roughness;
  27484. /**
  27485. * Helps to define how blurry the reflections should appears in the material.
  27486. */
  27487. roughness: number;
  27488. /**
  27489. * In case of refraction, define the value of the index of refraction.
  27490. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27491. */
  27492. indexOfRefraction: number;
  27493. /**
  27494. * Invert the refraction texture alongside the y axis.
  27495. * It can be useful with procedural textures or probe for instance.
  27496. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27497. */
  27498. invertRefractionY: boolean;
  27499. /**
  27500. * Defines the alpha limits in alpha test mode.
  27501. */
  27502. alphaCutOff: number;
  27503. private _useLightmapAsShadowmap;
  27504. /**
  27505. * In case of light mapping, define whether the map contains light or shadow informations.
  27506. */
  27507. useLightmapAsShadowmap: boolean;
  27508. private _diffuseFresnelParameters;
  27509. /**
  27510. * Define the diffuse fresnel parameters of the material.
  27511. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27512. */
  27513. diffuseFresnelParameters: FresnelParameters;
  27514. private _opacityFresnelParameters;
  27515. /**
  27516. * Define the opacity fresnel parameters of the material.
  27517. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27518. */
  27519. opacityFresnelParameters: FresnelParameters;
  27520. private _reflectionFresnelParameters;
  27521. /**
  27522. * Define the reflection fresnel parameters of the material.
  27523. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27524. */
  27525. reflectionFresnelParameters: FresnelParameters;
  27526. private _refractionFresnelParameters;
  27527. /**
  27528. * Define the refraction fresnel parameters of the material.
  27529. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27530. */
  27531. refractionFresnelParameters: FresnelParameters;
  27532. private _emissiveFresnelParameters;
  27533. /**
  27534. * Define the emissive fresnel parameters of the material.
  27535. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27536. */
  27537. emissiveFresnelParameters: FresnelParameters;
  27538. private _useReflectionFresnelFromSpecular;
  27539. /**
  27540. * If true automatically deducts the fresnels values from the material specularity.
  27541. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27542. */
  27543. useReflectionFresnelFromSpecular: boolean;
  27544. private _useGlossinessFromSpecularMapAlpha;
  27545. /**
  27546. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27547. */
  27548. useGlossinessFromSpecularMapAlpha: boolean;
  27549. private _maxSimultaneousLights;
  27550. /**
  27551. * Defines the maximum number of lights that can be used in the material
  27552. */
  27553. maxSimultaneousLights: number;
  27554. private _invertNormalMapX;
  27555. /**
  27556. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27557. */
  27558. invertNormalMapX: boolean;
  27559. private _invertNormalMapY;
  27560. /**
  27561. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27562. */
  27563. invertNormalMapY: boolean;
  27564. private _twoSidedLighting;
  27565. /**
  27566. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27567. */
  27568. twoSidedLighting: boolean;
  27569. /**
  27570. * Default configuration related to image processing available in the standard Material.
  27571. */
  27572. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27573. /**
  27574. * Gets the image processing configuration used either in this material.
  27575. */
  27576. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27577. /**
  27578. * Sets the Default image processing configuration used either in the this material.
  27579. *
  27580. * If sets to null, the scene one is in use.
  27581. */
  27582. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27583. /**
  27584. * Keep track of the image processing observer to allow dispose and replace.
  27585. */
  27586. private _imageProcessingObserver;
  27587. /**
  27588. * Attaches a new image processing configuration to the Standard Material.
  27589. * @param configuration
  27590. */
  27591. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27592. /**
  27593. * Gets wether the color curves effect is enabled.
  27594. */
  27595. get cameraColorCurvesEnabled(): boolean;
  27596. /**
  27597. * Sets wether the color curves effect is enabled.
  27598. */
  27599. set cameraColorCurvesEnabled(value: boolean);
  27600. /**
  27601. * Gets wether the color grading effect is enabled.
  27602. */
  27603. get cameraColorGradingEnabled(): boolean;
  27604. /**
  27605. * Gets wether the color grading effect is enabled.
  27606. */
  27607. set cameraColorGradingEnabled(value: boolean);
  27608. /**
  27609. * Gets wether tonemapping is enabled or not.
  27610. */
  27611. get cameraToneMappingEnabled(): boolean;
  27612. /**
  27613. * Sets wether tonemapping is enabled or not
  27614. */
  27615. set cameraToneMappingEnabled(value: boolean);
  27616. /**
  27617. * The camera exposure used on this material.
  27618. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27619. * This corresponds to a photographic exposure.
  27620. */
  27621. get cameraExposure(): number;
  27622. /**
  27623. * The camera exposure used on this material.
  27624. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27625. * This corresponds to a photographic exposure.
  27626. */
  27627. set cameraExposure(value: number);
  27628. /**
  27629. * Gets The camera contrast used on this material.
  27630. */
  27631. get cameraContrast(): number;
  27632. /**
  27633. * Sets The camera contrast used on this material.
  27634. */
  27635. set cameraContrast(value: number);
  27636. /**
  27637. * Gets the Color Grading 2D Lookup Texture.
  27638. */
  27639. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27640. /**
  27641. * Sets the Color Grading 2D Lookup Texture.
  27642. */
  27643. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27644. /**
  27645. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27646. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27647. * 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;
  27648. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27649. */
  27650. get cameraColorCurves(): Nullable<ColorCurves>;
  27651. /**
  27652. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27653. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27654. * 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;
  27655. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27656. */
  27657. set cameraColorCurves(value: Nullable<ColorCurves>);
  27658. /**
  27659. * Custom callback helping to override the default shader used in the material.
  27660. */
  27661. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  27662. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27663. protected _worldViewProjectionMatrix: Matrix;
  27664. protected _globalAmbientColor: Color3;
  27665. protected _useLogarithmicDepth: boolean;
  27666. protected _rebuildInParallel: boolean;
  27667. /**
  27668. * Instantiates a new standard material.
  27669. * This is the default material used in Babylon. It is the best trade off between quality
  27670. * and performances.
  27671. * @see http://doc.babylonjs.com/babylon101/materials
  27672. * @param name Define the name of the material in the scene
  27673. * @param scene Define the scene the material belong to
  27674. */
  27675. constructor(name: string, scene: Scene);
  27676. /**
  27677. * Gets a boolean indicating that current material needs to register RTT
  27678. */
  27679. get hasRenderTargetTextures(): boolean;
  27680. /**
  27681. * Gets the current class name of the material e.g. "StandardMaterial"
  27682. * Mainly use in serialization.
  27683. * @returns the class name
  27684. */
  27685. getClassName(): string;
  27686. /**
  27687. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27688. * You can try switching to logarithmic depth.
  27689. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27690. */
  27691. get useLogarithmicDepth(): boolean;
  27692. set useLogarithmicDepth(value: boolean);
  27693. /**
  27694. * Specifies if the material will require alpha blending
  27695. * @returns a boolean specifying if alpha blending is needed
  27696. */
  27697. needAlphaBlending(): boolean;
  27698. /**
  27699. * Specifies if this material should be rendered in alpha test mode
  27700. * @returns a boolean specifying if an alpha test is needed.
  27701. */
  27702. needAlphaTesting(): boolean;
  27703. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27704. /**
  27705. * Get the texture used for alpha test purpose.
  27706. * @returns the diffuse texture in case of the standard material.
  27707. */
  27708. getAlphaTestTexture(): Nullable<BaseTexture>;
  27709. /**
  27710. * Get if the submesh is ready to be used and all its information available.
  27711. * Child classes can use it to update shaders
  27712. * @param mesh defines the mesh to check
  27713. * @param subMesh defines which submesh to check
  27714. * @param useInstances specifies that instances should be used
  27715. * @returns a boolean indicating that the submesh is ready or not
  27716. */
  27717. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27718. /**
  27719. * Builds the material UBO layouts.
  27720. * Used internally during the effect preparation.
  27721. */
  27722. buildUniformLayout(): void;
  27723. /**
  27724. * Unbinds the material from the mesh
  27725. */
  27726. unbind(): void;
  27727. /**
  27728. * Binds the submesh to this material by preparing the effect and shader to draw
  27729. * @param world defines the world transformation matrix
  27730. * @param mesh defines the mesh containing the submesh
  27731. * @param subMesh defines the submesh to bind the material to
  27732. */
  27733. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27734. /**
  27735. * Get the list of animatables in the material.
  27736. * @returns the list of animatables object used in the material
  27737. */
  27738. getAnimatables(): IAnimatable[];
  27739. /**
  27740. * Gets the active textures from the material
  27741. * @returns an array of textures
  27742. */
  27743. getActiveTextures(): BaseTexture[];
  27744. /**
  27745. * Specifies if the material uses a texture
  27746. * @param texture defines the texture to check against the material
  27747. * @returns a boolean specifying if the material uses the texture
  27748. */
  27749. hasTexture(texture: BaseTexture): boolean;
  27750. /**
  27751. * Disposes the material
  27752. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27753. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27754. */
  27755. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27756. /**
  27757. * Makes a duplicate of the material, and gives it a new name
  27758. * @param name defines the new name for the duplicated material
  27759. * @returns the cloned material
  27760. */
  27761. clone(name: string): StandardMaterial;
  27762. /**
  27763. * Serializes this material in a JSON representation
  27764. * @returns the serialized material object
  27765. */
  27766. serialize(): any;
  27767. /**
  27768. * Creates a standard material from parsed material data
  27769. * @param source defines the JSON representation of the material
  27770. * @param scene defines the hosting scene
  27771. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27772. * @returns a new standard material
  27773. */
  27774. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27775. /**
  27776. * Are diffuse textures enabled in the application.
  27777. */
  27778. static get DiffuseTextureEnabled(): boolean;
  27779. static set DiffuseTextureEnabled(value: boolean);
  27780. /**
  27781. * Are ambient textures enabled in the application.
  27782. */
  27783. static get AmbientTextureEnabled(): boolean;
  27784. static set AmbientTextureEnabled(value: boolean);
  27785. /**
  27786. * Are opacity textures enabled in the application.
  27787. */
  27788. static get OpacityTextureEnabled(): boolean;
  27789. static set OpacityTextureEnabled(value: boolean);
  27790. /**
  27791. * Are reflection textures enabled in the application.
  27792. */
  27793. static get ReflectionTextureEnabled(): boolean;
  27794. static set ReflectionTextureEnabled(value: boolean);
  27795. /**
  27796. * Are emissive textures enabled in the application.
  27797. */
  27798. static get EmissiveTextureEnabled(): boolean;
  27799. static set EmissiveTextureEnabled(value: boolean);
  27800. /**
  27801. * Are specular textures enabled in the application.
  27802. */
  27803. static get SpecularTextureEnabled(): boolean;
  27804. static set SpecularTextureEnabled(value: boolean);
  27805. /**
  27806. * Are bump textures enabled in the application.
  27807. */
  27808. static get BumpTextureEnabled(): boolean;
  27809. static set BumpTextureEnabled(value: boolean);
  27810. /**
  27811. * Are lightmap textures enabled in the application.
  27812. */
  27813. static get LightmapTextureEnabled(): boolean;
  27814. static set LightmapTextureEnabled(value: boolean);
  27815. /**
  27816. * Are refraction textures enabled in the application.
  27817. */
  27818. static get RefractionTextureEnabled(): boolean;
  27819. static set RefractionTextureEnabled(value: boolean);
  27820. /**
  27821. * Are color grading textures enabled in the application.
  27822. */
  27823. static get ColorGradingTextureEnabled(): boolean;
  27824. static set ColorGradingTextureEnabled(value: boolean);
  27825. /**
  27826. * Are fresnels enabled in the application.
  27827. */
  27828. static get FresnelEnabled(): boolean;
  27829. static set FresnelEnabled(value: boolean);
  27830. }
  27831. }
  27832. declare module "babylonjs/Particles/solidParticleSystem" {
  27833. import { Nullable } from "babylonjs/types";
  27834. import { Vector3 } from "babylonjs/Maths/math.vector";
  27835. import { Mesh } from "babylonjs/Meshes/mesh";
  27836. import { Scene, IDisposable } from "babylonjs/scene";
  27837. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  27838. import { Material } from "babylonjs/Materials/material";
  27839. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  27840. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  27841. /**
  27842. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27843. *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.
  27844. * The SPS is also a particle system. It provides some methods to manage the particles.
  27845. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27846. *
  27847. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27848. */
  27849. export class SolidParticleSystem implements IDisposable {
  27850. /**
  27851. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27852. * Example : var p = SPS.particles[i];
  27853. */
  27854. particles: SolidParticle[];
  27855. /**
  27856. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27857. */
  27858. nbParticles: number;
  27859. /**
  27860. * If the particles must ever face the camera (default false). Useful for planar particles.
  27861. */
  27862. billboard: boolean;
  27863. /**
  27864. * Recompute normals when adding a shape
  27865. */
  27866. recomputeNormals: boolean;
  27867. /**
  27868. * This a counter ofr your own usage. It's not set by any SPS functions.
  27869. */
  27870. counter: number;
  27871. /**
  27872. * The SPS name. This name is also given to the underlying mesh.
  27873. */
  27874. name: string;
  27875. /**
  27876. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27877. */
  27878. mesh: Mesh;
  27879. /**
  27880. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27881. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27882. */
  27883. vars: any;
  27884. /**
  27885. * This array is populated when the SPS is set as 'pickable'.
  27886. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27887. * Each element of this array is an object `{idx: int, faceId: int}`.
  27888. * `idx` is the picked particle index in the `SPS.particles` array
  27889. * `faceId` is the picked face index counted within this particle.
  27890. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  27891. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  27892. * Use the method SPS.pickedParticle(pickingInfo) instead.
  27893. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27894. */
  27895. pickedParticles: {
  27896. idx: number;
  27897. faceId: number;
  27898. }[];
  27899. /**
  27900. * This array is populated when the SPS is set as 'pickable'
  27901. * Each key of this array is a submesh index.
  27902. * Each element of this array is a second array defined like this :
  27903. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  27904. * Each element of this second array is an object `{idx: int, faceId: int}`.
  27905. * `idx` is the picked particle index in the `SPS.particles` array
  27906. * `faceId` is the picked face index counted within this particle.
  27907. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  27908. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27909. */
  27910. pickedBySubMesh: {
  27911. idx: number;
  27912. faceId: number;
  27913. }[][];
  27914. /**
  27915. * This array is populated when `enableDepthSort` is set to true.
  27916. * Each element of this array is an instance of the class DepthSortedParticle.
  27917. */
  27918. depthSortedParticles: DepthSortedParticle[];
  27919. /**
  27920. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27921. * @hidden
  27922. */
  27923. _bSphereOnly: boolean;
  27924. /**
  27925. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27926. * @hidden
  27927. */
  27928. _bSphereRadiusFactor: number;
  27929. private _scene;
  27930. private _positions;
  27931. private _indices;
  27932. private _normals;
  27933. private _colors;
  27934. private _uvs;
  27935. private _indices32;
  27936. private _positions32;
  27937. private _normals32;
  27938. private _fixedNormal32;
  27939. private _colors32;
  27940. private _uvs32;
  27941. private _index;
  27942. private _updatable;
  27943. private _pickable;
  27944. private _isVisibilityBoxLocked;
  27945. private _alwaysVisible;
  27946. private _depthSort;
  27947. private _expandable;
  27948. private _shapeCounter;
  27949. private _copy;
  27950. private _color;
  27951. private _computeParticleColor;
  27952. private _computeParticleTexture;
  27953. private _computeParticleRotation;
  27954. private _computeParticleVertex;
  27955. private _computeBoundingBox;
  27956. private _depthSortParticles;
  27957. private _camera;
  27958. private _mustUnrotateFixedNormals;
  27959. private _particlesIntersect;
  27960. private _needs32Bits;
  27961. private _isNotBuilt;
  27962. private _lastParticleId;
  27963. private _idxOfId;
  27964. private _multimaterialEnabled;
  27965. private _useModelMaterial;
  27966. private _indicesByMaterial;
  27967. private _materialIndexes;
  27968. private _depthSortFunction;
  27969. private _materialSortFunction;
  27970. private _materials;
  27971. private _multimaterial;
  27972. private _materialIndexesById;
  27973. private _defaultMaterial;
  27974. private _autoUpdateSubMeshes;
  27975. /**
  27976. * Creates a SPS (Solid Particle System) object.
  27977. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27978. * @param scene (Scene) is the scene in which the SPS is added.
  27979. * @param options defines the options of the sps e.g.
  27980. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27981. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27982. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27983. * * 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.
  27984. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27985. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27986. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27987. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27988. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27989. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27990. */
  27991. constructor(name: string, scene: Scene, options?: {
  27992. updatable?: boolean;
  27993. isPickable?: boolean;
  27994. enableDepthSort?: boolean;
  27995. particleIntersection?: boolean;
  27996. boundingSphereOnly?: boolean;
  27997. bSphereRadiusFactor?: number;
  27998. expandable?: boolean;
  27999. useModelMaterial?: boolean;
  28000. enableMultiMaterial?: boolean;
  28001. });
  28002. /**
  28003. * Builds the SPS underlying mesh. Returns a standard Mesh.
  28004. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  28005. * @returns the created mesh
  28006. */
  28007. buildMesh(): Mesh;
  28008. /**
  28009. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  28010. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  28011. * Thus the particles generated from `digest()` have their property `position` set yet.
  28012. * @param mesh ( Mesh ) is the mesh to be digested
  28013. * @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
  28014. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  28015. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  28016. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  28017. * @returns the current SPS
  28018. */
  28019. digest(mesh: Mesh, options?: {
  28020. facetNb?: number;
  28021. number?: number;
  28022. delta?: number;
  28023. storage?: [];
  28024. }): SolidParticleSystem;
  28025. /**
  28026. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  28027. * @hidden
  28028. */
  28029. private _unrotateFixedNormals;
  28030. /**
  28031. * Resets the temporary working copy particle
  28032. * @hidden
  28033. */
  28034. private _resetCopy;
  28035. /**
  28036. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  28037. * @param p the current index in the positions array to be updated
  28038. * @param ind the current index in the indices array
  28039. * @param shape a Vector3 array, the shape geometry
  28040. * @param positions the positions array to be updated
  28041. * @param meshInd the shape indices array
  28042. * @param indices the indices array to be updated
  28043. * @param meshUV the shape uv array
  28044. * @param uvs the uv array to be updated
  28045. * @param meshCol the shape color array
  28046. * @param colors the color array to be updated
  28047. * @param meshNor the shape normals array
  28048. * @param normals the normals array to be updated
  28049. * @param idx the particle index
  28050. * @param idxInShape the particle index in its shape
  28051. * @param options the addShape() method passed options
  28052. * @model the particle model
  28053. * @hidden
  28054. */
  28055. private _meshBuilder;
  28056. /**
  28057. * Returns a shape Vector3 array from positions float array
  28058. * @param positions float array
  28059. * @returns a vector3 array
  28060. * @hidden
  28061. */
  28062. private _posToShape;
  28063. /**
  28064. * Returns a shapeUV array from a float uvs (array deep copy)
  28065. * @param uvs as a float array
  28066. * @returns a shapeUV array
  28067. * @hidden
  28068. */
  28069. private _uvsToShapeUV;
  28070. /**
  28071. * Adds a new particle object in the particles array
  28072. * @param idx particle index in particles array
  28073. * @param id particle id
  28074. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  28075. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  28076. * @param model particle ModelShape object
  28077. * @param shapeId model shape identifier
  28078. * @param idxInShape index of the particle in the current model
  28079. * @param bInfo model bounding info object
  28080. * @param storage target storage array, if any
  28081. * @hidden
  28082. */
  28083. private _addParticle;
  28084. /**
  28085. * Adds some particles to the SPS from the model shape. Returns the shape id.
  28086. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  28087. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  28088. * @param nb (positive integer) the number of particles to be created from this model
  28089. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  28090. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  28091. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  28092. * @returns the number of shapes in the system
  28093. */
  28094. addShape(mesh: Mesh, nb: number, options?: {
  28095. positionFunction?: any;
  28096. vertexFunction?: any;
  28097. storage?: [];
  28098. }): number;
  28099. /**
  28100. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  28101. * @hidden
  28102. */
  28103. private _rebuildParticle;
  28104. /**
  28105. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  28106. * @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.
  28107. * @returns the SPS.
  28108. */
  28109. rebuildMesh(reset?: boolean): SolidParticleSystem;
  28110. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  28111. * Returns an array with the removed particles.
  28112. * 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.
  28113. * The SPS can't be empty so at least one particle needs to remain in place.
  28114. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  28115. * @param start index of the first particle to remove
  28116. * @param end index of the last particle to remove (included)
  28117. * @returns an array populated with the removed particles
  28118. */
  28119. removeParticles(start: number, end: number): SolidParticle[];
  28120. /**
  28121. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  28122. * @param solidParticleArray an array populated with Solid Particles objects
  28123. * @returns the SPS
  28124. */
  28125. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  28126. /**
  28127. * Creates a new particle and modifies the SPS mesh geometry :
  28128. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  28129. * - calls _addParticle() to populate the particle array
  28130. * factorized code from addShape() and insertParticlesFromArray()
  28131. * @param idx particle index in the particles array
  28132. * @param i particle index in its shape
  28133. * @param modelShape particle ModelShape object
  28134. * @param shape shape vertex array
  28135. * @param meshInd shape indices array
  28136. * @param meshUV shape uv array
  28137. * @param meshCol shape color array
  28138. * @param meshNor shape normals array
  28139. * @param bbInfo shape bounding info
  28140. * @param storage target particle storage
  28141. * @options addShape() passed options
  28142. * @hidden
  28143. */
  28144. private _insertNewParticle;
  28145. /**
  28146. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  28147. * This method calls `updateParticle()` for each particle of the SPS.
  28148. * For an animated SPS, it is usually called within the render loop.
  28149. * 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.
  28150. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  28151. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  28152. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  28153. * @returns the SPS.
  28154. */
  28155. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  28156. /**
  28157. * Disposes the SPS.
  28158. */
  28159. dispose(): void;
  28160. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  28161. * idx is the particle index in the SPS
  28162. * faceId is the picked face index counted within this particle.
  28163. * Returns null if the pickInfo can't identify a picked particle.
  28164. * @param pickingInfo (PickingInfo object)
  28165. * @returns {idx: number, faceId: number} or null
  28166. */
  28167. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  28168. idx: number;
  28169. faceId: number;
  28170. }>;
  28171. /**
  28172. * Returns a SolidParticle object from its identifier : particle.id
  28173. * @param id (integer) the particle Id
  28174. * @returns the searched particle or null if not found in the SPS.
  28175. */
  28176. getParticleById(id: number): Nullable<SolidParticle>;
  28177. /**
  28178. * Returns a new array populated with the particles having the passed shapeId.
  28179. * @param shapeId (integer) the shape identifier
  28180. * @returns a new solid particle array
  28181. */
  28182. getParticlesByShapeId(shapeId: number): SolidParticle[];
  28183. /**
  28184. * Populates the passed array "ref" with the particles having the passed shapeId.
  28185. * @param shapeId the shape identifier
  28186. * @returns the SPS
  28187. * @param ref
  28188. */
  28189. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  28190. /**
  28191. * Computes the required SubMeshes according the materials assigned to the particles.
  28192. * @returns the solid particle system.
  28193. * Does nothing if called before the SPS mesh is built.
  28194. */
  28195. computeSubMeshes(): SolidParticleSystem;
  28196. /**
  28197. * Sorts the solid particles by material when MultiMaterial is enabled.
  28198. * Updates the indices32 array.
  28199. * Updates the indicesByMaterial array.
  28200. * Updates the mesh indices array.
  28201. * @returns the SPS
  28202. * @hidden
  28203. */
  28204. private _sortParticlesByMaterial;
  28205. /**
  28206. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  28207. * @hidden
  28208. */
  28209. private _setMaterialIndexesById;
  28210. /**
  28211. * Returns an array with unique values of Materials from the passed array
  28212. * @param array the material array to be checked and filtered
  28213. * @hidden
  28214. */
  28215. private _filterUniqueMaterialId;
  28216. /**
  28217. * Sets a new Standard Material as _defaultMaterial if not already set.
  28218. * @hidden
  28219. */
  28220. private _setDefaultMaterial;
  28221. /**
  28222. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  28223. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28224. * @returns the SPS.
  28225. */
  28226. refreshVisibleSize(): SolidParticleSystem;
  28227. /**
  28228. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  28229. * @param size the size (float) of the visibility box
  28230. * note : this doesn't lock the SPS mesh bounding box.
  28231. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28232. */
  28233. setVisibilityBox(size: number): void;
  28234. /**
  28235. * Gets whether the SPS as always visible or not
  28236. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28237. */
  28238. get isAlwaysVisible(): boolean;
  28239. /**
  28240. * Sets the SPS as always visible or not
  28241. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28242. */
  28243. set isAlwaysVisible(val: boolean);
  28244. /**
  28245. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28246. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28247. */
  28248. set isVisibilityBoxLocked(val: boolean);
  28249. /**
  28250. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28251. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28252. */
  28253. get isVisibilityBoxLocked(): boolean;
  28254. /**
  28255. * Tells to `setParticles()` to compute the particle rotations or not.
  28256. * Default value : true. The SPS is faster when it's set to false.
  28257. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28258. */
  28259. set computeParticleRotation(val: boolean);
  28260. /**
  28261. * Tells to `setParticles()` to compute the particle colors or not.
  28262. * Default value : true. The SPS is faster when it's set to false.
  28263. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28264. */
  28265. set computeParticleColor(val: boolean);
  28266. set computeParticleTexture(val: boolean);
  28267. /**
  28268. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  28269. * Default value : false. The SPS is faster when it's set to false.
  28270. * Note : the particle custom vertex positions aren't stored values.
  28271. */
  28272. set computeParticleVertex(val: boolean);
  28273. /**
  28274. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  28275. */
  28276. set computeBoundingBox(val: boolean);
  28277. /**
  28278. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  28279. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28280. * Default : `true`
  28281. */
  28282. set depthSortParticles(val: boolean);
  28283. /**
  28284. * Gets if `setParticles()` computes the particle rotations or not.
  28285. * Default value : true. The SPS is faster when it's set to false.
  28286. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28287. */
  28288. get computeParticleRotation(): boolean;
  28289. /**
  28290. * Gets if `setParticles()` computes the particle colors or not.
  28291. * Default value : true. The SPS is faster when it's set to false.
  28292. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28293. */
  28294. get computeParticleColor(): boolean;
  28295. /**
  28296. * Gets if `setParticles()` computes the particle textures or not.
  28297. * Default value : true. The SPS is faster when it's set to false.
  28298. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  28299. */
  28300. get computeParticleTexture(): boolean;
  28301. /**
  28302. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  28303. * Default value : false. The SPS is faster when it's set to false.
  28304. * Note : the particle custom vertex positions aren't stored values.
  28305. */
  28306. get computeParticleVertex(): boolean;
  28307. /**
  28308. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  28309. */
  28310. get computeBoundingBox(): boolean;
  28311. /**
  28312. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  28313. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28314. * Default : `true`
  28315. */
  28316. get depthSortParticles(): boolean;
  28317. /**
  28318. * Gets if the SPS is created as expandable at construction time.
  28319. * Default : `false`
  28320. */
  28321. get expandable(): boolean;
  28322. /**
  28323. * Gets if the SPS supports the Multi Materials
  28324. */
  28325. get multimaterialEnabled(): boolean;
  28326. /**
  28327. * Gets if the SPS uses the model materials for its own multimaterial.
  28328. */
  28329. get useModelMaterial(): boolean;
  28330. /**
  28331. * The SPS used material array.
  28332. */
  28333. get materials(): Material[];
  28334. /**
  28335. * Sets the SPS MultiMaterial from the passed materials.
  28336. * Note : the passed array is internally copied and not used then by reference.
  28337. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  28338. */
  28339. setMultiMaterial(materials: Material[]): void;
  28340. /**
  28341. * The SPS computed multimaterial object
  28342. */
  28343. get multimaterial(): MultiMaterial;
  28344. set multimaterial(mm: MultiMaterial);
  28345. /**
  28346. * If the subMeshes must be updated on the next call to setParticles()
  28347. */
  28348. get autoUpdateSubMeshes(): boolean;
  28349. set autoUpdateSubMeshes(val: boolean);
  28350. /**
  28351. * This function does nothing. It may be overwritten to set all the particle first values.
  28352. * The SPS doesn't call this function, you may have to call it by your own.
  28353. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28354. */
  28355. initParticles(): void;
  28356. /**
  28357. * This function does nothing. It may be overwritten to recycle a particle.
  28358. * The SPS doesn't call this function, you may have to call it by your own.
  28359. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28360. * @param particle The particle to recycle
  28361. * @returns the recycled particle
  28362. */
  28363. recycleParticle(particle: SolidParticle): SolidParticle;
  28364. /**
  28365. * Updates a particle : this function should be overwritten by the user.
  28366. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  28367. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28368. * @example : just set a particle position or velocity and recycle conditions
  28369. * @param particle The particle to update
  28370. * @returns the updated particle
  28371. */
  28372. updateParticle(particle: SolidParticle): SolidParticle;
  28373. /**
  28374. * Updates a vertex of a particle : it can be overwritten by the user.
  28375. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  28376. * @param particle the current particle
  28377. * @param vertex the current index of the current particle
  28378. * @param pt the index of the current vertex in the particle shape
  28379. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  28380. * @example : just set a vertex particle position
  28381. * @returns the updated vertex
  28382. */
  28383. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  28384. /**
  28385. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  28386. * This does nothing and may be overwritten by the user.
  28387. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28388. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28389. * @param update the boolean update value actually passed to setParticles()
  28390. */
  28391. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28392. /**
  28393. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28394. * This will be passed three parameters.
  28395. * This does nothing and may be overwritten by the user.
  28396. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28397. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28398. * @param update the boolean update value actually passed to setParticles()
  28399. */
  28400. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28401. }
  28402. }
  28403. declare module "babylonjs/Particles/solidParticle" {
  28404. import { Nullable } from "babylonjs/types";
  28405. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  28406. import { Color4 } from "babylonjs/Maths/math.color";
  28407. import { Mesh } from "babylonjs/Meshes/mesh";
  28408. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28409. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28410. import { Plane } from "babylonjs/Maths/math.plane";
  28411. import { Material } from "babylonjs/Materials/material";
  28412. /**
  28413. * Represents one particle of a solid particle system.
  28414. */
  28415. export class SolidParticle {
  28416. /**
  28417. * particle global index
  28418. */
  28419. idx: number;
  28420. /**
  28421. * particle identifier
  28422. */
  28423. id: number;
  28424. /**
  28425. * The color of the particle
  28426. */
  28427. color: Nullable<Color4>;
  28428. /**
  28429. * The world space position of the particle.
  28430. */
  28431. position: Vector3;
  28432. /**
  28433. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28434. */
  28435. rotation: Vector3;
  28436. /**
  28437. * The world space rotation quaternion of the particle.
  28438. */
  28439. rotationQuaternion: Nullable<Quaternion>;
  28440. /**
  28441. * The scaling of the particle.
  28442. */
  28443. scaling: Vector3;
  28444. /**
  28445. * The uvs of the particle.
  28446. */
  28447. uvs: Vector4;
  28448. /**
  28449. * The current speed of the particle.
  28450. */
  28451. velocity: Vector3;
  28452. /**
  28453. * The pivot point in the particle local space.
  28454. */
  28455. pivot: Vector3;
  28456. /**
  28457. * Must the particle be translated from its pivot point in its local space ?
  28458. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28459. * Default : false
  28460. */
  28461. translateFromPivot: boolean;
  28462. /**
  28463. * Is the particle active or not ?
  28464. */
  28465. alive: boolean;
  28466. /**
  28467. * Is the particle visible or not ?
  28468. */
  28469. isVisible: boolean;
  28470. /**
  28471. * Index of this particle in the global "positions" array (Internal use)
  28472. * @hidden
  28473. */
  28474. _pos: number;
  28475. /**
  28476. * @hidden Index of this particle in the global "indices" array (Internal use)
  28477. */
  28478. _ind: number;
  28479. /**
  28480. * @hidden ModelShape of this particle (Internal use)
  28481. */
  28482. _model: ModelShape;
  28483. /**
  28484. * ModelShape id of this particle
  28485. */
  28486. shapeId: number;
  28487. /**
  28488. * Index of the particle in its shape id
  28489. */
  28490. idxInShape: number;
  28491. /**
  28492. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28493. */
  28494. _modelBoundingInfo: BoundingInfo;
  28495. /**
  28496. * @hidden Particle BoundingInfo object (Internal use)
  28497. */
  28498. _boundingInfo: BoundingInfo;
  28499. /**
  28500. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28501. */
  28502. _sps: SolidParticleSystem;
  28503. /**
  28504. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28505. */
  28506. _stillInvisible: boolean;
  28507. /**
  28508. * @hidden Last computed particle rotation matrix
  28509. */
  28510. _rotationMatrix: number[];
  28511. /**
  28512. * Parent particle Id, if any.
  28513. * Default null.
  28514. */
  28515. parentId: Nullable<number>;
  28516. /**
  28517. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28518. */
  28519. materialIndex: Nullable<number>;
  28520. /**
  28521. * Custom object or properties.
  28522. */
  28523. props: Nullable<any>;
  28524. /**
  28525. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28526. * The possible values are :
  28527. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28528. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28529. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28530. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28531. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28532. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28533. * */
  28534. cullingStrategy: number;
  28535. /**
  28536. * @hidden Internal global position in the SPS.
  28537. */
  28538. _globalPosition: Vector3;
  28539. /**
  28540. * Creates a Solid Particle object.
  28541. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28542. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28543. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28544. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28545. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28546. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28547. * @param shapeId (integer) is the model shape identifier in the SPS.
  28548. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28549. * @param sps defines the sps it is associated to
  28550. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28551. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28552. */
  28553. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28554. /**
  28555. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28556. * @param target the particle target
  28557. * @returns the current particle
  28558. */
  28559. copyToRef(target: SolidParticle): SolidParticle;
  28560. /**
  28561. * Legacy support, changed scale to scaling
  28562. */
  28563. get scale(): Vector3;
  28564. /**
  28565. * Legacy support, changed scale to scaling
  28566. */
  28567. set scale(scale: Vector3);
  28568. /**
  28569. * Legacy support, changed quaternion to rotationQuaternion
  28570. */
  28571. get quaternion(): Nullable<Quaternion>;
  28572. /**
  28573. * Legacy support, changed quaternion to rotationQuaternion
  28574. */
  28575. set quaternion(q: Nullable<Quaternion>);
  28576. /**
  28577. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28578. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28579. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28580. * @returns true if it intersects
  28581. */
  28582. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28583. /**
  28584. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28585. * A particle is in the frustum if its bounding box intersects the frustum
  28586. * @param frustumPlanes defines the frustum to test
  28587. * @returns true if the particle is in the frustum planes
  28588. */
  28589. isInFrustum(frustumPlanes: Plane[]): boolean;
  28590. /**
  28591. * get the rotation matrix of the particle
  28592. * @hidden
  28593. */
  28594. getRotationMatrix(m: Matrix): void;
  28595. }
  28596. /**
  28597. * Represents the shape of the model used by one particle of a solid particle system.
  28598. * SPS internal tool, don't use it manually.
  28599. */
  28600. export class ModelShape {
  28601. /**
  28602. * The shape id
  28603. * @hidden
  28604. */
  28605. shapeID: number;
  28606. /**
  28607. * flat array of model positions (internal use)
  28608. * @hidden
  28609. */
  28610. _shape: Vector3[];
  28611. /**
  28612. * flat array of model UVs (internal use)
  28613. * @hidden
  28614. */
  28615. _shapeUV: number[];
  28616. /**
  28617. * color array of the model
  28618. * @hidden
  28619. */
  28620. _shapeColors: number[];
  28621. /**
  28622. * indices array of the model
  28623. * @hidden
  28624. */
  28625. _indices: number[];
  28626. /**
  28627. * normals array of the model
  28628. * @hidden
  28629. */
  28630. _normals: number[];
  28631. /**
  28632. * length of the shape in the model indices array (internal use)
  28633. * @hidden
  28634. */
  28635. _indicesLength: number;
  28636. /**
  28637. * Custom position function (internal use)
  28638. * @hidden
  28639. */
  28640. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28641. /**
  28642. * Custom vertex function (internal use)
  28643. * @hidden
  28644. */
  28645. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28646. /**
  28647. * Model material (internal use)
  28648. * @hidden
  28649. */
  28650. _material: Nullable<Material>;
  28651. /**
  28652. * 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.
  28653. * SPS internal tool, don't use it manually.
  28654. * @hidden
  28655. */
  28656. 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>);
  28657. }
  28658. /**
  28659. * Represents a Depth Sorted Particle in the solid particle system.
  28660. * @hidden
  28661. */
  28662. export class DepthSortedParticle {
  28663. /**
  28664. * Particle index
  28665. */
  28666. idx: number;
  28667. /**
  28668. * Index of the particle in the "indices" array
  28669. */
  28670. ind: number;
  28671. /**
  28672. * Length of the particle shape in the "indices" array
  28673. */
  28674. indicesLength: number;
  28675. /**
  28676. * Squared distance from the particle to the camera
  28677. */
  28678. sqDistance: number;
  28679. /**
  28680. * Material index when used with MultiMaterials
  28681. */
  28682. materialIndex: number;
  28683. /**
  28684. * Creates a new sorted particle
  28685. * @param materialIndex
  28686. */
  28687. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  28688. }
  28689. }
  28690. declare module "babylonjs/Collisions/meshCollisionData" {
  28691. import { Collider } from "babylonjs/Collisions/collider";
  28692. import { Vector3 } from "babylonjs/Maths/math.vector";
  28693. import { Nullable } from "babylonjs/types";
  28694. import { Observer } from "babylonjs/Misc/observable";
  28695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28696. /**
  28697. * @hidden
  28698. */
  28699. export class _MeshCollisionData {
  28700. _checkCollisions: boolean;
  28701. _collisionMask: number;
  28702. _collisionGroup: number;
  28703. _collider: Nullable<Collider>;
  28704. _oldPositionForCollisions: Vector3;
  28705. _diffPositionForCollisions: Vector3;
  28706. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28707. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28708. }
  28709. }
  28710. declare module "babylonjs/Meshes/abstractMesh" {
  28711. import { Observable } from "babylonjs/Misc/observable";
  28712. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28713. import { Camera } from "babylonjs/Cameras/camera";
  28714. import { Scene, IDisposable } from "babylonjs/scene";
  28715. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28716. import { Node } from "babylonjs/node";
  28717. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28718. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28719. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28720. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28721. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28722. import { Material } from "babylonjs/Materials/material";
  28723. import { Light } from "babylonjs/Lights/light";
  28724. import { Skeleton } from "babylonjs/Bones/skeleton";
  28725. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28726. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28727. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28728. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28729. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28730. import { Plane } from "babylonjs/Maths/math.plane";
  28731. import { Ray } from "babylonjs/Culling/ray";
  28732. import { Collider } from "babylonjs/Collisions/collider";
  28733. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28734. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28735. /** @hidden */
  28736. class _FacetDataStorage {
  28737. facetPositions: Vector3[];
  28738. facetNormals: Vector3[];
  28739. facetPartitioning: number[][];
  28740. facetNb: number;
  28741. partitioningSubdivisions: number;
  28742. partitioningBBoxRatio: number;
  28743. facetDataEnabled: boolean;
  28744. facetParameters: any;
  28745. bbSize: Vector3;
  28746. subDiv: {
  28747. max: number;
  28748. X: number;
  28749. Y: number;
  28750. Z: number;
  28751. };
  28752. facetDepthSort: boolean;
  28753. facetDepthSortEnabled: boolean;
  28754. depthSortedIndices: IndicesArray;
  28755. depthSortedFacets: {
  28756. ind: number;
  28757. sqDistance: number;
  28758. }[];
  28759. facetDepthSortFunction: (f1: {
  28760. ind: number;
  28761. sqDistance: number;
  28762. }, f2: {
  28763. ind: number;
  28764. sqDistance: number;
  28765. }) => number;
  28766. facetDepthSortFrom: Vector3;
  28767. facetDepthSortOrigin: Vector3;
  28768. invertedMatrix: Matrix;
  28769. }
  28770. /**
  28771. * @hidden
  28772. **/
  28773. class _InternalAbstractMeshDataInfo {
  28774. _hasVertexAlpha: boolean;
  28775. _useVertexColors: boolean;
  28776. _numBoneInfluencers: number;
  28777. _applyFog: boolean;
  28778. _receiveShadows: boolean;
  28779. _facetData: _FacetDataStorage;
  28780. _visibility: number;
  28781. _skeleton: Nullable<Skeleton>;
  28782. _layerMask: number;
  28783. _computeBonesUsingShaders: boolean;
  28784. _isActive: boolean;
  28785. _onlyForInstances: boolean;
  28786. _isActiveIntermediate: boolean;
  28787. _onlyForInstancesIntermediate: boolean;
  28788. _actAsRegularMesh: boolean;
  28789. }
  28790. /**
  28791. * Class used to store all common mesh properties
  28792. */
  28793. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28794. /** No occlusion */
  28795. static OCCLUSION_TYPE_NONE: number;
  28796. /** Occlusion set to optimisitic */
  28797. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28798. /** Occlusion set to strict */
  28799. static OCCLUSION_TYPE_STRICT: number;
  28800. /** Use an accurante occlusion algorithm */
  28801. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28802. /** Use a conservative occlusion algorithm */
  28803. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28804. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28805. * Test order :
  28806. * Is the bounding sphere outside the frustum ?
  28807. * If not, are the bounding box vertices outside the frustum ?
  28808. * It not, then the cullable object is in the frustum.
  28809. */
  28810. static readonly CULLINGSTRATEGY_STANDARD: number;
  28811. /** Culling strategy : Bounding Sphere Only.
  28812. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28813. * It's also less accurate than the standard because some not visible objects can still be selected.
  28814. * Test : is the bounding sphere outside the frustum ?
  28815. * If not, then the cullable object is in the frustum.
  28816. */
  28817. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28818. /** Culling strategy : Optimistic Inclusion.
  28819. * This in an inclusion test first, then the standard exclusion test.
  28820. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28821. * 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.
  28822. * Anyway, it's as accurate as the standard strategy.
  28823. * Test :
  28824. * Is the cullable object bounding sphere center in the frustum ?
  28825. * If not, apply the default culling strategy.
  28826. */
  28827. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28828. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28829. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28830. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28831. * 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.
  28832. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28833. * Test :
  28834. * Is the cullable object bounding sphere center in the frustum ?
  28835. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28836. */
  28837. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28838. /**
  28839. * No billboard
  28840. */
  28841. static get BILLBOARDMODE_NONE(): number;
  28842. /** Billboard on X axis */
  28843. static get BILLBOARDMODE_X(): number;
  28844. /** Billboard on Y axis */
  28845. static get BILLBOARDMODE_Y(): number;
  28846. /** Billboard on Z axis */
  28847. static get BILLBOARDMODE_Z(): number;
  28848. /** Billboard on all axes */
  28849. static get BILLBOARDMODE_ALL(): number;
  28850. /** Billboard on using position instead of orientation */
  28851. static get BILLBOARDMODE_USE_POSITION(): number;
  28852. /** @hidden */
  28853. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28854. /**
  28855. * The culling strategy to use to check whether the mesh must be rendered or not.
  28856. * This value can be changed at any time and will be used on the next render mesh selection.
  28857. * The possible values are :
  28858. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28859. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28860. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28861. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28862. * Please read each static variable documentation to get details about the culling process.
  28863. * */
  28864. cullingStrategy: number;
  28865. /**
  28866. * Gets the number of facets in the mesh
  28867. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28868. */
  28869. get facetNb(): number;
  28870. /**
  28871. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28872. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28873. */
  28874. get partitioningSubdivisions(): number;
  28875. set partitioningSubdivisions(nb: number);
  28876. /**
  28877. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28878. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28879. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28880. */
  28881. get partitioningBBoxRatio(): number;
  28882. set partitioningBBoxRatio(ratio: number);
  28883. /**
  28884. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28885. * Works only for updatable meshes.
  28886. * Doesn't work with multi-materials
  28887. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28888. */
  28889. get mustDepthSortFacets(): boolean;
  28890. set mustDepthSortFacets(sort: boolean);
  28891. /**
  28892. * The location (Vector3) where the facet depth sort must be computed from.
  28893. * By default, the active camera position.
  28894. * Used only when facet depth sort is enabled
  28895. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28896. */
  28897. get facetDepthSortFrom(): Vector3;
  28898. set facetDepthSortFrom(location: Vector3);
  28899. /**
  28900. * gets a boolean indicating if facetData is enabled
  28901. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28902. */
  28903. get isFacetDataEnabled(): boolean;
  28904. /** @hidden */
  28905. _updateNonUniformScalingState(value: boolean): boolean;
  28906. /**
  28907. * An event triggered when this mesh collides with another one
  28908. */
  28909. onCollideObservable: Observable<AbstractMesh>;
  28910. /** Set a function to call when this mesh collides with another one */
  28911. set onCollide(callback: () => void);
  28912. /**
  28913. * An event triggered when the collision's position changes
  28914. */
  28915. onCollisionPositionChangeObservable: Observable<Vector3>;
  28916. /** Set a function to call when the collision's position changes */
  28917. set onCollisionPositionChange(callback: () => void);
  28918. /**
  28919. * An event triggered when material is changed
  28920. */
  28921. onMaterialChangedObservable: Observable<AbstractMesh>;
  28922. /**
  28923. * Gets or sets the orientation for POV movement & rotation
  28924. */
  28925. definedFacingForward: boolean;
  28926. /** @hidden */
  28927. _occlusionQuery: Nullable<WebGLQuery>;
  28928. /** @hidden */
  28929. _renderingGroup: Nullable<RenderingGroup>;
  28930. /**
  28931. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28932. */
  28933. get visibility(): number;
  28934. /**
  28935. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28936. */
  28937. set visibility(value: number);
  28938. /** Gets or sets the alpha index used to sort transparent meshes
  28939. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28940. */
  28941. alphaIndex: number;
  28942. /**
  28943. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28944. */
  28945. isVisible: boolean;
  28946. /**
  28947. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28948. */
  28949. isPickable: boolean;
  28950. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28951. showSubMeshesBoundingBox: boolean;
  28952. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28953. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28954. */
  28955. isBlocker: boolean;
  28956. /**
  28957. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28958. */
  28959. enablePointerMoveEvents: boolean;
  28960. /**
  28961. * Specifies the rendering group id for this mesh (0 by default)
  28962. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28963. */
  28964. renderingGroupId: number;
  28965. private _material;
  28966. /** Gets or sets current material */
  28967. get material(): Nullable<Material>;
  28968. set material(value: Nullable<Material>);
  28969. /**
  28970. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28971. * @see http://doc.babylonjs.com/babylon101/shadows
  28972. */
  28973. get receiveShadows(): boolean;
  28974. set receiveShadows(value: boolean);
  28975. /** Defines color to use when rendering outline */
  28976. outlineColor: Color3;
  28977. /** Define width to use when rendering outline */
  28978. outlineWidth: number;
  28979. /** Defines color to use when rendering overlay */
  28980. overlayColor: Color3;
  28981. /** Defines alpha to use when rendering overlay */
  28982. overlayAlpha: number;
  28983. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28984. get hasVertexAlpha(): boolean;
  28985. set hasVertexAlpha(value: boolean);
  28986. /** 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) */
  28987. get useVertexColors(): boolean;
  28988. set useVertexColors(value: boolean);
  28989. /**
  28990. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28991. */
  28992. get computeBonesUsingShaders(): boolean;
  28993. set computeBonesUsingShaders(value: boolean);
  28994. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28995. get numBoneInfluencers(): number;
  28996. set numBoneInfluencers(value: number);
  28997. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28998. get applyFog(): boolean;
  28999. set applyFog(value: boolean);
  29000. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  29001. useOctreeForRenderingSelection: boolean;
  29002. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  29003. useOctreeForPicking: boolean;
  29004. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  29005. useOctreeForCollisions: boolean;
  29006. /**
  29007. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  29008. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  29009. */
  29010. get layerMask(): number;
  29011. set layerMask(value: number);
  29012. /**
  29013. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  29014. */
  29015. alwaysSelectAsActiveMesh: boolean;
  29016. /**
  29017. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  29018. */
  29019. doNotSyncBoundingInfo: boolean;
  29020. /**
  29021. * Gets or sets the current action manager
  29022. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29023. */
  29024. actionManager: Nullable<AbstractActionManager>;
  29025. private _meshCollisionData;
  29026. /**
  29027. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  29028. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29029. */
  29030. ellipsoid: Vector3;
  29031. /**
  29032. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  29033. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29034. */
  29035. ellipsoidOffset: Vector3;
  29036. /**
  29037. * Gets or sets a collision mask used to mask collisions (default is -1).
  29038. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  29039. */
  29040. get collisionMask(): number;
  29041. set collisionMask(mask: number);
  29042. /**
  29043. * Gets or sets the current collision group mask (-1 by default).
  29044. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  29045. */
  29046. get collisionGroup(): number;
  29047. set collisionGroup(mask: number);
  29048. /**
  29049. * Defines edge width used when edgesRenderer is enabled
  29050. * @see https://www.babylonjs-playground.com/#10OJSG#13
  29051. */
  29052. edgesWidth: number;
  29053. /**
  29054. * Defines edge color used when edgesRenderer is enabled
  29055. * @see https://www.babylonjs-playground.com/#10OJSG#13
  29056. */
  29057. edgesColor: Color4;
  29058. /** @hidden */
  29059. _edgesRenderer: Nullable<IEdgesRenderer>;
  29060. /** @hidden */
  29061. _masterMesh: Nullable<AbstractMesh>;
  29062. /** @hidden */
  29063. _boundingInfo: Nullable<BoundingInfo>;
  29064. /** @hidden */
  29065. _renderId: number;
  29066. /**
  29067. * Gets or sets the list of subMeshes
  29068. * @see http://doc.babylonjs.com/how_to/multi_materials
  29069. */
  29070. subMeshes: SubMesh[];
  29071. /** @hidden */
  29072. _intersectionsInProgress: AbstractMesh[];
  29073. /** @hidden */
  29074. _unIndexed: boolean;
  29075. /** @hidden */
  29076. _lightSources: Light[];
  29077. /** Gets the list of lights affecting that mesh */
  29078. get lightSources(): Light[];
  29079. /** @hidden */
  29080. get _positions(): Nullable<Vector3[]>;
  29081. /** @hidden */
  29082. _waitingData: {
  29083. lods: Nullable<any>;
  29084. actions: Nullable<any>;
  29085. freezeWorldMatrix: Nullable<boolean>;
  29086. };
  29087. /** @hidden */
  29088. _bonesTransformMatrices: Nullable<Float32Array>;
  29089. /** @hidden */
  29090. _transformMatrixTexture: Nullable<RawTexture>;
  29091. /**
  29092. * Gets or sets a skeleton to apply skining transformations
  29093. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  29094. */
  29095. set skeleton(value: Nullable<Skeleton>);
  29096. get skeleton(): Nullable<Skeleton>;
  29097. /**
  29098. * An event triggered when the mesh is rebuilt.
  29099. */
  29100. onRebuildObservable: Observable<AbstractMesh>;
  29101. /**
  29102. * Creates a new AbstractMesh
  29103. * @param name defines the name of the mesh
  29104. * @param scene defines the hosting scene
  29105. */
  29106. constructor(name: string, scene?: Nullable<Scene>);
  29107. /**
  29108. * Returns the string "AbstractMesh"
  29109. * @returns "AbstractMesh"
  29110. */
  29111. getClassName(): string;
  29112. /**
  29113. * Gets a string representation of the current mesh
  29114. * @param fullDetails defines a boolean indicating if full details must be included
  29115. * @returns a string representation of the current mesh
  29116. */
  29117. toString(fullDetails?: boolean): string;
  29118. /**
  29119. * @hidden
  29120. */
  29121. protected _getEffectiveParent(): Nullable<Node>;
  29122. /** @hidden */
  29123. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29124. /** @hidden */
  29125. _rebuild(): void;
  29126. /** @hidden */
  29127. _resyncLightSources(): void;
  29128. /** @hidden */
  29129. _resyncLightSource(light: Light): void;
  29130. /** @hidden */
  29131. _unBindEffect(): void;
  29132. /** @hidden */
  29133. _removeLightSource(light: Light, dispose: boolean): void;
  29134. private _markSubMeshesAsDirty;
  29135. /** @hidden */
  29136. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  29137. /** @hidden */
  29138. _markSubMeshesAsAttributesDirty(): void;
  29139. /** @hidden */
  29140. _markSubMeshesAsMiscDirty(): void;
  29141. /**
  29142. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  29143. */
  29144. get scaling(): Vector3;
  29145. set scaling(newScaling: Vector3);
  29146. /**
  29147. * Returns true if the mesh is blocked. Implemented by child classes
  29148. */
  29149. get isBlocked(): boolean;
  29150. /**
  29151. * Returns the mesh itself by default. Implemented by child classes
  29152. * @param camera defines the camera to use to pick the right LOD level
  29153. * @returns the currentAbstractMesh
  29154. */
  29155. getLOD(camera: Camera): Nullable<AbstractMesh>;
  29156. /**
  29157. * Returns 0 by default. Implemented by child classes
  29158. * @returns an integer
  29159. */
  29160. getTotalVertices(): number;
  29161. /**
  29162. * Returns a positive integer : the total number of indices in this mesh geometry.
  29163. * @returns the numner of indices or zero if the mesh has no geometry.
  29164. */
  29165. getTotalIndices(): number;
  29166. /**
  29167. * Returns null by default. Implemented by child classes
  29168. * @returns null
  29169. */
  29170. getIndices(): Nullable<IndicesArray>;
  29171. /**
  29172. * Returns the array of the requested vertex data kind. Implemented by child classes
  29173. * @param kind defines the vertex data kind to use
  29174. * @returns null
  29175. */
  29176. getVerticesData(kind: string): Nullable<FloatArray>;
  29177. /**
  29178. * Sets the vertex data of the mesh geometry for the requested `kind`.
  29179. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  29180. * Note that a new underlying VertexBuffer object is created each call.
  29181. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  29182. * @param kind defines vertex data kind:
  29183. * * VertexBuffer.PositionKind
  29184. * * VertexBuffer.UVKind
  29185. * * VertexBuffer.UV2Kind
  29186. * * VertexBuffer.UV3Kind
  29187. * * VertexBuffer.UV4Kind
  29188. * * VertexBuffer.UV5Kind
  29189. * * VertexBuffer.UV6Kind
  29190. * * VertexBuffer.ColorKind
  29191. * * VertexBuffer.MatricesIndicesKind
  29192. * * VertexBuffer.MatricesIndicesExtraKind
  29193. * * VertexBuffer.MatricesWeightsKind
  29194. * * VertexBuffer.MatricesWeightsExtraKind
  29195. * @param data defines the data source
  29196. * @param updatable defines if the data must be flagged as updatable (or static)
  29197. * @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
  29198. * @returns the current mesh
  29199. */
  29200. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29201. /**
  29202. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  29203. * If the mesh has no geometry, it is simply returned as it is.
  29204. * @param kind defines vertex data kind:
  29205. * * VertexBuffer.PositionKind
  29206. * * VertexBuffer.UVKind
  29207. * * VertexBuffer.UV2Kind
  29208. * * VertexBuffer.UV3Kind
  29209. * * VertexBuffer.UV4Kind
  29210. * * VertexBuffer.UV5Kind
  29211. * * VertexBuffer.UV6Kind
  29212. * * VertexBuffer.ColorKind
  29213. * * VertexBuffer.MatricesIndicesKind
  29214. * * VertexBuffer.MatricesIndicesExtraKind
  29215. * * VertexBuffer.MatricesWeightsKind
  29216. * * VertexBuffer.MatricesWeightsExtraKind
  29217. * @param data defines the data source
  29218. * @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
  29219. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  29220. * @returns the current mesh
  29221. */
  29222. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29223. /**
  29224. * Sets the mesh indices,
  29225. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  29226. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  29227. * @param totalVertices Defines the total number of vertices
  29228. * @returns the current mesh
  29229. */
  29230. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  29231. /**
  29232. * Gets a boolean indicating if specific vertex data is present
  29233. * @param kind defines the vertex data kind to use
  29234. * @returns true is data kind is present
  29235. */
  29236. isVerticesDataPresent(kind: string): boolean;
  29237. /**
  29238. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  29239. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  29240. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  29241. * @returns a BoundingInfo
  29242. */
  29243. getBoundingInfo(): BoundingInfo;
  29244. /**
  29245. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  29246. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  29247. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  29248. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  29249. * @returns the current mesh
  29250. */
  29251. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  29252. /**
  29253. * Overwrite the current bounding info
  29254. * @param boundingInfo defines the new bounding info
  29255. * @returns the current mesh
  29256. */
  29257. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  29258. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  29259. get useBones(): boolean;
  29260. /** @hidden */
  29261. _preActivate(): void;
  29262. /** @hidden */
  29263. _preActivateForIntermediateRendering(renderId: number): void;
  29264. /** @hidden */
  29265. _activate(renderId: number, intermediateRendering: boolean): boolean;
  29266. /** @hidden */
  29267. _postActivate(): void;
  29268. /** @hidden */
  29269. _freeze(): void;
  29270. /** @hidden */
  29271. _unFreeze(): void;
  29272. /**
  29273. * Gets the current world matrix
  29274. * @returns a Matrix
  29275. */
  29276. getWorldMatrix(): Matrix;
  29277. /** @hidden */
  29278. _getWorldMatrixDeterminant(): number;
  29279. /**
  29280. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  29281. */
  29282. get isAnInstance(): boolean;
  29283. /**
  29284. * Gets a boolean indicating if this mesh has instances
  29285. */
  29286. get hasInstances(): boolean;
  29287. /**
  29288. * Perform relative position change from the point of view of behind the front of the mesh.
  29289. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29290. * Supports definition of mesh facing forward or backward
  29291. * @param amountRight defines the distance on the right axis
  29292. * @param amountUp defines the distance on the up axis
  29293. * @param amountForward defines the distance on the forward axis
  29294. * @returns the current mesh
  29295. */
  29296. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  29297. /**
  29298. * Calculate relative position change from the point of view of behind the front of the mesh.
  29299. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29300. * Supports definition of mesh facing forward or backward
  29301. * @param amountRight defines the distance on the right axis
  29302. * @param amountUp defines the distance on the up axis
  29303. * @param amountForward defines the distance on the forward axis
  29304. * @returns the new displacement vector
  29305. */
  29306. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  29307. /**
  29308. * Perform relative rotation change from the point of view of behind the front of the mesh.
  29309. * Supports definition of mesh facing forward or backward
  29310. * @param flipBack defines the flip
  29311. * @param twirlClockwise defines the twirl
  29312. * @param tiltRight defines the tilt
  29313. * @returns the current mesh
  29314. */
  29315. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  29316. /**
  29317. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  29318. * Supports definition of mesh facing forward or backward.
  29319. * @param flipBack defines the flip
  29320. * @param twirlClockwise defines the twirl
  29321. * @param tiltRight defines the tilt
  29322. * @returns the new rotation vector
  29323. */
  29324. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  29325. /**
  29326. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29327. * This means the mesh underlying bounding box and sphere are recomputed.
  29328. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29329. * @returns the current mesh
  29330. */
  29331. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  29332. /** @hidden */
  29333. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  29334. /** @hidden */
  29335. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  29336. /** @hidden */
  29337. _updateBoundingInfo(): AbstractMesh;
  29338. /** @hidden */
  29339. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  29340. /** @hidden */
  29341. protected _afterComputeWorldMatrix(): void;
  29342. /** @hidden */
  29343. get _effectiveMesh(): AbstractMesh;
  29344. /**
  29345. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29346. * A mesh is in the frustum if its bounding box intersects the frustum
  29347. * @param frustumPlanes defines the frustum to test
  29348. * @returns true if the mesh is in the frustum planes
  29349. */
  29350. isInFrustum(frustumPlanes: Plane[]): boolean;
  29351. /**
  29352. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  29353. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  29354. * @param frustumPlanes defines the frustum to test
  29355. * @returns true if the mesh is completely in the frustum planes
  29356. */
  29357. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29358. /**
  29359. * True if the mesh intersects another mesh or a SolidParticle object
  29360. * @param mesh defines a target mesh or SolidParticle to test
  29361. * @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)
  29362. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  29363. * @returns true if there is an intersection
  29364. */
  29365. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  29366. /**
  29367. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  29368. * @param point defines the point to test
  29369. * @returns true if there is an intersection
  29370. */
  29371. intersectsPoint(point: Vector3): boolean;
  29372. /**
  29373. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  29374. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29375. */
  29376. get checkCollisions(): boolean;
  29377. set checkCollisions(collisionEnabled: boolean);
  29378. /**
  29379. * Gets Collider object used to compute collisions (not physics)
  29380. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29381. */
  29382. get collider(): Nullable<Collider>;
  29383. /**
  29384. * Move the mesh using collision engine
  29385. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29386. * @param displacement defines the requested displacement vector
  29387. * @returns the current mesh
  29388. */
  29389. moveWithCollisions(displacement: Vector3): AbstractMesh;
  29390. private _onCollisionPositionChange;
  29391. /** @hidden */
  29392. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29393. /** @hidden */
  29394. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29395. /** @hidden */
  29396. _checkCollision(collider: Collider): AbstractMesh;
  29397. /** @hidden */
  29398. _generatePointsArray(): boolean;
  29399. /**
  29400. * Checks if the passed Ray intersects with the mesh
  29401. * @param ray defines the ray to use
  29402. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29403. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29404. * @returns the picking info
  29405. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29406. */
  29407. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  29408. /**
  29409. * Clones the current mesh
  29410. * @param name defines the mesh name
  29411. * @param newParent defines the new mesh parent
  29412. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29413. * @returns the new mesh
  29414. */
  29415. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29416. /**
  29417. * Disposes all the submeshes of the current meshnp
  29418. * @returns the current mesh
  29419. */
  29420. releaseSubMeshes(): AbstractMesh;
  29421. /**
  29422. * Releases resources associated with this abstract mesh.
  29423. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29424. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29425. */
  29426. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29427. /**
  29428. * Adds the passed mesh as a child to the current mesh
  29429. * @param mesh defines the child mesh
  29430. * @returns the current mesh
  29431. */
  29432. addChild(mesh: AbstractMesh): AbstractMesh;
  29433. /**
  29434. * Removes the passed mesh from the current mesh children list
  29435. * @param mesh defines the child mesh
  29436. * @returns the current mesh
  29437. */
  29438. removeChild(mesh: AbstractMesh): AbstractMesh;
  29439. /** @hidden */
  29440. private _initFacetData;
  29441. /**
  29442. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29443. * This method can be called within the render loop.
  29444. * 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
  29445. * @returns the current mesh
  29446. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29447. */
  29448. updateFacetData(): AbstractMesh;
  29449. /**
  29450. * Returns the facetLocalNormals array.
  29451. * The normals are expressed in the mesh local spac
  29452. * @returns an array of Vector3
  29453. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29454. */
  29455. getFacetLocalNormals(): Vector3[];
  29456. /**
  29457. * Returns the facetLocalPositions array.
  29458. * The facet positions are expressed in the mesh local space
  29459. * @returns an array of Vector3
  29460. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29461. */
  29462. getFacetLocalPositions(): Vector3[];
  29463. /**
  29464. * Returns the facetLocalPartioning array
  29465. * @returns an array of array of numbers
  29466. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29467. */
  29468. getFacetLocalPartitioning(): number[][];
  29469. /**
  29470. * Returns the i-th facet position in the world system.
  29471. * This method allocates a new Vector3 per call
  29472. * @param i defines the facet index
  29473. * @returns a new Vector3
  29474. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29475. */
  29476. getFacetPosition(i: number): Vector3;
  29477. /**
  29478. * Sets the reference Vector3 with the i-th facet position in the world system
  29479. * @param i defines the facet index
  29480. * @param ref defines the target vector
  29481. * @returns the current mesh
  29482. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29483. */
  29484. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29485. /**
  29486. * Returns the i-th facet normal in the world system.
  29487. * This method allocates a new Vector3 per call
  29488. * @param i defines the facet index
  29489. * @returns a new Vector3
  29490. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29491. */
  29492. getFacetNormal(i: number): Vector3;
  29493. /**
  29494. * Sets the reference Vector3 with the i-th facet normal in the world system
  29495. * @param i defines the facet index
  29496. * @param ref defines the target vector
  29497. * @returns the current mesh
  29498. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29499. */
  29500. getFacetNormalToRef(i: number, ref: Vector3): this;
  29501. /**
  29502. * 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)
  29503. * @param x defines x coordinate
  29504. * @param y defines y coordinate
  29505. * @param z defines z coordinate
  29506. * @returns the array of facet indexes
  29507. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29508. */
  29509. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29510. /**
  29511. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29512. * @param projected sets as the (x,y,z) world projection on the facet
  29513. * @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
  29514. * @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
  29515. * @param x defines x coordinate
  29516. * @param y defines y coordinate
  29517. * @param z defines z coordinate
  29518. * @returns the face index if found (or null instead)
  29519. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29520. */
  29521. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29522. /**
  29523. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29524. * @param projected sets as the (x,y,z) local projection on the facet
  29525. * @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
  29526. * @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
  29527. * @param x defines x coordinate
  29528. * @param y defines y coordinate
  29529. * @param z defines z coordinate
  29530. * @returns the face index if found (or null instead)
  29531. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29532. */
  29533. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29534. /**
  29535. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29536. * @returns the parameters
  29537. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29538. */
  29539. getFacetDataParameters(): any;
  29540. /**
  29541. * Disables the feature FacetData and frees the related memory
  29542. * @returns the current mesh
  29543. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29544. */
  29545. disableFacetData(): AbstractMesh;
  29546. /**
  29547. * Updates the AbstractMesh indices array
  29548. * @param indices defines the data source
  29549. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29550. * @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)
  29551. * @returns the current mesh
  29552. */
  29553. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29554. /**
  29555. * Creates new normals data for the mesh
  29556. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29557. * @returns the current mesh
  29558. */
  29559. createNormals(updatable: boolean): AbstractMesh;
  29560. /**
  29561. * Align the mesh with a normal
  29562. * @param normal defines the normal to use
  29563. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29564. * @returns the current mesh
  29565. */
  29566. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29567. /** @hidden */
  29568. _checkOcclusionQuery(): boolean;
  29569. /**
  29570. * Disables the mesh edge rendering mode
  29571. * @returns the currentAbstractMesh
  29572. */
  29573. disableEdgesRendering(): AbstractMesh;
  29574. /**
  29575. * Enables the edge rendering mode on the mesh.
  29576. * This mode makes the mesh edges visible
  29577. * @param epsilon defines the maximal distance between two angles to detect a face
  29578. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29579. * @returns the currentAbstractMesh
  29580. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29581. */
  29582. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29583. }
  29584. }
  29585. declare module "babylonjs/Actions/actionEvent" {
  29586. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29587. import { Nullable } from "babylonjs/types";
  29588. import { Sprite } from "babylonjs/Sprites/sprite";
  29589. import { Scene } from "babylonjs/scene";
  29590. import { Vector2 } from "babylonjs/Maths/math.vector";
  29591. /**
  29592. * Interface used to define ActionEvent
  29593. */
  29594. export interface IActionEvent {
  29595. /** The mesh or sprite that triggered the action */
  29596. source: any;
  29597. /** The X mouse cursor position at the time of the event */
  29598. pointerX: number;
  29599. /** The Y mouse cursor position at the time of the event */
  29600. pointerY: number;
  29601. /** The mesh that is currently pointed at (can be null) */
  29602. meshUnderPointer: Nullable<AbstractMesh>;
  29603. /** the original (browser) event that triggered the ActionEvent */
  29604. sourceEvent?: any;
  29605. /** additional data for the event */
  29606. additionalData?: any;
  29607. }
  29608. /**
  29609. * ActionEvent is the event being sent when an action is triggered.
  29610. */
  29611. export class ActionEvent implements IActionEvent {
  29612. /** The mesh or sprite that triggered the action */
  29613. source: any;
  29614. /** The X mouse cursor position at the time of the event */
  29615. pointerX: number;
  29616. /** The Y mouse cursor position at the time of the event */
  29617. pointerY: number;
  29618. /** The mesh that is currently pointed at (can be null) */
  29619. meshUnderPointer: Nullable<AbstractMesh>;
  29620. /** the original (browser) event that triggered the ActionEvent */
  29621. sourceEvent?: any;
  29622. /** additional data for the event */
  29623. additionalData?: any;
  29624. /**
  29625. * Creates a new ActionEvent
  29626. * @param source The mesh or sprite that triggered the action
  29627. * @param pointerX The X mouse cursor position at the time of the event
  29628. * @param pointerY The Y mouse cursor position at the time of the event
  29629. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29630. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29631. * @param additionalData additional data for the event
  29632. */
  29633. constructor(
  29634. /** The mesh or sprite that triggered the action */
  29635. source: any,
  29636. /** The X mouse cursor position at the time of the event */
  29637. pointerX: number,
  29638. /** The Y mouse cursor position at the time of the event */
  29639. pointerY: number,
  29640. /** The mesh that is currently pointed at (can be null) */
  29641. meshUnderPointer: Nullable<AbstractMesh>,
  29642. /** the original (browser) event that triggered the ActionEvent */
  29643. sourceEvent?: any,
  29644. /** additional data for the event */
  29645. additionalData?: any);
  29646. /**
  29647. * Helper function to auto-create an ActionEvent from a source mesh.
  29648. * @param source The source mesh that triggered the event
  29649. * @param evt The original (browser) event
  29650. * @param additionalData additional data for the event
  29651. * @returns the new ActionEvent
  29652. */
  29653. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29654. /**
  29655. * Helper function to auto-create an ActionEvent from a source sprite
  29656. * @param source The source sprite that triggered the event
  29657. * @param scene Scene associated with the sprite
  29658. * @param evt The original (browser) event
  29659. * @param additionalData additional data for the event
  29660. * @returns the new ActionEvent
  29661. */
  29662. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29663. /**
  29664. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29665. * @param scene the scene where the event occurred
  29666. * @param evt The original (browser) event
  29667. * @returns the new ActionEvent
  29668. */
  29669. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29670. /**
  29671. * Helper function to auto-create an ActionEvent from a primitive
  29672. * @param prim defines the target primitive
  29673. * @param pointerPos defines the pointer position
  29674. * @param evt The original (browser) event
  29675. * @param additionalData additional data for the event
  29676. * @returns the new ActionEvent
  29677. */
  29678. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29679. }
  29680. }
  29681. declare module "babylonjs/Actions/abstractActionManager" {
  29682. import { IDisposable } from "babylonjs/scene";
  29683. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29684. import { IAction } from "babylonjs/Actions/action";
  29685. import { Nullable } from "babylonjs/types";
  29686. /**
  29687. * Abstract class used to decouple action Manager from scene and meshes.
  29688. * Do not instantiate.
  29689. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29690. */
  29691. export abstract class AbstractActionManager implements IDisposable {
  29692. /** Gets the list of active triggers */
  29693. static Triggers: {
  29694. [key: string]: number;
  29695. };
  29696. /** Gets the cursor to use when hovering items */
  29697. hoverCursor: string;
  29698. /** Gets the list of actions */
  29699. actions: IAction[];
  29700. /**
  29701. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29702. */
  29703. isRecursive: boolean;
  29704. /**
  29705. * Releases all associated resources
  29706. */
  29707. abstract dispose(): void;
  29708. /**
  29709. * Does this action manager has pointer triggers
  29710. */
  29711. abstract get hasPointerTriggers(): boolean;
  29712. /**
  29713. * Does this action manager has pick triggers
  29714. */
  29715. abstract get hasPickTriggers(): boolean;
  29716. /**
  29717. * Process a specific trigger
  29718. * @param trigger defines the trigger to process
  29719. * @param evt defines the event details to be processed
  29720. */
  29721. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29722. /**
  29723. * Does this action manager handles actions of any of the given triggers
  29724. * @param triggers defines the triggers to be tested
  29725. * @return a boolean indicating whether one (or more) of the triggers is handled
  29726. */
  29727. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29728. /**
  29729. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29730. * speed.
  29731. * @param triggerA defines the trigger to be tested
  29732. * @param triggerB defines the trigger to be tested
  29733. * @return a boolean indicating whether one (or more) of the triggers is handled
  29734. */
  29735. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29736. /**
  29737. * Does this action manager handles actions of a given trigger
  29738. * @param trigger defines the trigger to be tested
  29739. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29740. * @return whether the trigger is handled
  29741. */
  29742. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29743. /**
  29744. * Serialize this manager to a JSON object
  29745. * @param name defines the property name to store this manager
  29746. * @returns a JSON representation of this manager
  29747. */
  29748. abstract serialize(name: string): any;
  29749. /**
  29750. * Registers an action to this action manager
  29751. * @param action defines the action to be registered
  29752. * @return the action amended (prepared) after registration
  29753. */
  29754. abstract registerAction(action: IAction): Nullable<IAction>;
  29755. /**
  29756. * Unregisters an action to this action manager
  29757. * @param action defines the action to be unregistered
  29758. * @return a boolean indicating whether the action has been unregistered
  29759. */
  29760. abstract unregisterAction(action: IAction): Boolean;
  29761. /**
  29762. * Does exist one action manager with at least one trigger
  29763. **/
  29764. static get HasTriggers(): boolean;
  29765. /**
  29766. * Does exist one action manager with at least one pick trigger
  29767. **/
  29768. static get HasPickTriggers(): boolean;
  29769. /**
  29770. * Does exist one action manager that handles actions of a given trigger
  29771. * @param trigger defines the trigger to be tested
  29772. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29773. **/
  29774. static HasSpecificTrigger(trigger: number): boolean;
  29775. }
  29776. }
  29777. declare module "babylonjs/node" {
  29778. import { Scene } from "babylonjs/scene";
  29779. import { Nullable } from "babylonjs/types";
  29780. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29781. import { Engine } from "babylonjs/Engines/engine";
  29782. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29783. import { Observable } from "babylonjs/Misc/observable";
  29784. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29785. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29786. import { Animatable } from "babylonjs/Animations/animatable";
  29787. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29788. import { Animation } from "babylonjs/Animations/animation";
  29789. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29790. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29791. /**
  29792. * Defines how a node can be built from a string name.
  29793. */
  29794. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29795. /**
  29796. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29797. */
  29798. export class Node implements IBehaviorAware<Node> {
  29799. /** @hidden */
  29800. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29801. private static _NodeConstructors;
  29802. /**
  29803. * Add a new node constructor
  29804. * @param type defines the type name of the node to construct
  29805. * @param constructorFunc defines the constructor function
  29806. */
  29807. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29808. /**
  29809. * Returns a node constructor based on type name
  29810. * @param type defines the type name
  29811. * @param name defines the new node name
  29812. * @param scene defines the hosting scene
  29813. * @param options defines optional options to transmit to constructors
  29814. * @returns the new constructor or null
  29815. */
  29816. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29817. /**
  29818. * Gets or sets the name of the node
  29819. */
  29820. name: string;
  29821. /**
  29822. * Gets or sets the id of the node
  29823. */
  29824. id: string;
  29825. /**
  29826. * Gets or sets the unique id of the node
  29827. */
  29828. uniqueId: number;
  29829. /**
  29830. * Gets or sets a string used to store user defined state for the node
  29831. */
  29832. state: string;
  29833. /**
  29834. * Gets or sets an object used to store user defined information for the node
  29835. */
  29836. metadata: any;
  29837. /**
  29838. * For internal use only. Please do not use.
  29839. */
  29840. reservedDataStore: any;
  29841. /**
  29842. * List of inspectable custom properties (used by the Inspector)
  29843. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29844. */
  29845. inspectableCustomProperties: IInspectable[];
  29846. private _doNotSerialize;
  29847. /**
  29848. * Gets or sets a boolean used to define if the node must be serialized
  29849. */
  29850. get doNotSerialize(): boolean;
  29851. set doNotSerialize(value: boolean);
  29852. /** @hidden */
  29853. _isDisposed: boolean;
  29854. /**
  29855. * Gets a list of Animations associated with the node
  29856. */
  29857. animations: import("babylonjs/Animations/animation").Animation[];
  29858. protected _ranges: {
  29859. [name: string]: Nullable<AnimationRange>;
  29860. };
  29861. /**
  29862. * Callback raised when the node is ready to be used
  29863. */
  29864. onReady: Nullable<(node: Node) => void>;
  29865. private _isEnabled;
  29866. private _isParentEnabled;
  29867. private _isReady;
  29868. /** @hidden */
  29869. _currentRenderId: number;
  29870. private _parentUpdateId;
  29871. /** @hidden */
  29872. _childUpdateId: number;
  29873. /** @hidden */
  29874. _waitingParentId: Nullable<string>;
  29875. /** @hidden */
  29876. _scene: Scene;
  29877. /** @hidden */
  29878. _cache: any;
  29879. private _parentNode;
  29880. private _children;
  29881. /** @hidden */
  29882. _worldMatrix: Matrix;
  29883. /** @hidden */
  29884. _worldMatrixDeterminant: number;
  29885. /** @hidden */
  29886. _worldMatrixDeterminantIsDirty: boolean;
  29887. /** @hidden */
  29888. private _sceneRootNodesIndex;
  29889. /**
  29890. * Gets a boolean indicating if the node has been disposed
  29891. * @returns true if the node was disposed
  29892. */
  29893. isDisposed(): boolean;
  29894. /**
  29895. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29896. * @see https://doc.babylonjs.com/how_to/parenting
  29897. */
  29898. set parent(parent: Nullable<Node>);
  29899. get parent(): Nullable<Node>;
  29900. /** @hidden */
  29901. _addToSceneRootNodes(): void;
  29902. /** @hidden */
  29903. _removeFromSceneRootNodes(): void;
  29904. private _animationPropertiesOverride;
  29905. /**
  29906. * Gets or sets the animation properties override
  29907. */
  29908. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29909. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29910. /**
  29911. * Gets a string idenfifying the name of the class
  29912. * @returns "Node" string
  29913. */
  29914. getClassName(): string;
  29915. /** @hidden */
  29916. readonly _isNode: boolean;
  29917. /**
  29918. * An event triggered when the mesh is disposed
  29919. */
  29920. onDisposeObservable: Observable<Node>;
  29921. private _onDisposeObserver;
  29922. /**
  29923. * Sets a callback that will be raised when the node will be disposed
  29924. */
  29925. set onDispose(callback: () => void);
  29926. /**
  29927. * Creates a new Node
  29928. * @param name the name and id to be given to this node
  29929. * @param scene the scene this node will be added to
  29930. */
  29931. constructor(name: string, scene?: Nullable<Scene>);
  29932. /**
  29933. * Gets the scene of the node
  29934. * @returns a scene
  29935. */
  29936. getScene(): Scene;
  29937. /**
  29938. * Gets the engine of the node
  29939. * @returns a Engine
  29940. */
  29941. getEngine(): Engine;
  29942. private _behaviors;
  29943. /**
  29944. * Attach a behavior to the node
  29945. * @see http://doc.babylonjs.com/features/behaviour
  29946. * @param behavior defines the behavior to attach
  29947. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29948. * @returns the current Node
  29949. */
  29950. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29951. /**
  29952. * Remove an attached behavior
  29953. * @see http://doc.babylonjs.com/features/behaviour
  29954. * @param behavior defines the behavior to attach
  29955. * @returns the current Node
  29956. */
  29957. removeBehavior(behavior: Behavior<Node>): Node;
  29958. /**
  29959. * Gets the list of attached behaviors
  29960. * @see http://doc.babylonjs.com/features/behaviour
  29961. */
  29962. get behaviors(): Behavior<Node>[];
  29963. /**
  29964. * Gets an attached behavior by name
  29965. * @param name defines the name of the behavior to look for
  29966. * @see http://doc.babylonjs.com/features/behaviour
  29967. * @returns null if behavior was not found else the requested behavior
  29968. */
  29969. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29970. /**
  29971. * Returns the latest update of the World matrix
  29972. * @returns a Matrix
  29973. */
  29974. getWorldMatrix(): Matrix;
  29975. /** @hidden */
  29976. _getWorldMatrixDeterminant(): number;
  29977. /**
  29978. * Returns directly the latest state of the mesh World matrix.
  29979. * A Matrix is returned.
  29980. */
  29981. get worldMatrixFromCache(): Matrix;
  29982. /** @hidden */
  29983. _initCache(): void;
  29984. /** @hidden */
  29985. updateCache(force?: boolean): void;
  29986. /** @hidden */
  29987. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29988. /** @hidden */
  29989. _updateCache(ignoreParentClass?: boolean): void;
  29990. /** @hidden */
  29991. _isSynchronized(): boolean;
  29992. /** @hidden */
  29993. _markSyncedWithParent(): void;
  29994. /** @hidden */
  29995. isSynchronizedWithParent(): boolean;
  29996. /** @hidden */
  29997. isSynchronized(): boolean;
  29998. /**
  29999. * Is this node ready to be used/rendered
  30000. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  30001. * @return true if the node is ready
  30002. */
  30003. isReady(completeCheck?: boolean): boolean;
  30004. /**
  30005. * Is this node enabled?
  30006. * 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
  30007. * @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
  30008. * @return whether this node (and its parent) is enabled
  30009. */
  30010. isEnabled(checkAncestors?: boolean): boolean;
  30011. /** @hidden */
  30012. protected _syncParentEnabledState(): void;
  30013. /**
  30014. * Set the enabled state of this node
  30015. * @param value defines the new enabled state
  30016. */
  30017. setEnabled(value: boolean): void;
  30018. /**
  30019. * Is this node a descendant of the given node?
  30020. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  30021. * @param ancestor defines the parent node to inspect
  30022. * @returns a boolean indicating if this node is a descendant of the given node
  30023. */
  30024. isDescendantOf(ancestor: Node): boolean;
  30025. /** @hidden */
  30026. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  30027. /**
  30028. * Will return all nodes that have this node as ascendant
  30029. * @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
  30030. * @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
  30031. * @return all children nodes of all types
  30032. */
  30033. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  30034. /**
  30035. * Get all child-meshes of this node
  30036. * @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)
  30037. * @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
  30038. * @returns an array of AbstractMesh
  30039. */
  30040. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  30041. /**
  30042. * Get all direct children of this node
  30043. * @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
  30044. * @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)
  30045. * @returns an array of Node
  30046. */
  30047. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  30048. /** @hidden */
  30049. _setReady(state: boolean): void;
  30050. /**
  30051. * Get an animation by name
  30052. * @param name defines the name of the animation to look for
  30053. * @returns null if not found else the requested animation
  30054. */
  30055. getAnimationByName(name: string): Nullable<Animation>;
  30056. /**
  30057. * Creates an animation range for this node
  30058. * @param name defines the name of the range
  30059. * @param from defines the starting key
  30060. * @param to defines the end key
  30061. */
  30062. createAnimationRange(name: string, from: number, to: number): void;
  30063. /**
  30064. * Delete a specific animation range
  30065. * @param name defines the name of the range to delete
  30066. * @param deleteFrames defines if animation frames from the range must be deleted as well
  30067. */
  30068. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  30069. /**
  30070. * Get an animation range by name
  30071. * @param name defines the name of the animation range to look for
  30072. * @returns null if not found else the requested animation range
  30073. */
  30074. getAnimationRange(name: string): Nullable<AnimationRange>;
  30075. /**
  30076. * Gets the list of all animation ranges defined on this node
  30077. * @returns an array
  30078. */
  30079. getAnimationRanges(): Nullable<AnimationRange>[];
  30080. /**
  30081. * Will start the animation sequence
  30082. * @param name defines the range frames for animation sequence
  30083. * @param loop defines if the animation should loop (false by default)
  30084. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  30085. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  30086. * @returns the object created for this animation. If range does not exist, it will return null
  30087. */
  30088. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  30089. /**
  30090. * Serialize animation ranges into a JSON compatible object
  30091. * @returns serialization object
  30092. */
  30093. serializeAnimationRanges(): any;
  30094. /**
  30095. * Computes the world matrix of the node
  30096. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  30097. * @returns the world matrix
  30098. */
  30099. computeWorldMatrix(force?: boolean): Matrix;
  30100. /**
  30101. * Releases resources associated with this node.
  30102. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30103. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30104. */
  30105. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30106. /**
  30107. * Parse animation range data from a serialization object and store them into a given node
  30108. * @param node defines where to store the animation ranges
  30109. * @param parsedNode defines the serialization object to read data from
  30110. * @param scene defines the hosting scene
  30111. */
  30112. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  30113. /**
  30114. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  30115. * @param includeDescendants Include bounding info from descendants as well (true by default)
  30116. * @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
  30117. * @returns the new bounding vectors
  30118. */
  30119. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  30120. min: Vector3;
  30121. max: Vector3;
  30122. };
  30123. }
  30124. }
  30125. declare module "babylonjs/Animations/animation" {
  30126. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  30127. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  30128. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  30129. import { Nullable } from "babylonjs/types";
  30130. import { Scene } from "babylonjs/scene";
  30131. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  30132. import { AnimationRange } from "babylonjs/Animations/animationRange";
  30133. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  30134. import { Node } from "babylonjs/node";
  30135. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30136. import { Size } from "babylonjs/Maths/math.size";
  30137. import { Animatable } from "babylonjs/Animations/animatable";
  30138. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  30139. /**
  30140. * @hidden
  30141. */
  30142. export class _IAnimationState {
  30143. key: number;
  30144. repeatCount: number;
  30145. workValue?: any;
  30146. loopMode?: number;
  30147. offsetValue?: any;
  30148. highLimitValue?: any;
  30149. }
  30150. /**
  30151. * Class used to store any kind of animation
  30152. */
  30153. export class Animation {
  30154. /**Name of the animation */
  30155. name: string;
  30156. /**Property to animate */
  30157. targetProperty: string;
  30158. /**The frames per second of the animation */
  30159. framePerSecond: number;
  30160. /**The data type of the animation */
  30161. dataType: number;
  30162. /**The loop mode of the animation */
  30163. loopMode?: number | undefined;
  30164. /**Specifies if blending should be enabled */
  30165. enableBlending?: boolean | undefined;
  30166. /**
  30167. * Use matrix interpolation instead of using direct key value when animating matrices
  30168. */
  30169. static AllowMatricesInterpolation: boolean;
  30170. /**
  30171. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  30172. */
  30173. static AllowMatrixDecomposeForInterpolation: boolean;
  30174. /**
  30175. * Stores the key frames of the animation
  30176. */
  30177. private _keys;
  30178. /**
  30179. * Stores the easing function of the animation
  30180. */
  30181. private _easingFunction;
  30182. /**
  30183. * @hidden Internal use only
  30184. */
  30185. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  30186. /**
  30187. * The set of event that will be linked to this animation
  30188. */
  30189. private _events;
  30190. /**
  30191. * Stores an array of target property paths
  30192. */
  30193. targetPropertyPath: string[];
  30194. /**
  30195. * Stores the blending speed of the animation
  30196. */
  30197. blendingSpeed: number;
  30198. /**
  30199. * Stores the animation ranges for the animation
  30200. */
  30201. private _ranges;
  30202. /**
  30203. * @hidden Internal use
  30204. */
  30205. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  30206. /**
  30207. * Sets up an animation
  30208. * @param property The property to animate
  30209. * @param animationType The animation type to apply
  30210. * @param framePerSecond The frames per second of the animation
  30211. * @param easingFunction The easing function used in the animation
  30212. * @returns The created animation
  30213. */
  30214. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  30215. /**
  30216. * Create and start an animation on a node
  30217. * @param name defines the name of the global animation that will be run on all nodes
  30218. * @param node defines the root node where the animation will take place
  30219. * @param targetProperty defines property to animate
  30220. * @param framePerSecond defines the number of frame per second yo use
  30221. * @param totalFrame defines the number of frames in total
  30222. * @param from defines the initial value
  30223. * @param to defines the final value
  30224. * @param loopMode defines which loop mode you want to use (off by default)
  30225. * @param easingFunction defines the easing function to use (linear by default)
  30226. * @param onAnimationEnd defines the callback to call when animation end
  30227. * @returns the animatable created for this animation
  30228. */
  30229. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30230. /**
  30231. * Create and start an animation on a node and its descendants
  30232. * @param name defines the name of the global animation that will be run on all nodes
  30233. * @param node defines the root node where the animation will take place
  30234. * @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
  30235. * @param targetProperty defines property to animate
  30236. * @param framePerSecond defines the number of frame per second to use
  30237. * @param totalFrame defines the number of frames in total
  30238. * @param from defines the initial value
  30239. * @param to defines the final value
  30240. * @param loopMode defines which loop mode you want to use (off by default)
  30241. * @param easingFunction defines the easing function to use (linear by default)
  30242. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  30243. * @returns the list of animatables created for all nodes
  30244. * @example https://www.babylonjs-playground.com/#MH0VLI
  30245. */
  30246. 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[]>;
  30247. /**
  30248. * Creates a new animation, merges it with the existing animations and starts it
  30249. * @param name Name of the animation
  30250. * @param node Node which contains the scene that begins the animations
  30251. * @param targetProperty Specifies which property to animate
  30252. * @param framePerSecond The frames per second of the animation
  30253. * @param totalFrame The total number of frames
  30254. * @param from The frame at the beginning of the animation
  30255. * @param to The frame at the end of the animation
  30256. * @param loopMode Specifies the loop mode of the animation
  30257. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  30258. * @param onAnimationEnd Callback to run once the animation is complete
  30259. * @returns Nullable animation
  30260. */
  30261. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30262. /**
  30263. * Transition property of an host to the target Value
  30264. * @param property The property to transition
  30265. * @param targetValue The target Value of the property
  30266. * @param host The object where the property to animate belongs
  30267. * @param scene Scene used to run the animation
  30268. * @param frameRate Framerate (in frame/s) to use
  30269. * @param transition The transition type we want to use
  30270. * @param duration The duration of the animation, in milliseconds
  30271. * @param onAnimationEnd Callback trigger at the end of the animation
  30272. * @returns Nullable animation
  30273. */
  30274. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  30275. /**
  30276. * Return the array of runtime animations currently using this animation
  30277. */
  30278. get runtimeAnimations(): RuntimeAnimation[];
  30279. /**
  30280. * Specifies if any of the runtime animations are currently running
  30281. */
  30282. get hasRunningRuntimeAnimations(): boolean;
  30283. /**
  30284. * Initializes the animation
  30285. * @param name Name of the animation
  30286. * @param targetProperty Property to animate
  30287. * @param framePerSecond The frames per second of the animation
  30288. * @param dataType The data type of the animation
  30289. * @param loopMode The loop mode of the animation
  30290. * @param enableBlending Specifies if blending should be enabled
  30291. */
  30292. constructor(
  30293. /**Name of the animation */
  30294. name: string,
  30295. /**Property to animate */
  30296. targetProperty: string,
  30297. /**The frames per second of the animation */
  30298. framePerSecond: number,
  30299. /**The data type of the animation */
  30300. dataType: number,
  30301. /**The loop mode of the animation */
  30302. loopMode?: number | undefined,
  30303. /**Specifies if blending should be enabled */
  30304. enableBlending?: boolean | undefined);
  30305. /**
  30306. * Converts the animation to a string
  30307. * @param fullDetails support for multiple levels of logging within scene loading
  30308. * @returns String form of the animation
  30309. */
  30310. toString(fullDetails?: boolean): string;
  30311. /**
  30312. * Add an event to this animation
  30313. * @param event Event to add
  30314. */
  30315. addEvent(event: AnimationEvent): void;
  30316. /**
  30317. * Remove all events found at the given frame
  30318. * @param frame The frame to remove events from
  30319. */
  30320. removeEvents(frame: number): void;
  30321. /**
  30322. * Retrieves all the events from the animation
  30323. * @returns Events from the animation
  30324. */
  30325. getEvents(): AnimationEvent[];
  30326. /**
  30327. * Creates an animation range
  30328. * @param name Name of the animation range
  30329. * @param from Starting frame of the animation range
  30330. * @param to Ending frame of the animation
  30331. */
  30332. createRange(name: string, from: number, to: number): void;
  30333. /**
  30334. * Deletes an animation range by name
  30335. * @param name Name of the animation range to delete
  30336. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  30337. */
  30338. deleteRange(name: string, deleteFrames?: boolean): void;
  30339. /**
  30340. * Gets the animation range by name, or null if not defined
  30341. * @param name Name of the animation range
  30342. * @returns Nullable animation range
  30343. */
  30344. getRange(name: string): Nullable<AnimationRange>;
  30345. /**
  30346. * Gets the key frames from the animation
  30347. * @returns The key frames of the animation
  30348. */
  30349. getKeys(): Array<IAnimationKey>;
  30350. /**
  30351. * Gets the highest frame rate of the animation
  30352. * @returns Highest frame rate of the animation
  30353. */
  30354. getHighestFrame(): number;
  30355. /**
  30356. * Gets the easing function of the animation
  30357. * @returns Easing function of the animation
  30358. */
  30359. getEasingFunction(): IEasingFunction;
  30360. /**
  30361. * Sets the easing function of the animation
  30362. * @param easingFunction A custom mathematical formula for animation
  30363. */
  30364. setEasingFunction(easingFunction: EasingFunction): void;
  30365. /**
  30366. * Interpolates a scalar linearly
  30367. * @param startValue Start value of the animation curve
  30368. * @param endValue End value of the animation curve
  30369. * @param gradient Scalar amount to interpolate
  30370. * @returns Interpolated scalar value
  30371. */
  30372. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  30373. /**
  30374. * Interpolates a scalar cubically
  30375. * @param startValue Start value of the animation curve
  30376. * @param outTangent End tangent of the animation
  30377. * @param endValue End value of the animation curve
  30378. * @param inTangent Start tangent of the animation curve
  30379. * @param gradient Scalar amount to interpolate
  30380. * @returns Interpolated scalar value
  30381. */
  30382. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  30383. /**
  30384. * Interpolates a quaternion using a spherical linear interpolation
  30385. * @param startValue Start value of the animation curve
  30386. * @param endValue End value of the animation curve
  30387. * @param gradient Scalar amount to interpolate
  30388. * @returns Interpolated quaternion value
  30389. */
  30390. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30391. /**
  30392. * Interpolates a quaternion cubically
  30393. * @param startValue Start value of the animation curve
  30394. * @param outTangent End tangent of the animation curve
  30395. * @param endValue End value of the animation curve
  30396. * @param inTangent Start tangent of the animation curve
  30397. * @param gradient Scalar amount to interpolate
  30398. * @returns Interpolated quaternion value
  30399. */
  30400. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30401. /**
  30402. * Interpolates a Vector3 linearl
  30403. * @param startValue Start value of the animation curve
  30404. * @param endValue End value of the animation curve
  30405. * @param gradient Scalar amount to interpolate
  30406. * @returns Interpolated scalar value
  30407. */
  30408. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30409. /**
  30410. * Interpolates a Vector3 cubically
  30411. * @param startValue Start value of the animation curve
  30412. * @param outTangent End tangent of the animation
  30413. * @param endValue End value of the animation curve
  30414. * @param inTangent Start tangent of the animation curve
  30415. * @param gradient Scalar amount to interpolate
  30416. * @returns InterpolatedVector3 value
  30417. */
  30418. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30419. /**
  30420. * Interpolates a Vector2 linearly
  30421. * @param startValue Start value of the animation curve
  30422. * @param endValue End value of the animation curve
  30423. * @param gradient Scalar amount to interpolate
  30424. * @returns Interpolated Vector2 value
  30425. */
  30426. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30427. /**
  30428. * Interpolates a Vector2 cubically
  30429. * @param startValue Start value of the animation curve
  30430. * @param outTangent End tangent of the animation
  30431. * @param endValue End value of the animation curve
  30432. * @param inTangent Start tangent of the animation curve
  30433. * @param gradient Scalar amount to interpolate
  30434. * @returns Interpolated Vector2 value
  30435. */
  30436. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30437. /**
  30438. * Interpolates a size linearly
  30439. * @param startValue Start value of the animation curve
  30440. * @param endValue End value of the animation curve
  30441. * @param gradient Scalar amount to interpolate
  30442. * @returns Interpolated Size value
  30443. */
  30444. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30445. /**
  30446. * Interpolates a Color3 linearly
  30447. * @param startValue Start value of the animation curve
  30448. * @param endValue End value of the animation curve
  30449. * @param gradient Scalar amount to interpolate
  30450. * @returns Interpolated Color3 value
  30451. */
  30452. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30453. /**
  30454. * Interpolates a Color4 linearly
  30455. * @param startValue Start value of the animation curve
  30456. * @param endValue End value of the animation curve
  30457. * @param gradient Scalar amount to interpolate
  30458. * @returns Interpolated Color3 value
  30459. */
  30460. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30461. /**
  30462. * @hidden Internal use only
  30463. */
  30464. _getKeyValue(value: any): any;
  30465. /**
  30466. * @hidden Internal use only
  30467. */
  30468. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30469. /**
  30470. * Defines the function to use to interpolate matrices
  30471. * @param startValue defines the start matrix
  30472. * @param endValue defines the end matrix
  30473. * @param gradient defines the gradient between both matrices
  30474. * @param result defines an optional target matrix where to store the interpolation
  30475. * @returns the interpolated matrix
  30476. */
  30477. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30478. /**
  30479. * Makes a copy of the animation
  30480. * @returns Cloned animation
  30481. */
  30482. clone(): Animation;
  30483. /**
  30484. * Sets the key frames of the animation
  30485. * @param values The animation key frames to set
  30486. */
  30487. setKeys(values: Array<IAnimationKey>): void;
  30488. /**
  30489. * Serializes the animation to an object
  30490. * @returns Serialized object
  30491. */
  30492. serialize(): any;
  30493. /**
  30494. * Float animation type
  30495. */
  30496. static readonly ANIMATIONTYPE_FLOAT: number;
  30497. /**
  30498. * Vector3 animation type
  30499. */
  30500. static readonly ANIMATIONTYPE_VECTOR3: number;
  30501. /**
  30502. * Quaternion animation type
  30503. */
  30504. static readonly ANIMATIONTYPE_QUATERNION: number;
  30505. /**
  30506. * Matrix animation type
  30507. */
  30508. static readonly ANIMATIONTYPE_MATRIX: number;
  30509. /**
  30510. * Color3 animation type
  30511. */
  30512. static readonly ANIMATIONTYPE_COLOR3: number;
  30513. /**
  30514. * Color3 animation type
  30515. */
  30516. static readonly ANIMATIONTYPE_COLOR4: number;
  30517. /**
  30518. * Vector2 animation type
  30519. */
  30520. static readonly ANIMATIONTYPE_VECTOR2: number;
  30521. /**
  30522. * Size animation type
  30523. */
  30524. static readonly ANIMATIONTYPE_SIZE: number;
  30525. /**
  30526. * Relative Loop Mode
  30527. */
  30528. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30529. /**
  30530. * Cycle Loop Mode
  30531. */
  30532. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30533. /**
  30534. * Constant Loop Mode
  30535. */
  30536. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30537. /** @hidden */
  30538. static _UniversalLerp(left: any, right: any, amount: number): any;
  30539. /**
  30540. * Parses an animation object and creates an animation
  30541. * @param parsedAnimation Parsed animation object
  30542. * @returns Animation object
  30543. */
  30544. static Parse(parsedAnimation: any): Animation;
  30545. /**
  30546. * Appends the serialized animations from the source animations
  30547. * @param source Source containing the animations
  30548. * @param destination Target to store the animations
  30549. */
  30550. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30551. }
  30552. }
  30553. declare module "babylonjs/Animations/animatable.interface" {
  30554. import { Nullable } from "babylonjs/types";
  30555. import { Animation } from "babylonjs/Animations/animation";
  30556. /**
  30557. * Interface containing an array of animations
  30558. */
  30559. export interface IAnimatable {
  30560. /**
  30561. * Array of animations
  30562. */
  30563. animations: Nullable<Array<Animation>>;
  30564. }
  30565. }
  30566. declare module "babylonjs/Misc/decorators" {
  30567. import { Nullable } from "babylonjs/types";
  30568. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30569. import { Scene } from "babylonjs/scene";
  30570. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30571. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30572. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30573. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30574. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30575. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30576. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30577. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30578. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30579. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30580. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30581. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30582. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30583. /**
  30584. * Decorator used to define property that can be serialized as reference to a camera
  30585. * @param sourceName defines the name of the property to decorate
  30586. */
  30587. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30588. /**
  30589. * Class used to help serialization objects
  30590. */
  30591. export class SerializationHelper {
  30592. /** @hidden */
  30593. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30594. /** @hidden */
  30595. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30596. /** @hidden */
  30597. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30598. /** @hidden */
  30599. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30600. /**
  30601. * Appends the serialized animations from the source animations
  30602. * @param source Source containing the animations
  30603. * @param destination Target to store the animations
  30604. */
  30605. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30606. /**
  30607. * Static function used to serialized a specific entity
  30608. * @param entity defines the entity to serialize
  30609. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30610. * @returns a JSON compatible object representing the serialization of the entity
  30611. */
  30612. static Serialize<T>(entity: T, serializationObject?: any): any;
  30613. /**
  30614. * Creates a new entity from a serialization data object
  30615. * @param creationFunction defines a function used to instanciated the new entity
  30616. * @param source defines the source serialization data
  30617. * @param scene defines the hosting scene
  30618. * @param rootUrl defines the root url for resources
  30619. * @returns a new entity
  30620. */
  30621. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30622. /**
  30623. * Clones an object
  30624. * @param creationFunction defines the function used to instanciate the new object
  30625. * @param source defines the source object
  30626. * @returns the cloned object
  30627. */
  30628. static Clone<T>(creationFunction: () => T, source: T): T;
  30629. /**
  30630. * Instanciates a new object based on a source one (some data will be shared between both object)
  30631. * @param creationFunction defines the function used to instanciate the new object
  30632. * @param source defines the source object
  30633. * @returns the new object
  30634. */
  30635. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30636. }
  30637. }
  30638. declare module "babylonjs/Misc/guid" {
  30639. /**
  30640. * Class used to manipulate GUIDs
  30641. */
  30642. export class GUID {
  30643. /**
  30644. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30645. * Be aware Math.random() could cause collisions, but:
  30646. * "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"
  30647. * @returns a pseudo random id
  30648. */
  30649. static RandomId(): string;
  30650. }
  30651. }
  30652. declare module "babylonjs/Materials/Textures/baseTexture" {
  30653. import { Observable } from "babylonjs/Misc/observable";
  30654. import { Nullable } from "babylonjs/types";
  30655. import { Scene } from "babylonjs/scene";
  30656. import { Matrix } from "babylonjs/Maths/math.vector";
  30657. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30658. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30659. import { ISize } from "babylonjs/Maths/math.size";
  30660. import "babylonjs/Misc/fileTools";
  30661. /**
  30662. * Base class of all the textures in babylon.
  30663. * It groups all the common properties the materials, post process, lights... might need
  30664. * in order to make a correct use of the texture.
  30665. */
  30666. export class BaseTexture implements IAnimatable {
  30667. /**
  30668. * Default anisotropic filtering level for the application.
  30669. * It is set to 4 as a good tradeoff between perf and quality.
  30670. */
  30671. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30672. /**
  30673. * Gets or sets the unique id of the texture
  30674. */
  30675. uniqueId: number;
  30676. /**
  30677. * Define the name of the texture.
  30678. */
  30679. name: string;
  30680. /**
  30681. * Gets or sets an object used to store user defined information.
  30682. */
  30683. metadata: any;
  30684. /**
  30685. * For internal use only. Please do not use.
  30686. */
  30687. reservedDataStore: any;
  30688. private _hasAlpha;
  30689. /**
  30690. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30691. */
  30692. set hasAlpha(value: boolean);
  30693. get hasAlpha(): boolean;
  30694. /**
  30695. * Defines if the alpha value should be determined via the rgb values.
  30696. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30697. */
  30698. getAlphaFromRGB: boolean;
  30699. /**
  30700. * Intensity or strength of the texture.
  30701. * It is commonly used by materials to fine tune the intensity of the texture
  30702. */
  30703. level: number;
  30704. /**
  30705. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30706. * This is part of the texture as textures usually maps to one uv set.
  30707. */
  30708. coordinatesIndex: number;
  30709. private _coordinatesMode;
  30710. /**
  30711. * How a texture is mapped.
  30712. *
  30713. * | Value | Type | Description |
  30714. * | ----- | ----------------------------------- | ----------- |
  30715. * | 0 | EXPLICIT_MODE | |
  30716. * | 1 | SPHERICAL_MODE | |
  30717. * | 2 | PLANAR_MODE | |
  30718. * | 3 | CUBIC_MODE | |
  30719. * | 4 | PROJECTION_MODE | |
  30720. * | 5 | SKYBOX_MODE | |
  30721. * | 6 | INVCUBIC_MODE | |
  30722. * | 7 | EQUIRECTANGULAR_MODE | |
  30723. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30724. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30725. */
  30726. set coordinatesMode(value: number);
  30727. get coordinatesMode(): number;
  30728. /**
  30729. * | Value | Type | Description |
  30730. * | ----- | ------------------ | ----------- |
  30731. * | 0 | CLAMP_ADDRESSMODE | |
  30732. * | 1 | WRAP_ADDRESSMODE | |
  30733. * | 2 | MIRROR_ADDRESSMODE | |
  30734. */
  30735. wrapU: number;
  30736. /**
  30737. * | Value | Type | Description |
  30738. * | ----- | ------------------ | ----------- |
  30739. * | 0 | CLAMP_ADDRESSMODE | |
  30740. * | 1 | WRAP_ADDRESSMODE | |
  30741. * | 2 | MIRROR_ADDRESSMODE | |
  30742. */
  30743. wrapV: number;
  30744. /**
  30745. * | Value | Type | Description |
  30746. * | ----- | ------------------ | ----------- |
  30747. * | 0 | CLAMP_ADDRESSMODE | |
  30748. * | 1 | WRAP_ADDRESSMODE | |
  30749. * | 2 | MIRROR_ADDRESSMODE | |
  30750. */
  30751. wrapR: number;
  30752. /**
  30753. * With compliant hardware and browser (supporting anisotropic filtering)
  30754. * this defines the level of anisotropic filtering in the texture.
  30755. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30756. */
  30757. anisotropicFilteringLevel: number;
  30758. /**
  30759. * Define if the texture is a cube texture or if false a 2d texture.
  30760. */
  30761. get isCube(): boolean;
  30762. set isCube(value: boolean);
  30763. /**
  30764. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30765. */
  30766. get is3D(): boolean;
  30767. set is3D(value: boolean);
  30768. /**
  30769. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30770. */
  30771. get is2DArray(): boolean;
  30772. set is2DArray(value: boolean);
  30773. /**
  30774. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30775. * HDR texture are usually stored in linear space.
  30776. * This only impacts the PBR and Background materials
  30777. */
  30778. gammaSpace: boolean;
  30779. /**
  30780. * Gets or sets whether or not the texture contains RGBD data.
  30781. */
  30782. get isRGBD(): boolean;
  30783. set isRGBD(value: boolean);
  30784. /**
  30785. * Is Z inverted in the texture (useful in a cube texture).
  30786. */
  30787. invertZ: boolean;
  30788. /**
  30789. * Are mip maps generated for this texture or not.
  30790. */
  30791. get noMipmap(): boolean;
  30792. /**
  30793. * @hidden
  30794. */
  30795. lodLevelInAlpha: boolean;
  30796. /**
  30797. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30798. */
  30799. get lodGenerationOffset(): number;
  30800. set lodGenerationOffset(value: number);
  30801. /**
  30802. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30803. */
  30804. get lodGenerationScale(): number;
  30805. set lodGenerationScale(value: number);
  30806. /**
  30807. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30808. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30809. * average roughness values.
  30810. */
  30811. get linearSpecularLOD(): boolean;
  30812. set linearSpecularLOD(value: boolean);
  30813. /**
  30814. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30815. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30816. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30817. */
  30818. get irradianceTexture(): Nullable<BaseTexture>;
  30819. set irradianceTexture(value: Nullable<BaseTexture>);
  30820. /**
  30821. * Define if the texture is a render target.
  30822. */
  30823. isRenderTarget: boolean;
  30824. /**
  30825. * Define the unique id of the texture in the scene.
  30826. */
  30827. get uid(): string;
  30828. /**
  30829. * Return a string representation of the texture.
  30830. * @returns the texture as a string
  30831. */
  30832. toString(): string;
  30833. /**
  30834. * Get the class name of the texture.
  30835. * @returns "BaseTexture"
  30836. */
  30837. getClassName(): string;
  30838. /**
  30839. * Define the list of animation attached to the texture.
  30840. */
  30841. animations: import("babylonjs/Animations/animation").Animation[];
  30842. /**
  30843. * An event triggered when the texture is disposed.
  30844. */
  30845. onDisposeObservable: Observable<BaseTexture>;
  30846. private _onDisposeObserver;
  30847. /**
  30848. * Callback triggered when the texture has been disposed.
  30849. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30850. */
  30851. set onDispose(callback: () => void);
  30852. /**
  30853. * Define the current state of the loading sequence when in delayed load mode.
  30854. */
  30855. delayLoadState: number;
  30856. private _scene;
  30857. /** @hidden */
  30858. _texture: Nullable<InternalTexture>;
  30859. private _uid;
  30860. /**
  30861. * Define if the texture is preventinga material to render or not.
  30862. * If not and the texture is not ready, the engine will use a default black texture instead.
  30863. */
  30864. get isBlocking(): boolean;
  30865. /**
  30866. * Instantiates a new BaseTexture.
  30867. * Base class of all the textures in babylon.
  30868. * It groups all the common properties the materials, post process, lights... might need
  30869. * in order to make a correct use of the texture.
  30870. * @param scene Define the scene the texture blongs to
  30871. */
  30872. constructor(scene: Nullable<Scene>);
  30873. /**
  30874. * Get the scene the texture belongs to.
  30875. * @returns the scene or null if undefined
  30876. */
  30877. getScene(): Nullable<Scene>;
  30878. /**
  30879. * Get the texture transform matrix used to offset tile the texture for istance.
  30880. * @returns the transformation matrix
  30881. */
  30882. getTextureMatrix(): Matrix;
  30883. /**
  30884. * Get the texture reflection matrix used to rotate/transform the reflection.
  30885. * @returns the reflection matrix
  30886. */
  30887. getReflectionTextureMatrix(): Matrix;
  30888. /**
  30889. * Get the underlying lower level texture from Babylon.
  30890. * @returns the insternal texture
  30891. */
  30892. getInternalTexture(): Nullable<InternalTexture>;
  30893. /**
  30894. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30895. * @returns true if ready or not blocking
  30896. */
  30897. isReadyOrNotBlocking(): boolean;
  30898. /**
  30899. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30900. * @returns true if fully ready
  30901. */
  30902. isReady(): boolean;
  30903. private _cachedSize;
  30904. /**
  30905. * Get the size of the texture.
  30906. * @returns the texture size.
  30907. */
  30908. getSize(): ISize;
  30909. /**
  30910. * Get the base size of the texture.
  30911. * It can be different from the size if the texture has been resized for POT for instance
  30912. * @returns the base size
  30913. */
  30914. getBaseSize(): ISize;
  30915. /**
  30916. * Update the sampling mode of the texture.
  30917. * Default is Trilinear mode.
  30918. *
  30919. * | Value | Type | Description |
  30920. * | ----- | ------------------ | ----------- |
  30921. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30922. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30923. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30924. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30925. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30926. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30927. * | 7 | NEAREST_LINEAR | |
  30928. * | 8 | NEAREST_NEAREST | |
  30929. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30930. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30931. * | 11 | LINEAR_LINEAR | |
  30932. * | 12 | LINEAR_NEAREST | |
  30933. *
  30934. * > _mag_: magnification filter (close to the viewer)
  30935. * > _min_: minification filter (far from the viewer)
  30936. * > _mip_: filter used between mip map levels
  30937. *@param samplingMode Define the new sampling mode of the texture
  30938. */
  30939. updateSamplingMode(samplingMode: number): void;
  30940. /**
  30941. * Scales the texture if is `canRescale()`
  30942. * @param ratio the resize factor we want to use to rescale
  30943. */
  30944. scale(ratio: number): void;
  30945. /**
  30946. * Get if the texture can rescale.
  30947. */
  30948. get canRescale(): boolean;
  30949. /** @hidden */
  30950. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30951. /** @hidden */
  30952. _rebuild(): void;
  30953. /**
  30954. * Triggers the load sequence in delayed load mode.
  30955. */
  30956. delayLoad(): void;
  30957. /**
  30958. * Clones the texture.
  30959. * @returns the cloned texture
  30960. */
  30961. clone(): Nullable<BaseTexture>;
  30962. /**
  30963. * Get the texture underlying type (INT, FLOAT...)
  30964. */
  30965. get textureType(): number;
  30966. /**
  30967. * Get the texture underlying format (RGB, RGBA...)
  30968. */
  30969. get textureFormat(): number;
  30970. /**
  30971. * Indicates that textures need to be re-calculated for all materials
  30972. */
  30973. protected _markAllSubMeshesAsTexturesDirty(): void;
  30974. /**
  30975. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30976. * This will returns an RGBA array buffer containing either in values (0-255) or
  30977. * float values (0-1) depending of the underlying buffer type.
  30978. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30979. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30980. * @param buffer defines a user defined buffer to fill with data (can be null)
  30981. * @returns The Array buffer containing the pixels data.
  30982. */
  30983. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30984. /**
  30985. * Release and destroy the underlying lower level texture aka internalTexture.
  30986. */
  30987. releaseInternalTexture(): void;
  30988. /** @hidden */
  30989. get _lodTextureHigh(): Nullable<BaseTexture>;
  30990. /** @hidden */
  30991. get _lodTextureMid(): Nullable<BaseTexture>;
  30992. /** @hidden */
  30993. get _lodTextureLow(): Nullable<BaseTexture>;
  30994. /**
  30995. * Dispose the texture and release its associated resources.
  30996. */
  30997. dispose(): void;
  30998. /**
  30999. * Serialize the texture into a JSON representation that can be parsed later on.
  31000. * @returns the JSON representation of the texture
  31001. */
  31002. serialize(): any;
  31003. /**
  31004. * Helper function to be called back once a list of texture contains only ready textures.
  31005. * @param textures Define the list of textures to wait for
  31006. * @param callback Define the callback triggered once the entire list will be ready
  31007. */
  31008. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  31009. }
  31010. }
  31011. declare module "babylonjs/Materials/effect" {
  31012. import { Observable } from "babylonjs/Misc/observable";
  31013. import { Nullable } from "babylonjs/types";
  31014. import { IDisposable } from "babylonjs/scene";
  31015. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31016. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31017. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  31018. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31019. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31020. import { Engine } from "babylonjs/Engines/engine";
  31021. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31022. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31023. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31024. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31025. /**
  31026. * Options to be used when creating an effect.
  31027. */
  31028. export interface IEffectCreationOptions {
  31029. /**
  31030. * Atrributes that will be used in the shader.
  31031. */
  31032. attributes: string[];
  31033. /**
  31034. * Uniform varible names that will be set in the shader.
  31035. */
  31036. uniformsNames: string[];
  31037. /**
  31038. * Uniform buffer variable names that will be set in the shader.
  31039. */
  31040. uniformBuffersNames: string[];
  31041. /**
  31042. * Sampler texture variable names that will be set in the shader.
  31043. */
  31044. samplers: string[];
  31045. /**
  31046. * Define statements that will be set in the shader.
  31047. */
  31048. defines: any;
  31049. /**
  31050. * Possible fallbacks for this effect to improve performance when needed.
  31051. */
  31052. fallbacks: Nullable<IEffectFallbacks>;
  31053. /**
  31054. * Callback that will be called when the shader is compiled.
  31055. */
  31056. onCompiled: Nullable<(effect: Effect) => void>;
  31057. /**
  31058. * Callback that will be called if an error occurs during shader compilation.
  31059. */
  31060. onError: Nullable<(effect: Effect, errors: string) => void>;
  31061. /**
  31062. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31063. */
  31064. indexParameters?: any;
  31065. /**
  31066. * Max number of lights that can be used in the shader.
  31067. */
  31068. maxSimultaneousLights?: number;
  31069. /**
  31070. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  31071. */
  31072. transformFeedbackVaryings?: Nullable<string[]>;
  31073. }
  31074. /**
  31075. * Effect containing vertex and fragment shader that can be executed on an object.
  31076. */
  31077. export class Effect implements IDisposable {
  31078. /**
  31079. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31080. */
  31081. static ShadersRepository: string;
  31082. /**
  31083. * Enable logging of the shader code when a compilation error occurs
  31084. */
  31085. static LogShaderCodeOnCompilationError: boolean;
  31086. /**
  31087. * Name of the effect.
  31088. */
  31089. name: any;
  31090. /**
  31091. * String container all the define statements that should be set on the shader.
  31092. */
  31093. defines: string;
  31094. /**
  31095. * Callback that will be called when the shader is compiled.
  31096. */
  31097. onCompiled: Nullable<(effect: Effect) => void>;
  31098. /**
  31099. * Callback that will be called if an error occurs during shader compilation.
  31100. */
  31101. onError: Nullable<(effect: Effect, errors: string) => void>;
  31102. /**
  31103. * Callback that will be called when effect is bound.
  31104. */
  31105. onBind: Nullable<(effect: Effect) => void>;
  31106. /**
  31107. * Unique ID of the effect.
  31108. */
  31109. uniqueId: number;
  31110. /**
  31111. * Observable that will be called when the shader is compiled.
  31112. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  31113. */
  31114. onCompileObservable: Observable<Effect>;
  31115. /**
  31116. * Observable that will be called if an error occurs during shader compilation.
  31117. */
  31118. onErrorObservable: Observable<Effect>;
  31119. /** @hidden */
  31120. _onBindObservable: Nullable<Observable<Effect>>;
  31121. /**
  31122. * @hidden
  31123. * Specifies if the effect was previously ready
  31124. */
  31125. _wasPreviouslyReady: boolean;
  31126. /**
  31127. * Observable that will be called when effect is bound.
  31128. */
  31129. get onBindObservable(): Observable<Effect>;
  31130. /** @hidden */
  31131. _bonesComputationForcedToCPU: boolean;
  31132. private static _uniqueIdSeed;
  31133. private _engine;
  31134. private _uniformBuffersNames;
  31135. private _uniformsNames;
  31136. private _samplerList;
  31137. private _samplers;
  31138. private _isReady;
  31139. private _compilationError;
  31140. private _allFallbacksProcessed;
  31141. private _attributesNames;
  31142. private _attributes;
  31143. private _attributeLocationByName;
  31144. private _uniforms;
  31145. /**
  31146. * Key for the effect.
  31147. * @hidden
  31148. */
  31149. _key: string;
  31150. private _indexParameters;
  31151. private _fallbacks;
  31152. private _vertexSourceCode;
  31153. private _fragmentSourceCode;
  31154. private _vertexSourceCodeOverride;
  31155. private _fragmentSourceCodeOverride;
  31156. private _transformFeedbackVaryings;
  31157. /**
  31158. * Compiled shader to webGL program.
  31159. * @hidden
  31160. */
  31161. _pipelineContext: Nullable<IPipelineContext>;
  31162. private _valueCache;
  31163. private static _baseCache;
  31164. /**
  31165. * Instantiates an effect.
  31166. * An effect can be used to create/manage/execute vertex and fragment shaders.
  31167. * @param baseName Name of the effect.
  31168. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  31169. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  31170. * @param samplers List of sampler variables that will be passed to the shader.
  31171. * @param engine Engine to be used to render the effect
  31172. * @param defines Define statements to be added to the shader.
  31173. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  31174. * @param onCompiled Callback that will be called when the shader is compiled.
  31175. * @param onError Callback that will be called if an error occurs during shader compilation.
  31176. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31177. */
  31178. 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);
  31179. private _useFinalCode;
  31180. /**
  31181. * Unique key for this effect
  31182. */
  31183. get key(): string;
  31184. /**
  31185. * If the effect has been compiled and prepared.
  31186. * @returns if the effect is compiled and prepared.
  31187. */
  31188. isReady(): boolean;
  31189. private _isReadyInternal;
  31190. /**
  31191. * The engine the effect was initialized with.
  31192. * @returns the engine.
  31193. */
  31194. getEngine(): Engine;
  31195. /**
  31196. * The pipeline context for this effect
  31197. * @returns the associated pipeline context
  31198. */
  31199. getPipelineContext(): Nullable<IPipelineContext>;
  31200. /**
  31201. * The set of names of attribute variables for the shader.
  31202. * @returns An array of attribute names.
  31203. */
  31204. getAttributesNames(): string[];
  31205. /**
  31206. * Returns the attribute at the given index.
  31207. * @param index The index of the attribute.
  31208. * @returns The location of the attribute.
  31209. */
  31210. getAttributeLocation(index: number): number;
  31211. /**
  31212. * Returns the attribute based on the name of the variable.
  31213. * @param name of the attribute to look up.
  31214. * @returns the attribute location.
  31215. */
  31216. getAttributeLocationByName(name: string): number;
  31217. /**
  31218. * The number of attributes.
  31219. * @returns the numnber of attributes.
  31220. */
  31221. getAttributesCount(): number;
  31222. /**
  31223. * Gets the index of a uniform variable.
  31224. * @param uniformName of the uniform to look up.
  31225. * @returns the index.
  31226. */
  31227. getUniformIndex(uniformName: string): number;
  31228. /**
  31229. * Returns the attribute based on the name of the variable.
  31230. * @param uniformName of the uniform to look up.
  31231. * @returns the location of the uniform.
  31232. */
  31233. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  31234. /**
  31235. * Returns an array of sampler variable names
  31236. * @returns The array of sampler variable neames.
  31237. */
  31238. getSamplers(): string[];
  31239. /**
  31240. * The error from the last compilation.
  31241. * @returns the error string.
  31242. */
  31243. getCompilationError(): string;
  31244. /**
  31245. * Gets a boolean indicating that all fallbacks were used during compilation
  31246. * @returns true if all fallbacks were used
  31247. */
  31248. allFallbacksProcessed(): boolean;
  31249. /**
  31250. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  31251. * @param func The callback to be used.
  31252. */
  31253. executeWhenCompiled(func: (effect: Effect) => void): void;
  31254. private _checkIsReady;
  31255. private _loadShader;
  31256. /**
  31257. * Recompiles the webGL program
  31258. * @param vertexSourceCode The source code for the vertex shader.
  31259. * @param fragmentSourceCode The source code for the fragment shader.
  31260. * @param onCompiled Callback called when completed.
  31261. * @param onError Callback called on error.
  31262. * @hidden
  31263. */
  31264. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  31265. /**
  31266. * Prepares the effect
  31267. * @hidden
  31268. */
  31269. _prepareEffect(): void;
  31270. private _getShaderCodeAndErrorLine;
  31271. private _processCompilationErrors;
  31272. /**
  31273. * Checks if the effect is supported. (Must be called after compilation)
  31274. */
  31275. get isSupported(): boolean;
  31276. /**
  31277. * Binds a texture to the engine to be used as output of the shader.
  31278. * @param channel Name of the output variable.
  31279. * @param texture Texture to bind.
  31280. * @hidden
  31281. */
  31282. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  31283. /**
  31284. * Sets a texture on the engine to be used in the shader.
  31285. * @param channel Name of the sampler variable.
  31286. * @param texture Texture to set.
  31287. */
  31288. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  31289. /**
  31290. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  31291. * @param channel Name of the sampler variable.
  31292. * @param texture Texture to set.
  31293. */
  31294. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  31295. /**
  31296. * Sets an array of textures on the engine to be used in the shader.
  31297. * @param channel Name of the variable.
  31298. * @param textures Textures to set.
  31299. */
  31300. setTextureArray(channel: string, textures: BaseTexture[]): void;
  31301. /**
  31302. * 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)
  31303. * @param channel Name of the sampler variable.
  31304. * @param postProcess Post process to get the input texture from.
  31305. */
  31306. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  31307. /**
  31308. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  31309. * 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)
  31310. * @param channel Name of the sampler variable.
  31311. * @param postProcess Post process to get the output texture from.
  31312. */
  31313. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  31314. /** @hidden */
  31315. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  31316. /** @hidden */
  31317. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  31318. /** @hidden */
  31319. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  31320. /** @hidden */
  31321. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  31322. /**
  31323. * Binds a buffer to a uniform.
  31324. * @param buffer Buffer to bind.
  31325. * @param name Name of the uniform variable to bind to.
  31326. */
  31327. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  31328. /**
  31329. * Binds block to a uniform.
  31330. * @param blockName Name of the block to bind.
  31331. * @param index Index to bind.
  31332. */
  31333. bindUniformBlock(blockName: string, index: number): void;
  31334. /**
  31335. * Sets an interger value on a uniform variable.
  31336. * @param uniformName Name of the variable.
  31337. * @param value Value to be set.
  31338. * @returns this effect.
  31339. */
  31340. setInt(uniformName: string, value: number): Effect;
  31341. /**
  31342. * Sets an int array on a uniform variable.
  31343. * @param uniformName Name of the variable.
  31344. * @param array array to be set.
  31345. * @returns this effect.
  31346. */
  31347. setIntArray(uniformName: string, array: Int32Array): Effect;
  31348. /**
  31349. * 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)
  31350. * @param uniformName Name of the variable.
  31351. * @param array array to be set.
  31352. * @returns this effect.
  31353. */
  31354. setIntArray2(uniformName: string, array: Int32Array): Effect;
  31355. /**
  31356. * 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)
  31357. * @param uniformName Name of the variable.
  31358. * @param array array to be set.
  31359. * @returns this effect.
  31360. */
  31361. setIntArray3(uniformName: string, array: Int32Array): Effect;
  31362. /**
  31363. * 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)
  31364. * @param uniformName Name of the variable.
  31365. * @param array array to be set.
  31366. * @returns this effect.
  31367. */
  31368. setIntArray4(uniformName: string, array: Int32Array): Effect;
  31369. /**
  31370. * Sets an float array on a uniform variable.
  31371. * @param uniformName Name of the variable.
  31372. * @param array array to be set.
  31373. * @returns this effect.
  31374. */
  31375. setFloatArray(uniformName: string, array: Float32Array): Effect;
  31376. /**
  31377. * 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)
  31378. * @param uniformName Name of the variable.
  31379. * @param array array to be set.
  31380. * @returns this effect.
  31381. */
  31382. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  31383. /**
  31384. * 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)
  31385. * @param uniformName Name of the variable.
  31386. * @param array array to be set.
  31387. * @returns this effect.
  31388. */
  31389. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  31390. /**
  31391. * 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)
  31392. * @param uniformName Name of the variable.
  31393. * @param array array to be set.
  31394. * @returns this effect.
  31395. */
  31396. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31397. /**
  31398. * Sets an array on a uniform variable.
  31399. * @param uniformName Name of the variable.
  31400. * @param array array to be set.
  31401. * @returns this effect.
  31402. */
  31403. setArray(uniformName: string, array: number[]): Effect;
  31404. /**
  31405. * 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)
  31406. * @param uniformName Name of the variable.
  31407. * @param array array to be set.
  31408. * @returns this effect.
  31409. */
  31410. setArray2(uniformName: string, array: number[]): Effect;
  31411. /**
  31412. * 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)
  31413. * @param uniformName Name of the variable.
  31414. * @param array array to be set.
  31415. * @returns this effect.
  31416. */
  31417. setArray3(uniformName: string, array: number[]): Effect;
  31418. /**
  31419. * 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)
  31420. * @param uniformName Name of the variable.
  31421. * @param array array to be set.
  31422. * @returns this effect.
  31423. */
  31424. setArray4(uniformName: string, array: number[]): Effect;
  31425. /**
  31426. * Sets matrices on a uniform variable.
  31427. * @param uniformName Name of the variable.
  31428. * @param matrices matrices to be set.
  31429. * @returns this effect.
  31430. */
  31431. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31432. /**
  31433. * Sets matrix on a uniform variable.
  31434. * @param uniformName Name of the variable.
  31435. * @param matrix matrix to be set.
  31436. * @returns this effect.
  31437. */
  31438. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31439. /**
  31440. * 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)
  31441. * @param uniformName Name of the variable.
  31442. * @param matrix matrix to be set.
  31443. * @returns this effect.
  31444. */
  31445. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31446. /**
  31447. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31448. * @param uniformName Name of the variable.
  31449. * @param matrix matrix to be set.
  31450. * @returns this effect.
  31451. */
  31452. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31453. /**
  31454. * Sets a float on a uniform variable.
  31455. * @param uniformName Name of the variable.
  31456. * @param value value to be set.
  31457. * @returns this effect.
  31458. */
  31459. setFloat(uniformName: string, value: number): Effect;
  31460. /**
  31461. * Sets a boolean on a uniform variable.
  31462. * @param uniformName Name of the variable.
  31463. * @param bool value to be set.
  31464. * @returns this effect.
  31465. */
  31466. setBool(uniformName: string, bool: boolean): Effect;
  31467. /**
  31468. * Sets a Vector2 on a uniform variable.
  31469. * @param uniformName Name of the variable.
  31470. * @param vector2 vector2 to be set.
  31471. * @returns this effect.
  31472. */
  31473. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31474. /**
  31475. * Sets a float2 on a uniform variable.
  31476. * @param uniformName Name of the variable.
  31477. * @param x First float in float2.
  31478. * @param y Second float in float2.
  31479. * @returns this effect.
  31480. */
  31481. setFloat2(uniformName: string, x: number, y: number): Effect;
  31482. /**
  31483. * Sets a Vector3 on a uniform variable.
  31484. * @param uniformName Name of the variable.
  31485. * @param vector3 Value to be set.
  31486. * @returns this effect.
  31487. */
  31488. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31489. /**
  31490. * Sets a float3 on a uniform variable.
  31491. * @param uniformName Name of the variable.
  31492. * @param x First float in float3.
  31493. * @param y Second float in float3.
  31494. * @param z Third float in float3.
  31495. * @returns this effect.
  31496. */
  31497. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31498. /**
  31499. * Sets a Vector4 on a uniform variable.
  31500. * @param uniformName Name of the variable.
  31501. * @param vector4 Value to be set.
  31502. * @returns this effect.
  31503. */
  31504. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31505. /**
  31506. * Sets a float4 on a uniform variable.
  31507. * @param uniformName Name of the variable.
  31508. * @param x First float in float4.
  31509. * @param y Second float in float4.
  31510. * @param z Third float in float4.
  31511. * @param w Fourth float in float4.
  31512. * @returns this effect.
  31513. */
  31514. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31515. /**
  31516. * Sets a Color3 on a uniform variable.
  31517. * @param uniformName Name of the variable.
  31518. * @param color3 Value to be set.
  31519. * @returns this effect.
  31520. */
  31521. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31522. /**
  31523. * Sets a Color4 on a uniform variable.
  31524. * @param uniformName Name of the variable.
  31525. * @param color3 Value to be set.
  31526. * @param alpha Alpha value to be set.
  31527. * @returns this effect.
  31528. */
  31529. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31530. /**
  31531. * Sets a Color4 on a uniform variable
  31532. * @param uniformName defines the name of the variable
  31533. * @param color4 defines the value to be set
  31534. * @returns this effect.
  31535. */
  31536. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31537. /** Release all associated resources */
  31538. dispose(): void;
  31539. /**
  31540. * This function will add a new shader to the shader store
  31541. * @param name the name of the shader
  31542. * @param pixelShader optional pixel shader content
  31543. * @param vertexShader optional vertex shader content
  31544. */
  31545. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31546. /**
  31547. * Store of each shader (The can be looked up using effect.key)
  31548. */
  31549. static ShadersStore: {
  31550. [key: string]: string;
  31551. };
  31552. /**
  31553. * Store of each included file for a shader (The can be looked up using effect.key)
  31554. */
  31555. static IncludesShadersStore: {
  31556. [key: string]: string;
  31557. };
  31558. /**
  31559. * Resets the cache of effects.
  31560. */
  31561. static ResetCache(): void;
  31562. }
  31563. }
  31564. declare module "babylonjs/Engines/engineCapabilities" {
  31565. /**
  31566. * Interface used to describe the capabilities of the engine relatively to the current browser
  31567. */
  31568. export interface EngineCapabilities {
  31569. /** Maximum textures units per fragment shader */
  31570. maxTexturesImageUnits: number;
  31571. /** Maximum texture units per vertex shader */
  31572. maxVertexTextureImageUnits: number;
  31573. /** Maximum textures units in the entire pipeline */
  31574. maxCombinedTexturesImageUnits: number;
  31575. /** Maximum texture size */
  31576. maxTextureSize: number;
  31577. /** Maximum texture samples */
  31578. maxSamples?: number;
  31579. /** Maximum cube texture size */
  31580. maxCubemapTextureSize: number;
  31581. /** Maximum render texture size */
  31582. maxRenderTextureSize: number;
  31583. /** Maximum number of vertex attributes */
  31584. maxVertexAttribs: number;
  31585. /** Maximum number of varyings */
  31586. maxVaryingVectors: number;
  31587. /** Maximum number of uniforms per vertex shader */
  31588. maxVertexUniformVectors: number;
  31589. /** Maximum number of uniforms per fragment shader */
  31590. maxFragmentUniformVectors: number;
  31591. /** Defines if standard derivates (dx/dy) are supported */
  31592. standardDerivatives: boolean;
  31593. /** Defines if s3tc texture compression is supported */
  31594. s3tc?: WEBGL_compressed_texture_s3tc;
  31595. /** Defines if pvrtc texture compression is supported */
  31596. pvrtc: any;
  31597. /** Defines if etc1 texture compression is supported */
  31598. etc1: any;
  31599. /** Defines if etc2 texture compression is supported */
  31600. etc2: any;
  31601. /** Defines if astc texture compression is supported */
  31602. astc: any;
  31603. /** Defines if float textures are supported */
  31604. textureFloat: boolean;
  31605. /** Defines if vertex array objects are supported */
  31606. vertexArrayObject: boolean;
  31607. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31608. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31609. /** Gets the maximum level of anisotropy supported */
  31610. maxAnisotropy: number;
  31611. /** Defines if instancing is supported */
  31612. instancedArrays: boolean;
  31613. /** Defines if 32 bits indices are supported */
  31614. uintIndices: boolean;
  31615. /** Defines if high precision shaders are supported */
  31616. highPrecisionShaderSupported: boolean;
  31617. /** Defines if depth reading in the fragment shader is supported */
  31618. fragmentDepthSupported: boolean;
  31619. /** Defines if float texture linear filtering is supported*/
  31620. textureFloatLinearFiltering: boolean;
  31621. /** Defines if rendering to float textures is supported */
  31622. textureFloatRender: boolean;
  31623. /** Defines if half float textures are supported*/
  31624. textureHalfFloat: boolean;
  31625. /** Defines if half float texture linear filtering is supported*/
  31626. textureHalfFloatLinearFiltering: boolean;
  31627. /** Defines if rendering to half float textures is supported */
  31628. textureHalfFloatRender: boolean;
  31629. /** Defines if textureLOD shader command is supported */
  31630. textureLOD: boolean;
  31631. /** Defines if draw buffers extension is supported */
  31632. drawBuffersExtension: boolean;
  31633. /** Defines if depth textures are supported */
  31634. depthTextureExtension: boolean;
  31635. /** Defines if float color buffer are supported */
  31636. colorBufferFloat: boolean;
  31637. /** Gets disjoint timer query extension (null if not supported) */
  31638. timerQuery?: EXT_disjoint_timer_query;
  31639. /** Defines if timestamp can be used with timer query */
  31640. canUseTimestampForTimerQuery: boolean;
  31641. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31642. multiview?: any;
  31643. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31644. oculusMultiview?: any;
  31645. /** Function used to let the system compiles shaders in background */
  31646. parallelShaderCompile?: {
  31647. COMPLETION_STATUS_KHR: number;
  31648. };
  31649. /** Max number of texture samples for MSAA */
  31650. maxMSAASamples: number;
  31651. /** Defines if the blend min max extension is supported */
  31652. blendMinMax: boolean;
  31653. }
  31654. }
  31655. declare module "babylonjs/States/depthCullingState" {
  31656. import { Nullable } from "babylonjs/types";
  31657. /**
  31658. * @hidden
  31659. **/
  31660. export class DepthCullingState {
  31661. private _isDepthTestDirty;
  31662. private _isDepthMaskDirty;
  31663. private _isDepthFuncDirty;
  31664. private _isCullFaceDirty;
  31665. private _isCullDirty;
  31666. private _isZOffsetDirty;
  31667. private _isFrontFaceDirty;
  31668. private _depthTest;
  31669. private _depthMask;
  31670. private _depthFunc;
  31671. private _cull;
  31672. private _cullFace;
  31673. private _zOffset;
  31674. private _frontFace;
  31675. /**
  31676. * Initializes the state.
  31677. */
  31678. constructor();
  31679. get isDirty(): boolean;
  31680. get zOffset(): number;
  31681. set zOffset(value: number);
  31682. get cullFace(): Nullable<number>;
  31683. set cullFace(value: Nullable<number>);
  31684. get cull(): Nullable<boolean>;
  31685. set cull(value: Nullable<boolean>);
  31686. get depthFunc(): Nullable<number>;
  31687. set depthFunc(value: Nullable<number>);
  31688. get depthMask(): boolean;
  31689. set depthMask(value: boolean);
  31690. get depthTest(): boolean;
  31691. set depthTest(value: boolean);
  31692. get frontFace(): Nullable<number>;
  31693. set frontFace(value: Nullable<number>);
  31694. reset(): void;
  31695. apply(gl: WebGLRenderingContext): void;
  31696. }
  31697. }
  31698. declare module "babylonjs/States/stencilState" {
  31699. /**
  31700. * @hidden
  31701. **/
  31702. export class StencilState {
  31703. /** 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 */
  31704. static readonly ALWAYS: number;
  31705. /** Passed to stencilOperation to specify that stencil value must be kept */
  31706. static readonly KEEP: number;
  31707. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31708. static readonly REPLACE: number;
  31709. private _isStencilTestDirty;
  31710. private _isStencilMaskDirty;
  31711. private _isStencilFuncDirty;
  31712. private _isStencilOpDirty;
  31713. private _stencilTest;
  31714. private _stencilMask;
  31715. private _stencilFunc;
  31716. private _stencilFuncRef;
  31717. private _stencilFuncMask;
  31718. private _stencilOpStencilFail;
  31719. private _stencilOpDepthFail;
  31720. private _stencilOpStencilDepthPass;
  31721. get isDirty(): boolean;
  31722. get stencilFunc(): number;
  31723. set stencilFunc(value: number);
  31724. get stencilFuncRef(): number;
  31725. set stencilFuncRef(value: number);
  31726. get stencilFuncMask(): number;
  31727. set stencilFuncMask(value: number);
  31728. get stencilOpStencilFail(): number;
  31729. set stencilOpStencilFail(value: number);
  31730. get stencilOpDepthFail(): number;
  31731. set stencilOpDepthFail(value: number);
  31732. get stencilOpStencilDepthPass(): number;
  31733. set stencilOpStencilDepthPass(value: number);
  31734. get stencilMask(): number;
  31735. set stencilMask(value: number);
  31736. get stencilTest(): boolean;
  31737. set stencilTest(value: boolean);
  31738. constructor();
  31739. reset(): void;
  31740. apply(gl: WebGLRenderingContext): void;
  31741. }
  31742. }
  31743. declare module "babylonjs/States/alphaCullingState" {
  31744. /**
  31745. * @hidden
  31746. **/
  31747. export class AlphaState {
  31748. private _isAlphaBlendDirty;
  31749. private _isBlendFunctionParametersDirty;
  31750. private _isBlendEquationParametersDirty;
  31751. private _isBlendConstantsDirty;
  31752. private _alphaBlend;
  31753. private _blendFunctionParameters;
  31754. private _blendEquationParameters;
  31755. private _blendConstants;
  31756. /**
  31757. * Initializes the state.
  31758. */
  31759. constructor();
  31760. get isDirty(): boolean;
  31761. get alphaBlend(): boolean;
  31762. set alphaBlend(value: boolean);
  31763. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31764. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31765. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31766. reset(): void;
  31767. apply(gl: WebGLRenderingContext): void;
  31768. }
  31769. }
  31770. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31771. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31772. /** @hidden */
  31773. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31774. attributeProcessor(attribute: string): string;
  31775. varyingProcessor(varying: string, isFragment: boolean): string;
  31776. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31777. }
  31778. }
  31779. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31780. /**
  31781. * Interface for attribute information associated with buffer instanciation
  31782. */
  31783. export interface InstancingAttributeInfo {
  31784. /**
  31785. * Name of the GLSL attribute
  31786. * if attribute index is not specified, this is used to retrieve the index from the effect
  31787. */
  31788. attributeName: string;
  31789. /**
  31790. * Index/offset of the attribute in the vertex shader
  31791. * if not specified, this will be computes from the name.
  31792. */
  31793. index?: number;
  31794. /**
  31795. * size of the attribute, 1, 2, 3 or 4
  31796. */
  31797. attributeSize: number;
  31798. /**
  31799. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31800. */
  31801. offset: number;
  31802. /**
  31803. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31804. * default to 1
  31805. */
  31806. divisor?: number;
  31807. /**
  31808. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31809. * default is FLOAT
  31810. */
  31811. attributeType?: number;
  31812. /**
  31813. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31814. */
  31815. normalized?: boolean;
  31816. }
  31817. }
  31818. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  31819. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31820. import { Nullable } from "babylonjs/types";
  31821. module "babylonjs/Engines/thinEngine" {
  31822. interface ThinEngine {
  31823. /**
  31824. * Update a video texture
  31825. * @param texture defines the texture to update
  31826. * @param video defines the video element to use
  31827. * @param invertY defines if data must be stored with Y axis inverted
  31828. */
  31829. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31830. }
  31831. }
  31832. }
  31833. declare module "babylonjs/Materials/Textures/videoTexture" {
  31834. import { Observable } from "babylonjs/Misc/observable";
  31835. import { Nullable } from "babylonjs/types";
  31836. import { Scene } from "babylonjs/scene";
  31837. import { Texture } from "babylonjs/Materials/Textures/texture";
  31838. import "babylonjs/Engines/Extensions/engine.videoTexture";
  31839. /**
  31840. * Settings for finer control over video usage
  31841. */
  31842. export interface VideoTextureSettings {
  31843. /**
  31844. * Applies `autoplay` to video, if specified
  31845. */
  31846. autoPlay?: boolean;
  31847. /**
  31848. * Applies `loop` to video, if specified
  31849. */
  31850. loop?: boolean;
  31851. /**
  31852. * Automatically updates internal texture from video at every frame in the render loop
  31853. */
  31854. autoUpdateTexture: boolean;
  31855. /**
  31856. * Image src displayed during the video loading or until the user interacts with the video.
  31857. */
  31858. poster?: string;
  31859. }
  31860. /**
  31861. * If you want to display a video in your scene, this is the special texture for that.
  31862. * This special texture works similar to other textures, with the exception of a few parameters.
  31863. * @see https://doc.babylonjs.com/how_to/video_texture
  31864. */
  31865. export class VideoTexture extends Texture {
  31866. /**
  31867. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31868. */
  31869. readonly autoUpdateTexture: boolean;
  31870. /**
  31871. * The video instance used by the texture internally
  31872. */
  31873. readonly video: HTMLVideoElement;
  31874. private _onUserActionRequestedObservable;
  31875. /**
  31876. * Event triggerd when a dom action is required by the user to play the video.
  31877. * This happens due to recent changes in browser policies preventing video to auto start.
  31878. */
  31879. get onUserActionRequestedObservable(): Observable<Texture>;
  31880. private _generateMipMaps;
  31881. private _engine;
  31882. private _stillImageCaptured;
  31883. private _displayingPosterTexture;
  31884. private _settings;
  31885. private _createInternalTextureOnEvent;
  31886. private _frameId;
  31887. private _currentSrc;
  31888. /**
  31889. * Creates a video texture.
  31890. * If you want to display a video in your scene, this is the special texture for that.
  31891. * This special texture works similar to other textures, with the exception of a few parameters.
  31892. * @see https://doc.babylonjs.com/how_to/video_texture
  31893. * @param name optional name, will detect from video source, if not defined
  31894. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31895. * @param scene is obviously the current scene.
  31896. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31897. * @param invertY is false by default but can be used to invert video on Y axis
  31898. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31899. * @param settings allows finer control over video usage
  31900. */
  31901. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31902. private _getName;
  31903. private _getVideo;
  31904. private _createInternalTexture;
  31905. private reset;
  31906. /**
  31907. * @hidden Internal method to initiate `update`.
  31908. */
  31909. _rebuild(): void;
  31910. /**
  31911. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31912. */
  31913. update(): void;
  31914. /**
  31915. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31916. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31917. */
  31918. updateTexture(isVisible: boolean): void;
  31919. protected _updateInternalTexture: () => void;
  31920. /**
  31921. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31922. * @param url New url.
  31923. */
  31924. updateURL(url: string): void;
  31925. /**
  31926. * Clones the texture.
  31927. * @returns the cloned texture
  31928. */
  31929. clone(): VideoTexture;
  31930. /**
  31931. * Dispose the texture and release its associated resources.
  31932. */
  31933. dispose(): void;
  31934. /**
  31935. * Creates a video texture straight from a stream.
  31936. * @param scene Define the scene the texture should be created in
  31937. * @param stream Define the stream the texture should be created from
  31938. * @returns The created video texture as a promise
  31939. */
  31940. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31941. /**
  31942. * Creates a video texture straight from your WebCam video feed.
  31943. * @param scene Define the scene the texture should be created in
  31944. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31945. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31946. * @returns The created video texture as a promise
  31947. */
  31948. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31949. minWidth: number;
  31950. maxWidth: number;
  31951. minHeight: number;
  31952. maxHeight: number;
  31953. deviceId: string;
  31954. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31955. /**
  31956. * Creates a video texture straight from your WebCam video feed.
  31957. * @param scene Define the scene the texture should be created in
  31958. * @param onReady Define a callback to triggered once the texture will be ready
  31959. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31960. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31961. */
  31962. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31963. minWidth: number;
  31964. maxWidth: number;
  31965. minHeight: number;
  31966. maxHeight: number;
  31967. deviceId: string;
  31968. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31969. }
  31970. }
  31971. declare module "babylonjs/Engines/thinEngine" {
  31972. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  31973. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  31974. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31975. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31976. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  31977. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  31978. import { Observable } from "babylonjs/Misc/observable";
  31979. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  31980. import { StencilState } from "babylonjs/States/stencilState";
  31981. import { AlphaState } from "babylonjs/States/alphaCullingState";
  31982. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31983. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31984. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31985. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  31986. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31987. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31988. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31989. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  31990. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31991. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31992. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31993. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  31994. import { WebRequest } from "babylonjs/Misc/webRequest";
  31995. import { LoadFileError } from "babylonjs/Misc/fileTools";
  31996. /**
  31997. * Defines the interface used by objects working like Scene
  31998. * @hidden
  31999. */
  32000. export interface ISceneLike {
  32001. _addPendingData(data: any): void;
  32002. _removePendingData(data: any): void;
  32003. offlineProvider: IOfflineProvider;
  32004. }
  32005. /** Interface defining initialization parameters for Engine class */
  32006. export interface EngineOptions extends WebGLContextAttributes {
  32007. /**
  32008. * Defines if the engine should no exceed a specified device ratio
  32009. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  32010. */
  32011. limitDeviceRatio?: number;
  32012. /**
  32013. * Defines if webvr should be enabled automatically
  32014. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32015. */
  32016. autoEnableWebVR?: boolean;
  32017. /**
  32018. * Defines if webgl2 should be turned off even if supported
  32019. * @see http://doc.babylonjs.com/features/webgl2
  32020. */
  32021. disableWebGL2Support?: boolean;
  32022. /**
  32023. * Defines if webaudio should be initialized as well
  32024. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32025. */
  32026. audioEngine?: boolean;
  32027. /**
  32028. * Defines if animations should run using a deterministic lock step
  32029. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32030. */
  32031. deterministicLockstep?: boolean;
  32032. /** Defines the maximum steps to use with deterministic lock step mode */
  32033. lockstepMaxSteps?: number;
  32034. /** Defines the seconds between each deterministic lock step */
  32035. timeStep?: number;
  32036. /**
  32037. * Defines that engine should ignore context lost events
  32038. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  32039. */
  32040. doNotHandleContextLost?: boolean;
  32041. /**
  32042. * Defines that engine should ignore modifying touch action attribute and style
  32043. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  32044. */
  32045. doNotHandleTouchAction?: boolean;
  32046. /**
  32047. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  32048. */
  32049. useHighPrecisionFloats?: boolean;
  32050. }
  32051. /**
  32052. * The base engine class (root of all engines)
  32053. */
  32054. export class ThinEngine {
  32055. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  32056. static ExceptionList: ({
  32057. key: string;
  32058. capture: string;
  32059. captureConstraint: number;
  32060. targets: string[];
  32061. } | {
  32062. key: string;
  32063. capture: null;
  32064. captureConstraint: null;
  32065. targets: string[];
  32066. })[];
  32067. /** @hidden */
  32068. static _TextureLoaders: IInternalTextureLoader[];
  32069. /**
  32070. * Returns the current npm package of the sdk
  32071. */
  32072. static get NpmPackage(): string;
  32073. /**
  32074. * Returns the current version of the framework
  32075. */
  32076. static get Version(): string;
  32077. /**
  32078. * Returns a string describing the current engine
  32079. */
  32080. get description(): string;
  32081. /**
  32082. * Gets or sets the epsilon value used by collision engine
  32083. */
  32084. static CollisionsEpsilon: number;
  32085. /**
  32086. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  32087. */
  32088. static get ShadersRepository(): string;
  32089. static set ShadersRepository(value: string);
  32090. /** @hidden */
  32091. _shaderProcessor: IShaderProcessor;
  32092. /**
  32093. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  32094. */
  32095. forcePOTTextures: boolean;
  32096. /**
  32097. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  32098. */
  32099. isFullscreen: boolean;
  32100. /**
  32101. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  32102. */
  32103. cullBackFaces: boolean;
  32104. /**
  32105. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  32106. */
  32107. renderEvenInBackground: boolean;
  32108. /**
  32109. * Gets or sets a boolean indicating that cache can be kept between frames
  32110. */
  32111. preventCacheWipeBetweenFrames: boolean;
  32112. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  32113. validateShaderPrograms: boolean;
  32114. /**
  32115. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  32116. * This can provide greater z depth for distant objects.
  32117. */
  32118. useReverseDepthBuffer: boolean;
  32119. /**
  32120. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  32121. */
  32122. disableUniformBuffers: boolean;
  32123. /** @hidden */
  32124. _uniformBuffers: UniformBuffer[];
  32125. /**
  32126. * Gets a boolean indicating that the engine supports uniform buffers
  32127. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  32128. */
  32129. get supportsUniformBuffers(): boolean;
  32130. /** @hidden */
  32131. _gl: WebGLRenderingContext;
  32132. /** @hidden */
  32133. _webGLVersion: number;
  32134. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  32135. protected _windowIsBackground: boolean;
  32136. protected _creationOptions: EngineOptions;
  32137. protected _highPrecisionShadersAllowed: boolean;
  32138. /** @hidden */
  32139. get _shouldUseHighPrecisionShader(): boolean;
  32140. /**
  32141. * Gets a boolean indicating that only power of 2 textures are supported
  32142. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  32143. */
  32144. get needPOTTextures(): boolean;
  32145. /** @hidden */
  32146. _badOS: boolean;
  32147. /** @hidden */
  32148. _badDesktopOS: boolean;
  32149. private _hardwareScalingLevel;
  32150. /** @hidden */
  32151. _caps: EngineCapabilities;
  32152. private _isStencilEnable;
  32153. private _glVersion;
  32154. private _glRenderer;
  32155. private _glVendor;
  32156. /** @hidden */
  32157. _videoTextureSupported: boolean;
  32158. protected _renderingQueueLaunched: boolean;
  32159. protected _activeRenderLoops: (() => void)[];
  32160. /**
  32161. * Observable signaled when a context lost event is raised
  32162. */
  32163. onContextLostObservable: Observable<ThinEngine>;
  32164. /**
  32165. * Observable signaled when a context restored event is raised
  32166. */
  32167. onContextRestoredObservable: Observable<ThinEngine>;
  32168. private _onContextLost;
  32169. private _onContextRestored;
  32170. protected _contextWasLost: boolean;
  32171. /** @hidden */
  32172. _doNotHandleContextLost: boolean;
  32173. /**
  32174. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  32175. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  32176. */
  32177. get doNotHandleContextLost(): boolean;
  32178. set doNotHandleContextLost(value: boolean);
  32179. /**
  32180. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  32181. */
  32182. disableVertexArrayObjects: boolean;
  32183. /** @hidden */
  32184. protected _colorWrite: boolean;
  32185. /** @hidden */
  32186. protected _colorWriteChanged: boolean;
  32187. /** @hidden */
  32188. protected _depthCullingState: DepthCullingState;
  32189. /** @hidden */
  32190. protected _stencilState: StencilState;
  32191. /** @hidden */
  32192. _alphaState: AlphaState;
  32193. /** @hidden */
  32194. _alphaMode: number;
  32195. /** @hidden */
  32196. _alphaEquation: number;
  32197. /** @hidden */
  32198. _internalTexturesCache: InternalTexture[];
  32199. /** @hidden */
  32200. protected _activeChannel: number;
  32201. private _currentTextureChannel;
  32202. /** @hidden */
  32203. protected _boundTexturesCache: {
  32204. [key: string]: Nullable<InternalTexture>;
  32205. };
  32206. /** @hidden */
  32207. protected _currentEffect: Nullable<Effect>;
  32208. /** @hidden */
  32209. protected _currentProgram: Nullable<WebGLProgram>;
  32210. private _compiledEffects;
  32211. private _vertexAttribArraysEnabled;
  32212. /** @hidden */
  32213. protected _cachedViewport: Nullable<IViewportLike>;
  32214. private _cachedVertexArrayObject;
  32215. /** @hidden */
  32216. protected _cachedVertexBuffers: any;
  32217. /** @hidden */
  32218. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  32219. /** @hidden */
  32220. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  32221. /** @hidden */
  32222. _currentRenderTarget: Nullable<InternalTexture>;
  32223. private _uintIndicesCurrentlySet;
  32224. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  32225. /** @hidden */
  32226. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  32227. private _currentBufferPointers;
  32228. private _currentInstanceLocations;
  32229. private _currentInstanceBuffers;
  32230. private _textureUnits;
  32231. /** @hidden */
  32232. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32233. /** @hidden */
  32234. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32235. /** @hidden */
  32236. _boundRenderFunction: any;
  32237. private _vaoRecordInProgress;
  32238. private _mustWipeVertexAttributes;
  32239. private _emptyTexture;
  32240. private _emptyCubeTexture;
  32241. private _emptyTexture3D;
  32242. private _emptyTexture2DArray;
  32243. /** @hidden */
  32244. _frameHandler: number;
  32245. private _nextFreeTextureSlots;
  32246. private _maxSimultaneousTextures;
  32247. private _activeRequests;
  32248. protected _texturesSupported: string[];
  32249. /** @hidden */
  32250. _textureFormatInUse: Nullable<string>;
  32251. protected get _supportsHardwareTextureRescaling(): boolean;
  32252. private _framebufferDimensionsObject;
  32253. /**
  32254. * sets the object from which width and height will be taken from when getting render width and height
  32255. * Will fallback to the gl object
  32256. * @param dimensions the framebuffer width and height that will be used.
  32257. */
  32258. set framebufferDimensionsObject(dimensions: Nullable<{
  32259. framebufferWidth: number;
  32260. framebufferHeight: number;
  32261. }>);
  32262. /**
  32263. * Gets the list of texture formats supported
  32264. */
  32265. get texturesSupported(): Array<string>;
  32266. /**
  32267. * Gets the list of texture formats in use
  32268. */
  32269. get textureFormatInUse(): Nullable<string>;
  32270. /**
  32271. * Gets the current viewport
  32272. */
  32273. get currentViewport(): Nullable<IViewportLike>;
  32274. /**
  32275. * Gets the default empty texture
  32276. */
  32277. get emptyTexture(): InternalTexture;
  32278. /**
  32279. * Gets the default empty 3D texture
  32280. */
  32281. get emptyTexture3D(): InternalTexture;
  32282. /**
  32283. * Gets the default empty 2D array texture
  32284. */
  32285. get emptyTexture2DArray(): InternalTexture;
  32286. /**
  32287. * Gets the default empty cube texture
  32288. */
  32289. get emptyCubeTexture(): InternalTexture;
  32290. /**
  32291. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  32292. */
  32293. readonly premultipliedAlpha: boolean;
  32294. /**
  32295. * Observable event triggered before each texture is initialized
  32296. */
  32297. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32298. /**
  32299. * Creates a new engine
  32300. * @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
  32301. * @param antialias defines enable antialiasing (default: false)
  32302. * @param options defines further options to be sent to the getContext() function
  32303. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32304. */
  32305. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32306. private _rebuildInternalTextures;
  32307. private _rebuildEffects;
  32308. /**
  32309. * Gets a boolean indicating if all created effects are ready
  32310. * @returns true if all effects are ready
  32311. */
  32312. areAllEffectsReady(): boolean;
  32313. protected _rebuildBuffers(): void;
  32314. private _initGLContext;
  32315. /**
  32316. * Gets version of the current webGL context
  32317. */
  32318. get webGLVersion(): number;
  32319. /**
  32320. * Gets a string idenfifying the name of the class
  32321. * @returns "Engine" string
  32322. */
  32323. getClassName(): string;
  32324. /**
  32325. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  32326. */
  32327. get isStencilEnable(): boolean;
  32328. /** @hidden */
  32329. _prepareWorkingCanvas(): void;
  32330. /**
  32331. * Reset the texture cache to empty state
  32332. */
  32333. resetTextureCache(): void;
  32334. /**
  32335. * Gets an object containing information about the current webGL context
  32336. * @returns an object containing the vender, the renderer and the version of the current webGL context
  32337. */
  32338. getGlInfo(): {
  32339. vendor: string;
  32340. renderer: string;
  32341. version: string;
  32342. };
  32343. /**
  32344. * Defines the hardware scaling level.
  32345. * By default the hardware scaling level is computed from the window device ratio.
  32346. * 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.
  32347. * @param level defines the level to use
  32348. */
  32349. setHardwareScalingLevel(level: number): void;
  32350. /**
  32351. * Gets the current hardware scaling level.
  32352. * By default the hardware scaling level is computed from the window device ratio.
  32353. * 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.
  32354. * @returns a number indicating the current hardware scaling level
  32355. */
  32356. getHardwareScalingLevel(): number;
  32357. /**
  32358. * Gets the list of loaded textures
  32359. * @returns an array containing all loaded textures
  32360. */
  32361. getLoadedTexturesCache(): InternalTexture[];
  32362. /**
  32363. * Gets the object containing all engine capabilities
  32364. * @returns the EngineCapabilities object
  32365. */
  32366. getCaps(): EngineCapabilities;
  32367. /**
  32368. * stop executing a render loop function and remove it from the execution array
  32369. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  32370. */
  32371. stopRenderLoop(renderFunction?: () => void): void;
  32372. /** @hidden */
  32373. _renderLoop(): void;
  32374. /**
  32375. * Gets the HTML canvas attached with the current webGL context
  32376. * @returns a HTML canvas
  32377. */
  32378. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  32379. /**
  32380. * Gets host window
  32381. * @returns the host window object
  32382. */
  32383. getHostWindow(): Nullable<Window>;
  32384. /**
  32385. * Gets the current render width
  32386. * @param useScreen defines if screen size must be used (or the current render target if any)
  32387. * @returns a number defining the current render width
  32388. */
  32389. getRenderWidth(useScreen?: boolean): number;
  32390. /**
  32391. * Gets the current render height
  32392. * @param useScreen defines if screen size must be used (or the current render target if any)
  32393. * @returns a number defining the current render height
  32394. */
  32395. getRenderHeight(useScreen?: boolean): number;
  32396. /**
  32397. * Can be used to override the current requestAnimationFrame requester.
  32398. * @hidden
  32399. */
  32400. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32401. /**
  32402. * Register and execute a render loop. The engine can have more than one render function
  32403. * @param renderFunction defines the function to continuously execute
  32404. */
  32405. runRenderLoop(renderFunction: () => void): void;
  32406. /**
  32407. * Clear the current render buffer or the current render target (if any is set up)
  32408. * @param color defines the color to use
  32409. * @param backBuffer defines if the back buffer must be cleared
  32410. * @param depth defines if the depth buffer must be cleared
  32411. * @param stencil defines if the stencil buffer must be cleared
  32412. */
  32413. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32414. private _viewportCached;
  32415. /** @hidden */
  32416. _viewport(x: number, y: number, width: number, height: number): void;
  32417. /**
  32418. * Set the WebGL's viewport
  32419. * @param viewport defines the viewport element to be used
  32420. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32421. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32422. */
  32423. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32424. /**
  32425. * Begin a new frame
  32426. */
  32427. beginFrame(): void;
  32428. /**
  32429. * Enf the current frame
  32430. */
  32431. endFrame(): void;
  32432. /**
  32433. * Resize the view according to the canvas' size
  32434. */
  32435. resize(): void;
  32436. /**
  32437. * Force a specific size of the canvas
  32438. * @param width defines the new canvas' width
  32439. * @param height defines the new canvas' height
  32440. */
  32441. setSize(width: number, height: number): void;
  32442. /**
  32443. * Binds the frame buffer to the specified texture.
  32444. * @param texture The texture to render to or null for the default canvas
  32445. * @param faceIndex The face of the texture to render to in case of cube texture
  32446. * @param requiredWidth The width of the target to render to
  32447. * @param requiredHeight The height of the target to render to
  32448. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32449. * @param lodLevel defines the lod level to bind to the frame buffer
  32450. * @param layer defines the 2d array index to bind to frame buffer to
  32451. */
  32452. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  32453. /** @hidden */
  32454. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32455. /**
  32456. * Unbind the current render target texture from the webGL context
  32457. * @param texture defines the render target texture to unbind
  32458. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32459. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32460. */
  32461. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32462. /**
  32463. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32464. */
  32465. flushFramebuffer(): void;
  32466. /**
  32467. * Unbind the current render target and bind the default framebuffer
  32468. */
  32469. restoreDefaultFramebuffer(): void;
  32470. /** @hidden */
  32471. protected _resetVertexBufferBinding(): void;
  32472. /**
  32473. * Creates a vertex buffer
  32474. * @param data the data for the vertex buffer
  32475. * @returns the new WebGL static buffer
  32476. */
  32477. createVertexBuffer(data: DataArray): DataBuffer;
  32478. private _createVertexBuffer;
  32479. /**
  32480. * Creates a dynamic vertex buffer
  32481. * @param data the data for the dynamic vertex buffer
  32482. * @returns the new WebGL dynamic buffer
  32483. */
  32484. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32485. protected _resetIndexBufferBinding(): void;
  32486. /**
  32487. * Creates a new index buffer
  32488. * @param indices defines the content of the index buffer
  32489. * @param updatable defines if the index buffer must be updatable
  32490. * @returns a new webGL buffer
  32491. */
  32492. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32493. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32494. /**
  32495. * Bind a webGL buffer to the webGL context
  32496. * @param buffer defines the buffer to bind
  32497. */
  32498. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32499. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32500. private bindBuffer;
  32501. /**
  32502. * update the bound buffer with the given data
  32503. * @param data defines the data to update
  32504. */
  32505. updateArrayBuffer(data: Float32Array): void;
  32506. private _vertexAttribPointer;
  32507. /** @hidden */
  32508. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  32509. private _bindVertexBuffersAttributes;
  32510. /**
  32511. * Records a vertex array object
  32512. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32513. * @param vertexBuffers defines the list of vertex buffers to store
  32514. * @param indexBuffer defines the index buffer to store
  32515. * @param effect defines the effect to store
  32516. * @returns the new vertex array object
  32517. */
  32518. recordVertexArrayObject(vertexBuffers: {
  32519. [key: string]: VertexBuffer;
  32520. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32521. /**
  32522. * Bind a specific vertex array object
  32523. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32524. * @param vertexArrayObject defines the vertex array object to bind
  32525. * @param indexBuffer defines the index buffer to bind
  32526. */
  32527. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32528. /**
  32529. * Bind webGl buffers directly to the webGL context
  32530. * @param vertexBuffer defines the vertex buffer to bind
  32531. * @param indexBuffer defines the index buffer to bind
  32532. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32533. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32534. * @param effect defines the effect associated with the vertex buffer
  32535. */
  32536. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32537. private _unbindVertexArrayObject;
  32538. /**
  32539. * Bind a list of vertex buffers to the webGL context
  32540. * @param vertexBuffers defines the list of vertex buffers to bind
  32541. * @param indexBuffer defines the index buffer to bind
  32542. * @param effect defines the effect associated with the vertex buffers
  32543. */
  32544. bindBuffers(vertexBuffers: {
  32545. [key: string]: Nullable<VertexBuffer>;
  32546. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32547. /**
  32548. * Unbind all instance attributes
  32549. */
  32550. unbindInstanceAttributes(): void;
  32551. /**
  32552. * Release and free the memory of a vertex array object
  32553. * @param vao defines the vertex array object to delete
  32554. */
  32555. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32556. /** @hidden */
  32557. _releaseBuffer(buffer: DataBuffer): boolean;
  32558. protected _deleteBuffer(buffer: DataBuffer): void;
  32559. /**
  32560. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32561. * @param instancesBuffer defines the webGL buffer to update and bind
  32562. * @param data defines the data to store in the buffer
  32563. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32564. */
  32565. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32566. /**
  32567. * Bind the content of a webGL buffer used with instantiation
  32568. * @param instancesBuffer defines the webGL buffer to bind
  32569. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32570. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  32571. */
  32572. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32573. /**
  32574. * Disable the instance attribute corresponding to the name in parameter
  32575. * @param name defines the name of the attribute to disable
  32576. */
  32577. disableInstanceAttributeByName(name: string): void;
  32578. /**
  32579. * Disable the instance attribute corresponding to the location in parameter
  32580. * @param attributeLocation defines the attribute location of the attribute to disable
  32581. */
  32582. disableInstanceAttribute(attributeLocation: number): void;
  32583. /**
  32584. * Disable the attribute corresponding to the location in parameter
  32585. * @param attributeLocation defines the attribute location of the attribute to disable
  32586. */
  32587. disableAttributeByIndex(attributeLocation: number): void;
  32588. /**
  32589. * Send a draw order
  32590. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32591. * @param indexStart defines the starting index
  32592. * @param indexCount defines the number of index to draw
  32593. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32594. */
  32595. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32596. /**
  32597. * Draw a list of points
  32598. * @param verticesStart defines the index of first vertex to draw
  32599. * @param verticesCount defines the count of vertices to draw
  32600. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32601. */
  32602. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32603. /**
  32604. * Draw a list of unindexed primitives
  32605. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32606. * @param verticesStart defines the index of first vertex to draw
  32607. * @param verticesCount defines the count of vertices to draw
  32608. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32609. */
  32610. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32611. /**
  32612. * Draw a list of indexed primitives
  32613. * @param fillMode defines the primitive to use
  32614. * @param indexStart defines the starting index
  32615. * @param indexCount defines the number of index to draw
  32616. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32617. */
  32618. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32619. /**
  32620. * Draw a list of unindexed primitives
  32621. * @param fillMode defines the primitive to use
  32622. * @param verticesStart defines the index of first vertex to draw
  32623. * @param verticesCount defines the count of vertices to draw
  32624. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32625. */
  32626. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32627. private _drawMode;
  32628. /** @hidden */
  32629. protected _reportDrawCall(): void;
  32630. /** @hidden */
  32631. _releaseEffect(effect: Effect): void;
  32632. /** @hidden */
  32633. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32634. /**
  32635. * Create a new effect (used to store vertex/fragment shaders)
  32636. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32637. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32638. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32639. * @param samplers defines an array of string used to represent textures
  32640. * @param defines defines the string containing the defines to use to compile the shaders
  32641. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32642. * @param onCompiled defines a function to call when the effect creation is successful
  32643. * @param onError defines a function to call when the effect creation has failed
  32644. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32645. * @returns the new Effect
  32646. */
  32647. 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;
  32648. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32649. private _compileShader;
  32650. private _compileRawShader;
  32651. /** @hidden */
  32652. _getShaderSource(shader: WebGLShader): Nullable<string>;
  32653. /**
  32654. * Directly creates a webGL program
  32655. * @param pipelineContext defines the pipeline context to attach to
  32656. * @param vertexCode defines the vertex shader code to use
  32657. * @param fragmentCode defines the fragment shader code to use
  32658. * @param context defines the webGL context to use (if not set, the current one will be used)
  32659. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32660. * @returns the new webGL program
  32661. */
  32662. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32663. /**
  32664. * Creates a webGL program
  32665. * @param pipelineContext defines the pipeline context to attach to
  32666. * @param vertexCode defines the vertex shader code to use
  32667. * @param fragmentCode defines the fragment shader code to use
  32668. * @param defines defines the string containing the defines to use to compile the shaders
  32669. * @param context defines the webGL context to use (if not set, the current one will be used)
  32670. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32671. * @returns the new webGL program
  32672. */
  32673. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32674. /**
  32675. * Creates a new pipeline context
  32676. * @returns the new pipeline
  32677. */
  32678. createPipelineContext(): IPipelineContext;
  32679. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32680. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32681. /** @hidden */
  32682. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32683. /** @hidden */
  32684. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32685. /** @hidden */
  32686. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32687. /**
  32688. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32689. * @param pipelineContext defines the pipeline context to use
  32690. * @param uniformsNames defines the list of uniform names
  32691. * @returns an array of webGL uniform locations
  32692. */
  32693. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32694. /**
  32695. * Gets the lsit of active attributes for a given webGL program
  32696. * @param pipelineContext defines the pipeline context to use
  32697. * @param attributesNames defines the list of attribute names to get
  32698. * @returns an array of indices indicating the offset of each attribute
  32699. */
  32700. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32701. /**
  32702. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32703. * @param effect defines the effect to activate
  32704. */
  32705. enableEffect(effect: Nullable<Effect>): void;
  32706. /**
  32707. * Set the value of an uniform to a number (int)
  32708. * @param uniform defines the webGL uniform location where to store the value
  32709. * @param value defines the int number to store
  32710. */
  32711. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32712. /**
  32713. * Set the value of an uniform to an array of int32
  32714. * @param uniform defines the webGL uniform location where to store the value
  32715. * @param array defines the array of int32 to store
  32716. */
  32717. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32718. /**
  32719. * Set the value of an uniform to an array of int32 (stored as vec2)
  32720. * @param uniform defines the webGL uniform location where to store the value
  32721. * @param array defines the array of int32 to store
  32722. */
  32723. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32724. /**
  32725. * Set the value of an uniform to an array of int32 (stored as vec3)
  32726. * @param uniform defines the webGL uniform location where to store the value
  32727. * @param array defines the array of int32 to store
  32728. */
  32729. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32730. /**
  32731. * Set the value of an uniform to an array of int32 (stored as vec4)
  32732. * @param uniform defines the webGL uniform location where to store the value
  32733. * @param array defines the array of int32 to store
  32734. */
  32735. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32736. /**
  32737. * Set the value of an uniform to an array of number
  32738. * @param uniform defines the webGL uniform location where to store the value
  32739. * @param array defines the array of number to store
  32740. */
  32741. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32742. /**
  32743. * Set the value of an uniform to an array of number (stored as vec2)
  32744. * @param uniform defines the webGL uniform location where to store the value
  32745. * @param array defines the array of number to store
  32746. */
  32747. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32748. /**
  32749. * Set the value of an uniform to an array of number (stored as vec3)
  32750. * @param uniform defines the webGL uniform location where to store the value
  32751. * @param array defines the array of number to store
  32752. */
  32753. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32754. /**
  32755. * Set the value of an uniform to an array of number (stored as vec4)
  32756. * @param uniform defines the webGL uniform location where to store the value
  32757. * @param array defines the array of number to store
  32758. */
  32759. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32760. /**
  32761. * Set the value of an uniform to an array of float32 (stored as matrices)
  32762. * @param uniform defines the webGL uniform location where to store the value
  32763. * @param matrices defines the array of float32 to store
  32764. */
  32765. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32766. /**
  32767. * Set the value of an uniform to a matrix (3x3)
  32768. * @param uniform defines the webGL uniform location where to store the value
  32769. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32770. */
  32771. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32772. /**
  32773. * Set the value of an uniform to a matrix (2x2)
  32774. * @param uniform defines the webGL uniform location where to store the value
  32775. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32776. */
  32777. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32778. /**
  32779. * Set the value of an uniform to a number (float)
  32780. * @param uniform defines the webGL uniform location where to store the value
  32781. * @param value defines the float number to store
  32782. */
  32783. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32784. /**
  32785. * Set the value of an uniform to a vec2
  32786. * @param uniform defines the webGL uniform location where to store the value
  32787. * @param x defines the 1st component of the value
  32788. * @param y defines the 2nd component of the value
  32789. */
  32790. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32791. /**
  32792. * Set the value of an uniform to a vec3
  32793. * @param uniform defines the webGL uniform location where to store the value
  32794. * @param x defines the 1st component of the value
  32795. * @param y defines the 2nd component of the value
  32796. * @param z defines the 3rd component of the value
  32797. */
  32798. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32799. /**
  32800. * Set the value of an uniform to a vec4
  32801. * @param uniform defines the webGL uniform location where to store the value
  32802. * @param x defines the 1st component of the value
  32803. * @param y defines the 2nd component of the value
  32804. * @param z defines the 3rd component of the value
  32805. * @param w defines the 4th component of the value
  32806. */
  32807. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32808. /**
  32809. * Apply all cached states (depth, culling, stencil and alpha)
  32810. */
  32811. applyStates(): void;
  32812. /**
  32813. * Enable or disable color writing
  32814. * @param enable defines the state to set
  32815. */
  32816. setColorWrite(enable: boolean): void;
  32817. /**
  32818. * Gets a boolean indicating if color writing is enabled
  32819. * @returns the current color writing state
  32820. */
  32821. getColorWrite(): boolean;
  32822. /**
  32823. * Gets the depth culling state manager
  32824. */
  32825. get depthCullingState(): DepthCullingState;
  32826. /**
  32827. * Gets the alpha state manager
  32828. */
  32829. get alphaState(): AlphaState;
  32830. /**
  32831. * Gets the stencil state manager
  32832. */
  32833. get stencilState(): StencilState;
  32834. /**
  32835. * Clears the list of texture accessible through engine.
  32836. * This can help preventing texture load conflict due to name collision.
  32837. */
  32838. clearInternalTexturesCache(): void;
  32839. /**
  32840. * Force the entire cache to be cleared
  32841. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32842. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32843. */
  32844. wipeCaches(bruteForce?: boolean): void;
  32845. /** @hidden */
  32846. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32847. min: number;
  32848. mag: number;
  32849. };
  32850. /** @hidden */
  32851. _createTexture(): WebGLTexture;
  32852. /**
  32853. * Usually called from Texture.ts.
  32854. * Passed information to create a WebGLTexture
  32855. * @param urlArg defines a value which contains one of the following:
  32856. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32857. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32858. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32859. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32860. * @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)
  32861. * @param scene needed for loading to the correct scene
  32862. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32863. * @param onLoad optional callback to be called upon successful completion
  32864. * @param onError optional callback to be called upon failure
  32865. * @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
  32866. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32867. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32868. * @param forcedExtension defines the extension to use to pick the right loader
  32869. * @param mimeType defines an optional mime type
  32870. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32871. */
  32872. 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;
  32873. /**
  32874. * Loads an image as an HTMLImageElement.
  32875. * @param input url string, ArrayBuffer, or Blob to load
  32876. * @param onLoad callback called when the image successfully loads
  32877. * @param onError callback called when the image fails to load
  32878. * @param offlineProvider offline provider for caching
  32879. * @param mimeType optional mime type
  32880. * @returns the HTMLImageElement of the loaded image
  32881. * @hidden
  32882. */
  32883. 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>;
  32884. /**
  32885. * @hidden
  32886. */
  32887. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32888. /**
  32889. * Creates a raw texture
  32890. * @param data defines the data to store in the texture
  32891. * @param width defines the width of the texture
  32892. * @param height defines the height of the texture
  32893. * @param format defines the format of the data
  32894. * @param generateMipMaps defines if the engine should generate the mip levels
  32895. * @param invertY defines if data must be stored with Y axis inverted
  32896. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32897. * @param compression defines the compression used (null by default)
  32898. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32899. * @returns the raw texture inside an InternalTexture
  32900. */
  32901. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32902. /**
  32903. * Creates a new raw cube texture
  32904. * @param data defines the array of data to use to create each face
  32905. * @param size defines the size of the textures
  32906. * @param format defines the format of the data
  32907. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32908. * @param generateMipMaps defines if the engine should generate the mip levels
  32909. * @param invertY defines if data must be stored with Y axis inverted
  32910. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32911. * @param compression defines the compression used (null by default)
  32912. * @returns the cube texture as an InternalTexture
  32913. */
  32914. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32915. /**
  32916. * Creates a new raw 3D texture
  32917. * @param data defines the data used to create the texture
  32918. * @param width defines the width of the texture
  32919. * @param height defines the height of the texture
  32920. * @param depth defines the depth of the texture
  32921. * @param format defines the format of the texture
  32922. * @param generateMipMaps defines if the engine must generate mip levels
  32923. * @param invertY defines if data must be stored with Y axis inverted
  32924. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32925. * @param compression defines the compressed used (can be null)
  32926. * @param textureType defines the compressed used (can be null)
  32927. * @returns a new raw 3D texture (stored in an InternalTexture)
  32928. */
  32929. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32930. /**
  32931. * Creates a new raw 2D array texture
  32932. * @param data defines the data used to create the texture
  32933. * @param width defines the width of the texture
  32934. * @param height defines the height of the texture
  32935. * @param depth defines the number of layers of the texture
  32936. * @param format defines the format of the texture
  32937. * @param generateMipMaps defines if the engine must generate mip levels
  32938. * @param invertY defines if data must be stored with Y axis inverted
  32939. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32940. * @param compression defines the compressed used (can be null)
  32941. * @param textureType defines the compressed used (can be null)
  32942. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32943. */
  32944. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32945. private _unpackFlipYCached;
  32946. /**
  32947. * In case you are sharing the context with other applications, it might
  32948. * be interested to not cache the unpack flip y state to ensure a consistent
  32949. * value would be set.
  32950. */
  32951. enableUnpackFlipYCached: boolean;
  32952. /** @hidden */
  32953. _unpackFlipY(value: boolean): void;
  32954. /** @hidden */
  32955. _getUnpackAlignement(): number;
  32956. private _getTextureTarget;
  32957. /**
  32958. * Update the sampling mode of a given texture
  32959. * @param samplingMode defines the required sampling mode
  32960. * @param texture defines the texture to update
  32961. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32962. */
  32963. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32964. /**
  32965. * Update the sampling mode of a given texture
  32966. * @param texture defines the texture to update
  32967. * @param wrapU defines the texture wrap mode of the u coordinates
  32968. * @param wrapV defines the texture wrap mode of the v coordinates
  32969. * @param wrapR defines the texture wrap mode of the r coordinates
  32970. */
  32971. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32972. /** @hidden */
  32973. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32974. width: number;
  32975. height: number;
  32976. layers?: number;
  32977. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32978. /** @hidden */
  32979. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32980. /** @hidden */
  32981. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32982. /**
  32983. * Update a portion of an internal texture
  32984. * @param texture defines the texture to update
  32985. * @param imageData defines the data to store into the texture
  32986. * @param xOffset defines the x coordinates of the update rectangle
  32987. * @param yOffset defines the y coordinates of the update rectangle
  32988. * @param width defines the width of the update rectangle
  32989. * @param height defines the height of the update rectangle
  32990. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32991. * @param lod defines the lod level to update (0 by default)
  32992. */
  32993. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32994. /** @hidden */
  32995. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32996. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32997. private _prepareWebGLTexture;
  32998. /** @hidden */
  32999. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  33000. private _getDepthStencilBuffer;
  33001. /** @hidden */
  33002. _releaseFramebufferObjects(texture: InternalTexture): void;
  33003. /** @hidden */
  33004. _releaseTexture(texture: InternalTexture): void;
  33005. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  33006. protected _setProgram(program: WebGLProgram): void;
  33007. protected _boundUniforms: {
  33008. [key: number]: WebGLUniformLocation;
  33009. };
  33010. /**
  33011. * Binds an effect to the webGL context
  33012. * @param effect defines the effect to bind
  33013. */
  33014. bindSamplers(effect: Effect): void;
  33015. private _activateCurrentTexture;
  33016. /** @hidden */
  33017. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  33018. /** @hidden */
  33019. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  33020. /**
  33021. * Unbind all textures from the webGL context
  33022. */
  33023. unbindAllTextures(): void;
  33024. /**
  33025. * Sets a texture to the according uniform.
  33026. * @param channel The texture channel
  33027. * @param uniform The uniform to set
  33028. * @param texture The texture to apply
  33029. */
  33030. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  33031. private _bindSamplerUniformToChannel;
  33032. private _getTextureWrapMode;
  33033. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  33034. /**
  33035. * Sets an array of texture to the webGL context
  33036. * @param channel defines the channel where the texture array must be set
  33037. * @param uniform defines the associated uniform location
  33038. * @param textures defines the array of textures to bind
  33039. */
  33040. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  33041. /** @hidden */
  33042. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  33043. private _setTextureParameterFloat;
  33044. private _setTextureParameterInteger;
  33045. /**
  33046. * Unbind all vertex attributes from the webGL context
  33047. */
  33048. unbindAllAttributes(): void;
  33049. /**
  33050. * 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
  33051. */
  33052. releaseEffects(): void;
  33053. /**
  33054. * Dispose and release all associated resources
  33055. */
  33056. dispose(): void;
  33057. /**
  33058. * Attach a new callback raised when context lost event is fired
  33059. * @param callback defines the callback to call
  33060. */
  33061. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  33062. /**
  33063. * Attach a new callback raised when context restored event is fired
  33064. * @param callback defines the callback to call
  33065. */
  33066. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  33067. /**
  33068. * Get the current error code of the webGL context
  33069. * @returns the error code
  33070. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  33071. */
  33072. getError(): number;
  33073. private _canRenderToFloatFramebuffer;
  33074. private _canRenderToHalfFloatFramebuffer;
  33075. private _canRenderToFramebuffer;
  33076. /** @hidden */
  33077. _getWebGLTextureType(type: number): number;
  33078. /** @hidden */
  33079. _getInternalFormat(format: number): number;
  33080. /** @hidden */
  33081. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  33082. /** @hidden */
  33083. _getRGBAMultiSampleBufferFormat(type: number): number;
  33084. /** @hidden */
  33085. _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;
  33086. /**
  33087. * Loads a file from a url
  33088. * @param url url to load
  33089. * @param onSuccess callback called when the file successfully loads
  33090. * @param onProgress callback called while file is loading (if the server supports this mode)
  33091. * @param offlineProvider defines the offline provider for caching
  33092. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33093. * @param onError callback called when the file fails to load
  33094. * @returns a file request object
  33095. * @hidden
  33096. */
  33097. 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;
  33098. /**
  33099. * Reads pixels from the current frame buffer. Please note that this function can be slow
  33100. * @param x defines the x coordinate of the rectangle where pixels must be read
  33101. * @param y defines the y coordinate of the rectangle where pixels must be read
  33102. * @param width defines the width of the rectangle where pixels must be read
  33103. * @param height defines the height of the rectangle where pixels must be read
  33104. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  33105. * @returns a Uint8Array containing RGBA colors
  33106. */
  33107. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  33108. private static _isSupported;
  33109. /**
  33110. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  33111. * @returns true if the engine can be created
  33112. * @ignorenaming
  33113. */
  33114. static isSupported(): boolean;
  33115. /**
  33116. * Find the next highest power of two.
  33117. * @param x Number to start search from.
  33118. * @return Next highest power of two.
  33119. */
  33120. static CeilingPOT(x: number): number;
  33121. /**
  33122. * Find the next lowest power of two.
  33123. * @param x Number to start search from.
  33124. * @return Next lowest power of two.
  33125. */
  33126. static FloorPOT(x: number): number;
  33127. /**
  33128. * Find the nearest power of two.
  33129. * @param x Number to start search from.
  33130. * @return Next nearest power of two.
  33131. */
  33132. static NearestPOT(x: number): number;
  33133. /**
  33134. * Get the closest exponent of two
  33135. * @param value defines the value to approximate
  33136. * @param max defines the maximum value to return
  33137. * @param mode defines how to define the closest value
  33138. * @returns closest exponent of two of the given value
  33139. */
  33140. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  33141. /**
  33142. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  33143. * @param func - the function to be called
  33144. * @param requester - the object that will request the next frame. Falls back to window.
  33145. * @returns frame number
  33146. */
  33147. static QueueNewFrame(func: () => void, requester?: any): number;
  33148. /**
  33149. * Gets host document
  33150. * @returns the host document object
  33151. */
  33152. getHostDocument(): Nullable<Document>;
  33153. }
  33154. }
  33155. declare module "babylonjs/Maths/sphericalPolynomial" {
  33156. import { Vector3 } from "babylonjs/Maths/math.vector";
  33157. import { Color3 } from "babylonjs/Maths/math.color";
  33158. /**
  33159. * Class representing spherical harmonics coefficients to the 3rd degree
  33160. */
  33161. export class SphericalHarmonics {
  33162. /**
  33163. * Defines whether or not the harmonics have been prescaled for rendering.
  33164. */
  33165. preScaled: boolean;
  33166. /**
  33167. * The l0,0 coefficients of the spherical harmonics
  33168. */
  33169. l00: Vector3;
  33170. /**
  33171. * The l1,-1 coefficients of the spherical harmonics
  33172. */
  33173. l1_1: Vector3;
  33174. /**
  33175. * The l1,0 coefficients of the spherical harmonics
  33176. */
  33177. l10: Vector3;
  33178. /**
  33179. * The l1,1 coefficients of the spherical harmonics
  33180. */
  33181. l11: Vector3;
  33182. /**
  33183. * The l2,-2 coefficients of the spherical harmonics
  33184. */
  33185. l2_2: Vector3;
  33186. /**
  33187. * The l2,-1 coefficients of the spherical harmonics
  33188. */
  33189. l2_1: Vector3;
  33190. /**
  33191. * The l2,0 coefficients of the spherical harmonics
  33192. */
  33193. l20: Vector3;
  33194. /**
  33195. * The l2,1 coefficients of the spherical harmonics
  33196. */
  33197. l21: Vector3;
  33198. /**
  33199. * The l2,2 coefficients of the spherical harmonics
  33200. */
  33201. l22: Vector3;
  33202. /**
  33203. * Adds a light to the spherical harmonics
  33204. * @param direction the direction of the light
  33205. * @param color the color of the light
  33206. * @param deltaSolidAngle the delta solid angle of the light
  33207. */
  33208. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  33209. /**
  33210. * Scales the spherical harmonics by the given amount
  33211. * @param scale the amount to scale
  33212. */
  33213. scaleInPlace(scale: number): void;
  33214. /**
  33215. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  33216. *
  33217. * ```
  33218. * E_lm = A_l * L_lm
  33219. * ```
  33220. *
  33221. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  33222. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  33223. * the scaling factors are given in equation 9.
  33224. */
  33225. convertIncidentRadianceToIrradiance(): void;
  33226. /**
  33227. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  33228. *
  33229. * ```
  33230. * L = (1/pi) * E * rho
  33231. * ```
  33232. *
  33233. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  33234. */
  33235. convertIrradianceToLambertianRadiance(): void;
  33236. /**
  33237. * Integrates the reconstruction coefficients directly in to the SH preventing further
  33238. * required operations at run time.
  33239. *
  33240. * This is simply done by scaling back the SH with Ylm constants parameter.
  33241. * The trigonometric part being applied by the shader at run time.
  33242. */
  33243. preScaleForRendering(): void;
  33244. /**
  33245. * Constructs a spherical harmonics from an array.
  33246. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  33247. * @returns the spherical harmonics
  33248. */
  33249. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  33250. /**
  33251. * Gets the spherical harmonics from polynomial
  33252. * @param polynomial the spherical polynomial
  33253. * @returns the spherical harmonics
  33254. */
  33255. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  33256. }
  33257. /**
  33258. * Class representing spherical polynomial coefficients to the 3rd degree
  33259. */
  33260. export class SphericalPolynomial {
  33261. private _harmonics;
  33262. /**
  33263. * The spherical harmonics used to create the polynomials.
  33264. */
  33265. get preScaledHarmonics(): SphericalHarmonics;
  33266. /**
  33267. * The x coefficients of the spherical polynomial
  33268. */
  33269. x: Vector3;
  33270. /**
  33271. * The y coefficients of the spherical polynomial
  33272. */
  33273. y: Vector3;
  33274. /**
  33275. * The z coefficients of the spherical polynomial
  33276. */
  33277. z: Vector3;
  33278. /**
  33279. * The xx coefficients of the spherical polynomial
  33280. */
  33281. xx: Vector3;
  33282. /**
  33283. * The yy coefficients of the spherical polynomial
  33284. */
  33285. yy: Vector3;
  33286. /**
  33287. * The zz coefficients of the spherical polynomial
  33288. */
  33289. zz: Vector3;
  33290. /**
  33291. * The xy coefficients of the spherical polynomial
  33292. */
  33293. xy: Vector3;
  33294. /**
  33295. * The yz coefficients of the spherical polynomial
  33296. */
  33297. yz: Vector3;
  33298. /**
  33299. * The zx coefficients of the spherical polynomial
  33300. */
  33301. zx: Vector3;
  33302. /**
  33303. * Adds an ambient color to the spherical polynomial
  33304. * @param color the color to add
  33305. */
  33306. addAmbient(color: Color3): void;
  33307. /**
  33308. * Scales the spherical polynomial by the given amount
  33309. * @param scale the amount to scale
  33310. */
  33311. scaleInPlace(scale: number): void;
  33312. /**
  33313. * Gets the spherical polynomial from harmonics
  33314. * @param harmonics the spherical harmonics
  33315. * @returns the spherical polynomial
  33316. */
  33317. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  33318. /**
  33319. * Constructs a spherical polynomial from an array.
  33320. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  33321. * @returns the spherical polynomial
  33322. */
  33323. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  33324. }
  33325. }
  33326. declare module "babylonjs/Materials/Textures/internalTexture" {
  33327. import { Observable } from "babylonjs/Misc/observable";
  33328. import { Nullable, int } from "babylonjs/types";
  33329. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33330. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33331. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  33332. /**
  33333. * Defines the source of the internal texture
  33334. */
  33335. export enum InternalTextureSource {
  33336. /**
  33337. * The source of the texture data is unknown
  33338. */
  33339. Unknown = 0,
  33340. /**
  33341. * Texture data comes from an URL
  33342. */
  33343. Url = 1,
  33344. /**
  33345. * Texture data is only used for temporary storage
  33346. */
  33347. Temp = 2,
  33348. /**
  33349. * Texture data comes from raw data (ArrayBuffer)
  33350. */
  33351. Raw = 3,
  33352. /**
  33353. * Texture content is dynamic (video or dynamic texture)
  33354. */
  33355. Dynamic = 4,
  33356. /**
  33357. * Texture content is generated by rendering to it
  33358. */
  33359. RenderTarget = 5,
  33360. /**
  33361. * Texture content is part of a multi render target process
  33362. */
  33363. MultiRenderTarget = 6,
  33364. /**
  33365. * Texture data comes from a cube data file
  33366. */
  33367. Cube = 7,
  33368. /**
  33369. * Texture data comes from a raw cube data
  33370. */
  33371. CubeRaw = 8,
  33372. /**
  33373. * Texture data come from a prefiltered cube data file
  33374. */
  33375. CubePrefiltered = 9,
  33376. /**
  33377. * Texture content is raw 3D data
  33378. */
  33379. Raw3D = 10,
  33380. /**
  33381. * Texture content is raw 2D array data
  33382. */
  33383. Raw2DArray = 11,
  33384. /**
  33385. * Texture content is a depth texture
  33386. */
  33387. Depth = 12,
  33388. /**
  33389. * Texture data comes from a raw cube data encoded with RGBD
  33390. */
  33391. CubeRawRGBD = 13
  33392. }
  33393. /**
  33394. * Class used to store data associated with WebGL texture data for the engine
  33395. * This class should not be used directly
  33396. */
  33397. export class InternalTexture {
  33398. /** @hidden */
  33399. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  33400. /**
  33401. * Defines if the texture is ready
  33402. */
  33403. isReady: boolean;
  33404. /**
  33405. * Defines if the texture is a cube texture
  33406. */
  33407. isCube: boolean;
  33408. /**
  33409. * Defines if the texture contains 3D data
  33410. */
  33411. is3D: boolean;
  33412. /**
  33413. * Defines if the texture contains 2D array data
  33414. */
  33415. is2DArray: boolean;
  33416. /**
  33417. * Defines if the texture contains multiview data
  33418. */
  33419. isMultiview: boolean;
  33420. /**
  33421. * Gets the URL used to load this texture
  33422. */
  33423. url: string;
  33424. /**
  33425. * Gets the sampling mode of the texture
  33426. */
  33427. samplingMode: number;
  33428. /**
  33429. * Gets a boolean indicating if the texture needs mipmaps generation
  33430. */
  33431. generateMipMaps: boolean;
  33432. /**
  33433. * Gets the number of samples used by the texture (WebGL2+ only)
  33434. */
  33435. samples: number;
  33436. /**
  33437. * Gets the type of the texture (int, float...)
  33438. */
  33439. type: number;
  33440. /**
  33441. * Gets the format of the texture (RGB, RGBA...)
  33442. */
  33443. format: number;
  33444. /**
  33445. * Observable called when the texture is loaded
  33446. */
  33447. onLoadedObservable: Observable<InternalTexture>;
  33448. /**
  33449. * Gets the width of the texture
  33450. */
  33451. width: number;
  33452. /**
  33453. * Gets the height of the texture
  33454. */
  33455. height: number;
  33456. /**
  33457. * Gets the depth of the texture
  33458. */
  33459. depth: number;
  33460. /**
  33461. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33462. */
  33463. baseWidth: number;
  33464. /**
  33465. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33466. */
  33467. baseHeight: number;
  33468. /**
  33469. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33470. */
  33471. baseDepth: number;
  33472. /**
  33473. * Gets a boolean indicating if the texture is inverted on Y axis
  33474. */
  33475. invertY: boolean;
  33476. /** @hidden */
  33477. _invertVScale: boolean;
  33478. /** @hidden */
  33479. _associatedChannel: number;
  33480. /** @hidden */
  33481. _source: InternalTextureSource;
  33482. /** @hidden */
  33483. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33484. /** @hidden */
  33485. _bufferView: Nullable<ArrayBufferView>;
  33486. /** @hidden */
  33487. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33488. /** @hidden */
  33489. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33490. /** @hidden */
  33491. _size: number;
  33492. /** @hidden */
  33493. _extension: string;
  33494. /** @hidden */
  33495. _files: Nullable<string[]>;
  33496. /** @hidden */
  33497. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33498. /** @hidden */
  33499. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33500. /** @hidden */
  33501. _framebuffer: Nullable<WebGLFramebuffer>;
  33502. /** @hidden */
  33503. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33504. /** @hidden */
  33505. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33506. /** @hidden */
  33507. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33508. /** @hidden */
  33509. _attachments: Nullable<number[]>;
  33510. /** @hidden */
  33511. _cachedCoordinatesMode: Nullable<number>;
  33512. /** @hidden */
  33513. _cachedWrapU: Nullable<number>;
  33514. /** @hidden */
  33515. _cachedWrapV: Nullable<number>;
  33516. /** @hidden */
  33517. _cachedWrapR: Nullable<number>;
  33518. /** @hidden */
  33519. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33520. /** @hidden */
  33521. _isDisabled: boolean;
  33522. /** @hidden */
  33523. _compression: Nullable<string>;
  33524. /** @hidden */
  33525. _generateStencilBuffer: boolean;
  33526. /** @hidden */
  33527. _generateDepthBuffer: boolean;
  33528. /** @hidden */
  33529. _comparisonFunction: number;
  33530. /** @hidden */
  33531. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33532. /** @hidden */
  33533. _lodGenerationScale: number;
  33534. /** @hidden */
  33535. _lodGenerationOffset: number;
  33536. /** @hidden */
  33537. _depthStencilTexture: Nullable<InternalTexture>;
  33538. /** @hidden */
  33539. _colorTextureArray: Nullable<WebGLTexture>;
  33540. /** @hidden */
  33541. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33542. /** @hidden */
  33543. _lodTextureHigh: Nullable<BaseTexture>;
  33544. /** @hidden */
  33545. _lodTextureMid: Nullable<BaseTexture>;
  33546. /** @hidden */
  33547. _lodTextureLow: Nullable<BaseTexture>;
  33548. /** @hidden */
  33549. _isRGBD: boolean;
  33550. /** @hidden */
  33551. _linearSpecularLOD: boolean;
  33552. /** @hidden */
  33553. _irradianceTexture: Nullable<BaseTexture>;
  33554. /** @hidden */
  33555. _webGLTexture: Nullable<WebGLTexture>;
  33556. /** @hidden */
  33557. _references: number;
  33558. private _engine;
  33559. /**
  33560. * Gets the Engine the texture belongs to.
  33561. * @returns The babylon engine
  33562. */
  33563. getEngine(): ThinEngine;
  33564. /**
  33565. * Gets the data source type of the texture
  33566. */
  33567. get source(): InternalTextureSource;
  33568. /**
  33569. * Creates a new InternalTexture
  33570. * @param engine defines the engine to use
  33571. * @param source defines the type of data that will be used
  33572. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33573. */
  33574. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33575. /**
  33576. * Increments the number of references (ie. the number of Texture that point to it)
  33577. */
  33578. incrementReferences(): void;
  33579. /**
  33580. * Change the size of the texture (not the size of the content)
  33581. * @param width defines the new width
  33582. * @param height defines the new height
  33583. * @param depth defines the new depth (1 by default)
  33584. */
  33585. updateSize(width: int, height: int, depth?: int): void;
  33586. /** @hidden */
  33587. _rebuild(): void;
  33588. /** @hidden */
  33589. _swapAndDie(target: InternalTexture): void;
  33590. /**
  33591. * Dispose the current allocated resources
  33592. */
  33593. dispose(): void;
  33594. }
  33595. }
  33596. declare module "babylonjs/Audio/analyser" {
  33597. import { Scene } from "babylonjs/scene";
  33598. /**
  33599. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33600. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33601. */
  33602. export class Analyser {
  33603. /**
  33604. * Gets or sets the smoothing
  33605. * @ignorenaming
  33606. */
  33607. SMOOTHING: number;
  33608. /**
  33609. * Gets or sets the FFT table size
  33610. * @ignorenaming
  33611. */
  33612. FFT_SIZE: number;
  33613. /**
  33614. * Gets or sets the bar graph amplitude
  33615. * @ignorenaming
  33616. */
  33617. BARGRAPHAMPLITUDE: number;
  33618. /**
  33619. * Gets or sets the position of the debug canvas
  33620. * @ignorenaming
  33621. */
  33622. DEBUGCANVASPOS: {
  33623. x: number;
  33624. y: number;
  33625. };
  33626. /**
  33627. * Gets or sets the debug canvas size
  33628. * @ignorenaming
  33629. */
  33630. DEBUGCANVASSIZE: {
  33631. width: number;
  33632. height: number;
  33633. };
  33634. private _byteFreqs;
  33635. private _byteTime;
  33636. private _floatFreqs;
  33637. private _webAudioAnalyser;
  33638. private _debugCanvas;
  33639. private _debugCanvasContext;
  33640. private _scene;
  33641. private _registerFunc;
  33642. private _audioEngine;
  33643. /**
  33644. * Creates a new analyser
  33645. * @param scene defines hosting scene
  33646. */
  33647. constructor(scene: Scene);
  33648. /**
  33649. * Get the number of data values you will have to play with for the visualization
  33650. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33651. * @returns a number
  33652. */
  33653. getFrequencyBinCount(): number;
  33654. /**
  33655. * Gets the current frequency data as a byte array
  33656. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33657. * @returns a Uint8Array
  33658. */
  33659. getByteFrequencyData(): Uint8Array;
  33660. /**
  33661. * Gets the current waveform as a byte array
  33662. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33663. * @returns a Uint8Array
  33664. */
  33665. getByteTimeDomainData(): Uint8Array;
  33666. /**
  33667. * Gets the current frequency data as a float array
  33668. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33669. * @returns a Float32Array
  33670. */
  33671. getFloatFrequencyData(): Float32Array;
  33672. /**
  33673. * Renders the debug canvas
  33674. */
  33675. drawDebugCanvas(): void;
  33676. /**
  33677. * Stops rendering the debug canvas and removes it
  33678. */
  33679. stopDebugCanvas(): void;
  33680. /**
  33681. * Connects two audio nodes
  33682. * @param inputAudioNode defines first node to connect
  33683. * @param outputAudioNode defines second node to connect
  33684. */
  33685. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33686. /**
  33687. * Releases all associated resources
  33688. */
  33689. dispose(): void;
  33690. }
  33691. }
  33692. declare module "babylonjs/Audio/audioEngine" {
  33693. import { IDisposable } from "babylonjs/scene";
  33694. import { Analyser } from "babylonjs/Audio/analyser";
  33695. import { Nullable } from "babylonjs/types";
  33696. import { Observable } from "babylonjs/Misc/observable";
  33697. /**
  33698. * This represents an audio engine and it is responsible
  33699. * to play, synchronize and analyse sounds throughout the application.
  33700. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33701. */
  33702. export interface IAudioEngine extends IDisposable {
  33703. /**
  33704. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33705. */
  33706. readonly canUseWebAudio: boolean;
  33707. /**
  33708. * Gets the current AudioContext if available.
  33709. */
  33710. readonly audioContext: Nullable<AudioContext>;
  33711. /**
  33712. * The master gain node defines the global audio volume of your audio engine.
  33713. */
  33714. readonly masterGain: GainNode;
  33715. /**
  33716. * Gets whether or not mp3 are supported by your browser.
  33717. */
  33718. readonly isMP3supported: boolean;
  33719. /**
  33720. * Gets whether or not ogg are supported by your browser.
  33721. */
  33722. readonly isOGGsupported: boolean;
  33723. /**
  33724. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33725. * @ignoreNaming
  33726. */
  33727. WarnedWebAudioUnsupported: boolean;
  33728. /**
  33729. * Defines if the audio engine relies on a custom unlocked button.
  33730. * In this case, the embedded button will not be displayed.
  33731. */
  33732. useCustomUnlockedButton: boolean;
  33733. /**
  33734. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33735. */
  33736. readonly unlocked: boolean;
  33737. /**
  33738. * Event raised when audio has been unlocked on the browser.
  33739. */
  33740. onAudioUnlockedObservable: Observable<AudioEngine>;
  33741. /**
  33742. * Event raised when audio has been locked on the browser.
  33743. */
  33744. onAudioLockedObservable: Observable<AudioEngine>;
  33745. /**
  33746. * Flags the audio engine in Locked state.
  33747. * This happens due to new browser policies preventing audio to autoplay.
  33748. */
  33749. lock(): void;
  33750. /**
  33751. * Unlocks the audio engine once a user action has been done on the dom.
  33752. * This is helpful to resume play once browser policies have been satisfied.
  33753. */
  33754. unlock(): void;
  33755. /**
  33756. * Gets the global volume sets on the master gain.
  33757. * @returns the global volume if set or -1 otherwise
  33758. */
  33759. getGlobalVolume(): number;
  33760. /**
  33761. * Sets the global volume of your experience (sets on the master gain).
  33762. * @param newVolume Defines the new global volume of the application
  33763. */
  33764. setGlobalVolume(newVolume: number): void;
  33765. /**
  33766. * Connect the audio engine to an audio analyser allowing some amazing
  33767. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33768. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33769. * @param analyser The analyser to connect to the engine
  33770. */
  33771. connectToAnalyser(analyser: Analyser): void;
  33772. }
  33773. /**
  33774. * This represents the default audio engine used in babylon.
  33775. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33776. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33777. */
  33778. export class AudioEngine implements IAudioEngine {
  33779. private _audioContext;
  33780. private _audioContextInitialized;
  33781. private _muteButton;
  33782. private _hostElement;
  33783. /**
  33784. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33785. */
  33786. canUseWebAudio: boolean;
  33787. /**
  33788. * The master gain node defines the global audio volume of your audio engine.
  33789. */
  33790. masterGain: GainNode;
  33791. /**
  33792. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33793. * @ignoreNaming
  33794. */
  33795. WarnedWebAudioUnsupported: boolean;
  33796. /**
  33797. * Gets whether or not mp3 are supported by your browser.
  33798. */
  33799. isMP3supported: boolean;
  33800. /**
  33801. * Gets whether or not ogg are supported by your browser.
  33802. */
  33803. isOGGsupported: boolean;
  33804. /**
  33805. * Gets whether audio has been unlocked on the device.
  33806. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33807. * a user interaction has happened.
  33808. */
  33809. unlocked: boolean;
  33810. /**
  33811. * Defines if the audio engine relies on a custom unlocked button.
  33812. * In this case, the embedded button will not be displayed.
  33813. */
  33814. useCustomUnlockedButton: boolean;
  33815. /**
  33816. * Event raised when audio has been unlocked on the browser.
  33817. */
  33818. onAudioUnlockedObservable: Observable<AudioEngine>;
  33819. /**
  33820. * Event raised when audio has been locked on the browser.
  33821. */
  33822. onAudioLockedObservable: Observable<AudioEngine>;
  33823. /**
  33824. * Gets the current AudioContext if available.
  33825. */
  33826. get audioContext(): Nullable<AudioContext>;
  33827. private _connectedAnalyser;
  33828. /**
  33829. * Instantiates a new audio engine.
  33830. *
  33831. * There should be only one per page as some browsers restrict the number
  33832. * of audio contexts you can create.
  33833. * @param hostElement defines the host element where to display the mute icon if necessary
  33834. */
  33835. constructor(hostElement?: Nullable<HTMLElement>);
  33836. /**
  33837. * Flags the audio engine in Locked state.
  33838. * This happens due to new browser policies preventing audio to autoplay.
  33839. */
  33840. lock(): void;
  33841. /**
  33842. * Unlocks the audio engine once a user action has been done on the dom.
  33843. * This is helpful to resume play once browser policies have been satisfied.
  33844. */
  33845. unlock(): void;
  33846. private _resumeAudioContext;
  33847. private _initializeAudioContext;
  33848. private _tryToRun;
  33849. private _triggerRunningState;
  33850. private _triggerSuspendedState;
  33851. private _displayMuteButton;
  33852. private _moveButtonToTopLeft;
  33853. private _onResize;
  33854. private _hideMuteButton;
  33855. /**
  33856. * Destroy and release the resources associated with the audio ccontext.
  33857. */
  33858. dispose(): void;
  33859. /**
  33860. * Gets the global volume sets on the master gain.
  33861. * @returns the global volume if set or -1 otherwise
  33862. */
  33863. getGlobalVolume(): number;
  33864. /**
  33865. * Sets the global volume of your experience (sets on the master gain).
  33866. * @param newVolume Defines the new global volume of the application
  33867. */
  33868. setGlobalVolume(newVolume: number): void;
  33869. /**
  33870. * Connect the audio engine to an audio analyser allowing some amazing
  33871. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33872. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33873. * @param analyser The analyser to connect to the engine
  33874. */
  33875. connectToAnalyser(analyser: Analyser): void;
  33876. }
  33877. }
  33878. declare module "babylonjs/Loading/loadingScreen" {
  33879. /**
  33880. * Interface used to present a loading screen while loading a scene
  33881. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33882. */
  33883. export interface ILoadingScreen {
  33884. /**
  33885. * Function called to display the loading screen
  33886. */
  33887. displayLoadingUI: () => void;
  33888. /**
  33889. * Function called to hide the loading screen
  33890. */
  33891. hideLoadingUI: () => void;
  33892. /**
  33893. * Gets or sets the color to use for the background
  33894. */
  33895. loadingUIBackgroundColor: string;
  33896. /**
  33897. * Gets or sets the text to display while loading
  33898. */
  33899. loadingUIText: string;
  33900. }
  33901. /**
  33902. * Class used for the default loading screen
  33903. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33904. */
  33905. export class DefaultLoadingScreen implements ILoadingScreen {
  33906. private _renderingCanvas;
  33907. private _loadingText;
  33908. private _loadingDivBackgroundColor;
  33909. private _loadingDiv;
  33910. private _loadingTextDiv;
  33911. /** Gets or sets the logo url to use for the default loading screen */
  33912. static DefaultLogoUrl: string;
  33913. /** Gets or sets the spinner url to use for the default loading screen */
  33914. static DefaultSpinnerUrl: string;
  33915. /**
  33916. * Creates a new default loading screen
  33917. * @param _renderingCanvas defines the canvas used to render the scene
  33918. * @param _loadingText defines the default text to display
  33919. * @param _loadingDivBackgroundColor defines the default background color
  33920. */
  33921. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33922. /**
  33923. * Function called to display the loading screen
  33924. */
  33925. displayLoadingUI(): void;
  33926. /**
  33927. * Function called to hide the loading screen
  33928. */
  33929. hideLoadingUI(): void;
  33930. /**
  33931. * Gets or sets the text to display while loading
  33932. */
  33933. set loadingUIText(text: string);
  33934. get loadingUIText(): string;
  33935. /**
  33936. * Gets or sets the color to use for the background
  33937. */
  33938. get loadingUIBackgroundColor(): string;
  33939. set loadingUIBackgroundColor(color: string);
  33940. private _resizeLoadingUI;
  33941. }
  33942. }
  33943. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33944. /**
  33945. * Interface for any object that can request an animation frame
  33946. */
  33947. export interface ICustomAnimationFrameRequester {
  33948. /**
  33949. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33950. */
  33951. renderFunction?: Function;
  33952. /**
  33953. * Called to request the next frame to render to
  33954. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33955. */
  33956. requestAnimationFrame: Function;
  33957. /**
  33958. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33959. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33960. */
  33961. requestID?: number;
  33962. }
  33963. }
  33964. declare module "babylonjs/Misc/performanceMonitor" {
  33965. /**
  33966. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33967. */
  33968. export class PerformanceMonitor {
  33969. private _enabled;
  33970. private _rollingFrameTime;
  33971. private _lastFrameTimeMs;
  33972. /**
  33973. * constructor
  33974. * @param frameSampleSize The number of samples required to saturate the sliding window
  33975. */
  33976. constructor(frameSampleSize?: number);
  33977. /**
  33978. * Samples current frame
  33979. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33980. */
  33981. sampleFrame(timeMs?: number): void;
  33982. /**
  33983. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33984. */
  33985. get averageFrameTime(): number;
  33986. /**
  33987. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33988. */
  33989. get averageFrameTimeVariance(): number;
  33990. /**
  33991. * Returns the frame time of the most recent frame
  33992. */
  33993. get instantaneousFrameTime(): number;
  33994. /**
  33995. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33996. */
  33997. get averageFPS(): number;
  33998. /**
  33999. * Returns the average framerate in frames per second using the most recent frame time
  34000. */
  34001. get instantaneousFPS(): number;
  34002. /**
  34003. * Returns true if enough samples have been taken to completely fill the sliding window
  34004. */
  34005. get isSaturated(): boolean;
  34006. /**
  34007. * Enables contributions to the sliding window sample set
  34008. */
  34009. enable(): void;
  34010. /**
  34011. * Disables contributions to the sliding window sample set
  34012. * Samples will not be interpolated over the disabled period
  34013. */
  34014. disable(): void;
  34015. /**
  34016. * Returns true if sampling is enabled
  34017. */
  34018. get isEnabled(): boolean;
  34019. /**
  34020. * Resets performance monitor
  34021. */
  34022. reset(): void;
  34023. }
  34024. /**
  34025. * RollingAverage
  34026. *
  34027. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  34028. */
  34029. export class RollingAverage {
  34030. /**
  34031. * Current average
  34032. */
  34033. average: number;
  34034. /**
  34035. * Current variance
  34036. */
  34037. variance: number;
  34038. protected _samples: Array<number>;
  34039. protected _sampleCount: number;
  34040. protected _pos: number;
  34041. protected _m2: number;
  34042. /**
  34043. * constructor
  34044. * @param length The number of samples required to saturate the sliding window
  34045. */
  34046. constructor(length: number);
  34047. /**
  34048. * Adds a sample to the sample set
  34049. * @param v The sample value
  34050. */
  34051. add(v: number): void;
  34052. /**
  34053. * Returns previously added values or null if outside of history or outside the sliding window domain
  34054. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  34055. * @return Value previously recorded with add() or null if outside of range
  34056. */
  34057. history(i: number): number;
  34058. /**
  34059. * Returns true if enough samples have been taken to completely fill the sliding window
  34060. * @return true if sample-set saturated
  34061. */
  34062. isSaturated(): boolean;
  34063. /**
  34064. * Resets the rolling average (equivalent to 0 samples taken so far)
  34065. */
  34066. reset(): void;
  34067. /**
  34068. * Wraps a value around the sample range boundaries
  34069. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  34070. * @return Wrapped position in sample range
  34071. */
  34072. protected _wrapPosition(i: number): number;
  34073. }
  34074. }
  34075. declare module "babylonjs/Misc/perfCounter" {
  34076. /**
  34077. * This class is used to track a performance counter which is number based.
  34078. * The user has access to many properties which give statistics of different nature.
  34079. *
  34080. * The implementer can track two kinds of Performance Counter: time and count.
  34081. * 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.
  34082. * 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.
  34083. */
  34084. export class PerfCounter {
  34085. /**
  34086. * Gets or sets a global boolean to turn on and off all the counters
  34087. */
  34088. static Enabled: boolean;
  34089. /**
  34090. * Returns the smallest value ever
  34091. */
  34092. get min(): number;
  34093. /**
  34094. * Returns the biggest value ever
  34095. */
  34096. get max(): number;
  34097. /**
  34098. * Returns the average value since the performance counter is running
  34099. */
  34100. get average(): number;
  34101. /**
  34102. * Returns the average value of the last second the counter was monitored
  34103. */
  34104. get lastSecAverage(): number;
  34105. /**
  34106. * Returns the current value
  34107. */
  34108. get current(): number;
  34109. /**
  34110. * Gets the accumulated total
  34111. */
  34112. get total(): number;
  34113. /**
  34114. * Gets the total value count
  34115. */
  34116. get count(): number;
  34117. /**
  34118. * Creates a new counter
  34119. */
  34120. constructor();
  34121. /**
  34122. * Call this method to start monitoring a new frame.
  34123. * 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.
  34124. */
  34125. fetchNewFrame(): void;
  34126. /**
  34127. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  34128. * @param newCount the count value to add to the monitored count
  34129. * @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.
  34130. */
  34131. addCount(newCount: number, fetchResult: boolean): void;
  34132. /**
  34133. * Start monitoring this performance counter
  34134. */
  34135. beginMonitoring(): void;
  34136. /**
  34137. * Compute the time lapsed since the previous beginMonitoring() call.
  34138. * @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
  34139. */
  34140. endMonitoring(newFrame?: boolean): void;
  34141. private _fetchResult;
  34142. private _startMonitoringTime;
  34143. private _min;
  34144. private _max;
  34145. private _average;
  34146. private _current;
  34147. private _totalValueCount;
  34148. private _totalAccumulated;
  34149. private _lastSecAverage;
  34150. private _lastSecAccumulated;
  34151. private _lastSecTime;
  34152. private _lastSecValueCount;
  34153. }
  34154. }
  34155. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  34156. module "babylonjs/Engines/thinEngine" {
  34157. interface ThinEngine {
  34158. /**
  34159. * Sets alpha constants used by some alpha blending modes
  34160. * @param r defines the red component
  34161. * @param g defines the green component
  34162. * @param b defines the blue component
  34163. * @param a defines the alpha component
  34164. */
  34165. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  34166. /**
  34167. * Sets the current alpha mode
  34168. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  34169. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  34170. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34171. */
  34172. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  34173. /**
  34174. * Gets the current alpha mode
  34175. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34176. * @returns the current alpha mode
  34177. */
  34178. getAlphaMode(): number;
  34179. /**
  34180. * Sets the current alpha equation
  34181. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  34182. */
  34183. setAlphaEquation(equation: number): void;
  34184. /**
  34185. * Gets the current alpha equation.
  34186. * @returns the current alpha equation
  34187. */
  34188. getAlphaEquation(): number;
  34189. }
  34190. }
  34191. }
  34192. declare module "babylonjs/Engines/engine" {
  34193. import { Observable } from "babylonjs/Misc/observable";
  34194. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  34195. import { Scene } from "babylonjs/scene";
  34196. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34197. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  34198. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34199. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  34200. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  34201. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34202. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  34203. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  34204. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  34205. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34206. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  34207. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34208. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34209. import "babylonjs/Engines/Extensions/engine.alpha";
  34210. import { Material } from "babylonjs/Materials/material";
  34211. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34212. /**
  34213. * Defines the interface used by display changed events
  34214. */
  34215. export interface IDisplayChangedEventArgs {
  34216. /** Gets the vrDisplay object (if any) */
  34217. vrDisplay: Nullable<any>;
  34218. /** Gets a boolean indicating if webVR is supported */
  34219. vrSupported: boolean;
  34220. }
  34221. /**
  34222. * Defines the interface used by objects containing a viewport (like a camera)
  34223. */
  34224. interface IViewportOwnerLike {
  34225. /**
  34226. * Gets or sets the viewport
  34227. */
  34228. viewport: IViewportLike;
  34229. }
  34230. /**
  34231. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  34232. */
  34233. export class Engine extends ThinEngine {
  34234. /** Defines that alpha blending is disabled */
  34235. static readonly ALPHA_DISABLE: number;
  34236. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34237. static readonly ALPHA_ADD: number;
  34238. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34239. static readonly ALPHA_COMBINE: number;
  34240. /** Defines that alpha blending to DEST - SRC * DEST */
  34241. static readonly ALPHA_SUBTRACT: number;
  34242. /** Defines that alpha blending to SRC * DEST */
  34243. static readonly ALPHA_MULTIPLY: number;
  34244. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34245. static readonly ALPHA_MAXIMIZED: number;
  34246. /** Defines that alpha blending to SRC + DEST */
  34247. static readonly ALPHA_ONEONE: number;
  34248. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34249. static readonly ALPHA_PREMULTIPLIED: number;
  34250. /**
  34251. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34252. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34253. */
  34254. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  34255. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34256. static readonly ALPHA_INTERPOLATE: number;
  34257. /**
  34258. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34259. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34260. */
  34261. static readonly ALPHA_SCREENMODE: number;
  34262. /** Defines that the ressource is not delayed*/
  34263. static readonly DELAYLOADSTATE_NONE: number;
  34264. /** Defines that the ressource was successfully delay loaded */
  34265. static readonly DELAYLOADSTATE_LOADED: number;
  34266. /** Defines that the ressource is currently delay loading */
  34267. static readonly DELAYLOADSTATE_LOADING: number;
  34268. /** Defines that the ressource is delayed and has not started loading */
  34269. static readonly DELAYLOADSTATE_NOTLOADED: number;
  34270. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34271. static readonly NEVER: number;
  34272. /** 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 */
  34273. static readonly ALWAYS: number;
  34274. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34275. static readonly LESS: number;
  34276. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34277. static readonly EQUAL: number;
  34278. /** 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 */
  34279. static readonly LEQUAL: number;
  34280. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34281. static readonly GREATER: number;
  34282. /** 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 */
  34283. static readonly GEQUAL: number;
  34284. /** 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 */
  34285. static readonly NOTEQUAL: number;
  34286. /** Passed to stencilOperation to specify that stencil value must be kept */
  34287. static readonly KEEP: number;
  34288. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34289. static readonly REPLACE: number;
  34290. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34291. static readonly INCR: number;
  34292. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34293. static readonly DECR: number;
  34294. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34295. static readonly INVERT: number;
  34296. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34297. static readonly INCR_WRAP: number;
  34298. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34299. static readonly DECR_WRAP: number;
  34300. /** Texture is not repeating outside of 0..1 UVs */
  34301. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  34302. /** Texture is repeating outside of 0..1 UVs */
  34303. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  34304. /** Texture is repeating and mirrored */
  34305. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  34306. /** ALPHA */
  34307. static readonly TEXTUREFORMAT_ALPHA: number;
  34308. /** LUMINANCE */
  34309. static readonly TEXTUREFORMAT_LUMINANCE: number;
  34310. /** LUMINANCE_ALPHA */
  34311. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  34312. /** RGB */
  34313. static readonly TEXTUREFORMAT_RGB: number;
  34314. /** RGBA */
  34315. static readonly TEXTUREFORMAT_RGBA: number;
  34316. /** RED */
  34317. static readonly TEXTUREFORMAT_RED: number;
  34318. /** RED (2nd reference) */
  34319. static readonly TEXTUREFORMAT_R: number;
  34320. /** RG */
  34321. static readonly TEXTUREFORMAT_RG: number;
  34322. /** RED_INTEGER */
  34323. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  34324. /** RED_INTEGER (2nd reference) */
  34325. static readonly TEXTUREFORMAT_R_INTEGER: number;
  34326. /** RG_INTEGER */
  34327. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  34328. /** RGB_INTEGER */
  34329. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  34330. /** RGBA_INTEGER */
  34331. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  34332. /** UNSIGNED_BYTE */
  34333. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  34334. /** UNSIGNED_BYTE (2nd reference) */
  34335. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  34336. /** FLOAT */
  34337. static readonly TEXTURETYPE_FLOAT: number;
  34338. /** HALF_FLOAT */
  34339. static readonly TEXTURETYPE_HALF_FLOAT: number;
  34340. /** BYTE */
  34341. static readonly TEXTURETYPE_BYTE: number;
  34342. /** SHORT */
  34343. static readonly TEXTURETYPE_SHORT: number;
  34344. /** UNSIGNED_SHORT */
  34345. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  34346. /** INT */
  34347. static readonly TEXTURETYPE_INT: number;
  34348. /** UNSIGNED_INT */
  34349. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  34350. /** UNSIGNED_SHORT_4_4_4_4 */
  34351. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  34352. /** UNSIGNED_SHORT_5_5_5_1 */
  34353. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  34354. /** UNSIGNED_SHORT_5_6_5 */
  34355. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  34356. /** UNSIGNED_INT_2_10_10_10_REV */
  34357. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  34358. /** UNSIGNED_INT_24_8 */
  34359. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  34360. /** UNSIGNED_INT_10F_11F_11F_REV */
  34361. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  34362. /** UNSIGNED_INT_5_9_9_9_REV */
  34363. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  34364. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34365. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  34366. /** nearest is mag = nearest and min = nearest and mip = linear */
  34367. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  34368. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34369. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  34370. /** Trilinear is mag = linear and min = linear and mip = linear */
  34371. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  34372. /** nearest is mag = nearest and min = nearest and mip = linear */
  34373. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  34374. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34375. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  34376. /** Trilinear is mag = linear and min = linear and mip = linear */
  34377. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  34378. /** mag = nearest and min = nearest and mip = nearest */
  34379. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  34380. /** mag = nearest and min = linear and mip = nearest */
  34381. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  34382. /** mag = nearest and min = linear and mip = linear */
  34383. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  34384. /** mag = nearest and min = linear and mip = none */
  34385. static readonly TEXTURE_NEAREST_LINEAR: number;
  34386. /** mag = nearest and min = nearest and mip = none */
  34387. static readonly TEXTURE_NEAREST_NEAREST: number;
  34388. /** mag = linear and min = nearest and mip = nearest */
  34389. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  34390. /** mag = linear and min = nearest and mip = linear */
  34391. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  34392. /** mag = linear and min = linear and mip = none */
  34393. static readonly TEXTURE_LINEAR_LINEAR: number;
  34394. /** mag = linear and min = nearest and mip = none */
  34395. static readonly TEXTURE_LINEAR_NEAREST: number;
  34396. /** Explicit coordinates mode */
  34397. static readonly TEXTURE_EXPLICIT_MODE: number;
  34398. /** Spherical coordinates mode */
  34399. static readonly TEXTURE_SPHERICAL_MODE: number;
  34400. /** Planar coordinates mode */
  34401. static readonly TEXTURE_PLANAR_MODE: number;
  34402. /** Cubic coordinates mode */
  34403. static readonly TEXTURE_CUBIC_MODE: number;
  34404. /** Projection coordinates mode */
  34405. static readonly TEXTURE_PROJECTION_MODE: number;
  34406. /** Skybox coordinates mode */
  34407. static readonly TEXTURE_SKYBOX_MODE: number;
  34408. /** Inverse Cubic coordinates mode */
  34409. static readonly TEXTURE_INVCUBIC_MODE: number;
  34410. /** Equirectangular coordinates mode */
  34411. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  34412. /** Equirectangular Fixed coordinates mode */
  34413. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  34414. /** Equirectangular Fixed Mirrored coordinates mode */
  34415. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34416. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34417. static readonly SCALEMODE_FLOOR: number;
  34418. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34419. static readonly SCALEMODE_NEAREST: number;
  34420. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34421. static readonly SCALEMODE_CEILING: number;
  34422. /**
  34423. * Returns the current npm package of the sdk
  34424. */
  34425. static get NpmPackage(): string;
  34426. /**
  34427. * Returns the current version of the framework
  34428. */
  34429. static get Version(): string;
  34430. /** Gets the list of created engines */
  34431. static get Instances(): Engine[];
  34432. /**
  34433. * Gets the latest created engine
  34434. */
  34435. static get LastCreatedEngine(): Nullable<Engine>;
  34436. /**
  34437. * Gets the latest created scene
  34438. */
  34439. static get LastCreatedScene(): Nullable<Scene>;
  34440. /**
  34441. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34442. * @param flag defines which part of the materials must be marked as dirty
  34443. * @param predicate defines a predicate used to filter which materials should be affected
  34444. */
  34445. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34446. /**
  34447. * Method called to create the default loading screen.
  34448. * This can be overriden in your own app.
  34449. * @param canvas The rendering canvas element
  34450. * @returns The loading screen
  34451. */
  34452. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34453. /**
  34454. * Method called to create the default rescale post process on each engine.
  34455. */
  34456. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34457. /**
  34458. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34459. **/
  34460. enableOfflineSupport: boolean;
  34461. /**
  34462. * 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)
  34463. **/
  34464. disableManifestCheck: boolean;
  34465. /**
  34466. * Gets the list of created scenes
  34467. */
  34468. scenes: Scene[];
  34469. /**
  34470. * Event raised when a new scene is created
  34471. */
  34472. onNewSceneAddedObservable: Observable<Scene>;
  34473. /**
  34474. * Gets the list of created postprocesses
  34475. */
  34476. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34477. /**
  34478. * Gets a boolean indicating if the pointer is currently locked
  34479. */
  34480. isPointerLock: boolean;
  34481. /**
  34482. * Observable event triggered each time the rendering canvas is resized
  34483. */
  34484. onResizeObservable: Observable<Engine>;
  34485. /**
  34486. * Observable event triggered each time the canvas loses focus
  34487. */
  34488. onCanvasBlurObservable: Observable<Engine>;
  34489. /**
  34490. * Observable event triggered each time the canvas gains focus
  34491. */
  34492. onCanvasFocusObservable: Observable<Engine>;
  34493. /**
  34494. * Observable event triggered each time the canvas receives pointerout event
  34495. */
  34496. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34497. /**
  34498. * Observable raised when the engine begins a new frame
  34499. */
  34500. onBeginFrameObservable: Observable<Engine>;
  34501. /**
  34502. * If set, will be used to request the next animation frame for the render loop
  34503. */
  34504. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34505. /**
  34506. * Observable raised when the engine ends the current frame
  34507. */
  34508. onEndFrameObservable: Observable<Engine>;
  34509. /**
  34510. * Observable raised when the engine is about to compile a shader
  34511. */
  34512. onBeforeShaderCompilationObservable: Observable<Engine>;
  34513. /**
  34514. * Observable raised when the engine has jsut compiled a shader
  34515. */
  34516. onAfterShaderCompilationObservable: Observable<Engine>;
  34517. /**
  34518. * Gets the audio engine
  34519. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34520. * @ignorenaming
  34521. */
  34522. static audioEngine: IAudioEngine;
  34523. /**
  34524. * Default AudioEngine factory responsible of creating the Audio Engine.
  34525. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34526. */
  34527. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34528. /**
  34529. * Default offline support factory responsible of creating a tool used to store data locally.
  34530. * By default, this will create a Database object if the workload has been embedded.
  34531. */
  34532. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34533. private _loadingScreen;
  34534. private _pointerLockRequested;
  34535. private _dummyFramebuffer;
  34536. private _rescalePostProcess;
  34537. private _deterministicLockstep;
  34538. private _lockstepMaxSteps;
  34539. private _timeStep;
  34540. protected get _supportsHardwareTextureRescaling(): boolean;
  34541. private _fps;
  34542. private _deltaTime;
  34543. /** @hidden */
  34544. _drawCalls: PerfCounter;
  34545. /** 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 */
  34546. canvasTabIndex: number;
  34547. /**
  34548. * Turn this value on if you want to pause FPS computation when in background
  34549. */
  34550. disablePerformanceMonitorInBackground: boolean;
  34551. private _performanceMonitor;
  34552. /**
  34553. * Gets the performance monitor attached to this engine
  34554. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34555. */
  34556. get performanceMonitor(): PerformanceMonitor;
  34557. private _onFocus;
  34558. private _onBlur;
  34559. private _onCanvasPointerOut;
  34560. private _onCanvasBlur;
  34561. private _onCanvasFocus;
  34562. private _onFullscreenChange;
  34563. private _onPointerLockChange;
  34564. /**
  34565. * Gets the HTML element used to attach event listeners
  34566. * @returns a HTML element
  34567. */
  34568. getInputElement(): Nullable<HTMLElement>;
  34569. /**
  34570. * Creates a new engine
  34571. * @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
  34572. * @param antialias defines enable antialiasing (default: false)
  34573. * @param options defines further options to be sent to the getContext() function
  34574. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34575. */
  34576. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34577. /**
  34578. * Gets current aspect ratio
  34579. * @param viewportOwner defines the camera to use to get the aspect ratio
  34580. * @param useScreen defines if screen size must be used (or the current render target if any)
  34581. * @returns a number defining the aspect ratio
  34582. */
  34583. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34584. /**
  34585. * Gets current screen aspect ratio
  34586. * @returns a number defining the aspect ratio
  34587. */
  34588. getScreenAspectRatio(): number;
  34589. /**
  34590. * Gets the client rect of the HTML canvas attached with the current webGL context
  34591. * @returns a client rectanglee
  34592. */
  34593. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34594. /**
  34595. * Gets the client rect of the HTML element used for events
  34596. * @returns a client rectanglee
  34597. */
  34598. getInputElementClientRect(): Nullable<ClientRect>;
  34599. /**
  34600. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34601. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34602. * @returns true if engine is in deterministic lock step mode
  34603. */
  34604. isDeterministicLockStep(): boolean;
  34605. /**
  34606. * Gets the max steps when engine is running in deterministic lock step
  34607. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34608. * @returns the max steps
  34609. */
  34610. getLockstepMaxSteps(): number;
  34611. /**
  34612. * Returns the time in ms between steps when using deterministic lock step.
  34613. * @returns time step in (ms)
  34614. */
  34615. getTimeStep(): number;
  34616. /**
  34617. * Force the mipmap generation for the given render target texture
  34618. * @param texture defines the render target texture to use
  34619. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34620. */
  34621. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34622. /** States */
  34623. /**
  34624. * Set various states to the webGL context
  34625. * @param culling defines backface culling state
  34626. * @param zOffset defines the value to apply to zOffset (0 by default)
  34627. * @param force defines if states must be applied even if cache is up to date
  34628. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34629. */
  34630. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34631. /**
  34632. * Set the z offset to apply to current rendering
  34633. * @param value defines the offset to apply
  34634. */
  34635. setZOffset(value: number): void;
  34636. /**
  34637. * Gets the current value of the zOffset
  34638. * @returns the current zOffset state
  34639. */
  34640. getZOffset(): number;
  34641. /**
  34642. * Enable or disable depth buffering
  34643. * @param enable defines the state to set
  34644. */
  34645. setDepthBuffer(enable: boolean): void;
  34646. /**
  34647. * Gets a boolean indicating if depth writing is enabled
  34648. * @returns the current depth writing state
  34649. */
  34650. getDepthWrite(): boolean;
  34651. /**
  34652. * Enable or disable depth writing
  34653. * @param enable defines the state to set
  34654. */
  34655. setDepthWrite(enable: boolean): void;
  34656. /**
  34657. * Gets a boolean indicating if stencil buffer is enabled
  34658. * @returns the current stencil buffer state
  34659. */
  34660. getStencilBuffer(): boolean;
  34661. /**
  34662. * Enable or disable the stencil buffer
  34663. * @param enable defines if the stencil buffer must be enabled or disabled
  34664. */
  34665. setStencilBuffer(enable: boolean): void;
  34666. /**
  34667. * Gets the current stencil mask
  34668. * @returns a number defining the new stencil mask to use
  34669. */
  34670. getStencilMask(): number;
  34671. /**
  34672. * Sets the current stencil mask
  34673. * @param mask defines the new stencil mask to use
  34674. */
  34675. setStencilMask(mask: number): void;
  34676. /**
  34677. * Gets the current stencil function
  34678. * @returns a number defining the stencil function to use
  34679. */
  34680. getStencilFunction(): number;
  34681. /**
  34682. * Gets the current stencil reference value
  34683. * @returns a number defining the stencil reference value to use
  34684. */
  34685. getStencilFunctionReference(): number;
  34686. /**
  34687. * Gets the current stencil mask
  34688. * @returns a number defining the stencil mask to use
  34689. */
  34690. getStencilFunctionMask(): number;
  34691. /**
  34692. * Sets the current stencil function
  34693. * @param stencilFunc defines the new stencil function to use
  34694. */
  34695. setStencilFunction(stencilFunc: number): void;
  34696. /**
  34697. * Sets the current stencil reference
  34698. * @param reference defines the new stencil reference to use
  34699. */
  34700. setStencilFunctionReference(reference: number): void;
  34701. /**
  34702. * Sets the current stencil mask
  34703. * @param mask defines the new stencil mask to use
  34704. */
  34705. setStencilFunctionMask(mask: number): void;
  34706. /**
  34707. * Gets the current stencil operation when stencil fails
  34708. * @returns a number defining stencil operation to use when stencil fails
  34709. */
  34710. getStencilOperationFail(): number;
  34711. /**
  34712. * Gets the current stencil operation when depth fails
  34713. * @returns a number defining stencil operation to use when depth fails
  34714. */
  34715. getStencilOperationDepthFail(): number;
  34716. /**
  34717. * Gets the current stencil operation when stencil passes
  34718. * @returns a number defining stencil operation to use when stencil passes
  34719. */
  34720. getStencilOperationPass(): number;
  34721. /**
  34722. * Sets the stencil operation to use when stencil fails
  34723. * @param operation defines the stencil operation to use when stencil fails
  34724. */
  34725. setStencilOperationFail(operation: number): void;
  34726. /**
  34727. * Sets the stencil operation to use when depth fails
  34728. * @param operation defines the stencil operation to use when depth fails
  34729. */
  34730. setStencilOperationDepthFail(operation: number): void;
  34731. /**
  34732. * Sets the stencil operation to use when stencil passes
  34733. * @param operation defines the stencil operation to use when stencil passes
  34734. */
  34735. setStencilOperationPass(operation: number): void;
  34736. /**
  34737. * Sets a boolean indicating if the dithering state is enabled or disabled
  34738. * @param value defines the dithering state
  34739. */
  34740. setDitheringState(value: boolean): void;
  34741. /**
  34742. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34743. * @param value defines the rasterizer state
  34744. */
  34745. setRasterizerState(value: boolean): void;
  34746. /**
  34747. * Gets the current depth function
  34748. * @returns a number defining the depth function
  34749. */
  34750. getDepthFunction(): Nullable<number>;
  34751. /**
  34752. * Sets the current depth function
  34753. * @param depthFunc defines the function to use
  34754. */
  34755. setDepthFunction(depthFunc: number): void;
  34756. /**
  34757. * Sets the current depth function to GREATER
  34758. */
  34759. setDepthFunctionToGreater(): void;
  34760. /**
  34761. * Sets the current depth function to GEQUAL
  34762. */
  34763. setDepthFunctionToGreaterOrEqual(): void;
  34764. /**
  34765. * Sets the current depth function to LESS
  34766. */
  34767. setDepthFunctionToLess(): void;
  34768. /**
  34769. * Sets the current depth function to LEQUAL
  34770. */
  34771. setDepthFunctionToLessOrEqual(): void;
  34772. private _cachedStencilBuffer;
  34773. private _cachedStencilFunction;
  34774. private _cachedStencilMask;
  34775. private _cachedStencilOperationPass;
  34776. private _cachedStencilOperationFail;
  34777. private _cachedStencilOperationDepthFail;
  34778. private _cachedStencilReference;
  34779. /**
  34780. * Caches the the state of the stencil buffer
  34781. */
  34782. cacheStencilState(): void;
  34783. /**
  34784. * Restores the state of the stencil buffer
  34785. */
  34786. restoreStencilState(): void;
  34787. /**
  34788. * Directly set the WebGL Viewport
  34789. * @param x defines the x coordinate of the viewport (in screen space)
  34790. * @param y defines the y coordinate of the viewport (in screen space)
  34791. * @param width defines the width of the viewport (in screen space)
  34792. * @param height defines the height of the viewport (in screen space)
  34793. * @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
  34794. */
  34795. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34796. /**
  34797. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34798. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34799. * @param y defines the y-coordinate of the corner of the clear rectangle
  34800. * @param width defines the width of the clear rectangle
  34801. * @param height defines the height of the clear rectangle
  34802. * @param clearColor defines the clear color
  34803. */
  34804. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34805. /**
  34806. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34807. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34808. * @param y defines the y-coordinate of the corner of the clear rectangle
  34809. * @param width defines the width of the clear rectangle
  34810. * @param height defines the height of the clear rectangle
  34811. */
  34812. enableScissor(x: number, y: number, width: number, height: number): void;
  34813. /**
  34814. * Disable previously set scissor test rectangle
  34815. */
  34816. disableScissor(): void;
  34817. protected _reportDrawCall(): void;
  34818. /**
  34819. * Initializes a webVR display and starts listening to display change events
  34820. * The onVRDisplayChangedObservable will be notified upon these changes
  34821. * @returns The onVRDisplayChangedObservable
  34822. */
  34823. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34824. /** @hidden */
  34825. _prepareVRComponent(): void;
  34826. /** @hidden */
  34827. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34828. /** @hidden */
  34829. _submitVRFrame(): void;
  34830. /**
  34831. * Call this function to leave webVR mode
  34832. * Will do nothing if webVR is not supported or if there is no webVR device
  34833. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34834. */
  34835. disableVR(): void;
  34836. /**
  34837. * Gets a boolean indicating that the system is in VR mode and is presenting
  34838. * @returns true if VR mode is engaged
  34839. */
  34840. isVRPresenting(): boolean;
  34841. /** @hidden */
  34842. _requestVRFrame(): void;
  34843. /** @hidden */
  34844. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34845. /**
  34846. * Gets the source code of the vertex shader associated with a specific webGL program
  34847. * @param program defines the program to use
  34848. * @returns a string containing the source code of the vertex shader associated with the program
  34849. */
  34850. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34851. /**
  34852. * Gets the source code of the fragment shader associated with a specific webGL program
  34853. * @param program defines the program to use
  34854. * @returns a string containing the source code of the fragment shader associated with the program
  34855. */
  34856. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34857. /**
  34858. * Sets a depth stencil texture from a render target to the according uniform.
  34859. * @param channel The texture channel
  34860. * @param uniform The uniform to set
  34861. * @param texture The render target texture containing the depth stencil texture to apply
  34862. */
  34863. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34864. /**
  34865. * Sets a texture to the webGL context from a postprocess
  34866. * @param channel defines the channel to use
  34867. * @param postProcess defines the source postprocess
  34868. */
  34869. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34870. /**
  34871. * Binds the output of the passed in post process to the texture channel specified
  34872. * @param channel The channel the texture should be bound to
  34873. * @param postProcess The post process which's output should be bound
  34874. */
  34875. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34876. /** @hidden */
  34877. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34878. protected _rebuildBuffers(): void;
  34879. /** @hidden */
  34880. _renderFrame(): void;
  34881. _renderLoop(): void;
  34882. /** @hidden */
  34883. _renderViews(): boolean;
  34884. /**
  34885. * Toggle full screen mode
  34886. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34887. */
  34888. switchFullscreen(requestPointerLock: boolean): void;
  34889. /**
  34890. * Enters full screen mode
  34891. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34892. */
  34893. enterFullscreen(requestPointerLock: boolean): void;
  34894. /**
  34895. * Exits full screen mode
  34896. */
  34897. exitFullscreen(): void;
  34898. /**
  34899. * Enters Pointerlock mode
  34900. */
  34901. enterPointerlock(): void;
  34902. /**
  34903. * Exits Pointerlock mode
  34904. */
  34905. exitPointerlock(): void;
  34906. /**
  34907. * Begin a new frame
  34908. */
  34909. beginFrame(): void;
  34910. /**
  34911. * Enf the current frame
  34912. */
  34913. endFrame(): void;
  34914. resize(): void;
  34915. /**
  34916. * Force a specific size of the canvas
  34917. * @param width defines the new canvas' width
  34918. * @param height defines the new canvas' height
  34919. */
  34920. setSize(width: number, height: number): void;
  34921. /**
  34922. * Updates a dynamic vertex buffer.
  34923. * @param vertexBuffer the vertex buffer to update
  34924. * @param data the data used to update the vertex buffer
  34925. * @param byteOffset the byte offset of the data
  34926. * @param byteLength the byte length of the data
  34927. */
  34928. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34929. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34930. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34931. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34932. _releaseTexture(texture: InternalTexture): void;
  34933. /**
  34934. * @hidden
  34935. * Rescales a texture
  34936. * @param source input texutre
  34937. * @param destination destination texture
  34938. * @param scene scene to use to render the resize
  34939. * @param internalFormat format to use when resizing
  34940. * @param onComplete callback to be called when resize has completed
  34941. */
  34942. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34943. /**
  34944. * Gets the current framerate
  34945. * @returns a number representing the framerate
  34946. */
  34947. getFps(): number;
  34948. /**
  34949. * Gets the time spent between current and previous frame
  34950. * @returns a number representing the delta time in ms
  34951. */
  34952. getDeltaTime(): number;
  34953. private _measureFps;
  34954. /** @hidden */
  34955. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34956. /**
  34957. * Update a dynamic index buffer
  34958. * @param indexBuffer defines the target index buffer
  34959. * @param indices defines the data to update
  34960. * @param offset defines the offset in the target index buffer where update should start
  34961. */
  34962. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34963. /**
  34964. * Updates the sample count of a render target texture
  34965. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34966. * @param texture defines the texture to update
  34967. * @param samples defines the sample count to set
  34968. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34969. */
  34970. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34971. /**
  34972. * Updates a depth texture Comparison Mode and Function.
  34973. * If the comparison Function is equal to 0, the mode will be set to none.
  34974. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34975. * @param texture The texture to set the comparison function for
  34976. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34977. */
  34978. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34979. /**
  34980. * Creates a webGL buffer to use with instanciation
  34981. * @param capacity defines the size of the buffer
  34982. * @returns the webGL buffer
  34983. */
  34984. createInstancesBuffer(capacity: number): DataBuffer;
  34985. /**
  34986. * Delete a webGL buffer used with instanciation
  34987. * @param buffer defines the webGL buffer to delete
  34988. */
  34989. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34990. private _clientWaitAsync;
  34991. /** @hidden */
  34992. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  34993. /** @hidden */
  34994. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34995. dispose(): void;
  34996. private _disableTouchAction;
  34997. /**
  34998. * Display the loading screen
  34999. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35000. */
  35001. displayLoadingUI(): void;
  35002. /**
  35003. * Hide the loading screen
  35004. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35005. */
  35006. hideLoadingUI(): void;
  35007. /**
  35008. * Gets the current loading screen object
  35009. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35010. */
  35011. get loadingScreen(): ILoadingScreen;
  35012. /**
  35013. * Sets the current loading screen object
  35014. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35015. */
  35016. set loadingScreen(loadingScreen: ILoadingScreen);
  35017. /**
  35018. * Sets the current loading screen text
  35019. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35020. */
  35021. set loadingUIText(text: string);
  35022. /**
  35023. * Sets the current loading screen background color
  35024. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35025. */
  35026. set loadingUIBackgroundColor(color: string);
  35027. /** Pointerlock and fullscreen */
  35028. /**
  35029. * Ask the browser to promote the current element to pointerlock mode
  35030. * @param element defines the DOM element to promote
  35031. */
  35032. static _RequestPointerlock(element: HTMLElement): void;
  35033. /**
  35034. * Asks the browser to exit pointerlock mode
  35035. */
  35036. static _ExitPointerlock(): void;
  35037. /**
  35038. * Ask the browser to promote the current element to fullscreen rendering mode
  35039. * @param element defines the DOM element to promote
  35040. */
  35041. static _RequestFullscreen(element: HTMLElement): void;
  35042. /**
  35043. * Asks the browser to exit fullscreen mode
  35044. */
  35045. static _ExitFullscreen(): void;
  35046. }
  35047. }
  35048. declare module "babylonjs/Engines/engineStore" {
  35049. import { Nullable } from "babylonjs/types";
  35050. import { Engine } from "babylonjs/Engines/engine";
  35051. import { Scene } from "babylonjs/scene";
  35052. /**
  35053. * The engine store class is responsible to hold all the instances of Engine and Scene created
  35054. * during the life time of the application.
  35055. */
  35056. export class EngineStore {
  35057. /** Gets the list of created engines */
  35058. static Instances: import("babylonjs/Engines/engine").Engine[];
  35059. /** @hidden */
  35060. static _LastCreatedScene: Nullable<Scene>;
  35061. /**
  35062. * Gets the latest created engine
  35063. */
  35064. static get LastCreatedEngine(): Nullable<Engine>;
  35065. /**
  35066. * Gets the latest created scene
  35067. */
  35068. static get LastCreatedScene(): Nullable<Scene>;
  35069. /**
  35070. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35071. * @ignorenaming
  35072. */
  35073. static UseFallbackTexture: boolean;
  35074. /**
  35075. * Texture content used if a texture cannot loaded
  35076. * @ignorenaming
  35077. */
  35078. static FallbackTexture: string;
  35079. }
  35080. }
  35081. declare module "babylonjs/Misc/promise" {
  35082. /**
  35083. * Helper class that provides a small promise polyfill
  35084. */
  35085. export class PromisePolyfill {
  35086. /**
  35087. * Static function used to check if the polyfill is required
  35088. * If this is the case then the function will inject the polyfill to window.Promise
  35089. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  35090. */
  35091. static Apply(force?: boolean): void;
  35092. }
  35093. }
  35094. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  35095. /**
  35096. * Interface for screenshot methods with describe argument called `size` as object with options
  35097. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  35098. */
  35099. export interface IScreenshotSize {
  35100. /**
  35101. * number in pixels for canvas height
  35102. */
  35103. height?: number;
  35104. /**
  35105. * multiplier allowing render at a higher or lower resolution
  35106. * If value is defined then height and width will be ignored and taken from camera
  35107. */
  35108. precision?: number;
  35109. /**
  35110. * number in pixels for canvas width
  35111. */
  35112. width?: number;
  35113. }
  35114. }
  35115. declare module "babylonjs/Misc/tools" {
  35116. import { Nullable, float } from "babylonjs/types";
  35117. import { DomManagement } from "babylonjs/Misc/domManagement";
  35118. import { WebRequest } from "babylonjs/Misc/webRequest";
  35119. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35120. import { ReadFileError } from "babylonjs/Misc/fileTools";
  35121. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35122. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  35123. import { Camera } from "babylonjs/Cameras/camera";
  35124. import { Engine } from "babylonjs/Engines/engine";
  35125. interface IColor4Like {
  35126. r: float;
  35127. g: float;
  35128. b: float;
  35129. a: float;
  35130. }
  35131. /**
  35132. * Class containing a set of static utilities functions
  35133. */
  35134. export class Tools {
  35135. /**
  35136. * Gets or sets the base URL to use to load assets
  35137. */
  35138. static get BaseUrl(): string;
  35139. static set BaseUrl(value: string);
  35140. /**
  35141. * Enable/Disable Custom HTTP Request Headers globally.
  35142. * default = false
  35143. * @see CustomRequestHeaders
  35144. */
  35145. static UseCustomRequestHeaders: boolean;
  35146. /**
  35147. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  35148. * i.e. when loading files, where the server/service expects an Authorization header
  35149. */
  35150. static CustomRequestHeaders: {
  35151. [key: string]: string;
  35152. };
  35153. /**
  35154. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  35155. */
  35156. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  35157. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  35158. /**
  35159. * Default behaviour for cors in the application.
  35160. * It can be a string if the expected behavior is identical in the entire app.
  35161. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  35162. */
  35163. static get CorsBehavior(): string | ((url: string | string[]) => string);
  35164. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  35165. /**
  35166. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35167. * @ignorenaming
  35168. */
  35169. static get UseFallbackTexture(): boolean;
  35170. static set UseFallbackTexture(value: boolean);
  35171. /**
  35172. * Use this object to register external classes like custom textures or material
  35173. * to allow the laoders to instantiate them
  35174. */
  35175. static get RegisteredExternalClasses(): {
  35176. [key: string]: Object;
  35177. };
  35178. static set RegisteredExternalClasses(classes: {
  35179. [key: string]: Object;
  35180. });
  35181. /**
  35182. * Texture content used if a texture cannot loaded
  35183. * @ignorenaming
  35184. */
  35185. static get fallbackTexture(): string;
  35186. static set fallbackTexture(value: string);
  35187. /**
  35188. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  35189. * @param u defines the coordinate on X axis
  35190. * @param v defines the coordinate on Y axis
  35191. * @param width defines the width of the source data
  35192. * @param height defines the height of the source data
  35193. * @param pixels defines the source byte array
  35194. * @param color defines the output color
  35195. */
  35196. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  35197. /**
  35198. * Interpolates between a and b via alpha
  35199. * @param a The lower value (returned when alpha = 0)
  35200. * @param b The upper value (returned when alpha = 1)
  35201. * @param alpha The interpolation-factor
  35202. * @return The mixed value
  35203. */
  35204. static Mix(a: number, b: number, alpha: number): number;
  35205. /**
  35206. * Tries to instantiate a new object from a given class name
  35207. * @param className defines the class name to instantiate
  35208. * @returns the new object or null if the system was not able to do the instantiation
  35209. */
  35210. static Instantiate(className: string): any;
  35211. /**
  35212. * Provides a slice function that will work even on IE
  35213. * @param data defines the array to slice
  35214. * @param start defines the start of the data (optional)
  35215. * @param end defines the end of the data (optional)
  35216. * @returns the new sliced array
  35217. */
  35218. static Slice<T>(data: T, start?: number, end?: number): T;
  35219. /**
  35220. * Polyfill for setImmediate
  35221. * @param action defines the action to execute after the current execution block
  35222. */
  35223. static SetImmediate(action: () => void): void;
  35224. /**
  35225. * Function indicating if a number is an exponent of 2
  35226. * @param value defines the value to test
  35227. * @returns true if the value is an exponent of 2
  35228. */
  35229. static IsExponentOfTwo(value: number): boolean;
  35230. private static _tmpFloatArray;
  35231. /**
  35232. * Returns the nearest 32-bit single precision float representation of a Number
  35233. * @param value A Number. If the parameter is of a different type, it will get converted
  35234. * to a number or to NaN if it cannot be converted
  35235. * @returns number
  35236. */
  35237. static FloatRound(value: number): number;
  35238. /**
  35239. * Extracts the filename from a path
  35240. * @param path defines the path to use
  35241. * @returns the filename
  35242. */
  35243. static GetFilename(path: string): string;
  35244. /**
  35245. * Extracts the "folder" part of a path (everything before the filename).
  35246. * @param uri The URI to extract the info from
  35247. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  35248. * @returns The "folder" part of the path
  35249. */
  35250. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  35251. /**
  35252. * Extracts text content from a DOM element hierarchy
  35253. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  35254. */
  35255. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  35256. /**
  35257. * Convert an angle in radians to degrees
  35258. * @param angle defines the angle to convert
  35259. * @returns the angle in degrees
  35260. */
  35261. static ToDegrees(angle: number): number;
  35262. /**
  35263. * Convert an angle in degrees to radians
  35264. * @param angle defines the angle to convert
  35265. * @returns the angle in radians
  35266. */
  35267. static ToRadians(angle: number): number;
  35268. /**
  35269. * Returns an array if obj is not an array
  35270. * @param obj defines the object to evaluate as an array
  35271. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  35272. * @returns either obj directly if obj is an array or a new array containing obj
  35273. */
  35274. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  35275. /**
  35276. * Gets the pointer prefix to use
  35277. * @returns "pointer" if touch is enabled. Else returns "mouse"
  35278. */
  35279. static GetPointerPrefix(): string;
  35280. /**
  35281. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  35282. * @param url define the url we are trying
  35283. * @param element define the dom element where to configure the cors policy
  35284. */
  35285. static SetCorsBehavior(url: string | string[], element: {
  35286. crossOrigin: string | null;
  35287. }): void;
  35288. /**
  35289. * Removes unwanted characters from an url
  35290. * @param url defines the url to clean
  35291. * @returns the cleaned url
  35292. */
  35293. static CleanUrl(url: string): string;
  35294. /**
  35295. * Gets or sets a function used to pre-process url before using them to load assets
  35296. */
  35297. static get PreprocessUrl(): (url: string) => string;
  35298. static set PreprocessUrl(processor: (url: string) => string);
  35299. /**
  35300. * Loads an image as an HTMLImageElement.
  35301. * @param input url string, ArrayBuffer, or Blob to load
  35302. * @param onLoad callback called when the image successfully loads
  35303. * @param onError callback called when the image fails to load
  35304. * @param offlineProvider offline provider for caching
  35305. * @param mimeType optional mime type
  35306. * @returns the HTMLImageElement of the loaded image
  35307. */
  35308. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  35309. /**
  35310. * Loads a file from a url
  35311. * @param url url string, ArrayBuffer, or Blob to load
  35312. * @param onSuccess callback called when the file successfully loads
  35313. * @param onProgress callback called while file is loading (if the server supports this mode)
  35314. * @param offlineProvider defines the offline provider for caching
  35315. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35316. * @param onError callback called when the file fails to load
  35317. * @returns a file request object
  35318. */
  35319. 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;
  35320. /**
  35321. * Loads a file from a url
  35322. * @param url the file url to load
  35323. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35324. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  35325. */
  35326. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  35327. /**
  35328. * Load a script (identified by an url). When the url returns, the
  35329. * content of this file is added into a new script element, attached to the DOM (body element)
  35330. * @param scriptUrl defines the url of the script to laod
  35331. * @param onSuccess defines the callback called when the script is loaded
  35332. * @param onError defines the callback to call if an error occurs
  35333. * @param scriptId defines the id of the script element
  35334. */
  35335. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  35336. /**
  35337. * Load an asynchronous script (identified by an url). When the url returns, the
  35338. * content of this file is added into a new script element, attached to the DOM (body element)
  35339. * @param scriptUrl defines the url of the script to laod
  35340. * @param scriptId defines the id of the script element
  35341. * @returns a promise request object
  35342. */
  35343. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  35344. /**
  35345. * Loads a file from a blob
  35346. * @param fileToLoad defines the blob to use
  35347. * @param callback defines the callback to call when data is loaded
  35348. * @param progressCallback defines the callback to call during loading process
  35349. * @returns a file request object
  35350. */
  35351. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  35352. /**
  35353. * Reads a file from a File object
  35354. * @param file defines the file to load
  35355. * @param onSuccess defines the callback to call when data is loaded
  35356. * @param onProgress defines the callback to call during loading process
  35357. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  35358. * @param onError defines the callback to call when an error occurs
  35359. * @returns a file request object
  35360. */
  35361. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35362. /**
  35363. * Creates a data url from a given string content
  35364. * @param content defines the content to convert
  35365. * @returns the new data url link
  35366. */
  35367. static FileAsURL(content: string): string;
  35368. /**
  35369. * Format the given number to a specific decimal format
  35370. * @param value defines the number to format
  35371. * @param decimals defines the number of decimals to use
  35372. * @returns the formatted string
  35373. */
  35374. static Format(value: number, decimals?: number): string;
  35375. /**
  35376. * Tries to copy an object by duplicating every property
  35377. * @param source defines the source object
  35378. * @param destination defines the target object
  35379. * @param doNotCopyList defines a list of properties to avoid
  35380. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  35381. */
  35382. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  35383. /**
  35384. * Gets a boolean indicating if the given object has no own property
  35385. * @param obj defines the object to test
  35386. * @returns true if object has no own property
  35387. */
  35388. static IsEmpty(obj: any): boolean;
  35389. /**
  35390. * Function used to register events at window level
  35391. * @param windowElement defines the Window object to use
  35392. * @param events defines the events to register
  35393. */
  35394. static RegisterTopRootEvents(windowElement: Window, events: {
  35395. name: string;
  35396. handler: Nullable<(e: FocusEvent) => any>;
  35397. }[]): void;
  35398. /**
  35399. * Function used to unregister events from window level
  35400. * @param windowElement defines the Window object to use
  35401. * @param events defines the events to unregister
  35402. */
  35403. static UnregisterTopRootEvents(windowElement: Window, events: {
  35404. name: string;
  35405. handler: Nullable<(e: FocusEvent) => any>;
  35406. }[]): void;
  35407. /**
  35408. * @ignore
  35409. */
  35410. static _ScreenshotCanvas: HTMLCanvasElement;
  35411. /**
  35412. * Dumps the current bound framebuffer
  35413. * @param width defines the rendering width
  35414. * @param height defines the rendering height
  35415. * @param engine defines the hosting engine
  35416. * @param successCallback defines the callback triggered once the data are available
  35417. * @param mimeType defines the mime type of the result
  35418. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35419. */
  35420. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35421. /**
  35422. * Converts the canvas data to blob.
  35423. * This acts as a polyfill for browsers not supporting the to blob function.
  35424. * @param canvas Defines the canvas to extract the data from
  35425. * @param successCallback Defines the callback triggered once the data are available
  35426. * @param mimeType Defines the mime type of the result
  35427. */
  35428. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35429. /**
  35430. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35431. * @param successCallback defines the callback triggered once the data are available
  35432. * @param mimeType defines the mime type of the result
  35433. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35434. */
  35435. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35436. /**
  35437. * Downloads a blob in the browser
  35438. * @param blob defines the blob to download
  35439. * @param fileName defines the name of the downloaded file
  35440. */
  35441. static Download(blob: Blob, fileName: string): void;
  35442. /**
  35443. * Captures a screenshot of the current rendering
  35444. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35445. * @param engine defines the rendering engine
  35446. * @param camera defines the source camera
  35447. * @param size This parameter can be set to a single number or to an object with the
  35448. * following (optional) properties: precision, width, height. If a single number is passed,
  35449. * it will be used for both width and height. If an object is passed, the screenshot size
  35450. * will be derived from the parameters. The precision property is a multiplier allowing
  35451. * rendering at a higher or lower resolution
  35452. * @param successCallback defines the callback receives a single parameter which contains the
  35453. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35454. * src parameter of an <img> to display it
  35455. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35456. * Check your browser for supported MIME types
  35457. */
  35458. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35459. /**
  35460. * Captures a screenshot of the current rendering
  35461. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35462. * @param engine defines the rendering engine
  35463. * @param camera defines the source camera
  35464. * @param size This parameter can be set to a single number or to an object with the
  35465. * following (optional) properties: precision, width, height. If a single number is passed,
  35466. * it will be used for both width and height. If an object is passed, the screenshot size
  35467. * will be derived from the parameters. The precision property is a multiplier allowing
  35468. * rendering at a higher or lower resolution
  35469. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35470. * Check your browser for supported MIME types
  35471. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35472. * to the src parameter of an <img> to display it
  35473. */
  35474. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35475. /**
  35476. * Generates an image screenshot from the specified camera.
  35477. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35478. * @param engine The engine to use for rendering
  35479. * @param camera The camera to use for rendering
  35480. * @param size This parameter can be set to a single number or to an object with the
  35481. * following (optional) properties: precision, width, height. If a single number is passed,
  35482. * it will be used for both width and height. If an object is passed, the screenshot size
  35483. * will be derived from the parameters. The precision property is a multiplier allowing
  35484. * rendering at a higher or lower resolution
  35485. * @param successCallback The callback receives a single parameter which contains the
  35486. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35487. * src parameter of an <img> to display it
  35488. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35489. * Check your browser for supported MIME types
  35490. * @param samples Texture samples (default: 1)
  35491. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35492. * @param fileName A name for for the downloaded file.
  35493. */
  35494. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35495. /**
  35496. * Generates an image screenshot from the specified camera.
  35497. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35498. * @param engine The engine to use for rendering
  35499. * @param camera The camera to use for rendering
  35500. * @param size This parameter can be set to a single number or to an object with the
  35501. * following (optional) properties: precision, width, height. If a single number is passed,
  35502. * it will be used for both width and height. If an object is passed, the screenshot size
  35503. * will be derived from the parameters. The precision property is a multiplier allowing
  35504. * rendering at a higher or lower resolution
  35505. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35506. * Check your browser for supported MIME types
  35507. * @param samples Texture samples (default: 1)
  35508. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35509. * @param fileName A name for for the downloaded file.
  35510. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35511. * to the src parameter of an <img> to display it
  35512. */
  35513. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35514. /**
  35515. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35516. * Be aware Math.random() could cause collisions, but:
  35517. * "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"
  35518. * @returns a pseudo random id
  35519. */
  35520. static RandomId(): string;
  35521. /**
  35522. * Test if the given uri is a base64 string
  35523. * @param uri The uri to test
  35524. * @return True if the uri is a base64 string or false otherwise
  35525. */
  35526. static IsBase64(uri: string): boolean;
  35527. /**
  35528. * Decode the given base64 uri.
  35529. * @param uri The uri to decode
  35530. * @return The decoded base64 data.
  35531. */
  35532. static DecodeBase64(uri: string): ArrayBuffer;
  35533. /**
  35534. * Gets the absolute url.
  35535. * @param url the input url
  35536. * @return the absolute url
  35537. */
  35538. static GetAbsoluteUrl(url: string): string;
  35539. /**
  35540. * No log
  35541. */
  35542. static readonly NoneLogLevel: number;
  35543. /**
  35544. * Only message logs
  35545. */
  35546. static readonly MessageLogLevel: number;
  35547. /**
  35548. * Only warning logs
  35549. */
  35550. static readonly WarningLogLevel: number;
  35551. /**
  35552. * Only error logs
  35553. */
  35554. static readonly ErrorLogLevel: number;
  35555. /**
  35556. * All logs
  35557. */
  35558. static readonly AllLogLevel: number;
  35559. /**
  35560. * Gets a value indicating the number of loading errors
  35561. * @ignorenaming
  35562. */
  35563. static get errorsCount(): number;
  35564. /**
  35565. * Callback called when a new log is added
  35566. */
  35567. static OnNewCacheEntry: (entry: string) => void;
  35568. /**
  35569. * Log a message to the console
  35570. * @param message defines the message to log
  35571. */
  35572. static Log(message: string): void;
  35573. /**
  35574. * Write a warning message to the console
  35575. * @param message defines the message to log
  35576. */
  35577. static Warn(message: string): void;
  35578. /**
  35579. * Write an error message to the console
  35580. * @param message defines the message to log
  35581. */
  35582. static Error(message: string): void;
  35583. /**
  35584. * Gets current log cache (list of logs)
  35585. */
  35586. static get LogCache(): string;
  35587. /**
  35588. * Clears the log cache
  35589. */
  35590. static ClearLogCache(): void;
  35591. /**
  35592. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35593. */
  35594. static set LogLevels(level: number);
  35595. /**
  35596. * Checks if the window object exists
  35597. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35598. */
  35599. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35600. /**
  35601. * No performance log
  35602. */
  35603. static readonly PerformanceNoneLogLevel: number;
  35604. /**
  35605. * Use user marks to log performance
  35606. */
  35607. static readonly PerformanceUserMarkLogLevel: number;
  35608. /**
  35609. * Log performance to the console
  35610. */
  35611. static readonly PerformanceConsoleLogLevel: number;
  35612. private static _performance;
  35613. /**
  35614. * Sets the current performance log level
  35615. */
  35616. static set PerformanceLogLevel(level: number);
  35617. private static _StartPerformanceCounterDisabled;
  35618. private static _EndPerformanceCounterDisabled;
  35619. private static _StartUserMark;
  35620. private static _EndUserMark;
  35621. private static _StartPerformanceConsole;
  35622. private static _EndPerformanceConsole;
  35623. /**
  35624. * Starts a performance counter
  35625. */
  35626. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35627. /**
  35628. * Ends a specific performance coutner
  35629. */
  35630. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35631. /**
  35632. * Gets either window.performance.now() if supported or Date.now() else
  35633. */
  35634. static get Now(): number;
  35635. /**
  35636. * This method will return the name of the class used to create the instance of the given object.
  35637. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35638. * @param object the object to get the class name from
  35639. * @param isType defines if the object is actually a type
  35640. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35641. */
  35642. static GetClassName(object: any, isType?: boolean): string;
  35643. /**
  35644. * Gets the first element of an array satisfying a given predicate
  35645. * @param array defines the array to browse
  35646. * @param predicate defines the predicate to use
  35647. * @returns null if not found or the element
  35648. */
  35649. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35650. /**
  35651. * This method will return the name of the full name of the class, including its owning module (if any).
  35652. * 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).
  35653. * @param object the object to get the class name from
  35654. * @param isType defines if the object is actually a type
  35655. * @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.
  35656. * @ignorenaming
  35657. */
  35658. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35659. /**
  35660. * Returns a promise that resolves after the given amount of time.
  35661. * @param delay Number of milliseconds to delay
  35662. * @returns Promise that resolves after the given amount of time
  35663. */
  35664. static DelayAsync(delay: number): Promise<void>;
  35665. /**
  35666. * Utility function to detect if the current user agent is Safari
  35667. * @returns whether or not the current user agent is safari
  35668. */
  35669. static IsSafari(): boolean;
  35670. }
  35671. /**
  35672. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35673. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35674. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35675. * @param name The name of the class, case should be preserved
  35676. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35677. */
  35678. export function className(name: string, module?: string): (target: Object) => void;
  35679. /**
  35680. * An implementation of a loop for asynchronous functions.
  35681. */
  35682. export class AsyncLoop {
  35683. /**
  35684. * Defines the number of iterations for the loop
  35685. */
  35686. iterations: number;
  35687. /**
  35688. * Defines the current index of the loop.
  35689. */
  35690. index: number;
  35691. private _done;
  35692. private _fn;
  35693. private _successCallback;
  35694. /**
  35695. * Constructor.
  35696. * @param iterations the number of iterations.
  35697. * @param func the function to run each iteration
  35698. * @param successCallback the callback that will be called upon succesful execution
  35699. * @param offset starting offset.
  35700. */
  35701. constructor(
  35702. /**
  35703. * Defines the number of iterations for the loop
  35704. */
  35705. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35706. /**
  35707. * Execute the next iteration. Must be called after the last iteration was finished.
  35708. */
  35709. executeNext(): void;
  35710. /**
  35711. * Break the loop and run the success callback.
  35712. */
  35713. breakLoop(): void;
  35714. /**
  35715. * Create and run an async loop.
  35716. * @param iterations the number of iterations.
  35717. * @param fn the function to run each iteration
  35718. * @param successCallback the callback that will be called upon succesful execution
  35719. * @param offset starting offset.
  35720. * @returns the created async loop object
  35721. */
  35722. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35723. /**
  35724. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35725. * @param iterations total number of iterations
  35726. * @param syncedIterations number of synchronous iterations in each async iteration.
  35727. * @param fn the function to call each iteration.
  35728. * @param callback a success call back that will be called when iterating stops.
  35729. * @param breakFunction a break condition (optional)
  35730. * @param timeout timeout settings for the setTimeout function. default - 0.
  35731. * @returns the created async loop object
  35732. */
  35733. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35734. }
  35735. }
  35736. declare module "babylonjs/Misc/stringDictionary" {
  35737. import { Nullable } from "babylonjs/types";
  35738. /**
  35739. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35740. * The underlying implementation relies on an associative array to ensure the best performances.
  35741. * The value can be anything including 'null' but except 'undefined'
  35742. */
  35743. export class StringDictionary<T> {
  35744. /**
  35745. * This will clear this dictionary and copy the content from the 'source' one.
  35746. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35747. * @param source the dictionary to take the content from and copy to this dictionary
  35748. */
  35749. copyFrom(source: StringDictionary<T>): void;
  35750. /**
  35751. * Get a value based from its key
  35752. * @param key the given key to get the matching value from
  35753. * @return the value if found, otherwise undefined is returned
  35754. */
  35755. get(key: string): T | undefined;
  35756. /**
  35757. * Get a value from its key or add it if it doesn't exist.
  35758. * This method will ensure you that a given key/data will be present in the dictionary.
  35759. * @param key the given key to get the matching value from
  35760. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35761. * The factory will only be invoked if there's no data for the given key.
  35762. * @return the value corresponding to the key.
  35763. */
  35764. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35765. /**
  35766. * Get a value from its key if present in the dictionary otherwise add it
  35767. * @param key the key to get the value from
  35768. * @param val if there's no such key/value pair in the dictionary add it with this value
  35769. * @return the value corresponding to the key
  35770. */
  35771. getOrAdd(key: string, val: T): T;
  35772. /**
  35773. * Check if there's a given key in the dictionary
  35774. * @param key the key to check for
  35775. * @return true if the key is present, false otherwise
  35776. */
  35777. contains(key: string): boolean;
  35778. /**
  35779. * Add a new key and its corresponding value
  35780. * @param key the key to add
  35781. * @param value the value corresponding to the key
  35782. * @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
  35783. */
  35784. add(key: string, value: T): boolean;
  35785. /**
  35786. * Update a specific value associated to a key
  35787. * @param key defines the key to use
  35788. * @param value defines the value to store
  35789. * @returns true if the value was updated (or false if the key was not found)
  35790. */
  35791. set(key: string, value: T): boolean;
  35792. /**
  35793. * Get the element of the given key and remove it from the dictionary
  35794. * @param key defines the key to search
  35795. * @returns the value associated with the key or null if not found
  35796. */
  35797. getAndRemove(key: string): Nullable<T>;
  35798. /**
  35799. * Remove a key/value from the dictionary.
  35800. * @param key the key to remove
  35801. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35802. */
  35803. remove(key: string): boolean;
  35804. /**
  35805. * Clear the whole content of the dictionary
  35806. */
  35807. clear(): void;
  35808. /**
  35809. * Gets the current count
  35810. */
  35811. get count(): number;
  35812. /**
  35813. * Execute a callback on each key/val of the dictionary.
  35814. * Note that you can remove any element in this dictionary in the callback implementation
  35815. * @param callback the callback to execute on a given key/value pair
  35816. */
  35817. forEach(callback: (key: string, val: T) => void): void;
  35818. /**
  35819. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35820. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35821. * Note that you can remove any element in this dictionary in the callback implementation
  35822. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35823. * @returns the first item
  35824. */
  35825. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35826. private _count;
  35827. private _data;
  35828. }
  35829. }
  35830. declare module "babylonjs/Collisions/collisionCoordinator" {
  35831. import { Nullable } from "babylonjs/types";
  35832. import { Scene } from "babylonjs/scene";
  35833. import { Vector3 } from "babylonjs/Maths/math.vector";
  35834. import { Collider } from "babylonjs/Collisions/collider";
  35835. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35836. /** @hidden */
  35837. export interface ICollisionCoordinator {
  35838. createCollider(): Collider;
  35839. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35840. init(scene: Scene): void;
  35841. }
  35842. /** @hidden */
  35843. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35844. private _scene;
  35845. private _scaledPosition;
  35846. private _scaledVelocity;
  35847. private _finalPosition;
  35848. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35849. createCollider(): Collider;
  35850. init(scene: Scene): void;
  35851. private _collideWithWorld;
  35852. }
  35853. }
  35854. declare module "babylonjs/Inputs/scene.inputManager" {
  35855. import { Nullable } from "babylonjs/types";
  35856. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35857. import { Vector2 } from "babylonjs/Maths/math.vector";
  35858. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35859. import { Scene } from "babylonjs/scene";
  35860. /**
  35861. * Class used to manage all inputs for the scene.
  35862. */
  35863. export class InputManager {
  35864. /** The distance in pixel that you have to move to prevent some events */
  35865. static DragMovementThreshold: number;
  35866. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35867. static LongPressDelay: number;
  35868. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35869. static DoubleClickDelay: number;
  35870. /** If you need to check double click without raising a single click at first click, enable this flag */
  35871. static ExclusiveDoubleClickMode: boolean;
  35872. private _wheelEventName;
  35873. private _onPointerMove;
  35874. private _onPointerDown;
  35875. private _onPointerUp;
  35876. private _initClickEvent;
  35877. private _initActionManager;
  35878. private _delayedSimpleClick;
  35879. private _delayedSimpleClickTimeout;
  35880. private _previousDelayedSimpleClickTimeout;
  35881. private _meshPickProceed;
  35882. private _previousButtonPressed;
  35883. private _currentPickResult;
  35884. private _previousPickResult;
  35885. private _totalPointersPressed;
  35886. private _doubleClickOccured;
  35887. private _pointerOverMesh;
  35888. private _pickedDownMesh;
  35889. private _pickedUpMesh;
  35890. private _pointerX;
  35891. private _pointerY;
  35892. private _unTranslatedPointerX;
  35893. private _unTranslatedPointerY;
  35894. private _startingPointerPosition;
  35895. private _previousStartingPointerPosition;
  35896. private _startingPointerTime;
  35897. private _previousStartingPointerTime;
  35898. private _pointerCaptures;
  35899. private _onKeyDown;
  35900. private _onKeyUp;
  35901. private _onCanvasFocusObserver;
  35902. private _onCanvasBlurObserver;
  35903. private _scene;
  35904. /**
  35905. * Creates a new InputManager
  35906. * @param scene defines the hosting scene
  35907. */
  35908. constructor(scene: Scene);
  35909. /**
  35910. * Gets the mesh that is currently under the pointer
  35911. */
  35912. get meshUnderPointer(): Nullable<AbstractMesh>;
  35913. /**
  35914. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35915. */
  35916. get unTranslatedPointer(): Vector2;
  35917. /**
  35918. * Gets or sets the current on-screen X position of the pointer
  35919. */
  35920. get pointerX(): number;
  35921. set pointerX(value: number);
  35922. /**
  35923. * Gets or sets the current on-screen Y position of the pointer
  35924. */
  35925. get pointerY(): number;
  35926. set pointerY(value: number);
  35927. private _updatePointerPosition;
  35928. private _processPointerMove;
  35929. private _setRayOnPointerInfo;
  35930. private _checkPrePointerObservable;
  35931. /**
  35932. * Use this method to simulate a pointer move on a mesh
  35933. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35934. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35935. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35936. */
  35937. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35938. /**
  35939. * Use this method to simulate a pointer down on a mesh
  35940. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35941. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35942. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35943. */
  35944. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35945. private _processPointerDown;
  35946. /** @hidden */
  35947. _isPointerSwiping(): boolean;
  35948. /**
  35949. * Use this method to simulate a pointer up on a mesh
  35950. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35951. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35952. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35953. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35954. */
  35955. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35956. private _processPointerUp;
  35957. /**
  35958. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35959. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35960. * @returns true if the pointer was captured
  35961. */
  35962. isPointerCaptured(pointerId?: number): boolean;
  35963. /**
  35964. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35965. * @param attachUp defines if you want to attach events to pointerup
  35966. * @param attachDown defines if you want to attach events to pointerdown
  35967. * @param attachMove defines if you want to attach events to pointermove
  35968. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35969. */
  35970. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35971. /**
  35972. * Detaches all event handlers
  35973. */
  35974. detachControl(): void;
  35975. /**
  35976. * Force the value of meshUnderPointer
  35977. * @param mesh defines the mesh to use
  35978. */
  35979. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35980. /**
  35981. * Gets the mesh under the pointer
  35982. * @returns a Mesh or null if no mesh is under the pointer
  35983. */
  35984. getPointerOverMesh(): Nullable<AbstractMesh>;
  35985. }
  35986. }
  35987. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35988. /**
  35989. * Helper class used to generate session unique ID
  35990. */
  35991. export class UniqueIdGenerator {
  35992. private static _UniqueIdCounter;
  35993. /**
  35994. * Gets an unique (relatively to the current scene) Id
  35995. */
  35996. static get UniqueId(): number;
  35997. }
  35998. }
  35999. declare module "babylonjs/Animations/animationGroup" {
  36000. import { Animatable } from "babylonjs/Animations/animatable";
  36001. import { Animation } from "babylonjs/Animations/animation";
  36002. import { Scene, IDisposable } from "babylonjs/scene";
  36003. import { Observable } from "babylonjs/Misc/observable";
  36004. import { Nullable } from "babylonjs/types";
  36005. import "babylonjs/Animations/animatable";
  36006. /**
  36007. * This class defines the direct association between an animation and a target
  36008. */
  36009. export class TargetedAnimation {
  36010. /**
  36011. * Animation to perform
  36012. */
  36013. animation: Animation;
  36014. /**
  36015. * Target to animate
  36016. */
  36017. target: any;
  36018. /**
  36019. * Serialize the object
  36020. * @returns the JSON object representing the current entity
  36021. */
  36022. serialize(): any;
  36023. }
  36024. /**
  36025. * Use this class to create coordinated animations on multiple targets
  36026. */
  36027. export class AnimationGroup implements IDisposable {
  36028. /** The name of the animation group */
  36029. name: string;
  36030. private _scene;
  36031. private _targetedAnimations;
  36032. private _animatables;
  36033. private _from;
  36034. private _to;
  36035. private _isStarted;
  36036. private _isPaused;
  36037. private _speedRatio;
  36038. private _loopAnimation;
  36039. /**
  36040. * Gets or sets the unique id of the node
  36041. */
  36042. uniqueId: number;
  36043. /**
  36044. * This observable will notify when one animation have ended
  36045. */
  36046. onAnimationEndObservable: Observable<TargetedAnimation>;
  36047. /**
  36048. * Observer raised when one animation loops
  36049. */
  36050. onAnimationLoopObservable: Observable<TargetedAnimation>;
  36051. /**
  36052. * Observer raised when all animations have looped
  36053. */
  36054. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  36055. /**
  36056. * This observable will notify when all animations have ended.
  36057. */
  36058. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  36059. /**
  36060. * This observable will notify when all animations have paused.
  36061. */
  36062. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  36063. /**
  36064. * This observable will notify when all animations are playing.
  36065. */
  36066. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  36067. /**
  36068. * Gets the first frame
  36069. */
  36070. get from(): number;
  36071. /**
  36072. * Gets the last frame
  36073. */
  36074. get to(): number;
  36075. /**
  36076. * Define if the animations are started
  36077. */
  36078. get isStarted(): boolean;
  36079. /**
  36080. * Gets a value indicating that the current group is playing
  36081. */
  36082. get isPlaying(): boolean;
  36083. /**
  36084. * Gets or sets the speed ratio to use for all animations
  36085. */
  36086. get speedRatio(): number;
  36087. /**
  36088. * Gets or sets the speed ratio to use for all animations
  36089. */
  36090. set speedRatio(value: number);
  36091. /**
  36092. * Gets or sets if all animations should loop or not
  36093. */
  36094. get loopAnimation(): boolean;
  36095. set loopAnimation(value: boolean);
  36096. /**
  36097. * Gets the targeted animations for this animation group
  36098. */
  36099. get targetedAnimations(): Array<TargetedAnimation>;
  36100. /**
  36101. * returning the list of animatables controlled by this animation group.
  36102. */
  36103. get animatables(): Array<Animatable>;
  36104. /**
  36105. * Instantiates a new Animation Group.
  36106. * This helps managing several animations at once.
  36107. * @see http://doc.babylonjs.com/how_to/group
  36108. * @param name Defines the name of the group
  36109. * @param scene Defines the scene the group belongs to
  36110. */
  36111. constructor(
  36112. /** The name of the animation group */
  36113. name: string, scene?: Nullable<Scene>);
  36114. /**
  36115. * Add an animation (with its target) in the group
  36116. * @param animation defines the animation we want to add
  36117. * @param target defines the target of the animation
  36118. * @returns the TargetedAnimation object
  36119. */
  36120. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  36121. /**
  36122. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  36123. * It can add constant keys at begin or end
  36124. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  36125. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  36126. * @returns the animation group
  36127. */
  36128. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  36129. private _animationLoopCount;
  36130. private _animationLoopFlags;
  36131. private _processLoop;
  36132. /**
  36133. * Start all animations on given targets
  36134. * @param loop defines if animations must loop
  36135. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  36136. * @param from defines the from key (optional)
  36137. * @param to defines the to key (optional)
  36138. * @returns the current animation group
  36139. */
  36140. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  36141. /**
  36142. * Pause all animations
  36143. * @returns the animation group
  36144. */
  36145. pause(): AnimationGroup;
  36146. /**
  36147. * Play all animations to initial state
  36148. * This function will start() the animations if they were not started or will restart() them if they were paused
  36149. * @param loop defines if animations must loop
  36150. * @returns the animation group
  36151. */
  36152. play(loop?: boolean): AnimationGroup;
  36153. /**
  36154. * Reset all animations to initial state
  36155. * @returns the animation group
  36156. */
  36157. reset(): AnimationGroup;
  36158. /**
  36159. * Restart animations from key 0
  36160. * @returns the animation group
  36161. */
  36162. restart(): AnimationGroup;
  36163. /**
  36164. * Stop all animations
  36165. * @returns the animation group
  36166. */
  36167. stop(): AnimationGroup;
  36168. /**
  36169. * Set animation weight for all animatables
  36170. * @param weight defines the weight to use
  36171. * @return the animationGroup
  36172. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36173. */
  36174. setWeightForAllAnimatables(weight: number): AnimationGroup;
  36175. /**
  36176. * Synchronize and normalize all animatables with a source animatable
  36177. * @param root defines the root animatable to synchronize with
  36178. * @return the animationGroup
  36179. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36180. */
  36181. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  36182. /**
  36183. * Goes to a specific frame in this animation group
  36184. * @param frame the frame number to go to
  36185. * @return the animationGroup
  36186. */
  36187. goToFrame(frame: number): AnimationGroup;
  36188. /**
  36189. * Dispose all associated resources
  36190. */
  36191. dispose(): void;
  36192. private _checkAnimationGroupEnded;
  36193. /**
  36194. * Clone the current animation group and returns a copy
  36195. * @param newName defines the name of the new group
  36196. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  36197. * @returns the new aniamtion group
  36198. */
  36199. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  36200. /**
  36201. * Serializes the animationGroup to an object
  36202. * @returns Serialized object
  36203. */
  36204. serialize(): any;
  36205. /**
  36206. * Returns a new AnimationGroup object parsed from the source provided.
  36207. * @param parsedAnimationGroup defines the source
  36208. * @param scene defines the scene that will receive the animationGroup
  36209. * @returns a new AnimationGroup
  36210. */
  36211. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  36212. /**
  36213. * Returns the string "AnimationGroup"
  36214. * @returns "AnimationGroup"
  36215. */
  36216. getClassName(): string;
  36217. /**
  36218. * Creates a detailled string about the object
  36219. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  36220. * @returns a string representing the object
  36221. */
  36222. toString(fullDetails?: boolean): string;
  36223. }
  36224. }
  36225. declare module "babylonjs/scene" {
  36226. import { Nullable } from "babylonjs/types";
  36227. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  36228. import { Observable } from "babylonjs/Misc/observable";
  36229. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  36230. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  36231. import { Geometry } from "babylonjs/Meshes/geometry";
  36232. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36233. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36234. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36235. import { Mesh } from "babylonjs/Meshes/mesh";
  36236. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36237. import { Bone } from "babylonjs/Bones/bone";
  36238. import { Skeleton } from "babylonjs/Bones/skeleton";
  36239. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36240. import { Camera } from "babylonjs/Cameras/camera";
  36241. import { AbstractScene } from "babylonjs/abstractScene";
  36242. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36243. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  36244. import { Material } from "babylonjs/Materials/material";
  36245. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  36246. import { Effect } from "babylonjs/Materials/effect";
  36247. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36248. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36249. import { Light } from "babylonjs/Lights/light";
  36250. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36251. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  36252. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  36253. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  36254. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  36255. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  36256. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36257. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  36258. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  36259. import { Engine } from "babylonjs/Engines/engine";
  36260. import { Node } from "babylonjs/node";
  36261. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  36262. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36263. import { WebRequest } from "babylonjs/Misc/webRequest";
  36264. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  36265. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  36266. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36267. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  36268. import { Plane } from "babylonjs/Maths/math.plane";
  36269. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  36270. import { Ray } from "babylonjs/Culling/ray";
  36271. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36272. import { Animation } from "babylonjs/Animations/animation";
  36273. import { Animatable } from "babylonjs/Animations/animatable";
  36274. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36275. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  36276. import { Collider } from "babylonjs/Collisions/collider";
  36277. /**
  36278. * Define an interface for all classes that will hold resources
  36279. */
  36280. export interface IDisposable {
  36281. /**
  36282. * Releases all held resources
  36283. */
  36284. dispose(): void;
  36285. }
  36286. /** Interface defining initialization parameters for Scene class */
  36287. export interface SceneOptions {
  36288. /**
  36289. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  36290. * It will improve performance when the number of geometries becomes important.
  36291. */
  36292. useGeometryUniqueIdsMap?: boolean;
  36293. /**
  36294. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  36295. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36296. */
  36297. useMaterialMeshMap?: boolean;
  36298. /**
  36299. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  36300. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36301. */
  36302. useClonedMeshMap?: boolean;
  36303. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  36304. virtual?: boolean;
  36305. }
  36306. /**
  36307. * Represents a scene to be rendered by the engine.
  36308. * @see http://doc.babylonjs.com/features/scene
  36309. */
  36310. export class Scene extends AbstractScene implements IAnimatable {
  36311. /** The fog is deactivated */
  36312. static readonly FOGMODE_NONE: number;
  36313. /** The fog density is following an exponential function */
  36314. static readonly FOGMODE_EXP: number;
  36315. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  36316. static readonly FOGMODE_EXP2: number;
  36317. /** The fog density is following a linear function. */
  36318. static readonly FOGMODE_LINEAR: number;
  36319. /**
  36320. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  36321. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36322. */
  36323. static MinDeltaTime: number;
  36324. /**
  36325. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  36326. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36327. */
  36328. static MaxDeltaTime: number;
  36329. /**
  36330. * Factory used to create the default material.
  36331. * @param name The name of the material to create
  36332. * @param scene The scene to create the material for
  36333. * @returns The default material
  36334. */
  36335. static DefaultMaterialFactory(scene: Scene): Material;
  36336. /**
  36337. * Factory used to create the a collision coordinator.
  36338. * @returns The collision coordinator
  36339. */
  36340. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  36341. /** @hidden */
  36342. _inputManager: InputManager;
  36343. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  36344. cameraToUseForPointers: Nullable<Camera>;
  36345. /** @hidden */
  36346. readonly _isScene: boolean;
  36347. /** @hidden */
  36348. _blockEntityCollection: boolean;
  36349. /**
  36350. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  36351. */
  36352. autoClear: boolean;
  36353. /**
  36354. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  36355. */
  36356. autoClearDepthAndStencil: boolean;
  36357. /**
  36358. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  36359. */
  36360. clearColor: Color4;
  36361. /**
  36362. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  36363. */
  36364. ambientColor: Color3;
  36365. /**
  36366. * This is use to store the default BRDF lookup for PBR materials in your scene.
  36367. * It should only be one of the following (if not the default embedded one):
  36368. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  36369. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  36370. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  36371. * The material properties need to be setup according to the type of texture in use.
  36372. */
  36373. environmentBRDFTexture: BaseTexture;
  36374. /** @hidden */
  36375. protected _environmentTexture: Nullable<BaseTexture>;
  36376. /**
  36377. * Texture used in all pbr material as the reflection texture.
  36378. * As in the majority of the scene they are the same (exception for multi room and so on),
  36379. * this is easier to reference from here than from all the materials.
  36380. */
  36381. get environmentTexture(): Nullable<BaseTexture>;
  36382. /**
  36383. * Texture used in all pbr material as the reflection texture.
  36384. * As in the majority of the scene they are the same (exception for multi room and so on),
  36385. * this is easier to set here than in all the materials.
  36386. */
  36387. set environmentTexture(value: Nullable<BaseTexture>);
  36388. /** @hidden */
  36389. protected _environmentIntensity: number;
  36390. /**
  36391. * Intensity of the environment in all pbr material.
  36392. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36393. * As in the majority of the scene they are the same (exception for multi room and so on),
  36394. * this is easier to reference from here than from all the materials.
  36395. */
  36396. get environmentIntensity(): number;
  36397. /**
  36398. * Intensity of the environment in all pbr material.
  36399. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36400. * As in the majority of the scene they are the same (exception for multi room and so on),
  36401. * this is easier to set here than in all the materials.
  36402. */
  36403. set environmentIntensity(value: number);
  36404. /** @hidden */
  36405. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36406. /**
  36407. * Default image processing configuration used either in the rendering
  36408. * Forward main pass or through the imageProcessingPostProcess if present.
  36409. * As in the majority of the scene they are the same (exception for multi camera),
  36410. * this is easier to reference from here than from all the materials and post process.
  36411. *
  36412. * No setter as we it is a shared configuration, you can set the values instead.
  36413. */
  36414. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36415. private _forceWireframe;
  36416. /**
  36417. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36418. */
  36419. set forceWireframe(value: boolean);
  36420. get forceWireframe(): boolean;
  36421. private _skipFrustumClipping;
  36422. /**
  36423. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36424. */
  36425. set skipFrustumClipping(value: boolean);
  36426. get skipFrustumClipping(): boolean;
  36427. private _forcePointsCloud;
  36428. /**
  36429. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36430. */
  36431. set forcePointsCloud(value: boolean);
  36432. get forcePointsCloud(): boolean;
  36433. /**
  36434. * Gets or sets the active clipplane 1
  36435. */
  36436. clipPlane: Nullable<Plane>;
  36437. /**
  36438. * Gets or sets the active clipplane 2
  36439. */
  36440. clipPlane2: Nullable<Plane>;
  36441. /**
  36442. * Gets or sets the active clipplane 3
  36443. */
  36444. clipPlane3: Nullable<Plane>;
  36445. /**
  36446. * Gets or sets the active clipplane 4
  36447. */
  36448. clipPlane4: Nullable<Plane>;
  36449. /**
  36450. * Gets or sets the active clipplane 5
  36451. */
  36452. clipPlane5: Nullable<Plane>;
  36453. /**
  36454. * Gets or sets the active clipplane 6
  36455. */
  36456. clipPlane6: Nullable<Plane>;
  36457. /**
  36458. * Gets or sets a boolean indicating if animations are enabled
  36459. */
  36460. animationsEnabled: boolean;
  36461. private _animationPropertiesOverride;
  36462. /**
  36463. * Gets or sets the animation properties override
  36464. */
  36465. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36466. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36467. /**
  36468. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36469. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36470. */
  36471. useConstantAnimationDeltaTime: boolean;
  36472. /**
  36473. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36474. * Please note that it requires to run a ray cast through the scene on every frame
  36475. */
  36476. constantlyUpdateMeshUnderPointer: boolean;
  36477. /**
  36478. * Defines the HTML cursor to use when hovering over interactive elements
  36479. */
  36480. hoverCursor: string;
  36481. /**
  36482. * Defines the HTML default cursor to use (empty by default)
  36483. */
  36484. defaultCursor: string;
  36485. /**
  36486. * Defines whether cursors are handled by the scene.
  36487. */
  36488. doNotHandleCursors: boolean;
  36489. /**
  36490. * This is used to call preventDefault() on pointer down
  36491. * in order to block unwanted artifacts like system double clicks
  36492. */
  36493. preventDefaultOnPointerDown: boolean;
  36494. /**
  36495. * This is used to call preventDefault() on pointer up
  36496. * in order to block unwanted artifacts like system double clicks
  36497. */
  36498. preventDefaultOnPointerUp: boolean;
  36499. /**
  36500. * Gets or sets user defined metadata
  36501. */
  36502. metadata: any;
  36503. /**
  36504. * For internal use only. Please do not use.
  36505. */
  36506. reservedDataStore: any;
  36507. /**
  36508. * Gets the name of the plugin used to load this scene (null by default)
  36509. */
  36510. loadingPluginName: string;
  36511. /**
  36512. * Use this array to add regular expressions used to disable offline support for specific urls
  36513. */
  36514. disableOfflineSupportExceptionRules: RegExp[];
  36515. /**
  36516. * An event triggered when the scene is disposed.
  36517. */
  36518. onDisposeObservable: Observable<Scene>;
  36519. private _onDisposeObserver;
  36520. /** Sets a function to be executed when this scene is disposed. */
  36521. set onDispose(callback: () => void);
  36522. /**
  36523. * An event triggered before rendering the scene (right after animations and physics)
  36524. */
  36525. onBeforeRenderObservable: Observable<Scene>;
  36526. private _onBeforeRenderObserver;
  36527. /** Sets a function to be executed before rendering this scene */
  36528. set beforeRender(callback: Nullable<() => void>);
  36529. /**
  36530. * An event triggered after rendering the scene
  36531. */
  36532. onAfterRenderObservable: Observable<Scene>;
  36533. /**
  36534. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36535. */
  36536. onAfterRenderCameraObservable: Observable<Camera>;
  36537. private _onAfterRenderObserver;
  36538. /** Sets a function to be executed after rendering this scene */
  36539. set afterRender(callback: Nullable<() => void>);
  36540. /**
  36541. * An event triggered before animating the scene
  36542. */
  36543. onBeforeAnimationsObservable: Observable<Scene>;
  36544. /**
  36545. * An event triggered after animations processing
  36546. */
  36547. onAfterAnimationsObservable: Observable<Scene>;
  36548. /**
  36549. * An event triggered before draw calls are ready to be sent
  36550. */
  36551. onBeforeDrawPhaseObservable: Observable<Scene>;
  36552. /**
  36553. * An event triggered after draw calls have been sent
  36554. */
  36555. onAfterDrawPhaseObservable: Observable<Scene>;
  36556. /**
  36557. * An event triggered when the scene is ready
  36558. */
  36559. onReadyObservable: Observable<Scene>;
  36560. /**
  36561. * An event triggered before rendering a camera
  36562. */
  36563. onBeforeCameraRenderObservable: Observable<Camera>;
  36564. private _onBeforeCameraRenderObserver;
  36565. /** Sets a function to be executed before rendering a camera*/
  36566. set beforeCameraRender(callback: () => void);
  36567. /**
  36568. * An event triggered after rendering a camera
  36569. */
  36570. onAfterCameraRenderObservable: Observable<Camera>;
  36571. private _onAfterCameraRenderObserver;
  36572. /** Sets a function to be executed after rendering a camera*/
  36573. set afterCameraRender(callback: () => void);
  36574. /**
  36575. * An event triggered when active meshes evaluation is about to start
  36576. */
  36577. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36578. /**
  36579. * An event triggered when active meshes evaluation is done
  36580. */
  36581. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36582. /**
  36583. * An event triggered when particles rendering is about to start
  36584. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36585. */
  36586. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36587. /**
  36588. * An event triggered when particles rendering is done
  36589. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36590. */
  36591. onAfterParticlesRenderingObservable: Observable<Scene>;
  36592. /**
  36593. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36594. */
  36595. onDataLoadedObservable: Observable<Scene>;
  36596. /**
  36597. * An event triggered when a camera is created
  36598. */
  36599. onNewCameraAddedObservable: Observable<Camera>;
  36600. /**
  36601. * An event triggered when a camera is removed
  36602. */
  36603. onCameraRemovedObservable: Observable<Camera>;
  36604. /**
  36605. * An event triggered when a light is created
  36606. */
  36607. onNewLightAddedObservable: Observable<Light>;
  36608. /**
  36609. * An event triggered when a light is removed
  36610. */
  36611. onLightRemovedObservable: Observable<Light>;
  36612. /**
  36613. * An event triggered when a geometry is created
  36614. */
  36615. onNewGeometryAddedObservable: Observable<Geometry>;
  36616. /**
  36617. * An event triggered when a geometry is removed
  36618. */
  36619. onGeometryRemovedObservable: Observable<Geometry>;
  36620. /**
  36621. * An event triggered when a transform node is created
  36622. */
  36623. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36624. /**
  36625. * An event triggered when a transform node is removed
  36626. */
  36627. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36628. /**
  36629. * An event triggered when a mesh is created
  36630. */
  36631. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36632. /**
  36633. * An event triggered when a mesh is removed
  36634. */
  36635. onMeshRemovedObservable: Observable<AbstractMesh>;
  36636. /**
  36637. * An event triggered when a skeleton is created
  36638. */
  36639. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36640. /**
  36641. * An event triggered when a skeleton is removed
  36642. */
  36643. onSkeletonRemovedObservable: Observable<Skeleton>;
  36644. /**
  36645. * An event triggered when a material is created
  36646. */
  36647. onNewMaterialAddedObservable: Observable<Material>;
  36648. /**
  36649. * An event triggered when a material is removed
  36650. */
  36651. onMaterialRemovedObservable: Observable<Material>;
  36652. /**
  36653. * An event triggered when a texture is created
  36654. */
  36655. onNewTextureAddedObservable: Observable<BaseTexture>;
  36656. /**
  36657. * An event triggered when a texture is removed
  36658. */
  36659. onTextureRemovedObservable: Observable<BaseTexture>;
  36660. /**
  36661. * An event triggered when render targets are about to be rendered
  36662. * Can happen multiple times per frame.
  36663. */
  36664. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36665. /**
  36666. * An event triggered when render targets were rendered.
  36667. * Can happen multiple times per frame.
  36668. */
  36669. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36670. /**
  36671. * An event triggered before calculating deterministic simulation step
  36672. */
  36673. onBeforeStepObservable: Observable<Scene>;
  36674. /**
  36675. * An event triggered after calculating deterministic simulation step
  36676. */
  36677. onAfterStepObservable: Observable<Scene>;
  36678. /**
  36679. * An event triggered when the activeCamera property is updated
  36680. */
  36681. onActiveCameraChanged: Observable<Scene>;
  36682. /**
  36683. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36684. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36685. * 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)
  36686. */
  36687. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36688. /**
  36689. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36690. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36691. * 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)
  36692. */
  36693. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36694. /**
  36695. * This Observable will when a mesh has been imported into the scene.
  36696. */
  36697. onMeshImportedObservable: Observable<AbstractMesh>;
  36698. /**
  36699. * This Observable will when an animation file has been imported into the scene.
  36700. */
  36701. onAnimationFileImportedObservable: Observable<Scene>;
  36702. /**
  36703. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36704. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36705. */
  36706. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36707. /** @hidden */
  36708. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36709. /**
  36710. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36711. */
  36712. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36713. /**
  36714. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36715. */
  36716. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36717. /**
  36718. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36719. */
  36720. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36721. /** Callback called when a pointer move is detected */
  36722. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36723. /** Callback called when a pointer down is detected */
  36724. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36725. /** Callback called when a pointer up is detected */
  36726. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36727. /** Callback called when a pointer pick is detected */
  36728. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36729. /**
  36730. * 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).
  36731. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36732. */
  36733. onPrePointerObservable: Observable<PointerInfoPre>;
  36734. /**
  36735. * Observable event triggered each time an input event is received from the rendering canvas
  36736. */
  36737. onPointerObservable: Observable<PointerInfo>;
  36738. /**
  36739. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36740. */
  36741. get unTranslatedPointer(): Vector2;
  36742. /**
  36743. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36744. */
  36745. static get DragMovementThreshold(): number;
  36746. static set DragMovementThreshold(value: number);
  36747. /**
  36748. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36749. */
  36750. static get LongPressDelay(): number;
  36751. static set LongPressDelay(value: number);
  36752. /**
  36753. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36754. */
  36755. static get DoubleClickDelay(): number;
  36756. static set DoubleClickDelay(value: number);
  36757. /** If you need to check double click without raising a single click at first click, enable this flag */
  36758. static get ExclusiveDoubleClickMode(): boolean;
  36759. static set ExclusiveDoubleClickMode(value: boolean);
  36760. /** @hidden */
  36761. _mirroredCameraPosition: Nullable<Vector3>;
  36762. /**
  36763. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36764. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36765. */
  36766. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36767. /**
  36768. * Observable event triggered each time an keyboard event is received from the hosting window
  36769. */
  36770. onKeyboardObservable: Observable<KeyboardInfo>;
  36771. private _useRightHandedSystem;
  36772. /**
  36773. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36774. */
  36775. set useRightHandedSystem(value: boolean);
  36776. get useRightHandedSystem(): boolean;
  36777. private _timeAccumulator;
  36778. private _currentStepId;
  36779. private _currentInternalStep;
  36780. /**
  36781. * Sets the step Id used by deterministic lock step
  36782. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36783. * @param newStepId defines the step Id
  36784. */
  36785. setStepId(newStepId: number): void;
  36786. /**
  36787. * Gets the step Id used by deterministic lock step
  36788. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36789. * @returns the step Id
  36790. */
  36791. getStepId(): number;
  36792. /**
  36793. * Gets the internal step used by deterministic lock step
  36794. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36795. * @returns the internal step
  36796. */
  36797. getInternalStep(): number;
  36798. private _fogEnabled;
  36799. /**
  36800. * Gets or sets a boolean indicating if fog is enabled on this scene
  36801. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36802. * (Default is true)
  36803. */
  36804. set fogEnabled(value: boolean);
  36805. get fogEnabled(): boolean;
  36806. private _fogMode;
  36807. /**
  36808. * Gets or sets the fog mode to use
  36809. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36810. * | mode | value |
  36811. * | --- | --- |
  36812. * | FOGMODE_NONE | 0 |
  36813. * | FOGMODE_EXP | 1 |
  36814. * | FOGMODE_EXP2 | 2 |
  36815. * | FOGMODE_LINEAR | 3 |
  36816. */
  36817. set fogMode(value: number);
  36818. get fogMode(): number;
  36819. /**
  36820. * Gets or sets the fog color to use
  36821. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36822. * (Default is Color3(0.2, 0.2, 0.3))
  36823. */
  36824. fogColor: Color3;
  36825. /**
  36826. * Gets or sets the fog density to use
  36827. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36828. * (Default is 0.1)
  36829. */
  36830. fogDensity: number;
  36831. /**
  36832. * Gets or sets the fog start distance to use
  36833. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36834. * (Default is 0)
  36835. */
  36836. fogStart: number;
  36837. /**
  36838. * Gets or sets the fog end distance to use
  36839. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36840. * (Default is 1000)
  36841. */
  36842. fogEnd: number;
  36843. private _shadowsEnabled;
  36844. /**
  36845. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36846. */
  36847. set shadowsEnabled(value: boolean);
  36848. get shadowsEnabled(): boolean;
  36849. private _lightsEnabled;
  36850. /**
  36851. * Gets or sets a boolean indicating if lights are enabled on this scene
  36852. */
  36853. set lightsEnabled(value: boolean);
  36854. get lightsEnabled(): boolean;
  36855. /** All of the active cameras added to this scene. */
  36856. activeCameras: Camera[];
  36857. /** @hidden */
  36858. _activeCamera: Nullable<Camera>;
  36859. /** Gets or sets the current active camera */
  36860. get activeCamera(): Nullable<Camera>;
  36861. set activeCamera(value: Nullable<Camera>);
  36862. private _defaultMaterial;
  36863. /** The default material used on meshes when no material is affected */
  36864. get defaultMaterial(): Material;
  36865. /** The default material used on meshes when no material is affected */
  36866. set defaultMaterial(value: Material);
  36867. private _texturesEnabled;
  36868. /**
  36869. * Gets or sets a boolean indicating if textures are enabled on this scene
  36870. */
  36871. set texturesEnabled(value: boolean);
  36872. get texturesEnabled(): boolean;
  36873. /**
  36874. * Gets or sets a boolean indicating if particles are enabled on this scene
  36875. */
  36876. particlesEnabled: boolean;
  36877. /**
  36878. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36879. */
  36880. spritesEnabled: boolean;
  36881. private _skeletonsEnabled;
  36882. /**
  36883. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36884. */
  36885. set skeletonsEnabled(value: boolean);
  36886. get skeletonsEnabled(): boolean;
  36887. /**
  36888. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36889. */
  36890. lensFlaresEnabled: boolean;
  36891. /**
  36892. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36893. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36894. */
  36895. collisionsEnabled: boolean;
  36896. private _collisionCoordinator;
  36897. /** @hidden */
  36898. get collisionCoordinator(): ICollisionCoordinator;
  36899. /**
  36900. * Defines the gravity applied to this scene (used only for collisions)
  36901. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36902. */
  36903. gravity: Vector3;
  36904. /**
  36905. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36906. */
  36907. postProcessesEnabled: boolean;
  36908. /**
  36909. * The list of postprocesses added to the scene
  36910. */
  36911. postProcesses: PostProcess[];
  36912. /**
  36913. * Gets the current postprocess manager
  36914. */
  36915. postProcessManager: PostProcessManager;
  36916. /**
  36917. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36918. */
  36919. renderTargetsEnabled: boolean;
  36920. /**
  36921. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36922. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36923. */
  36924. dumpNextRenderTargets: boolean;
  36925. /**
  36926. * The list of user defined render targets added to the scene
  36927. */
  36928. customRenderTargets: RenderTargetTexture[];
  36929. /**
  36930. * Defines if texture loading must be delayed
  36931. * If true, textures will only be loaded when they need to be rendered
  36932. */
  36933. useDelayedTextureLoading: boolean;
  36934. /**
  36935. * Gets the list of meshes imported to the scene through SceneLoader
  36936. */
  36937. importedMeshesFiles: String[];
  36938. /**
  36939. * Gets or sets a boolean indicating if probes are enabled on this scene
  36940. */
  36941. probesEnabled: boolean;
  36942. /**
  36943. * Gets or sets the current offline provider to use to store scene data
  36944. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36945. */
  36946. offlineProvider: IOfflineProvider;
  36947. /**
  36948. * Gets or sets the action manager associated with the scene
  36949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36950. */
  36951. actionManager: AbstractActionManager;
  36952. private _meshesForIntersections;
  36953. /**
  36954. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36955. */
  36956. proceduralTexturesEnabled: boolean;
  36957. private _engine;
  36958. private _totalVertices;
  36959. /** @hidden */
  36960. _activeIndices: PerfCounter;
  36961. /** @hidden */
  36962. _activeParticles: PerfCounter;
  36963. /** @hidden */
  36964. _activeBones: PerfCounter;
  36965. private _animationRatio;
  36966. /** @hidden */
  36967. _animationTimeLast: number;
  36968. /** @hidden */
  36969. _animationTime: number;
  36970. /**
  36971. * Gets or sets a general scale for animation speed
  36972. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36973. */
  36974. animationTimeScale: number;
  36975. /** @hidden */
  36976. _cachedMaterial: Nullable<Material>;
  36977. /** @hidden */
  36978. _cachedEffect: Nullable<Effect>;
  36979. /** @hidden */
  36980. _cachedVisibility: Nullable<number>;
  36981. private _renderId;
  36982. private _frameId;
  36983. private _executeWhenReadyTimeoutId;
  36984. private _intermediateRendering;
  36985. private _viewUpdateFlag;
  36986. private _projectionUpdateFlag;
  36987. /** @hidden */
  36988. _toBeDisposed: Nullable<IDisposable>[];
  36989. private _activeRequests;
  36990. /** @hidden */
  36991. _pendingData: any[];
  36992. private _isDisposed;
  36993. /**
  36994. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36995. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36996. */
  36997. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36998. private _activeMeshes;
  36999. private _processedMaterials;
  37000. private _renderTargets;
  37001. /** @hidden */
  37002. _activeParticleSystems: SmartArray<IParticleSystem>;
  37003. private _activeSkeletons;
  37004. private _softwareSkinnedMeshes;
  37005. private _renderingManager;
  37006. /** @hidden */
  37007. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  37008. private _transformMatrix;
  37009. private _sceneUbo;
  37010. /** @hidden */
  37011. _viewMatrix: Matrix;
  37012. private _projectionMatrix;
  37013. /** @hidden */
  37014. _forcedViewPosition: Nullable<Vector3>;
  37015. /** @hidden */
  37016. _frustumPlanes: Plane[];
  37017. /**
  37018. * Gets the list of frustum planes (built from the active camera)
  37019. */
  37020. get frustumPlanes(): Plane[];
  37021. /**
  37022. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  37023. * This is useful if there are more lights that the maximum simulteanous authorized
  37024. */
  37025. requireLightSorting: boolean;
  37026. /** @hidden */
  37027. readonly useMaterialMeshMap: boolean;
  37028. /** @hidden */
  37029. readonly useClonedMeshMap: boolean;
  37030. private _externalData;
  37031. private _uid;
  37032. /**
  37033. * @hidden
  37034. * Backing store of defined scene components.
  37035. */
  37036. _components: ISceneComponent[];
  37037. /**
  37038. * @hidden
  37039. * Backing store of defined scene components.
  37040. */
  37041. _serializableComponents: ISceneSerializableComponent[];
  37042. /**
  37043. * List of components to register on the next registration step.
  37044. */
  37045. private _transientComponents;
  37046. /**
  37047. * Registers the transient components if needed.
  37048. */
  37049. private _registerTransientComponents;
  37050. /**
  37051. * @hidden
  37052. * Add a component to the scene.
  37053. * Note that the ccomponent could be registered on th next frame if this is called after
  37054. * the register component stage.
  37055. * @param component Defines the component to add to the scene
  37056. */
  37057. _addComponent(component: ISceneComponent): void;
  37058. /**
  37059. * @hidden
  37060. * Gets a component from the scene.
  37061. * @param name defines the name of the component to retrieve
  37062. * @returns the component or null if not present
  37063. */
  37064. _getComponent(name: string): Nullable<ISceneComponent>;
  37065. /**
  37066. * @hidden
  37067. * Defines the actions happening before camera updates.
  37068. */
  37069. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  37070. /**
  37071. * @hidden
  37072. * Defines the actions happening before clear the canvas.
  37073. */
  37074. _beforeClearStage: Stage<SimpleStageAction>;
  37075. /**
  37076. * @hidden
  37077. * Defines the actions when collecting render targets for the frame.
  37078. */
  37079. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  37080. /**
  37081. * @hidden
  37082. * Defines the actions happening for one camera in the frame.
  37083. */
  37084. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  37085. /**
  37086. * @hidden
  37087. * Defines the actions happening during the per mesh ready checks.
  37088. */
  37089. _isReadyForMeshStage: Stage<MeshStageAction>;
  37090. /**
  37091. * @hidden
  37092. * Defines the actions happening before evaluate active mesh checks.
  37093. */
  37094. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  37095. /**
  37096. * @hidden
  37097. * Defines the actions happening during the evaluate sub mesh checks.
  37098. */
  37099. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  37100. /**
  37101. * @hidden
  37102. * Defines the actions happening during the active mesh stage.
  37103. */
  37104. _activeMeshStage: Stage<ActiveMeshStageAction>;
  37105. /**
  37106. * @hidden
  37107. * Defines the actions happening during the per camera render target step.
  37108. */
  37109. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  37110. /**
  37111. * @hidden
  37112. * Defines the actions happening just before the active camera is drawing.
  37113. */
  37114. _beforeCameraDrawStage: Stage<CameraStageAction>;
  37115. /**
  37116. * @hidden
  37117. * Defines the actions happening just before a render target is drawing.
  37118. */
  37119. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  37120. /**
  37121. * @hidden
  37122. * Defines the actions happening just before a rendering group is drawing.
  37123. */
  37124. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  37125. /**
  37126. * @hidden
  37127. * Defines the actions happening just before a mesh is drawing.
  37128. */
  37129. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  37130. /**
  37131. * @hidden
  37132. * Defines the actions happening just after a mesh has been drawn.
  37133. */
  37134. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  37135. /**
  37136. * @hidden
  37137. * Defines the actions happening just after a rendering group has been drawn.
  37138. */
  37139. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  37140. /**
  37141. * @hidden
  37142. * Defines the actions happening just after the active camera has been drawn.
  37143. */
  37144. _afterCameraDrawStage: Stage<CameraStageAction>;
  37145. /**
  37146. * @hidden
  37147. * Defines the actions happening just after a render target has been drawn.
  37148. */
  37149. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  37150. /**
  37151. * @hidden
  37152. * Defines the actions happening just after rendering all cameras and computing intersections.
  37153. */
  37154. _afterRenderStage: Stage<SimpleStageAction>;
  37155. /**
  37156. * @hidden
  37157. * Defines the actions happening when a pointer move event happens.
  37158. */
  37159. _pointerMoveStage: Stage<PointerMoveStageAction>;
  37160. /**
  37161. * @hidden
  37162. * Defines the actions happening when a pointer down event happens.
  37163. */
  37164. _pointerDownStage: Stage<PointerUpDownStageAction>;
  37165. /**
  37166. * @hidden
  37167. * Defines the actions happening when a pointer up event happens.
  37168. */
  37169. _pointerUpStage: Stage<PointerUpDownStageAction>;
  37170. /**
  37171. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  37172. */
  37173. private geometriesByUniqueId;
  37174. /**
  37175. * Creates a new Scene
  37176. * @param engine defines the engine to use to render this scene
  37177. * @param options defines the scene options
  37178. */
  37179. constructor(engine: Engine, options?: SceneOptions);
  37180. /**
  37181. * Gets a string idenfifying the name of the class
  37182. * @returns "Scene" string
  37183. */
  37184. getClassName(): string;
  37185. private _defaultMeshCandidates;
  37186. /**
  37187. * @hidden
  37188. */
  37189. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  37190. private _defaultSubMeshCandidates;
  37191. /**
  37192. * @hidden
  37193. */
  37194. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  37195. /**
  37196. * Sets the default candidate providers for the scene.
  37197. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  37198. * and getCollidingSubMeshCandidates to their default function
  37199. */
  37200. setDefaultCandidateProviders(): void;
  37201. /**
  37202. * Gets the mesh that is currently under the pointer
  37203. */
  37204. get meshUnderPointer(): Nullable<AbstractMesh>;
  37205. /**
  37206. * Gets or sets the current on-screen X position of the pointer
  37207. */
  37208. get pointerX(): number;
  37209. set pointerX(value: number);
  37210. /**
  37211. * Gets or sets the current on-screen Y position of the pointer
  37212. */
  37213. get pointerY(): number;
  37214. set pointerY(value: number);
  37215. /**
  37216. * Gets the cached material (ie. the latest rendered one)
  37217. * @returns the cached material
  37218. */
  37219. getCachedMaterial(): Nullable<Material>;
  37220. /**
  37221. * Gets the cached effect (ie. the latest rendered one)
  37222. * @returns the cached effect
  37223. */
  37224. getCachedEffect(): Nullable<Effect>;
  37225. /**
  37226. * Gets the cached visibility state (ie. the latest rendered one)
  37227. * @returns the cached visibility state
  37228. */
  37229. getCachedVisibility(): Nullable<number>;
  37230. /**
  37231. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  37232. * @param material defines the current material
  37233. * @param effect defines the current effect
  37234. * @param visibility defines the current visibility state
  37235. * @returns true if one parameter is not cached
  37236. */
  37237. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  37238. /**
  37239. * Gets the engine associated with the scene
  37240. * @returns an Engine
  37241. */
  37242. getEngine(): Engine;
  37243. /**
  37244. * Gets the total number of vertices rendered per frame
  37245. * @returns the total number of vertices rendered per frame
  37246. */
  37247. getTotalVertices(): number;
  37248. /**
  37249. * Gets the performance counter for total vertices
  37250. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37251. */
  37252. get totalVerticesPerfCounter(): PerfCounter;
  37253. /**
  37254. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  37255. * @returns the total number of active indices rendered per frame
  37256. */
  37257. getActiveIndices(): number;
  37258. /**
  37259. * Gets the performance counter for active indices
  37260. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37261. */
  37262. get totalActiveIndicesPerfCounter(): PerfCounter;
  37263. /**
  37264. * Gets the total number of active particles rendered per frame
  37265. * @returns the total number of active particles rendered per frame
  37266. */
  37267. getActiveParticles(): number;
  37268. /**
  37269. * Gets the performance counter for active particles
  37270. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37271. */
  37272. get activeParticlesPerfCounter(): PerfCounter;
  37273. /**
  37274. * Gets the total number of active bones rendered per frame
  37275. * @returns the total number of active bones rendered per frame
  37276. */
  37277. getActiveBones(): number;
  37278. /**
  37279. * Gets the performance counter for active bones
  37280. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37281. */
  37282. get activeBonesPerfCounter(): PerfCounter;
  37283. /**
  37284. * Gets the array of active meshes
  37285. * @returns an array of AbstractMesh
  37286. */
  37287. getActiveMeshes(): SmartArray<AbstractMesh>;
  37288. /**
  37289. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  37290. * @returns a number
  37291. */
  37292. getAnimationRatio(): number;
  37293. /**
  37294. * Gets an unique Id for the current render phase
  37295. * @returns a number
  37296. */
  37297. getRenderId(): number;
  37298. /**
  37299. * Gets an unique Id for the current frame
  37300. * @returns a number
  37301. */
  37302. getFrameId(): number;
  37303. /** Call this function if you want to manually increment the render Id*/
  37304. incrementRenderId(): void;
  37305. private _createUbo;
  37306. /**
  37307. * Use this method to simulate a pointer move on a mesh
  37308. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37309. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37310. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37311. * @returns the current scene
  37312. */
  37313. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37314. /**
  37315. * Use this method to simulate a pointer down on a mesh
  37316. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37317. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37318. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37319. * @returns the current scene
  37320. */
  37321. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37322. /**
  37323. * Use this method to simulate a pointer up on a mesh
  37324. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37325. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37326. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37327. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37328. * @returns the current scene
  37329. */
  37330. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  37331. /**
  37332. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37333. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37334. * @returns true if the pointer was captured
  37335. */
  37336. isPointerCaptured(pointerId?: number): boolean;
  37337. /**
  37338. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37339. * @param attachUp defines if you want to attach events to pointerup
  37340. * @param attachDown defines if you want to attach events to pointerdown
  37341. * @param attachMove defines if you want to attach events to pointermove
  37342. */
  37343. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  37344. /** Detaches all event handlers*/
  37345. detachControl(): void;
  37346. /**
  37347. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  37348. * Delay loaded resources are not taking in account
  37349. * @return true if all required resources are ready
  37350. */
  37351. isReady(): boolean;
  37352. /** Resets all cached information relative to material (including effect and visibility) */
  37353. resetCachedMaterial(): void;
  37354. /**
  37355. * Registers a function to be called before every frame render
  37356. * @param func defines the function to register
  37357. */
  37358. registerBeforeRender(func: () => void): void;
  37359. /**
  37360. * Unregisters a function called before every frame render
  37361. * @param func defines the function to unregister
  37362. */
  37363. unregisterBeforeRender(func: () => void): void;
  37364. /**
  37365. * Registers a function to be called after every frame render
  37366. * @param func defines the function to register
  37367. */
  37368. registerAfterRender(func: () => void): void;
  37369. /**
  37370. * Unregisters a function called after every frame render
  37371. * @param func defines the function to unregister
  37372. */
  37373. unregisterAfterRender(func: () => void): void;
  37374. private _executeOnceBeforeRender;
  37375. /**
  37376. * The provided function will run before render once and will be disposed afterwards.
  37377. * A timeout delay can be provided so that the function will be executed in N ms.
  37378. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  37379. * @param func The function to be executed.
  37380. * @param timeout optional delay in ms
  37381. */
  37382. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  37383. /** @hidden */
  37384. _addPendingData(data: any): void;
  37385. /** @hidden */
  37386. _removePendingData(data: any): void;
  37387. /**
  37388. * Returns the number of items waiting to be loaded
  37389. * @returns the number of items waiting to be loaded
  37390. */
  37391. getWaitingItemsCount(): number;
  37392. /**
  37393. * Returns a boolean indicating if the scene is still loading data
  37394. */
  37395. get isLoading(): boolean;
  37396. /**
  37397. * Registers a function to be executed when the scene is ready
  37398. * @param {Function} func - the function to be executed
  37399. */
  37400. executeWhenReady(func: () => void): void;
  37401. /**
  37402. * Returns a promise that resolves when the scene is ready
  37403. * @returns A promise that resolves when the scene is ready
  37404. */
  37405. whenReadyAsync(): Promise<void>;
  37406. /** @hidden */
  37407. _checkIsReady(): void;
  37408. /**
  37409. * Gets all animatable attached to the scene
  37410. */
  37411. get animatables(): Animatable[];
  37412. /**
  37413. * Resets the last animation time frame.
  37414. * Useful to override when animations start running when loading a scene for the first time.
  37415. */
  37416. resetLastAnimationTimeFrame(): void;
  37417. /**
  37418. * Gets the current view matrix
  37419. * @returns a Matrix
  37420. */
  37421. getViewMatrix(): Matrix;
  37422. /**
  37423. * Gets the current projection matrix
  37424. * @returns a Matrix
  37425. */
  37426. getProjectionMatrix(): Matrix;
  37427. /**
  37428. * Gets the current transform matrix
  37429. * @returns a Matrix made of View * Projection
  37430. */
  37431. getTransformMatrix(): Matrix;
  37432. /**
  37433. * Sets the current transform matrix
  37434. * @param viewL defines the View matrix to use
  37435. * @param projectionL defines the Projection matrix to use
  37436. * @param viewR defines the right View matrix to use (if provided)
  37437. * @param projectionR defines the right Projection matrix to use (if provided)
  37438. */
  37439. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37440. /**
  37441. * Gets the uniform buffer used to store scene data
  37442. * @returns a UniformBuffer
  37443. */
  37444. getSceneUniformBuffer(): UniformBuffer;
  37445. /**
  37446. * Gets an unique (relatively to the current scene) Id
  37447. * @returns an unique number for the scene
  37448. */
  37449. getUniqueId(): number;
  37450. /**
  37451. * Add a mesh to the list of scene's meshes
  37452. * @param newMesh defines the mesh to add
  37453. * @param recursive if all child meshes should also be added to the scene
  37454. */
  37455. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37456. /**
  37457. * Remove a mesh for the list of scene's meshes
  37458. * @param toRemove defines the mesh to remove
  37459. * @param recursive if all child meshes should also be removed from the scene
  37460. * @returns the index where the mesh was in the mesh list
  37461. */
  37462. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37463. /**
  37464. * Add a transform node to the list of scene's transform nodes
  37465. * @param newTransformNode defines the transform node to add
  37466. */
  37467. addTransformNode(newTransformNode: TransformNode): void;
  37468. /**
  37469. * Remove a transform node for the list of scene's transform nodes
  37470. * @param toRemove defines the transform node to remove
  37471. * @returns the index where the transform node was in the transform node list
  37472. */
  37473. removeTransformNode(toRemove: TransformNode): number;
  37474. /**
  37475. * Remove a skeleton for the list of scene's skeletons
  37476. * @param toRemove defines the skeleton to remove
  37477. * @returns the index where the skeleton was in the skeleton list
  37478. */
  37479. removeSkeleton(toRemove: Skeleton): number;
  37480. /**
  37481. * Remove a morph target for the list of scene's morph targets
  37482. * @param toRemove defines the morph target to remove
  37483. * @returns the index where the morph target was in the morph target list
  37484. */
  37485. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37486. /**
  37487. * Remove a light for the list of scene's lights
  37488. * @param toRemove defines the light to remove
  37489. * @returns the index where the light was in the light list
  37490. */
  37491. removeLight(toRemove: Light): number;
  37492. /**
  37493. * Remove a camera for the list of scene's cameras
  37494. * @param toRemove defines the camera to remove
  37495. * @returns the index where the camera was in the camera list
  37496. */
  37497. removeCamera(toRemove: Camera): number;
  37498. /**
  37499. * Remove a particle system for the list of scene's particle systems
  37500. * @param toRemove defines the particle system to remove
  37501. * @returns the index where the particle system was in the particle system list
  37502. */
  37503. removeParticleSystem(toRemove: IParticleSystem): number;
  37504. /**
  37505. * Remove a animation for the list of scene's animations
  37506. * @param toRemove defines the animation to remove
  37507. * @returns the index where the animation was in the animation list
  37508. */
  37509. removeAnimation(toRemove: Animation): number;
  37510. /**
  37511. * Will stop the animation of the given target
  37512. * @param target - the target
  37513. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37514. * @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)
  37515. */
  37516. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37517. /**
  37518. * Removes the given animation group from this scene.
  37519. * @param toRemove The animation group to remove
  37520. * @returns The index of the removed animation group
  37521. */
  37522. removeAnimationGroup(toRemove: AnimationGroup): number;
  37523. /**
  37524. * Removes the given multi-material from this scene.
  37525. * @param toRemove The multi-material to remove
  37526. * @returns The index of the removed multi-material
  37527. */
  37528. removeMultiMaterial(toRemove: MultiMaterial): number;
  37529. /**
  37530. * Removes the given material from this scene.
  37531. * @param toRemove The material to remove
  37532. * @returns The index of the removed material
  37533. */
  37534. removeMaterial(toRemove: Material): number;
  37535. /**
  37536. * Removes the given action manager from this scene.
  37537. * @param toRemove The action manager to remove
  37538. * @returns The index of the removed action manager
  37539. */
  37540. removeActionManager(toRemove: AbstractActionManager): number;
  37541. /**
  37542. * Removes the given texture from this scene.
  37543. * @param toRemove The texture to remove
  37544. * @returns The index of the removed texture
  37545. */
  37546. removeTexture(toRemove: BaseTexture): number;
  37547. /**
  37548. * Adds the given light to this scene
  37549. * @param newLight The light to add
  37550. */
  37551. addLight(newLight: Light): void;
  37552. /**
  37553. * Sorts the list list based on light priorities
  37554. */
  37555. sortLightsByPriority(): void;
  37556. /**
  37557. * Adds the given camera to this scene
  37558. * @param newCamera The camera to add
  37559. */
  37560. addCamera(newCamera: Camera): void;
  37561. /**
  37562. * Adds the given skeleton to this scene
  37563. * @param newSkeleton The skeleton to add
  37564. */
  37565. addSkeleton(newSkeleton: Skeleton): void;
  37566. /**
  37567. * Adds the given particle system to this scene
  37568. * @param newParticleSystem The particle system to add
  37569. */
  37570. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37571. /**
  37572. * Adds the given animation to this scene
  37573. * @param newAnimation The animation to add
  37574. */
  37575. addAnimation(newAnimation: Animation): void;
  37576. /**
  37577. * Adds the given animation group to this scene.
  37578. * @param newAnimationGroup The animation group to add
  37579. */
  37580. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37581. /**
  37582. * Adds the given multi-material to this scene
  37583. * @param newMultiMaterial The multi-material to add
  37584. */
  37585. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37586. /**
  37587. * Adds the given material to this scene
  37588. * @param newMaterial The material to add
  37589. */
  37590. addMaterial(newMaterial: Material): void;
  37591. /**
  37592. * Adds the given morph target to this scene
  37593. * @param newMorphTargetManager The morph target to add
  37594. */
  37595. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37596. /**
  37597. * Adds the given geometry to this scene
  37598. * @param newGeometry The geometry to add
  37599. */
  37600. addGeometry(newGeometry: Geometry): void;
  37601. /**
  37602. * Adds the given action manager to this scene
  37603. * @param newActionManager The action manager to add
  37604. */
  37605. addActionManager(newActionManager: AbstractActionManager): void;
  37606. /**
  37607. * Adds the given texture to this scene.
  37608. * @param newTexture The texture to add
  37609. */
  37610. addTexture(newTexture: BaseTexture): void;
  37611. /**
  37612. * Switch active camera
  37613. * @param newCamera defines the new active camera
  37614. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37615. */
  37616. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37617. /**
  37618. * sets the active camera of the scene using its ID
  37619. * @param id defines the camera's ID
  37620. * @return the new active camera or null if none found.
  37621. */
  37622. setActiveCameraByID(id: string): Nullable<Camera>;
  37623. /**
  37624. * sets the active camera of the scene using its name
  37625. * @param name defines the camera's name
  37626. * @returns the new active camera or null if none found.
  37627. */
  37628. setActiveCameraByName(name: string): Nullable<Camera>;
  37629. /**
  37630. * get an animation group using its name
  37631. * @param name defines the material's name
  37632. * @return the animation group or null if none found.
  37633. */
  37634. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37635. /**
  37636. * Get a material using its unique id
  37637. * @param uniqueId defines the material's unique id
  37638. * @return the material or null if none found.
  37639. */
  37640. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37641. /**
  37642. * get a material using its id
  37643. * @param id defines the material's ID
  37644. * @return the material or null if none found.
  37645. */
  37646. getMaterialByID(id: string): Nullable<Material>;
  37647. /**
  37648. * Gets a the last added material using a given id
  37649. * @param id defines the material's ID
  37650. * @return the last material with the given id or null if none found.
  37651. */
  37652. getLastMaterialByID(id: string): Nullable<Material>;
  37653. /**
  37654. * Gets a material using its name
  37655. * @param name defines the material's name
  37656. * @return the material or null if none found.
  37657. */
  37658. getMaterialByName(name: string): Nullable<Material>;
  37659. /**
  37660. * Get a texture using its unique id
  37661. * @param uniqueId defines the texture's unique id
  37662. * @return the texture or null if none found.
  37663. */
  37664. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37665. /**
  37666. * Gets a camera using its id
  37667. * @param id defines the id to look for
  37668. * @returns the camera or null if not found
  37669. */
  37670. getCameraByID(id: string): Nullable<Camera>;
  37671. /**
  37672. * Gets a camera using its unique id
  37673. * @param uniqueId defines the unique id to look for
  37674. * @returns the camera or null if not found
  37675. */
  37676. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37677. /**
  37678. * Gets a camera using its name
  37679. * @param name defines the camera's name
  37680. * @return the camera or null if none found.
  37681. */
  37682. getCameraByName(name: string): Nullable<Camera>;
  37683. /**
  37684. * Gets a bone using its id
  37685. * @param id defines the bone's id
  37686. * @return the bone or null if not found
  37687. */
  37688. getBoneByID(id: string): Nullable<Bone>;
  37689. /**
  37690. * Gets a bone using its id
  37691. * @param name defines the bone's name
  37692. * @return the bone or null if not found
  37693. */
  37694. getBoneByName(name: string): Nullable<Bone>;
  37695. /**
  37696. * Gets a light node using its name
  37697. * @param name defines the the light's name
  37698. * @return the light or null if none found.
  37699. */
  37700. getLightByName(name: string): Nullable<Light>;
  37701. /**
  37702. * Gets a light node using its id
  37703. * @param id defines the light's id
  37704. * @return the light or null if none found.
  37705. */
  37706. getLightByID(id: string): Nullable<Light>;
  37707. /**
  37708. * Gets a light node using its scene-generated unique ID
  37709. * @param uniqueId defines the light's unique id
  37710. * @return the light or null if none found.
  37711. */
  37712. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37713. /**
  37714. * Gets a particle system by id
  37715. * @param id defines the particle system id
  37716. * @return the corresponding system or null if none found
  37717. */
  37718. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37719. /**
  37720. * Gets a geometry using its ID
  37721. * @param id defines the geometry's id
  37722. * @return the geometry or null if none found.
  37723. */
  37724. getGeometryByID(id: string): Nullable<Geometry>;
  37725. private _getGeometryByUniqueID;
  37726. /**
  37727. * Add a new geometry to this scene
  37728. * @param geometry defines the geometry to be added to the scene.
  37729. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37730. * @return a boolean defining if the geometry was added or not
  37731. */
  37732. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37733. /**
  37734. * Removes an existing geometry
  37735. * @param geometry defines the geometry to be removed from the scene
  37736. * @return a boolean defining if the geometry was removed or not
  37737. */
  37738. removeGeometry(geometry: Geometry): boolean;
  37739. /**
  37740. * Gets the list of geometries attached to the scene
  37741. * @returns an array of Geometry
  37742. */
  37743. getGeometries(): Geometry[];
  37744. /**
  37745. * Gets the first added mesh found of a given ID
  37746. * @param id defines the id to search for
  37747. * @return the mesh found or null if not found at all
  37748. */
  37749. getMeshByID(id: string): Nullable<AbstractMesh>;
  37750. /**
  37751. * Gets a list of meshes using their id
  37752. * @param id defines the id to search for
  37753. * @returns a list of meshes
  37754. */
  37755. getMeshesByID(id: string): Array<AbstractMesh>;
  37756. /**
  37757. * Gets the first added transform node found of a given ID
  37758. * @param id defines the id to search for
  37759. * @return the found transform node or null if not found at all.
  37760. */
  37761. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37762. /**
  37763. * Gets a transform node with its auto-generated unique id
  37764. * @param uniqueId efines the unique id to search for
  37765. * @return the found transform node or null if not found at all.
  37766. */
  37767. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37768. /**
  37769. * Gets a list of transform nodes using their id
  37770. * @param id defines the id to search for
  37771. * @returns a list of transform nodes
  37772. */
  37773. getTransformNodesByID(id: string): Array<TransformNode>;
  37774. /**
  37775. * Gets a mesh with its auto-generated unique id
  37776. * @param uniqueId defines the unique id to search for
  37777. * @return the found mesh or null if not found at all.
  37778. */
  37779. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37780. /**
  37781. * Gets a the last added mesh using a given id
  37782. * @param id defines the id to search for
  37783. * @return the found mesh or null if not found at all.
  37784. */
  37785. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37786. /**
  37787. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37788. * @param id defines the id to search for
  37789. * @return the found node or null if not found at all
  37790. */
  37791. getLastEntryByID(id: string): Nullable<Node>;
  37792. /**
  37793. * Gets a node (Mesh, Camera, Light) using a given id
  37794. * @param id defines the id to search for
  37795. * @return the found node or null if not found at all
  37796. */
  37797. getNodeByID(id: string): Nullable<Node>;
  37798. /**
  37799. * Gets a node (Mesh, Camera, Light) using a given name
  37800. * @param name defines the name to search for
  37801. * @return the found node or null if not found at all.
  37802. */
  37803. getNodeByName(name: string): Nullable<Node>;
  37804. /**
  37805. * Gets a mesh using a given name
  37806. * @param name defines the name to search for
  37807. * @return the found mesh or null if not found at all.
  37808. */
  37809. getMeshByName(name: string): Nullable<AbstractMesh>;
  37810. /**
  37811. * Gets a transform node using a given name
  37812. * @param name defines the name to search for
  37813. * @return the found transform node or null if not found at all.
  37814. */
  37815. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37816. /**
  37817. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37818. * @param id defines the id to search for
  37819. * @return the found skeleton or null if not found at all.
  37820. */
  37821. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37822. /**
  37823. * Gets a skeleton using a given auto generated unique id
  37824. * @param uniqueId defines the unique id to search for
  37825. * @return the found skeleton or null if not found at all.
  37826. */
  37827. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37828. /**
  37829. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37830. * @param id defines the id to search for
  37831. * @return the found skeleton or null if not found at all.
  37832. */
  37833. getSkeletonById(id: string): Nullable<Skeleton>;
  37834. /**
  37835. * Gets a skeleton using a given name
  37836. * @param name defines the name to search for
  37837. * @return the found skeleton or null if not found at all.
  37838. */
  37839. getSkeletonByName(name: string): Nullable<Skeleton>;
  37840. /**
  37841. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37842. * @param id defines the id to search for
  37843. * @return the found morph target manager or null if not found at all.
  37844. */
  37845. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37846. /**
  37847. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37848. * @param id defines the id to search for
  37849. * @return the found morph target or null if not found at all.
  37850. */
  37851. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37852. /**
  37853. * Gets a boolean indicating if the given mesh is active
  37854. * @param mesh defines the mesh to look for
  37855. * @returns true if the mesh is in the active list
  37856. */
  37857. isActiveMesh(mesh: AbstractMesh): boolean;
  37858. /**
  37859. * Return a unique id as a string which can serve as an identifier for the scene
  37860. */
  37861. get uid(): string;
  37862. /**
  37863. * Add an externaly attached data from its key.
  37864. * This method call will fail and return false, if such key already exists.
  37865. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37866. * @param key the unique key that identifies the data
  37867. * @param data the data object to associate to the key for this Engine instance
  37868. * @return true if no such key were already present and the data was added successfully, false otherwise
  37869. */
  37870. addExternalData<T>(key: string, data: T): boolean;
  37871. /**
  37872. * Get an externaly attached data from its key
  37873. * @param key the unique key that identifies the data
  37874. * @return the associated data, if present (can be null), or undefined if not present
  37875. */
  37876. getExternalData<T>(key: string): Nullable<T>;
  37877. /**
  37878. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37879. * @param key the unique key that identifies the data
  37880. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37881. * @return the associated data, can be null if the factory returned null.
  37882. */
  37883. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37884. /**
  37885. * Remove an externaly attached data from the Engine instance
  37886. * @param key the unique key that identifies the data
  37887. * @return true if the data was successfully removed, false if it doesn't exist
  37888. */
  37889. removeExternalData(key: string): boolean;
  37890. private _evaluateSubMesh;
  37891. /**
  37892. * Clear the processed materials smart array preventing retention point in material dispose.
  37893. */
  37894. freeProcessedMaterials(): void;
  37895. private _preventFreeActiveMeshesAndRenderingGroups;
  37896. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37897. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37898. * when disposing several meshes in a row or a hierarchy of meshes.
  37899. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37900. */
  37901. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37902. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37903. /**
  37904. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37905. */
  37906. freeActiveMeshes(): void;
  37907. /**
  37908. * Clear the info related to rendering groups preventing retention points during dispose.
  37909. */
  37910. freeRenderingGroups(): void;
  37911. /** @hidden */
  37912. _isInIntermediateRendering(): boolean;
  37913. /**
  37914. * Lambda returning the list of potentially active meshes.
  37915. */
  37916. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37917. /**
  37918. * Lambda returning the list of potentially active sub meshes.
  37919. */
  37920. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37921. /**
  37922. * Lambda returning the list of potentially intersecting sub meshes.
  37923. */
  37924. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37925. /**
  37926. * Lambda returning the list of potentially colliding sub meshes.
  37927. */
  37928. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37929. private _activeMeshesFrozen;
  37930. private _skipEvaluateActiveMeshesCompletely;
  37931. /**
  37932. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37933. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37934. * @returns the current scene
  37935. */
  37936. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37937. /**
  37938. * Use this function to restart evaluating active meshes on every frame
  37939. * @returns the current scene
  37940. */
  37941. unfreezeActiveMeshes(): Scene;
  37942. private _evaluateActiveMeshes;
  37943. private _activeMesh;
  37944. /**
  37945. * Update the transform matrix to update from the current active camera
  37946. * @param force defines a boolean used to force the update even if cache is up to date
  37947. */
  37948. updateTransformMatrix(force?: boolean): void;
  37949. private _bindFrameBuffer;
  37950. /** @hidden */
  37951. _allowPostProcessClearColor: boolean;
  37952. /** @hidden */
  37953. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37954. private _processSubCameras;
  37955. private _checkIntersections;
  37956. /** @hidden */
  37957. _advancePhysicsEngineStep(step: number): void;
  37958. /**
  37959. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37960. */
  37961. getDeterministicFrameTime: () => number;
  37962. /** @hidden */
  37963. _animate(): void;
  37964. /** Execute all animations (for a frame) */
  37965. animate(): void;
  37966. /**
  37967. * Render the scene
  37968. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37969. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37970. */
  37971. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37972. /**
  37973. * Freeze all materials
  37974. * A frozen material will not be updatable but should be faster to render
  37975. */
  37976. freezeMaterials(): void;
  37977. /**
  37978. * Unfreeze all materials
  37979. * A frozen material will not be updatable but should be faster to render
  37980. */
  37981. unfreezeMaterials(): void;
  37982. /**
  37983. * Releases all held ressources
  37984. */
  37985. dispose(): void;
  37986. /**
  37987. * Gets if the scene is already disposed
  37988. */
  37989. get isDisposed(): boolean;
  37990. /**
  37991. * Call this function to reduce memory footprint of the scene.
  37992. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37993. */
  37994. clearCachedVertexData(): void;
  37995. /**
  37996. * This function will remove the local cached buffer data from texture.
  37997. * It will save memory but will prevent the texture from being rebuilt
  37998. */
  37999. cleanCachedTextureBuffer(): void;
  38000. /**
  38001. * Get the world extend vectors with an optional filter
  38002. *
  38003. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  38004. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  38005. */
  38006. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  38007. min: Vector3;
  38008. max: Vector3;
  38009. };
  38010. /**
  38011. * Creates a ray that can be used to pick in the scene
  38012. * @param x defines the x coordinate of the origin (on-screen)
  38013. * @param y defines the y coordinate of the origin (on-screen)
  38014. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  38015. * @param camera defines the camera to use for the picking
  38016. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  38017. * @returns a Ray
  38018. */
  38019. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  38020. /**
  38021. * Creates a ray that can be used to pick in the scene
  38022. * @param x defines the x coordinate of the origin (on-screen)
  38023. * @param y defines the y coordinate of the origin (on-screen)
  38024. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  38025. * @param result defines the ray where to store the picking ray
  38026. * @param camera defines the camera to use for the picking
  38027. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  38028. * @returns the current scene
  38029. */
  38030. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  38031. /**
  38032. * Creates a ray that can be used to pick in the scene
  38033. * @param x defines the x coordinate of the origin (on-screen)
  38034. * @param y defines the y coordinate of the origin (on-screen)
  38035. * @param camera defines the camera to use for the picking
  38036. * @returns a Ray
  38037. */
  38038. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  38039. /**
  38040. * Creates a ray that can be used to pick in the scene
  38041. * @param x defines the x coordinate of the origin (on-screen)
  38042. * @param y defines the y coordinate of the origin (on-screen)
  38043. * @param result defines the ray where to store the picking ray
  38044. * @param camera defines the camera to use for the picking
  38045. * @returns the current scene
  38046. */
  38047. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  38048. /** Launch a ray to try to pick a mesh in the scene
  38049. * @param x position on screen
  38050. * @param y position on screen
  38051. * @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
  38052. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  38053. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  38054. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38055. * @returns a PickingInfo
  38056. */
  38057. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  38058. /** Use the given ray to pick a mesh in the scene
  38059. * @param ray The ray to use to pick meshes
  38060. * @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
  38061. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  38062. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38063. * @returns a PickingInfo
  38064. */
  38065. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  38066. /**
  38067. * Launch a ray to try to pick a mesh in the scene
  38068. * @param x X position on screen
  38069. * @param y Y position on screen
  38070. * @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
  38071. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  38072. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38073. * @returns an array of PickingInfo
  38074. */
  38075. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  38076. /**
  38077. * Launch a ray to try to pick a mesh in the scene
  38078. * @param ray Ray to use
  38079. * @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
  38080. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38081. * @returns an array of PickingInfo
  38082. */
  38083. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  38084. /**
  38085. * Force the value of meshUnderPointer
  38086. * @param mesh defines the mesh to use
  38087. */
  38088. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  38089. /**
  38090. * Gets the mesh under the pointer
  38091. * @returns a Mesh or null if no mesh is under the pointer
  38092. */
  38093. getPointerOverMesh(): Nullable<AbstractMesh>;
  38094. /** @hidden */
  38095. _rebuildGeometries(): void;
  38096. /** @hidden */
  38097. _rebuildTextures(): void;
  38098. private _getByTags;
  38099. /**
  38100. * Get a list of meshes by tags
  38101. * @param tagsQuery defines the tags query to use
  38102. * @param forEach defines a predicate used to filter results
  38103. * @returns an array of Mesh
  38104. */
  38105. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  38106. /**
  38107. * Get a list of cameras by tags
  38108. * @param tagsQuery defines the tags query to use
  38109. * @param forEach defines a predicate used to filter results
  38110. * @returns an array of Camera
  38111. */
  38112. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  38113. /**
  38114. * Get a list of lights by tags
  38115. * @param tagsQuery defines the tags query to use
  38116. * @param forEach defines a predicate used to filter results
  38117. * @returns an array of Light
  38118. */
  38119. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  38120. /**
  38121. * Get a list of materials by tags
  38122. * @param tagsQuery defines the tags query to use
  38123. * @param forEach defines a predicate used to filter results
  38124. * @returns an array of Material
  38125. */
  38126. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  38127. /**
  38128. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  38129. * This allowed control for front to back rendering or reversly depending of the special needs.
  38130. *
  38131. * @param renderingGroupId The rendering group id corresponding to its index
  38132. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  38133. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  38134. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  38135. */
  38136. 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;
  38137. /**
  38138. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  38139. *
  38140. * @param renderingGroupId The rendering group id corresponding to its index
  38141. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  38142. * @param depth Automatically clears depth between groups if true and autoClear is true.
  38143. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  38144. */
  38145. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  38146. /**
  38147. * Gets the current auto clear configuration for one rendering group of the rendering
  38148. * manager.
  38149. * @param index the rendering group index to get the information for
  38150. * @returns The auto clear setup for the requested rendering group
  38151. */
  38152. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  38153. private _blockMaterialDirtyMechanism;
  38154. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  38155. get blockMaterialDirtyMechanism(): boolean;
  38156. set blockMaterialDirtyMechanism(value: boolean);
  38157. /**
  38158. * Will flag all materials as dirty to trigger new shader compilation
  38159. * @param flag defines the flag used to specify which material part must be marked as dirty
  38160. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  38161. */
  38162. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38163. /** @hidden */
  38164. _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;
  38165. /** @hidden */
  38166. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38167. /** @hidden */
  38168. _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;
  38169. /** @hidden */
  38170. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  38171. /** @hidden */
  38172. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38173. /** @hidden */
  38174. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38175. }
  38176. }
  38177. declare module "babylonjs/assetContainer" {
  38178. import { AbstractScene } from "babylonjs/abstractScene";
  38179. import { Scene } from "babylonjs/scene";
  38180. import { Mesh } from "babylonjs/Meshes/mesh";
  38181. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38182. import { Skeleton } from "babylonjs/Bones/skeleton";
  38183. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38184. import { Animatable } from "babylonjs/Animations/animatable";
  38185. import { Nullable } from "babylonjs/types";
  38186. import { Node } from "babylonjs/node";
  38187. /**
  38188. * Set of assets to keep when moving a scene into an asset container.
  38189. */
  38190. export class KeepAssets extends AbstractScene {
  38191. }
  38192. /**
  38193. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  38194. */
  38195. export class InstantiatedEntries {
  38196. /**
  38197. * List of new root nodes (eg. nodes with no parent)
  38198. */
  38199. rootNodes: TransformNode[];
  38200. /**
  38201. * List of new skeletons
  38202. */
  38203. skeletons: Skeleton[];
  38204. /**
  38205. * List of new animation groups
  38206. */
  38207. animationGroups: AnimationGroup[];
  38208. }
  38209. /**
  38210. * Container with a set of assets that can be added or removed from a scene.
  38211. */
  38212. export class AssetContainer extends AbstractScene {
  38213. private _wasAddedToScene;
  38214. /**
  38215. * The scene the AssetContainer belongs to.
  38216. */
  38217. scene: Scene;
  38218. /**
  38219. * Instantiates an AssetContainer.
  38220. * @param scene The scene the AssetContainer belongs to.
  38221. */
  38222. constructor(scene: Scene);
  38223. /**
  38224. * Instantiate or clone all meshes and add the new ones to the scene.
  38225. * Skeletons and animation groups will all be cloned
  38226. * @param nameFunction defines an optional function used to get new names for clones
  38227. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  38228. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  38229. */
  38230. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  38231. /**
  38232. * Adds all the assets from the container to the scene.
  38233. */
  38234. addAllToScene(): void;
  38235. /**
  38236. * Removes all the assets in the container from the scene
  38237. */
  38238. removeAllFromScene(): void;
  38239. /**
  38240. * Disposes all the assets in the container
  38241. */
  38242. dispose(): void;
  38243. private _moveAssets;
  38244. /**
  38245. * Removes all the assets contained in the scene and adds them to the container.
  38246. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  38247. */
  38248. moveAllFromScene(keepAssets?: KeepAssets): void;
  38249. /**
  38250. * 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.
  38251. * @returns the root mesh
  38252. */
  38253. createRootMesh(): Mesh;
  38254. /**
  38255. * Merge animations from this asset container into a scene
  38256. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  38257. * @param animatables set of animatables to retarget to a node from the scene
  38258. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  38259. */
  38260. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  38261. }
  38262. }
  38263. declare module "babylonjs/abstractScene" {
  38264. import { Scene } from "babylonjs/scene";
  38265. import { Nullable } from "babylonjs/types";
  38266. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38267. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38268. import { Geometry } from "babylonjs/Meshes/geometry";
  38269. import { Skeleton } from "babylonjs/Bones/skeleton";
  38270. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  38271. import { AssetContainer } from "babylonjs/assetContainer";
  38272. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  38273. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38274. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38275. import { Material } from "babylonjs/Materials/material";
  38276. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  38277. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  38278. import { Camera } from "babylonjs/Cameras/camera";
  38279. import { Light } from "babylonjs/Lights/light";
  38280. import { Node } from "babylonjs/node";
  38281. import { Animation } from "babylonjs/Animations/animation";
  38282. /**
  38283. * Defines how the parser contract is defined.
  38284. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  38285. */
  38286. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  38287. /**
  38288. * Defines how the individual parser contract is defined.
  38289. * These parser can parse an individual asset
  38290. */
  38291. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  38292. /**
  38293. * Base class of the scene acting as a container for the different elements composing a scene.
  38294. * This class is dynamically extended by the different components of the scene increasing
  38295. * flexibility and reducing coupling
  38296. */
  38297. export abstract class AbstractScene {
  38298. /**
  38299. * Stores the list of available parsers in the application.
  38300. */
  38301. private static _BabylonFileParsers;
  38302. /**
  38303. * Stores the list of available individual parsers in the application.
  38304. */
  38305. private static _IndividualBabylonFileParsers;
  38306. /**
  38307. * Adds a parser in the list of available ones
  38308. * @param name Defines the name of the parser
  38309. * @param parser Defines the parser to add
  38310. */
  38311. static AddParser(name: string, parser: BabylonFileParser): void;
  38312. /**
  38313. * Gets a general parser from the list of avaialble ones
  38314. * @param name Defines the name of the parser
  38315. * @returns the requested parser or null
  38316. */
  38317. static GetParser(name: string): Nullable<BabylonFileParser>;
  38318. /**
  38319. * Adds n individual parser in the list of available ones
  38320. * @param name Defines the name of the parser
  38321. * @param parser Defines the parser to add
  38322. */
  38323. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  38324. /**
  38325. * Gets an individual parser from the list of avaialble ones
  38326. * @param name Defines the name of the parser
  38327. * @returns the requested parser or null
  38328. */
  38329. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  38330. /**
  38331. * Parser json data and populate both a scene and its associated container object
  38332. * @param jsonData Defines the data to parse
  38333. * @param scene Defines the scene to parse the data for
  38334. * @param container Defines the container attached to the parsing sequence
  38335. * @param rootUrl Defines the root url of the data
  38336. */
  38337. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  38338. /**
  38339. * Gets the list of root nodes (ie. nodes with no parent)
  38340. */
  38341. rootNodes: Node[];
  38342. /** All of the cameras added to this scene
  38343. * @see http://doc.babylonjs.com/babylon101/cameras
  38344. */
  38345. cameras: Camera[];
  38346. /**
  38347. * All of the lights added to this scene
  38348. * @see http://doc.babylonjs.com/babylon101/lights
  38349. */
  38350. lights: Light[];
  38351. /**
  38352. * All of the (abstract) meshes added to this scene
  38353. */
  38354. meshes: AbstractMesh[];
  38355. /**
  38356. * The list of skeletons added to the scene
  38357. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  38358. */
  38359. skeletons: Skeleton[];
  38360. /**
  38361. * All of the particle systems added to this scene
  38362. * @see http://doc.babylonjs.com/babylon101/particles
  38363. */
  38364. particleSystems: IParticleSystem[];
  38365. /**
  38366. * Gets a list of Animations associated with the scene
  38367. */
  38368. animations: Animation[];
  38369. /**
  38370. * All of the animation groups added to this scene
  38371. * @see http://doc.babylonjs.com/how_to/group
  38372. */
  38373. animationGroups: AnimationGroup[];
  38374. /**
  38375. * All of the multi-materials added to this scene
  38376. * @see http://doc.babylonjs.com/how_to/multi_materials
  38377. */
  38378. multiMaterials: MultiMaterial[];
  38379. /**
  38380. * All of the materials added to this scene
  38381. * In the context of a Scene, it is not supposed to be modified manually.
  38382. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  38383. * Note also that the order of the Material within the array is not significant and might change.
  38384. * @see http://doc.babylonjs.com/babylon101/materials
  38385. */
  38386. materials: Material[];
  38387. /**
  38388. * The list of morph target managers added to the scene
  38389. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  38390. */
  38391. morphTargetManagers: MorphTargetManager[];
  38392. /**
  38393. * The list of geometries used in the scene.
  38394. */
  38395. geometries: Geometry[];
  38396. /**
  38397. * All of the tranform nodes added to this scene
  38398. * In the context of a Scene, it is not supposed to be modified manually.
  38399. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  38400. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  38401. * @see http://doc.babylonjs.com/how_to/transformnode
  38402. */
  38403. transformNodes: TransformNode[];
  38404. /**
  38405. * ActionManagers available on the scene.
  38406. */
  38407. actionManagers: AbstractActionManager[];
  38408. /**
  38409. * Textures to keep.
  38410. */
  38411. textures: BaseTexture[];
  38412. /**
  38413. * Environment texture for the scene
  38414. */
  38415. environmentTexture: Nullable<BaseTexture>;
  38416. /**
  38417. * @returns all meshes, lights, cameras, transformNodes and bones
  38418. */
  38419. getNodes(): Array<Node>;
  38420. }
  38421. }
  38422. declare module "babylonjs/Audio/sound" {
  38423. import { Observable } from "babylonjs/Misc/observable";
  38424. import { Vector3 } from "babylonjs/Maths/math.vector";
  38425. import { Nullable } from "babylonjs/types";
  38426. import { Scene } from "babylonjs/scene";
  38427. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38428. /**
  38429. * Interface used to define options for Sound class
  38430. */
  38431. export interface ISoundOptions {
  38432. /**
  38433. * Does the sound autoplay once loaded.
  38434. */
  38435. autoplay?: boolean;
  38436. /**
  38437. * Does the sound loop after it finishes playing once.
  38438. */
  38439. loop?: boolean;
  38440. /**
  38441. * Sound's volume
  38442. */
  38443. volume?: number;
  38444. /**
  38445. * Is it a spatial sound?
  38446. */
  38447. spatialSound?: boolean;
  38448. /**
  38449. * Maximum distance to hear that sound
  38450. */
  38451. maxDistance?: number;
  38452. /**
  38453. * Uses user defined attenuation function
  38454. */
  38455. useCustomAttenuation?: boolean;
  38456. /**
  38457. * Define the roll off factor of spatial sounds.
  38458. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38459. */
  38460. rolloffFactor?: number;
  38461. /**
  38462. * Define the reference distance the sound should be heard perfectly.
  38463. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38464. */
  38465. refDistance?: number;
  38466. /**
  38467. * Define the distance attenuation model the sound will follow.
  38468. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38469. */
  38470. distanceModel?: string;
  38471. /**
  38472. * Defines the playback speed (1 by default)
  38473. */
  38474. playbackRate?: number;
  38475. /**
  38476. * Defines if the sound is from a streaming source
  38477. */
  38478. streaming?: boolean;
  38479. /**
  38480. * Defines an optional length (in seconds) inside the sound file
  38481. */
  38482. length?: number;
  38483. /**
  38484. * Defines an optional offset (in seconds) inside the sound file
  38485. */
  38486. offset?: number;
  38487. /**
  38488. * If true, URLs will not be required to state the audio file codec to use.
  38489. */
  38490. skipCodecCheck?: boolean;
  38491. }
  38492. /**
  38493. * Defines a sound that can be played in the application.
  38494. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38495. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38496. */
  38497. export class Sound {
  38498. /**
  38499. * The name of the sound in the scene.
  38500. */
  38501. name: string;
  38502. /**
  38503. * Does the sound autoplay once loaded.
  38504. */
  38505. autoplay: boolean;
  38506. /**
  38507. * Does the sound loop after it finishes playing once.
  38508. */
  38509. loop: boolean;
  38510. /**
  38511. * Does the sound use a custom attenuation curve to simulate the falloff
  38512. * happening when the source gets further away from the camera.
  38513. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38514. */
  38515. useCustomAttenuation: boolean;
  38516. /**
  38517. * The sound track id this sound belongs to.
  38518. */
  38519. soundTrackId: number;
  38520. /**
  38521. * Is this sound currently played.
  38522. */
  38523. isPlaying: boolean;
  38524. /**
  38525. * Is this sound currently paused.
  38526. */
  38527. isPaused: boolean;
  38528. /**
  38529. * Does this sound enables spatial sound.
  38530. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38531. */
  38532. spatialSound: boolean;
  38533. /**
  38534. * Define the reference distance the sound should be heard perfectly.
  38535. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38536. */
  38537. refDistance: number;
  38538. /**
  38539. * Define the roll off factor of spatial sounds.
  38540. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38541. */
  38542. rolloffFactor: number;
  38543. /**
  38544. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38545. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38546. */
  38547. maxDistance: number;
  38548. /**
  38549. * Define the distance attenuation model the sound will follow.
  38550. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38551. */
  38552. distanceModel: string;
  38553. /**
  38554. * @hidden
  38555. * Back Compat
  38556. **/
  38557. onended: () => any;
  38558. /**
  38559. * Observable event when the current playing sound finishes.
  38560. */
  38561. onEndedObservable: Observable<Sound>;
  38562. private _panningModel;
  38563. private _playbackRate;
  38564. private _streaming;
  38565. private _startTime;
  38566. private _startOffset;
  38567. private _position;
  38568. /** @hidden */
  38569. _positionInEmitterSpace: boolean;
  38570. private _localDirection;
  38571. private _volume;
  38572. private _isReadyToPlay;
  38573. private _isDirectional;
  38574. private _readyToPlayCallback;
  38575. private _audioBuffer;
  38576. private _soundSource;
  38577. private _streamingSource;
  38578. private _soundPanner;
  38579. private _soundGain;
  38580. private _inputAudioNode;
  38581. private _outputAudioNode;
  38582. private _coneInnerAngle;
  38583. private _coneOuterAngle;
  38584. private _coneOuterGain;
  38585. private _scene;
  38586. private _connectedTransformNode;
  38587. private _customAttenuationFunction;
  38588. private _registerFunc;
  38589. private _isOutputConnected;
  38590. private _htmlAudioElement;
  38591. private _urlType;
  38592. private _length?;
  38593. private _offset?;
  38594. /** @hidden */
  38595. static _SceneComponentInitialization: (scene: Scene) => void;
  38596. /**
  38597. * Create a sound and attach it to a scene
  38598. * @param name Name of your sound
  38599. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38600. * @param scene defines the scene the sound belongs to
  38601. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38602. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38603. */
  38604. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38605. /**
  38606. * Release the sound and its associated resources
  38607. */
  38608. dispose(): void;
  38609. /**
  38610. * Gets if the sounds is ready to be played or not.
  38611. * @returns true if ready, otherwise false
  38612. */
  38613. isReady(): boolean;
  38614. private _soundLoaded;
  38615. /**
  38616. * Sets the data of the sound from an audiobuffer
  38617. * @param audioBuffer The audioBuffer containing the data
  38618. */
  38619. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38620. /**
  38621. * Updates the current sounds options such as maxdistance, loop...
  38622. * @param options A JSON object containing values named as the object properties
  38623. */
  38624. updateOptions(options: ISoundOptions): void;
  38625. private _createSpatialParameters;
  38626. private _updateSpatialParameters;
  38627. /**
  38628. * Switch the panning model to HRTF:
  38629. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38630. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38631. */
  38632. switchPanningModelToHRTF(): void;
  38633. /**
  38634. * Switch the panning model to Equal Power:
  38635. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38636. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38637. */
  38638. switchPanningModelToEqualPower(): void;
  38639. private _switchPanningModel;
  38640. /**
  38641. * Connect this sound to a sound track audio node like gain...
  38642. * @param soundTrackAudioNode the sound track audio node to connect to
  38643. */
  38644. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38645. /**
  38646. * Transform this sound into a directional source
  38647. * @param coneInnerAngle Size of the inner cone in degree
  38648. * @param coneOuterAngle Size of the outer cone in degree
  38649. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38650. */
  38651. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38652. /**
  38653. * Gets or sets the inner angle for the directional cone.
  38654. */
  38655. get directionalConeInnerAngle(): number;
  38656. /**
  38657. * Gets or sets the inner angle for the directional cone.
  38658. */
  38659. set directionalConeInnerAngle(value: number);
  38660. /**
  38661. * Gets or sets the outer angle for the directional cone.
  38662. */
  38663. get directionalConeOuterAngle(): number;
  38664. /**
  38665. * Gets or sets the outer angle for the directional cone.
  38666. */
  38667. set directionalConeOuterAngle(value: number);
  38668. /**
  38669. * Sets the position of the emitter if spatial sound is enabled
  38670. * @param newPosition Defines the new posisiton
  38671. */
  38672. setPosition(newPosition: Vector3): void;
  38673. /**
  38674. * Sets the local direction of the emitter if spatial sound is enabled
  38675. * @param newLocalDirection Defines the new local direction
  38676. */
  38677. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38678. private _updateDirection;
  38679. /** @hidden */
  38680. updateDistanceFromListener(): void;
  38681. /**
  38682. * Sets a new custom attenuation function for the sound.
  38683. * @param callback Defines the function used for the attenuation
  38684. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38685. */
  38686. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38687. /**
  38688. * Play the sound
  38689. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38690. * @param offset (optional) Start the sound at a specific time in seconds
  38691. * @param length (optional) Sound duration (in seconds)
  38692. */
  38693. play(time?: number, offset?: number, length?: number): void;
  38694. private _onended;
  38695. /**
  38696. * Stop the sound
  38697. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38698. */
  38699. stop(time?: number): void;
  38700. /**
  38701. * Put the sound in pause
  38702. */
  38703. pause(): void;
  38704. /**
  38705. * Sets a dedicated volume for this sounds
  38706. * @param newVolume Define the new volume of the sound
  38707. * @param time Define time for gradual change to new volume
  38708. */
  38709. setVolume(newVolume: number, time?: number): void;
  38710. /**
  38711. * Set the sound play back rate
  38712. * @param newPlaybackRate Define the playback rate the sound should be played at
  38713. */
  38714. setPlaybackRate(newPlaybackRate: number): void;
  38715. /**
  38716. * Gets the volume of the sound.
  38717. * @returns the volume of the sound
  38718. */
  38719. getVolume(): number;
  38720. /**
  38721. * Attach the sound to a dedicated mesh
  38722. * @param transformNode The transform node to connect the sound with
  38723. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38724. */
  38725. attachToMesh(transformNode: TransformNode): void;
  38726. /**
  38727. * Detach the sound from the previously attached mesh
  38728. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38729. */
  38730. detachFromMesh(): void;
  38731. private _onRegisterAfterWorldMatrixUpdate;
  38732. /**
  38733. * Clone the current sound in the scene.
  38734. * @returns the new sound clone
  38735. */
  38736. clone(): Nullable<Sound>;
  38737. /**
  38738. * Gets the current underlying audio buffer containing the data
  38739. * @returns the audio buffer
  38740. */
  38741. getAudioBuffer(): Nullable<AudioBuffer>;
  38742. /**
  38743. * Serializes the Sound in a JSON representation
  38744. * @returns the JSON representation of the sound
  38745. */
  38746. serialize(): any;
  38747. /**
  38748. * Parse a JSON representation of a sound to innstantiate in a given scene
  38749. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38750. * @param scene Define the scene the new parsed sound should be created in
  38751. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38752. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38753. * @returns the newly parsed sound
  38754. */
  38755. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38756. }
  38757. }
  38758. declare module "babylonjs/Actions/directAudioActions" {
  38759. import { Action } from "babylonjs/Actions/action";
  38760. import { Condition } from "babylonjs/Actions/condition";
  38761. import { Sound } from "babylonjs/Audio/sound";
  38762. /**
  38763. * This defines an action helpful to play a defined sound on a triggered action.
  38764. */
  38765. export class PlaySoundAction extends Action {
  38766. private _sound;
  38767. /**
  38768. * Instantiate the action
  38769. * @param triggerOptions defines the trigger options
  38770. * @param sound defines the sound to play
  38771. * @param condition defines the trigger related conditions
  38772. */
  38773. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38774. /** @hidden */
  38775. _prepare(): void;
  38776. /**
  38777. * Execute the action and play the sound.
  38778. */
  38779. execute(): void;
  38780. /**
  38781. * Serializes the actions and its related information.
  38782. * @param parent defines the object to serialize in
  38783. * @returns the serialized object
  38784. */
  38785. serialize(parent: any): any;
  38786. }
  38787. /**
  38788. * This defines an action helpful to stop a defined sound on a triggered action.
  38789. */
  38790. export class StopSoundAction extends Action {
  38791. private _sound;
  38792. /**
  38793. * Instantiate the action
  38794. * @param triggerOptions defines the trigger options
  38795. * @param sound defines the sound to stop
  38796. * @param condition defines the trigger related conditions
  38797. */
  38798. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38799. /** @hidden */
  38800. _prepare(): void;
  38801. /**
  38802. * Execute the action and stop the sound.
  38803. */
  38804. execute(): void;
  38805. /**
  38806. * Serializes the actions and its related information.
  38807. * @param parent defines the object to serialize in
  38808. * @returns the serialized object
  38809. */
  38810. serialize(parent: any): any;
  38811. }
  38812. }
  38813. declare module "babylonjs/Actions/interpolateValueAction" {
  38814. import { Action } from "babylonjs/Actions/action";
  38815. import { Condition } from "babylonjs/Actions/condition";
  38816. import { Observable } from "babylonjs/Misc/observable";
  38817. /**
  38818. * This defines an action responsible to change the value of a property
  38819. * by interpolating between its current value and the newly set one once triggered.
  38820. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38821. */
  38822. export class InterpolateValueAction extends Action {
  38823. /**
  38824. * Defines the path of the property where the value should be interpolated
  38825. */
  38826. propertyPath: string;
  38827. /**
  38828. * Defines the target value at the end of the interpolation.
  38829. */
  38830. value: any;
  38831. /**
  38832. * Defines the time it will take for the property to interpolate to the value.
  38833. */
  38834. duration: number;
  38835. /**
  38836. * Defines if the other scene animations should be stopped when the action has been triggered
  38837. */
  38838. stopOtherAnimations?: boolean;
  38839. /**
  38840. * Defines a callback raised once the interpolation animation has been done.
  38841. */
  38842. onInterpolationDone?: () => void;
  38843. /**
  38844. * Observable triggered once the interpolation animation has been done.
  38845. */
  38846. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38847. private _target;
  38848. private _effectiveTarget;
  38849. private _property;
  38850. /**
  38851. * Instantiate the action
  38852. * @param triggerOptions defines the trigger options
  38853. * @param target defines the object containing the value to interpolate
  38854. * @param propertyPath defines the path to the property in the target object
  38855. * @param value defines the target value at the end of the interpolation
  38856. * @param duration deines the time it will take for the property to interpolate to the value.
  38857. * @param condition defines the trigger related conditions
  38858. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38859. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38860. */
  38861. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38862. /** @hidden */
  38863. _prepare(): void;
  38864. /**
  38865. * Execute the action starts the value interpolation.
  38866. */
  38867. execute(): void;
  38868. /**
  38869. * Serializes the actions and its related information.
  38870. * @param parent defines the object to serialize in
  38871. * @returns the serialized object
  38872. */
  38873. serialize(parent: any): any;
  38874. }
  38875. }
  38876. declare module "babylonjs/Actions/index" {
  38877. export * from "babylonjs/Actions/abstractActionManager";
  38878. export * from "babylonjs/Actions/action";
  38879. export * from "babylonjs/Actions/actionEvent";
  38880. export * from "babylonjs/Actions/actionManager";
  38881. export * from "babylonjs/Actions/condition";
  38882. export * from "babylonjs/Actions/directActions";
  38883. export * from "babylonjs/Actions/directAudioActions";
  38884. export * from "babylonjs/Actions/interpolateValueAction";
  38885. }
  38886. declare module "babylonjs/Animations/index" {
  38887. export * from "babylonjs/Animations/animatable";
  38888. export * from "babylonjs/Animations/animation";
  38889. export * from "babylonjs/Animations/animationGroup";
  38890. export * from "babylonjs/Animations/animationPropertiesOverride";
  38891. export * from "babylonjs/Animations/easing";
  38892. export * from "babylonjs/Animations/runtimeAnimation";
  38893. export * from "babylonjs/Animations/animationEvent";
  38894. export * from "babylonjs/Animations/animationGroup";
  38895. export * from "babylonjs/Animations/animationKey";
  38896. export * from "babylonjs/Animations/animationRange";
  38897. export * from "babylonjs/Animations/animatable.interface";
  38898. }
  38899. declare module "babylonjs/Audio/soundTrack" {
  38900. import { Sound } from "babylonjs/Audio/sound";
  38901. import { Analyser } from "babylonjs/Audio/analyser";
  38902. import { Scene } from "babylonjs/scene";
  38903. /**
  38904. * Options allowed during the creation of a sound track.
  38905. */
  38906. export interface ISoundTrackOptions {
  38907. /**
  38908. * The volume the sound track should take during creation
  38909. */
  38910. volume?: number;
  38911. /**
  38912. * Define if the sound track is the main sound track of the scene
  38913. */
  38914. mainTrack?: boolean;
  38915. }
  38916. /**
  38917. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38918. * It will be also used in a future release to apply effects on a specific track.
  38919. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38920. */
  38921. export class SoundTrack {
  38922. /**
  38923. * The unique identifier of the sound track in the scene.
  38924. */
  38925. id: number;
  38926. /**
  38927. * The list of sounds included in the sound track.
  38928. */
  38929. soundCollection: Array<Sound>;
  38930. private _outputAudioNode;
  38931. private _scene;
  38932. private _connectedAnalyser;
  38933. private _options;
  38934. private _isInitialized;
  38935. /**
  38936. * Creates a new sound track.
  38937. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38938. * @param scene Define the scene the sound track belongs to
  38939. * @param options
  38940. */
  38941. constructor(scene: Scene, options?: ISoundTrackOptions);
  38942. private _initializeSoundTrackAudioGraph;
  38943. /**
  38944. * Release the sound track and its associated resources
  38945. */
  38946. dispose(): void;
  38947. /**
  38948. * Adds a sound to this sound track
  38949. * @param sound define the cound to add
  38950. * @ignoreNaming
  38951. */
  38952. AddSound(sound: Sound): void;
  38953. /**
  38954. * Removes a sound to this sound track
  38955. * @param sound define the cound to remove
  38956. * @ignoreNaming
  38957. */
  38958. RemoveSound(sound: Sound): void;
  38959. /**
  38960. * Set a global volume for the full sound track.
  38961. * @param newVolume Define the new volume of the sound track
  38962. */
  38963. setVolume(newVolume: number): void;
  38964. /**
  38965. * Switch the panning model to HRTF:
  38966. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38967. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38968. */
  38969. switchPanningModelToHRTF(): void;
  38970. /**
  38971. * Switch the panning model to Equal Power:
  38972. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38973. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38974. */
  38975. switchPanningModelToEqualPower(): void;
  38976. /**
  38977. * Connect the sound track to an audio analyser allowing some amazing
  38978. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38979. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38980. * @param analyser The analyser to connect to the engine
  38981. */
  38982. connectToAnalyser(analyser: Analyser): void;
  38983. }
  38984. }
  38985. declare module "babylonjs/Audio/audioSceneComponent" {
  38986. import { Sound } from "babylonjs/Audio/sound";
  38987. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38988. import { Nullable } from "babylonjs/types";
  38989. import { Vector3 } from "babylonjs/Maths/math.vector";
  38990. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38991. import { Scene } from "babylonjs/scene";
  38992. import { AbstractScene } from "babylonjs/abstractScene";
  38993. import "babylonjs/Audio/audioEngine";
  38994. module "babylonjs/abstractScene" {
  38995. interface AbstractScene {
  38996. /**
  38997. * The list of sounds used in the scene.
  38998. */
  38999. sounds: Nullable<Array<Sound>>;
  39000. }
  39001. }
  39002. module "babylonjs/scene" {
  39003. interface Scene {
  39004. /**
  39005. * @hidden
  39006. * Backing field
  39007. */
  39008. _mainSoundTrack: SoundTrack;
  39009. /**
  39010. * The main sound track played by the scene.
  39011. * It cotains your primary collection of sounds.
  39012. */
  39013. mainSoundTrack: SoundTrack;
  39014. /**
  39015. * The list of sound tracks added to the scene
  39016. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39017. */
  39018. soundTracks: Nullable<Array<SoundTrack>>;
  39019. /**
  39020. * Gets a sound using a given name
  39021. * @param name defines the name to search for
  39022. * @return the found sound or null if not found at all.
  39023. */
  39024. getSoundByName(name: string): Nullable<Sound>;
  39025. /**
  39026. * Gets or sets if audio support is enabled
  39027. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39028. */
  39029. audioEnabled: boolean;
  39030. /**
  39031. * Gets or sets if audio will be output to headphones
  39032. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39033. */
  39034. headphone: boolean;
  39035. /**
  39036. * Gets or sets custom audio listener position provider
  39037. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39038. */
  39039. audioListenerPositionProvider: Nullable<() => Vector3>;
  39040. /**
  39041. * Gets or sets a refresh rate when using 3D audio positioning
  39042. */
  39043. audioPositioningRefreshRate: number;
  39044. }
  39045. }
  39046. /**
  39047. * Defines the sound scene component responsible to manage any sounds
  39048. * in a given scene.
  39049. */
  39050. export class AudioSceneComponent implements ISceneSerializableComponent {
  39051. /**
  39052. * The component name helpfull to identify the component in the list of scene components.
  39053. */
  39054. readonly name: string;
  39055. /**
  39056. * The scene the component belongs to.
  39057. */
  39058. scene: Scene;
  39059. private _audioEnabled;
  39060. /**
  39061. * Gets whether audio is enabled or not.
  39062. * Please use related enable/disable method to switch state.
  39063. */
  39064. get audioEnabled(): boolean;
  39065. private _headphone;
  39066. /**
  39067. * Gets whether audio is outputing to headphone or not.
  39068. * Please use the according Switch methods to change output.
  39069. */
  39070. get headphone(): boolean;
  39071. /**
  39072. * Gets or sets a refresh rate when using 3D audio positioning
  39073. */
  39074. audioPositioningRefreshRate: number;
  39075. private _audioListenerPositionProvider;
  39076. /**
  39077. * Gets the current audio listener position provider
  39078. */
  39079. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  39080. /**
  39081. * Sets a custom listener position for all sounds in the scene
  39082. * By default, this is the position of the first active camera
  39083. */
  39084. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  39085. /**
  39086. * Creates a new instance of the component for the given scene
  39087. * @param scene Defines the scene to register the component in
  39088. */
  39089. constructor(scene: Scene);
  39090. /**
  39091. * Registers the component in a given scene
  39092. */
  39093. register(): void;
  39094. /**
  39095. * Rebuilds the elements related to this component in case of
  39096. * context lost for instance.
  39097. */
  39098. rebuild(): void;
  39099. /**
  39100. * Serializes the component data to the specified json object
  39101. * @param serializationObject The object to serialize to
  39102. */
  39103. serialize(serializationObject: any): void;
  39104. /**
  39105. * Adds all the elements from the container to the scene
  39106. * @param container the container holding the elements
  39107. */
  39108. addFromContainer(container: AbstractScene): void;
  39109. /**
  39110. * Removes all the elements in the container from the scene
  39111. * @param container contains the elements to remove
  39112. * @param dispose if the removed element should be disposed (default: false)
  39113. */
  39114. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  39115. /**
  39116. * Disposes the component and the associated ressources.
  39117. */
  39118. dispose(): void;
  39119. /**
  39120. * Disables audio in the associated scene.
  39121. */
  39122. disableAudio(): void;
  39123. /**
  39124. * Enables audio in the associated scene.
  39125. */
  39126. enableAudio(): void;
  39127. /**
  39128. * Switch audio to headphone output.
  39129. */
  39130. switchAudioModeForHeadphones(): void;
  39131. /**
  39132. * Switch audio to normal speakers.
  39133. */
  39134. switchAudioModeForNormalSpeakers(): void;
  39135. private _cachedCameraDirection;
  39136. private _cachedCameraPosition;
  39137. private _lastCheck;
  39138. private _afterRender;
  39139. }
  39140. }
  39141. declare module "babylonjs/Audio/weightedsound" {
  39142. import { Sound } from "babylonjs/Audio/sound";
  39143. /**
  39144. * Wraps one or more Sound objects and selects one with random weight for playback.
  39145. */
  39146. export class WeightedSound {
  39147. /** When true a Sound will be selected and played when the current playing Sound completes. */
  39148. loop: boolean;
  39149. private _coneInnerAngle;
  39150. private _coneOuterAngle;
  39151. private _volume;
  39152. /** A Sound is currently playing. */
  39153. isPlaying: boolean;
  39154. /** A Sound is currently paused. */
  39155. isPaused: boolean;
  39156. private _sounds;
  39157. private _weights;
  39158. private _currentIndex?;
  39159. /**
  39160. * Creates a new WeightedSound from the list of sounds given.
  39161. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  39162. * @param sounds Array of Sounds that will be selected from.
  39163. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  39164. */
  39165. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  39166. /**
  39167. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  39168. */
  39169. get directionalConeInnerAngle(): number;
  39170. /**
  39171. * The size of cone in degress for a directional sound in which there will be no attenuation.
  39172. */
  39173. set directionalConeInnerAngle(value: number);
  39174. /**
  39175. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39176. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39177. */
  39178. get directionalConeOuterAngle(): number;
  39179. /**
  39180. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39181. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39182. */
  39183. set directionalConeOuterAngle(value: number);
  39184. /**
  39185. * Playback volume.
  39186. */
  39187. get volume(): number;
  39188. /**
  39189. * Playback volume.
  39190. */
  39191. set volume(value: number);
  39192. private _onended;
  39193. /**
  39194. * Suspend playback
  39195. */
  39196. pause(): void;
  39197. /**
  39198. * Stop playback
  39199. */
  39200. stop(): void;
  39201. /**
  39202. * Start playback.
  39203. * @param startOffset Position the clip head at a specific time in seconds.
  39204. */
  39205. play(startOffset?: number): void;
  39206. }
  39207. }
  39208. declare module "babylonjs/Audio/index" {
  39209. export * from "babylonjs/Audio/analyser";
  39210. export * from "babylonjs/Audio/audioEngine";
  39211. export * from "babylonjs/Audio/audioSceneComponent";
  39212. export * from "babylonjs/Audio/sound";
  39213. export * from "babylonjs/Audio/soundTrack";
  39214. export * from "babylonjs/Audio/weightedsound";
  39215. }
  39216. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  39217. import { Behavior } from "babylonjs/Behaviors/behavior";
  39218. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39219. import { BackEase } from "babylonjs/Animations/easing";
  39220. /**
  39221. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  39222. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39223. */
  39224. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  39225. /**
  39226. * Gets the name of the behavior.
  39227. */
  39228. get name(): string;
  39229. /**
  39230. * The easing function used by animations
  39231. */
  39232. static EasingFunction: BackEase;
  39233. /**
  39234. * The easing mode used by animations
  39235. */
  39236. static EasingMode: number;
  39237. /**
  39238. * The duration of the animation, in milliseconds
  39239. */
  39240. transitionDuration: number;
  39241. /**
  39242. * Length of the distance animated by the transition when lower radius is reached
  39243. */
  39244. lowerRadiusTransitionRange: number;
  39245. /**
  39246. * Length of the distance animated by the transition when upper radius is reached
  39247. */
  39248. upperRadiusTransitionRange: number;
  39249. private _autoTransitionRange;
  39250. /**
  39251. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39252. */
  39253. get autoTransitionRange(): boolean;
  39254. /**
  39255. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39256. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  39257. */
  39258. set autoTransitionRange(value: boolean);
  39259. private _attachedCamera;
  39260. private _onAfterCheckInputsObserver;
  39261. private _onMeshTargetChangedObserver;
  39262. /**
  39263. * Initializes the behavior.
  39264. */
  39265. init(): void;
  39266. /**
  39267. * Attaches the behavior to its arc rotate camera.
  39268. * @param camera Defines the camera to attach the behavior to
  39269. */
  39270. attach(camera: ArcRotateCamera): void;
  39271. /**
  39272. * Detaches the behavior from its current arc rotate camera.
  39273. */
  39274. detach(): void;
  39275. private _radiusIsAnimating;
  39276. private _radiusBounceTransition;
  39277. private _animatables;
  39278. private _cachedWheelPrecision;
  39279. /**
  39280. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  39281. * @param radiusLimit The limit to check against.
  39282. * @return Bool to indicate if at limit.
  39283. */
  39284. private _isRadiusAtLimit;
  39285. /**
  39286. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  39287. * @param radiusDelta The delta by which to animate to. Can be negative.
  39288. */
  39289. private _applyBoundRadiusAnimation;
  39290. /**
  39291. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  39292. */
  39293. protected _clearAnimationLocks(): void;
  39294. /**
  39295. * Stops and removes all animations that have been applied to the camera
  39296. */
  39297. stopAllAnimations(): void;
  39298. }
  39299. }
  39300. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  39301. import { Behavior } from "babylonjs/Behaviors/behavior";
  39302. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39303. import { ExponentialEase } from "babylonjs/Animations/easing";
  39304. import { Nullable } from "babylonjs/types";
  39305. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39306. import { Vector3 } from "babylonjs/Maths/math.vector";
  39307. /**
  39308. * 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.
  39309. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39310. */
  39311. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  39312. /**
  39313. * Gets the name of the behavior.
  39314. */
  39315. get name(): string;
  39316. private _mode;
  39317. private _radiusScale;
  39318. private _positionScale;
  39319. private _defaultElevation;
  39320. private _elevationReturnTime;
  39321. private _elevationReturnWaitTime;
  39322. private _zoomStopsAnimation;
  39323. private _framingTime;
  39324. /**
  39325. * The easing function used by animations
  39326. */
  39327. static EasingFunction: ExponentialEase;
  39328. /**
  39329. * The easing mode used by animations
  39330. */
  39331. static EasingMode: number;
  39332. /**
  39333. * Sets the current mode used by the behavior
  39334. */
  39335. set mode(mode: number);
  39336. /**
  39337. * Gets current mode used by the behavior.
  39338. */
  39339. get mode(): number;
  39340. /**
  39341. * Sets the scale applied to the radius (1 by default)
  39342. */
  39343. set radiusScale(radius: number);
  39344. /**
  39345. * Gets the scale applied to the radius
  39346. */
  39347. get radiusScale(): number;
  39348. /**
  39349. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39350. */
  39351. set positionScale(scale: number);
  39352. /**
  39353. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39354. */
  39355. get positionScale(): number;
  39356. /**
  39357. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39358. * behaviour is triggered, in radians.
  39359. */
  39360. set defaultElevation(elevation: number);
  39361. /**
  39362. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39363. * behaviour is triggered, in radians.
  39364. */
  39365. get defaultElevation(): number;
  39366. /**
  39367. * Sets the time (in milliseconds) taken to return to the default beta position.
  39368. * Negative value indicates camera should not return to default.
  39369. */
  39370. set elevationReturnTime(speed: number);
  39371. /**
  39372. * Gets the time (in milliseconds) taken to return to the default beta position.
  39373. * Negative value indicates camera should not return to default.
  39374. */
  39375. get elevationReturnTime(): number;
  39376. /**
  39377. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39378. */
  39379. set elevationReturnWaitTime(time: number);
  39380. /**
  39381. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39382. */
  39383. get elevationReturnWaitTime(): number;
  39384. /**
  39385. * Sets the flag that indicates if user zooming should stop animation.
  39386. */
  39387. set zoomStopsAnimation(flag: boolean);
  39388. /**
  39389. * Gets the flag that indicates if user zooming should stop animation.
  39390. */
  39391. get zoomStopsAnimation(): boolean;
  39392. /**
  39393. * Sets the transition time when framing the mesh, in milliseconds
  39394. */
  39395. set framingTime(time: number);
  39396. /**
  39397. * Gets the transition time when framing the mesh, in milliseconds
  39398. */
  39399. get framingTime(): number;
  39400. /**
  39401. * Define if the behavior should automatically change the configured
  39402. * camera limits and sensibilities.
  39403. */
  39404. autoCorrectCameraLimitsAndSensibility: boolean;
  39405. private _onPrePointerObservableObserver;
  39406. private _onAfterCheckInputsObserver;
  39407. private _onMeshTargetChangedObserver;
  39408. private _attachedCamera;
  39409. private _isPointerDown;
  39410. private _lastInteractionTime;
  39411. /**
  39412. * Initializes the behavior.
  39413. */
  39414. init(): void;
  39415. /**
  39416. * Attaches the behavior to its arc rotate camera.
  39417. * @param camera Defines the camera to attach the behavior to
  39418. */
  39419. attach(camera: ArcRotateCamera): void;
  39420. /**
  39421. * Detaches the behavior from its current arc rotate camera.
  39422. */
  39423. detach(): void;
  39424. private _animatables;
  39425. private _betaIsAnimating;
  39426. private _betaTransition;
  39427. private _radiusTransition;
  39428. private _vectorTransition;
  39429. /**
  39430. * Targets the given mesh and updates zoom level accordingly.
  39431. * @param mesh The mesh to target.
  39432. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39433. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39434. */
  39435. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39436. /**
  39437. * Targets the given mesh with its children and updates zoom level accordingly.
  39438. * @param mesh The mesh to target.
  39439. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39440. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39441. */
  39442. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39443. /**
  39444. * Targets the given meshes with their children and updates zoom level accordingly.
  39445. * @param meshes The mesh to target.
  39446. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39447. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39448. */
  39449. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39450. /**
  39451. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39452. * @param minimumWorld Determines the smaller position of the bounding box extend
  39453. * @param maximumWorld Determines the bigger position of the bounding box extend
  39454. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39455. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39456. */
  39457. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39458. /**
  39459. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39460. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39461. * frustum width.
  39462. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39463. * to fully enclose the mesh in the viewing frustum.
  39464. */
  39465. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39466. /**
  39467. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39468. * is automatically returned to its default position (expected to be above ground plane).
  39469. */
  39470. private _maintainCameraAboveGround;
  39471. /**
  39472. * Returns the frustum slope based on the canvas ratio and camera FOV
  39473. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39474. */
  39475. private _getFrustumSlope;
  39476. /**
  39477. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39478. */
  39479. private _clearAnimationLocks;
  39480. /**
  39481. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39482. */
  39483. private _applyUserInteraction;
  39484. /**
  39485. * Stops and removes all animations that have been applied to the camera
  39486. */
  39487. stopAllAnimations(): void;
  39488. /**
  39489. * Gets a value indicating if the user is moving the camera
  39490. */
  39491. get isUserIsMoving(): boolean;
  39492. /**
  39493. * The camera can move all the way towards the mesh.
  39494. */
  39495. static IgnoreBoundsSizeMode: number;
  39496. /**
  39497. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39498. */
  39499. static FitFrustumSidesMode: number;
  39500. }
  39501. }
  39502. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39503. import { Nullable } from "babylonjs/types";
  39504. import { Camera } from "babylonjs/Cameras/camera";
  39505. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39506. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39507. /**
  39508. * Base class for Camera Pointer Inputs.
  39509. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39510. * for example usage.
  39511. */
  39512. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39513. /**
  39514. * Defines the camera the input is attached to.
  39515. */
  39516. abstract camera: Camera;
  39517. /**
  39518. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39519. */
  39520. protected _altKey: boolean;
  39521. protected _ctrlKey: boolean;
  39522. protected _metaKey: boolean;
  39523. protected _shiftKey: boolean;
  39524. /**
  39525. * Which mouse buttons were pressed at time of last mouse event.
  39526. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39527. */
  39528. protected _buttonsPressed: number;
  39529. /**
  39530. * Defines the buttons associated with the input to handle camera move.
  39531. */
  39532. buttons: number[];
  39533. /**
  39534. * Attach the input controls to a specific dom element to get the input from.
  39535. * @param element Defines the element the controls should be listened from
  39536. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39537. */
  39538. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39539. /**
  39540. * Detach the current controls from the specified dom element.
  39541. * @param element Defines the element to stop listening the inputs from
  39542. */
  39543. detachControl(element: Nullable<HTMLElement>): void;
  39544. /**
  39545. * Gets the class name of the current input.
  39546. * @returns the class name
  39547. */
  39548. getClassName(): string;
  39549. /**
  39550. * Get the friendly name associated with the input class.
  39551. * @returns the input friendly name
  39552. */
  39553. getSimpleName(): string;
  39554. /**
  39555. * Called on pointer POINTERDOUBLETAP event.
  39556. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39557. */
  39558. protected onDoubleTap(type: string): void;
  39559. /**
  39560. * Called on pointer POINTERMOVE event if only a single touch is active.
  39561. * Override this method to provide functionality.
  39562. */
  39563. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39564. /**
  39565. * Called on pointer POINTERMOVE event if multiple touches are active.
  39566. * Override this method to provide functionality.
  39567. */
  39568. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39569. /**
  39570. * Called on JS contextmenu event.
  39571. * Override this method to provide functionality.
  39572. */
  39573. protected onContextMenu(evt: PointerEvent): void;
  39574. /**
  39575. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39576. * press.
  39577. * Override this method to provide functionality.
  39578. */
  39579. protected onButtonDown(evt: PointerEvent): void;
  39580. /**
  39581. * Called each time a new POINTERUP event occurs. Ie, for each button
  39582. * release.
  39583. * Override this method to provide functionality.
  39584. */
  39585. protected onButtonUp(evt: PointerEvent): void;
  39586. /**
  39587. * Called when window becomes inactive.
  39588. * Override this method to provide functionality.
  39589. */
  39590. protected onLostFocus(): void;
  39591. private _pointerInput;
  39592. private _observer;
  39593. private _onLostFocus;
  39594. private pointA;
  39595. private pointB;
  39596. }
  39597. }
  39598. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39599. import { Nullable } from "babylonjs/types";
  39600. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39601. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39602. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39603. /**
  39604. * Manage the pointers inputs to control an arc rotate camera.
  39605. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39606. */
  39607. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39608. /**
  39609. * Defines the camera the input is attached to.
  39610. */
  39611. camera: ArcRotateCamera;
  39612. /**
  39613. * Gets the class name of the current input.
  39614. * @returns the class name
  39615. */
  39616. getClassName(): string;
  39617. /**
  39618. * Defines the buttons associated with the input to handle camera move.
  39619. */
  39620. buttons: number[];
  39621. /**
  39622. * Defines the pointer angular sensibility along the X axis or how fast is
  39623. * the camera rotating.
  39624. */
  39625. angularSensibilityX: number;
  39626. /**
  39627. * Defines the pointer angular sensibility along the Y axis or how fast is
  39628. * the camera rotating.
  39629. */
  39630. angularSensibilityY: number;
  39631. /**
  39632. * Defines the pointer pinch precision or how fast is the camera zooming.
  39633. */
  39634. pinchPrecision: number;
  39635. /**
  39636. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39637. * from 0.
  39638. * It defines the percentage of current camera.radius to use as delta when
  39639. * pinch zoom is used.
  39640. */
  39641. pinchDeltaPercentage: number;
  39642. /**
  39643. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39644. * that any object in the plane at the camera's target point will scale
  39645. * perfectly with finger motion.
  39646. * Overrides pinchDeltaPercentage and pinchPrecision.
  39647. */
  39648. useNaturalPinchZoom: boolean;
  39649. /**
  39650. * Defines the pointer panning sensibility or how fast is the camera moving.
  39651. */
  39652. panningSensibility: number;
  39653. /**
  39654. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39655. */
  39656. multiTouchPanning: boolean;
  39657. /**
  39658. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39659. * zoom (pinch) through multitouch.
  39660. */
  39661. multiTouchPanAndZoom: boolean;
  39662. /**
  39663. * Revers pinch action direction.
  39664. */
  39665. pinchInwards: boolean;
  39666. private _isPanClick;
  39667. private _twoFingerActivityCount;
  39668. private _isPinching;
  39669. /**
  39670. * Called on pointer POINTERMOVE event if only a single touch is active.
  39671. */
  39672. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39673. /**
  39674. * Called on pointer POINTERDOUBLETAP event.
  39675. */
  39676. protected onDoubleTap(type: string): void;
  39677. /**
  39678. * Called on pointer POINTERMOVE event if multiple touches are active.
  39679. */
  39680. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39681. /**
  39682. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39683. * press.
  39684. */
  39685. protected onButtonDown(evt: PointerEvent): void;
  39686. /**
  39687. * Called each time a new POINTERUP event occurs. Ie, for each button
  39688. * release.
  39689. */
  39690. protected onButtonUp(evt: PointerEvent): void;
  39691. /**
  39692. * Called when window becomes inactive.
  39693. */
  39694. protected onLostFocus(): void;
  39695. }
  39696. }
  39697. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39698. import { Nullable } from "babylonjs/types";
  39699. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39700. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39701. /**
  39702. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39703. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39704. */
  39705. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39706. /**
  39707. * Defines the camera the input is attached to.
  39708. */
  39709. camera: ArcRotateCamera;
  39710. /**
  39711. * Defines the list of key codes associated with the up action (increase alpha)
  39712. */
  39713. keysUp: number[];
  39714. /**
  39715. * Defines the list of key codes associated with the down action (decrease alpha)
  39716. */
  39717. keysDown: number[];
  39718. /**
  39719. * Defines the list of key codes associated with the left action (increase beta)
  39720. */
  39721. keysLeft: number[];
  39722. /**
  39723. * Defines the list of key codes associated with the right action (decrease beta)
  39724. */
  39725. keysRight: number[];
  39726. /**
  39727. * Defines the list of key codes associated with the reset action.
  39728. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39729. */
  39730. keysReset: number[];
  39731. /**
  39732. * Defines the panning sensibility of the inputs.
  39733. * (How fast is the camera panning)
  39734. */
  39735. panningSensibility: number;
  39736. /**
  39737. * Defines the zooming sensibility of the inputs.
  39738. * (How fast is the camera zooming)
  39739. */
  39740. zoomingSensibility: number;
  39741. /**
  39742. * Defines whether maintaining the alt key down switch the movement mode from
  39743. * orientation to zoom.
  39744. */
  39745. useAltToZoom: boolean;
  39746. /**
  39747. * Rotation speed of the camera
  39748. */
  39749. angularSpeed: number;
  39750. private _keys;
  39751. private _ctrlPressed;
  39752. private _altPressed;
  39753. private _onCanvasBlurObserver;
  39754. private _onKeyboardObserver;
  39755. private _engine;
  39756. private _scene;
  39757. /**
  39758. * Attach the input controls to a specific dom element to get the input from.
  39759. * @param element Defines the element the controls should be listened from
  39760. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39761. */
  39762. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39763. /**
  39764. * Detach the current controls from the specified dom element.
  39765. * @param element Defines the element to stop listening the inputs from
  39766. */
  39767. detachControl(element: Nullable<HTMLElement>): void;
  39768. /**
  39769. * Update the current camera state depending on the inputs that have been used this frame.
  39770. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39771. */
  39772. checkInputs(): void;
  39773. /**
  39774. * Gets the class name of the current intput.
  39775. * @returns the class name
  39776. */
  39777. getClassName(): string;
  39778. /**
  39779. * Get the friendly name associated with the input class.
  39780. * @returns the input friendly name
  39781. */
  39782. getSimpleName(): string;
  39783. }
  39784. }
  39785. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  39786. import { Nullable } from "babylonjs/types";
  39787. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39788. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39789. /**
  39790. * Manage the mouse wheel inputs to control an arc rotate camera.
  39791. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39792. */
  39793. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39794. /**
  39795. * Defines the camera the input is attached to.
  39796. */
  39797. camera: ArcRotateCamera;
  39798. /**
  39799. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39800. */
  39801. wheelPrecision: number;
  39802. /**
  39803. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39804. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39805. */
  39806. wheelDeltaPercentage: number;
  39807. private _wheel;
  39808. private _observer;
  39809. private computeDeltaFromMouseWheelLegacyEvent;
  39810. /**
  39811. * Attach the input controls to a specific dom element to get the input from.
  39812. * @param element Defines the element the controls should be listened from
  39813. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39814. */
  39815. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39816. /**
  39817. * Detach the current controls from the specified dom element.
  39818. * @param element Defines the element to stop listening the inputs from
  39819. */
  39820. detachControl(element: Nullable<HTMLElement>): void;
  39821. /**
  39822. * Gets the class name of the current intput.
  39823. * @returns the class name
  39824. */
  39825. getClassName(): string;
  39826. /**
  39827. * Get the friendly name associated with the input class.
  39828. * @returns the input friendly name
  39829. */
  39830. getSimpleName(): string;
  39831. }
  39832. }
  39833. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39834. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39835. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39836. /**
  39837. * Default Inputs manager for the ArcRotateCamera.
  39838. * It groups all the default supported inputs for ease of use.
  39839. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39840. */
  39841. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39842. /**
  39843. * Instantiates a new ArcRotateCameraInputsManager.
  39844. * @param camera Defines the camera the inputs belong to
  39845. */
  39846. constructor(camera: ArcRotateCamera);
  39847. /**
  39848. * Add mouse wheel input support to the input manager.
  39849. * @returns the current input manager
  39850. */
  39851. addMouseWheel(): ArcRotateCameraInputsManager;
  39852. /**
  39853. * Add pointers input support to the input manager.
  39854. * @returns the current input manager
  39855. */
  39856. addPointers(): ArcRotateCameraInputsManager;
  39857. /**
  39858. * Add keyboard input support to the input manager.
  39859. * @returns the current input manager
  39860. */
  39861. addKeyboard(): ArcRotateCameraInputsManager;
  39862. }
  39863. }
  39864. declare module "babylonjs/Cameras/arcRotateCamera" {
  39865. import { Observable } from "babylonjs/Misc/observable";
  39866. import { Nullable } from "babylonjs/types";
  39867. import { Scene } from "babylonjs/scene";
  39868. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  39869. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39870. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39871. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39872. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39873. import { Camera } from "babylonjs/Cameras/camera";
  39874. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39875. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39876. import { Collider } from "babylonjs/Collisions/collider";
  39877. /**
  39878. * This represents an orbital type of camera.
  39879. *
  39880. * 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.
  39881. * 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.
  39882. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39883. */
  39884. export class ArcRotateCamera extends TargetCamera {
  39885. /**
  39886. * Defines the rotation angle of the camera along the longitudinal axis.
  39887. */
  39888. alpha: number;
  39889. /**
  39890. * Defines the rotation angle of the camera along the latitudinal axis.
  39891. */
  39892. beta: number;
  39893. /**
  39894. * Defines the radius of the camera from it s target point.
  39895. */
  39896. radius: number;
  39897. protected _target: Vector3;
  39898. protected _targetHost: Nullable<AbstractMesh>;
  39899. /**
  39900. * Defines the target point of the camera.
  39901. * The camera looks towards it form the radius distance.
  39902. */
  39903. get target(): Vector3;
  39904. set target(value: Vector3);
  39905. /**
  39906. * Define the current local position of the camera in the scene
  39907. */
  39908. get position(): Vector3;
  39909. set position(newPosition: Vector3);
  39910. protected _upVector: Vector3;
  39911. protected _upToYMatrix: Matrix;
  39912. protected _YToUpMatrix: Matrix;
  39913. /**
  39914. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39915. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39916. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39917. */
  39918. set upVector(vec: Vector3);
  39919. get upVector(): Vector3;
  39920. /**
  39921. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39922. */
  39923. setMatUp(): void;
  39924. /**
  39925. * Current inertia value on the longitudinal axis.
  39926. * The bigger this number the longer it will take for the camera to stop.
  39927. */
  39928. inertialAlphaOffset: number;
  39929. /**
  39930. * Current inertia value on the latitudinal axis.
  39931. * The bigger this number the longer it will take for the camera to stop.
  39932. */
  39933. inertialBetaOffset: number;
  39934. /**
  39935. * Current inertia value on the radius axis.
  39936. * The bigger this number the longer it will take for the camera to stop.
  39937. */
  39938. inertialRadiusOffset: number;
  39939. /**
  39940. * Minimum allowed angle on the longitudinal axis.
  39941. * This can help limiting how the Camera is able to move in the scene.
  39942. */
  39943. lowerAlphaLimit: Nullable<number>;
  39944. /**
  39945. * Maximum allowed angle on the longitudinal axis.
  39946. * This can help limiting how the Camera is able to move in the scene.
  39947. */
  39948. upperAlphaLimit: Nullable<number>;
  39949. /**
  39950. * Minimum allowed angle on the latitudinal axis.
  39951. * This can help limiting how the Camera is able to move in the scene.
  39952. */
  39953. lowerBetaLimit: number;
  39954. /**
  39955. * Maximum allowed angle on the latitudinal axis.
  39956. * This can help limiting how the Camera is able to move in the scene.
  39957. */
  39958. upperBetaLimit: number;
  39959. /**
  39960. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39961. * This can help limiting how the Camera is able to move in the scene.
  39962. */
  39963. lowerRadiusLimit: Nullable<number>;
  39964. /**
  39965. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39966. * This can help limiting how the Camera is able to move in the scene.
  39967. */
  39968. upperRadiusLimit: Nullable<number>;
  39969. /**
  39970. * Defines the current inertia value used during panning of the camera along the X axis.
  39971. */
  39972. inertialPanningX: number;
  39973. /**
  39974. * Defines the current inertia value used during panning of the camera along the Y axis.
  39975. */
  39976. inertialPanningY: number;
  39977. /**
  39978. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39979. * Basically if your fingers moves away from more than this distance you will be considered
  39980. * in pinch mode.
  39981. */
  39982. pinchToPanMaxDistance: number;
  39983. /**
  39984. * Defines the maximum distance the camera can pan.
  39985. * This could help keeping the cammera always in your scene.
  39986. */
  39987. panningDistanceLimit: Nullable<number>;
  39988. /**
  39989. * Defines the target of the camera before paning.
  39990. */
  39991. panningOriginTarget: Vector3;
  39992. /**
  39993. * Defines the value of the inertia used during panning.
  39994. * 0 would mean stop inertia and one would mean no decelleration at all.
  39995. */
  39996. panningInertia: number;
  39997. /**
  39998. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39999. */
  40000. get angularSensibilityX(): number;
  40001. set angularSensibilityX(value: number);
  40002. /**
  40003. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  40004. */
  40005. get angularSensibilityY(): number;
  40006. set angularSensibilityY(value: number);
  40007. /**
  40008. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  40009. */
  40010. get pinchPrecision(): number;
  40011. set pinchPrecision(value: number);
  40012. /**
  40013. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  40014. * It will be used instead of pinchDeltaPrecision if different from 0.
  40015. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  40016. */
  40017. get pinchDeltaPercentage(): number;
  40018. set pinchDeltaPercentage(value: number);
  40019. /**
  40020. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  40021. * and pinch delta percentage.
  40022. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  40023. * that any object in the plane at the camera's target point will scale
  40024. * perfectly with finger motion.
  40025. */
  40026. get useNaturalPinchZoom(): boolean;
  40027. set useNaturalPinchZoom(value: boolean);
  40028. /**
  40029. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  40030. */
  40031. get panningSensibility(): number;
  40032. set panningSensibility(value: number);
  40033. /**
  40034. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  40035. */
  40036. get keysUp(): number[];
  40037. set keysUp(value: number[]);
  40038. /**
  40039. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  40040. */
  40041. get keysDown(): number[];
  40042. set keysDown(value: number[]);
  40043. /**
  40044. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  40045. */
  40046. get keysLeft(): number[];
  40047. set keysLeft(value: number[]);
  40048. /**
  40049. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  40050. */
  40051. get keysRight(): number[];
  40052. set keysRight(value: number[]);
  40053. /**
  40054. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  40055. */
  40056. get wheelPrecision(): number;
  40057. set wheelPrecision(value: number);
  40058. /**
  40059. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  40060. * It will be used instead of pinchDeltaPrecision if different from 0.
  40061. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  40062. */
  40063. get wheelDeltaPercentage(): number;
  40064. set wheelDeltaPercentage(value: number);
  40065. /**
  40066. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  40067. */
  40068. zoomOnFactor: number;
  40069. /**
  40070. * Defines a screen offset for the camera position.
  40071. */
  40072. targetScreenOffset: Vector2;
  40073. /**
  40074. * Allows the camera to be completely reversed.
  40075. * If false the camera can not arrive upside down.
  40076. */
  40077. allowUpsideDown: boolean;
  40078. /**
  40079. * Define if double tap/click is used to restore the previously saved state of the camera.
  40080. */
  40081. useInputToRestoreState: boolean;
  40082. /** @hidden */
  40083. _viewMatrix: Matrix;
  40084. /** @hidden */
  40085. _useCtrlForPanning: boolean;
  40086. /** @hidden */
  40087. _panningMouseButton: number;
  40088. /**
  40089. * Defines the input associated to the camera.
  40090. */
  40091. inputs: ArcRotateCameraInputsManager;
  40092. /** @hidden */
  40093. _reset: () => void;
  40094. /**
  40095. * Defines the allowed panning axis.
  40096. */
  40097. panningAxis: Vector3;
  40098. protected _localDirection: Vector3;
  40099. protected _transformedDirection: Vector3;
  40100. private _bouncingBehavior;
  40101. /**
  40102. * Gets the bouncing behavior of the camera if it has been enabled.
  40103. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40104. */
  40105. get bouncingBehavior(): Nullable<BouncingBehavior>;
  40106. /**
  40107. * Defines if the bouncing behavior of the camera is enabled on the camera.
  40108. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40109. */
  40110. get useBouncingBehavior(): boolean;
  40111. set useBouncingBehavior(value: boolean);
  40112. private _framingBehavior;
  40113. /**
  40114. * Gets the framing behavior of the camera if it has been enabled.
  40115. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40116. */
  40117. get framingBehavior(): Nullable<FramingBehavior>;
  40118. /**
  40119. * Defines if the framing behavior of the camera is enabled on the camera.
  40120. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40121. */
  40122. get useFramingBehavior(): boolean;
  40123. set useFramingBehavior(value: boolean);
  40124. private _autoRotationBehavior;
  40125. /**
  40126. * Gets the auto rotation behavior of the camera if it has been enabled.
  40127. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40128. */
  40129. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  40130. /**
  40131. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  40132. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40133. */
  40134. get useAutoRotationBehavior(): boolean;
  40135. set useAutoRotationBehavior(value: boolean);
  40136. /**
  40137. * Observable triggered when the mesh target has been changed on the camera.
  40138. */
  40139. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  40140. /**
  40141. * Event raised when the camera is colliding with a mesh.
  40142. */
  40143. onCollide: (collidedMesh: AbstractMesh) => void;
  40144. /**
  40145. * Defines whether the camera should check collision with the objects oh the scene.
  40146. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  40147. */
  40148. checkCollisions: boolean;
  40149. /**
  40150. * Defines the collision radius of the camera.
  40151. * This simulates a sphere around the camera.
  40152. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40153. */
  40154. collisionRadius: Vector3;
  40155. protected _collider: Collider;
  40156. protected _previousPosition: Vector3;
  40157. protected _collisionVelocity: Vector3;
  40158. protected _newPosition: Vector3;
  40159. protected _previousAlpha: number;
  40160. protected _previousBeta: number;
  40161. protected _previousRadius: number;
  40162. protected _collisionTriggered: boolean;
  40163. protected _targetBoundingCenter: Nullable<Vector3>;
  40164. private _computationVector;
  40165. /**
  40166. * Instantiates a new ArcRotateCamera in a given scene
  40167. * @param name Defines the name of the camera
  40168. * @param alpha Defines the camera rotation along the logitudinal axis
  40169. * @param beta Defines the camera rotation along the latitudinal axis
  40170. * @param radius Defines the camera distance from its target
  40171. * @param target Defines the camera target
  40172. * @param scene Defines the scene the camera belongs to
  40173. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  40174. */
  40175. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40176. /** @hidden */
  40177. _initCache(): void;
  40178. /** @hidden */
  40179. _updateCache(ignoreParentClass?: boolean): void;
  40180. protected _getTargetPosition(): Vector3;
  40181. private _storedAlpha;
  40182. private _storedBeta;
  40183. private _storedRadius;
  40184. private _storedTarget;
  40185. private _storedTargetScreenOffset;
  40186. /**
  40187. * Stores the current state of the camera (alpha, beta, radius and target)
  40188. * @returns the camera itself
  40189. */
  40190. storeState(): Camera;
  40191. /**
  40192. * @hidden
  40193. * Restored camera state. You must call storeState() first
  40194. */
  40195. _restoreStateValues(): boolean;
  40196. /** @hidden */
  40197. _isSynchronizedViewMatrix(): boolean;
  40198. /**
  40199. * Attached controls to the current camera.
  40200. * @param element Defines the element the controls should be listened from
  40201. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40202. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  40203. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  40204. */
  40205. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  40206. /**
  40207. * Detach the current controls from the camera.
  40208. * The camera will stop reacting to inputs.
  40209. * @param element Defines the element to stop listening the inputs from
  40210. */
  40211. detachControl(element: HTMLElement): void;
  40212. /** @hidden */
  40213. _checkInputs(): void;
  40214. protected _checkLimits(): void;
  40215. /**
  40216. * Rebuilds angles (alpha, beta) and radius from the give position and target
  40217. */
  40218. rebuildAnglesAndRadius(): void;
  40219. /**
  40220. * Use a position to define the current camera related information like alpha, beta and radius
  40221. * @param position Defines the position to set the camera at
  40222. */
  40223. setPosition(position: Vector3): void;
  40224. /**
  40225. * Defines the target the camera should look at.
  40226. * This will automatically adapt alpha beta and radius to fit within the new target.
  40227. * @param target Defines the new target as a Vector or a mesh
  40228. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  40229. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  40230. */
  40231. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  40232. /** @hidden */
  40233. _getViewMatrix(): Matrix;
  40234. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  40235. /**
  40236. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  40237. * @param meshes Defines the mesh to zoom on
  40238. * @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)
  40239. */
  40240. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  40241. /**
  40242. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  40243. * The target will be changed but the radius
  40244. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  40245. * @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)
  40246. */
  40247. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  40248. min: Vector3;
  40249. max: Vector3;
  40250. distance: number;
  40251. }, doNotUpdateMaxZ?: boolean): void;
  40252. /**
  40253. * @override
  40254. * Override Camera.createRigCamera
  40255. */
  40256. createRigCamera(name: string, cameraIndex: number): Camera;
  40257. /**
  40258. * @hidden
  40259. * @override
  40260. * Override Camera._updateRigCameras
  40261. */
  40262. _updateRigCameras(): void;
  40263. /**
  40264. * Destroy the camera and release the current resources hold by it.
  40265. */
  40266. dispose(): void;
  40267. /**
  40268. * Gets the current object class name.
  40269. * @return the class name
  40270. */
  40271. getClassName(): string;
  40272. }
  40273. }
  40274. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  40275. import { Behavior } from "babylonjs/Behaviors/behavior";
  40276. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40277. /**
  40278. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40279. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40280. */
  40281. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40282. /**
  40283. * Gets the name of the behavior.
  40284. */
  40285. get name(): string;
  40286. private _zoomStopsAnimation;
  40287. private _idleRotationSpeed;
  40288. private _idleRotationWaitTime;
  40289. private _idleRotationSpinupTime;
  40290. /**
  40291. * Sets the flag that indicates if user zooming should stop animation.
  40292. */
  40293. set zoomStopsAnimation(flag: boolean);
  40294. /**
  40295. * Gets the flag that indicates if user zooming should stop animation.
  40296. */
  40297. get zoomStopsAnimation(): boolean;
  40298. /**
  40299. * Sets the default speed at which the camera rotates around the model.
  40300. */
  40301. set idleRotationSpeed(speed: number);
  40302. /**
  40303. * Gets the default speed at which the camera rotates around the model.
  40304. */
  40305. get idleRotationSpeed(): number;
  40306. /**
  40307. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40308. */
  40309. set idleRotationWaitTime(time: number);
  40310. /**
  40311. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40312. */
  40313. get idleRotationWaitTime(): number;
  40314. /**
  40315. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40316. */
  40317. set idleRotationSpinupTime(time: number);
  40318. /**
  40319. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40320. */
  40321. get idleRotationSpinupTime(): number;
  40322. /**
  40323. * Gets a value indicating if the camera is currently rotating because of this behavior
  40324. */
  40325. get rotationInProgress(): boolean;
  40326. private _onPrePointerObservableObserver;
  40327. private _onAfterCheckInputsObserver;
  40328. private _attachedCamera;
  40329. private _isPointerDown;
  40330. private _lastFrameTime;
  40331. private _lastInteractionTime;
  40332. private _cameraRotationSpeed;
  40333. /**
  40334. * Initializes the behavior.
  40335. */
  40336. init(): void;
  40337. /**
  40338. * Attaches the behavior to its arc rotate camera.
  40339. * @param camera Defines the camera to attach the behavior to
  40340. */
  40341. attach(camera: ArcRotateCamera): void;
  40342. /**
  40343. * Detaches the behavior from its current arc rotate camera.
  40344. */
  40345. detach(): void;
  40346. /**
  40347. * Returns true if user is scrolling.
  40348. * @return true if user is scrolling.
  40349. */
  40350. private _userIsZooming;
  40351. private _lastFrameRadius;
  40352. private _shouldAnimationStopForInteraction;
  40353. /**
  40354. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40355. */
  40356. private _applyUserInteraction;
  40357. private _userIsMoving;
  40358. }
  40359. }
  40360. declare module "babylonjs/Behaviors/Cameras/index" {
  40361. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40362. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40363. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  40364. }
  40365. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  40366. import { Mesh } from "babylonjs/Meshes/mesh";
  40367. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40368. import { Behavior } from "babylonjs/Behaviors/behavior";
  40369. /**
  40370. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40371. */
  40372. export class AttachToBoxBehavior implements Behavior<Mesh> {
  40373. private ui;
  40374. /**
  40375. * The name of the behavior
  40376. */
  40377. name: string;
  40378. /**
  40379. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40380. */
  40381. distanceAwayFromFace: number;
  40382. /**
  40383. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40384. */
  40385. distanceAwayFromBottomOfFace: number;
  40386. private _faceVectors;
  40387. private _target;
  40388. private _scene;
  40389. private _onRenderObserver;
  40390. private _tmpMatrix;
  40391. private _tmpVector;
  40392. /**
  40393. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40394. * @param ui The transform node that should be attched to the mesh
  40395. */
  40396. constructor(ui: TransformNode);
  40397. /**
  40398. * Initializes the behavior
  40399. */
  40400. init(): void;
  40401. private _closestFace;
  40402. private _zeroVector;
  40403. private _lookAtTmpMatrix;
  40404. private _lookAtToRef;
  40405. /**
  40406. * Attaches the AttachToBoxBehavior to the passed in mesh
  40407. * @param target The mesh that the specified node will be attached to
  40408. */
  40409. attach(target: Mesh): void;
  40410. /**
  40411. * Detaches the behavior from the mesh
  40412. */
  40413. detach(): void;
  40414. }
  40415. }
  40416. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  40417. import { Behavior } from "babylonjs/Behaviors/behavior";
  40418. import { Mesh } from "babylonjs/Meshes/mesh";
  40419. /**
  40420. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40421. */
  40422. export class FadeInOutBehavior implements Behavior<Mesh> {
  40423. /**
  40424. * Time in milliseconds to delay before fading in (Default: 0)
  40425. */
  40426. delay: number;
  40427. /**
  40428. * Time in milliseconds for the mesh to fade in (Default: 300)
  40429. */
  40430. fadeInTime: number;
  40431. private _millisecondsPerFrame;
  40432. private _hovered;
  40433. private _hoverValue;
  40434. private _ownerNode;
  40435. /**
  40436. * Instatiates the FadeInOutBehavior
  40437. */
  40438. constructor();
  40439. /**
  40440. * The name of the behavior
  40441. */
  40442. get name(): string;
  40443. /**
  40444. * Initializes the behavior
  40445. */
  40446. init(): void;
  40447. /**
  40448. * Attaches the fade behavior on the passed in mesh
  40449. * @param ownerNode The mesh that will be faded in/out once attached
  40450. */
  40451. attach(ownerNode: Mesh): void;
  40452. /**
  40453. * Detaches the behavior from the mesh
  40454. */
  40455. detach(): void;
  40456. /**
  40457. * Triggers the mesh to begin fading in or out
  40458. * @param value if the object should fade in or out (true to fade in)
  40459. */
  40460. fadeIn(value: boolean): void;
  40461. private _update;
  40462. private _setAllVisibility;
  40463. }
  40464. }
  40465. declare module "babylonjs/Misc/pivotTools" {
  40466. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40467. /**
  40468. * Class containing a set of static utilities functions for managing Pivots
  40469. * @hidden
  40470. */
  40471. export class PivotTools {
  40472. private static _PivotCached;
  40473. private static _OldPivotPoint;
  40474. private static _PivotTranslation;
  40475. private static _PivotTmpVector;
  40476. /** @hidden */
  40477. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40478. /** @hidden */
  40479. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40480. }
  40481. }
  40482. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40483. import { Scene } from "babylonjs/scene";
  40484. import { Vector4 } from "babylonjs/Maths/math.vector";
  40485. import { Mesh } from "babylonjs/Meshes/mesh";
  40486. import { Nullable } from "babylonjs/types";
  40487. import { Plane } from "babylonjs/Maths/math.plane";
  40488. /**
  40489. * Class containing static functions to help procedurally build meshes
  40490. */
  40491. export class PlaneBuilder {
  40492. /**
  40493. * Creates a plane mesh
  40494. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40495. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40496. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40497. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40498. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40500. * @param name defines the name of the mesh
  40501. * @param options defines the options used to create the mesh
  40502. * @param scene defines the hosting scene
  40503. * @returns the plane mesh
  40504. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40505. */
  40506. static CreatePlane(name: string, options: {
  40507. size?: number;
  40508. width?: number;
  40509. height?: number;
  40510. sideOrientation?: number;
  40511. frontUVs?: Vector4;
  40512. backUVs?: Vector4;
  40513. updatable?: boolean;
  40514. sourcePlane?: Plane;
  40515. }, scene?: Nullable<Scene>): Mesh;
  40516. }
  40517. }
  40518. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40519. import { Behavior } from "babylonjs/Behaviors/behavior";
  40520. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40521. import { Observable } from "babylonjs/Misc/observable";
  40522. import { Vector3 } from "babylonjs/Maths/math.vector";
  40523. import { Ray } from "babylonjs/Culling/ray";
  40524. import "babylonjs/Meshes/Builders/planeBuilder";
  40525. /**
  40526. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40527. */
  40528. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40529. private static _AnyMouseID;
  40530. /**
  40531. * Abstract mesh the behavior is set on
  40532. */
  40533. attachedNode: AbstractMesh;
  40534. private _dragPlane;
  40535. private _scene;
  40536. private _pointerObserver;
  40537. private _beforeRenderObserver;
  40538. private static _planeScene;
  40539. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40540. /**
  40541. * 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)
  40542. */
  40543. maxDragAngle: number;
  40544. /**
  40545. * @hidden
  40546. */
  40547. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40548. /**
  40549. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40550. */
  40551. currentDraggingPointerID: number;
  40552. /**
  40553. * The last position where the pointer hit the drag plane in world space
  40554. */
  40555. lastDragPosition: Vector3;
  40556. /**
  40557. * If the behavior is currently in a dragging state
  40558. */
  40559. dragging: boolean;
  40560. /**
  40561. * 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)
  40562. */
  40563. dragDeltaRatio: number;
  40564. /**
  40565. * If the drag plane orientation should be updated during the dragging (Default: true)
  40566. */
  40567. updateDragPlane: boolean;
  40568. private _debugMode;
  40569. private _moving;
  40570. /**
  40571. * Fires each time the attached mesh is dragged with the pointer
  40572. * * delta between last drag position and current drag position in world space
  40573. * * dragDistance along the drag axis
  40574. * * dragPlaneNormal normal of the current drag plane used during the drag
  40575. * * dragPlanePoint in world space where the drag intersects the drag plane
  40576. */
  40577. onDragObservable: Observable<{
  40578. delta: Vector3;
  40579. dragPlanePoint: Vector3;
  40580. dragPlaneNormal: Vector3;
  40581. dragDistance: number;
  40582. pointerId: number;
  40583. }>;
  40584. /**
  40585. * Fires each time a drag begins (eg. mouse down on mesh)
  40586. */
  40587. onDragStartObservable: Observable<{
  40588. dragPlanePoint: Vector3;
  40589. pointerId: number;
  40590. }>;
  40591. /**
  40592. * Fires each time a drag ends (eg. mouse release after drag)
  40593. */
  40594. onDragEndObservable: Observable<{
  40595. dragPlanePoint: Vector3;
  40596. pointerId: number;
  40597. }>;
  40598. /**
  40599. * If the attached mesh should be moved when dragged
  40600. */
  40601. moveAttached: boolean;
  40602. /**
  40603. * If the drag behavior will react to drag events (Default: true)
  40604. */
  40605. enabled: boolean;
  40606. /**
  40607. * If pointer events should start and release the drag (Default: true)
  40608. */
  40609. startAndReleaseDragOnPointerEvents: boolean;
  40610. /**
  40611. * If camera controls should be detached during the drag
  40612. */
  40613. detachCameraControls: boolean;
  40614. /**
  40615. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40616. */
  40617. useObjectOrientationForDragging: boolean;
  40618. private _options;
  40619. /**
  40620. * Gets the options used by the behavior
  40621. */
  40622. get options(): {
  40623. dragAxis?: Vector3;
  40624. dragPlaneNormal?: Vector3;
  40625. };
  40626. /**
  40627. * Sets the options used by the behavior
  40628. */
  40629. set options(options: {
  40630. dragAxis?: Vector3;
  40631. dragPlaneNormal?: Vector3;
  40632. });
  40633. /**
  40634. * Creates a pointer drag behavior that can be attached to a mesh
  40635. * @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)
  40636. */
  40637. constructor(options?: {
  40638. dragAxis?: Vector3;
  40639. dragPlaneNormal?: Vector3;
  40640. });
  40641. /**
  40642. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40643. */
  40644. validateDrag: (targetPosition: Vector3) => boolean;
  40645. /**
  40646. * The name of the behavior
  40647. */
  40648. get name(): string;
  40649. /**
  40650. * Initializes the behavior
  40651. */
  40652. init(): void;
  40653. private _tmpVector;
  40654. private _alternatePickedPoint;
  40655. private _worldDragAxis;
  40656. private _targetPosition;
  40657. private _attachedElement;
  40658. /**
  40659. * Attaches the drag behavior the passed in mesh
  40660. * @param ownerNode The mesh that will be dragged around once attached
  40661. * @param predicate Predicate to use for pick filtering
  40662. */
  40663. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40664. /**
  40665. * Force relase the drag action by code.
  40666. */
  40667. releaseDrag(): void;
  40668. private _startDragRay;
  40669. private _lastPointerRay;
  40670. /**
  40671. * Simulates the start of a pointer drag event on the behavior
  40672. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40673. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40674. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40675. */
  40676. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40677. private _startDrag;
  40678. private _dragDelta;
  40679. private _moveDrag;
  40680. private _pickWithRayOnDragPlane;
  40681. private _pointA;
  40682. private _pointB;
  40683. private _pointC;
  40684. private _lineA;
  40685. private _lineB;
  40686. private _localAxis;
  40687. private _lookAt;
  40688. private _updateDragPlanePosition;
  40689. /**
  40690. * Detaches the behavior from the mesh
  40691. */
  40692. detach(): void;
  40693. }
  40694. }
  40695. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40696. import { Mesh } from "babylonjs/Meshes/mesh";
  40697. import { Behavior } from "babylonjs/Behaviors/behavior";
  40698. /**
  40699. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40700. */
  40701. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40702. private _dragBehaviorA;
  40703. private _dragBehaviorB;
  40704. private _startDistance;
  40705. private _initialScale;
  40706. private _targetScale;
  40707. private _ownerNode;
  40708. private _sceneRenderObserver;
  40709. /**
  40710. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40711. */
  40712. constructor();
  40713. /**
  40714. * The name of the behavior
  40715. */
  40716. get name(): string;
  40717. /**
  40718. * Initializes the behavior
  40719. */
  40720. init(): void;
  40721. private _getCurrentDistance;
  40722. /**
  40723. * Attaches the scale behavior the passed in mesh
  40724. * @param ownerNode The mesh that will be scaled around once attached
  40725. */
  40726. attach(ownerNode: Mesh): void;
  40727. /**
  40728. * Detaches the behavior from the mesh
  40729. */
  40730. detach(): void;
  40731. }
  40732. }
  40733. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40734. import { Behavior } from "babylonjs/Behaviors/behavior";
  40735. import { Mesh } from "babylonjs/Meshes/mesh";
  40736. import { Observable } from "babylonjs/Misc/observable";
  40737. /**
  40738. * 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
  40739. */
  40740. export class SixDofDragBehavior implements Behavior<Mesh> {
  40741. private static _virtualScene;
  40742. private _ownerNode;
  40743. private _sceneRenderObserver;
  40744. private _scene;
  40745. private _targetPosition;
  40746. private _virtualOriginMesh;
  40747. private _virtualDragMesh;
  40748. private _pointerObserver;
  40749. private _moving;
  40750. private _startingOrientation;
  40751. /**
  40752. * 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)
  40753. */
  40754. private zDragFactor;
  40755. /**
  40756. * If the object should rotate to face the drag origin
  40757. */
  40758. rotateDraggedObject: boolean;
  40759. /**
  40760. * If the behavior is currently in a dragging state
  40761. */
  40762. dragging: boolean;
  40763. /**
  40764. * 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)
  40765. */
  40766. dragDeltaRatio: number;
  40767. /**
  40768. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40769. */
  40770. currentDraggingPointerID: number;
  40771. /**
  40772. * If camera controls should be detached during the drag
  40773. */
  40774. detachCameraControls: boolean;
  40775. /**
  40776. * Fires each time a drag starts
  40777. */
  40778. onDragStartObservable: Observable<{}>;
  40779. /**
  40780. * Fires each time a drag ends (eg. mouse release after drag)
  40781. */
  40782. onDragEndObservable: Observable<{}>;
  40783. /**
  40784. * 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
  40785. */
  40786. constructor();
  40787. /**
  40788. * The name of the behavior
  40789. */
  40790. get name(): string;
  40791. /**
  40792. * Initializes the behavior
  40793. */
  40794. init(): void;
  40795. /**
  40796. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  40797. */
  40798. private get _pointerCamera();
  40799. /**
  40800. * Attaches the scale behavior the passed in mesh
  40801. * @param ownerNode The mesh that will be scaled around once attached
  40802. */
  40803. attach(ownerNode: Mesh): void;
  40804. /**
  40805. * Detaches the behavior from the mesh
  40806. */
  40807. detach(): void;
  40808. }
  40809. }
  40810. declare module "babylonjs/Behaviors/Meshes/index" {
  40811. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  40812. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  40813. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  40814. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40815. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  40816. }
  40817. declare module "babylonjs/Behaviors/index" {
  40818. export * from "babylonjs/Behaviors/behavior";
  40819. export * from "babylonjs/Behaviors/Cameras/index";
  40820. export * from "babylonjs/Behaviors/Meshes/index";
  40821. }
  40822. declare module "babylonjs/Bones/boneIKController" {
  40823. import { Bone } from "babylonjs/Bones/bone";
  40824. import { Vector3 } from "babylonjs/Maths/math.vector";
  40825. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40826. import { Nullable } from "babylonjs/types";
  40827. /**
  40828. * Class used to apply inverse kinematics to bones
  40829. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40830. */
  40831. export class BoneIKController {
  40832. private static _tmpVecs;
  40833. private static _tmpQuat;
  40834. private static _tmpMats;
  40835. /**
  40836. * Gets or sets the target mesh
  40837. */
  40838. targetMesh: AbstractMesh;
  40839. /** Gets or sets the mesh used as pole */
  40840. poleTargetMesh: AbstractMesh;
  40841. /**
  40842. * Gets or sets the bone used as pole
  40843. */
  40844. poleTargetBone: Nullable<Bone>;
  40845. /**
  40846. * Gets or sets the target position
  40847. */
  40848. targetPosition: Vector3;
  40849. /**
  40850. * Gets or sets the pole target position
  40851. */
  40852. poleTargetPosition: Vector3;
  40853. /**
  40854. * Gets or sets the pole target local offset
  40855. */
  40856. poleTargetLocalOffset: Vector3;
  40857. /**
  40858. * Gets or sets the pole angle
  40859. */
  40860. poleAngle: number;
  40861. /**
  40862. * Gets or sets the mesh associated with the controller
  40863. */
  40864. mesh: AbstractMesh;
  40865. /**
  40866. * 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)
  40867. */
  40868. slerpAmount: number;
  40869. private _bone1Quat;
  40870. private _bone1Mat;
  40871. private _bone2Ang;
  40872. private _bone1;
  40873. private _bone2;
  40874. private _bone1Length;
  40875. private _bone2Length;
  40876. private _maxAngle;
  40877. private _maxReach;
  40878. private _rightHandedSystem;
  40879. private _bendAxis;
  40880. private _slerping;
  40881. private _adjustRoll;
  40882. /**
  40883. * Gets or sets maximum allowed angle
  40884. */
  40885. get maxAngle(): number;
  40886. set maxAngle(value: number);
  40887. /**
  40888. * Creates a new BoneIKController
  40889. * @param mesh defines the mesh to control
  40890. * @param bone defines the bone to control
  40891. * @param options defines options to set up the controller
  40892. */
  40893. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40894. targetMesh?: AbstractMesh;
  40895. poleTargetMesh?: AbstractMesh;
  40896. poleTargetBone?: Bone;
  40897. poleTargetLocalOffset?: Vector3;
  40898. poleAngle?: number;
  40899. bendAxis?: Vector3;
  40900. maxAngle?: number;
  40901. slerpAmount?: number;
  40902. });
  40903. private _setMaxAngle;
  40904. /**
  40905. * Force the controller to update the bones
  40906. */
  40907. update(): void;
  40908. }
  40909. }
  40910. declare module "babylonjs/Bones/boneLookController" {
  40911. import { Vector3 } from "babylonjs/Maths/math.vector";
  40912. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40913. import { Bone } from "babylonjs/Bones/bone";
  40914. import { Space } from "babylonjs/Maths/math.axis";
  40915. /**
  40916. * Class used to make a bone look toward a point in space
  40917. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40918. */
  40919. export class BoneLookController {
  40920. private static _tmpVecs;
  40921. private static _tmpQuat;
  40922. private static _tmpMats;
  40923. /**
  40924. * The target Vector3 that the bone will look at
  40925. */
  40926. target: Vector3;
  40927. /**
  40928. * The mesh that the bone is attached to
  40929. */
  40930. mesh: AbstractMesh;
  40931. /**
  40932. * The bone that will be looking to the target
  40933. */
  40934. bone: Bone;
  40935. /**
  40936. * The up axis of the coordinate system that is used when the bone is rotated
  40937. */
  40938. upAxis: Vector3;
  40939. /**
  40940. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40941. */
  40942. upAxisSpace: Space;
  40943. /**
  40944. * Used to make an adjustment to the yaw of the bone
  40945. */
  40946. adjustYaw: number;
  40947. /**
  40948. * Used to make an adjustment to the pitch of the bone
  40949. */
  40950. adjustPitch: number;
  40951. /**
  40952. * Used to make an adjustment to the roll of the bone
  40953. */
  40954. adjustRoll: number;
  40955. /**
  40956. * 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)
  40957. */
  40958. slerpAmount: number;
  40959. private _minYaw;
  40960. private _maxYaw;
  40961. private _minPitch;
  40962. private _maxPitch;
  40963. private _minYawSin;
  40964. private _minYawCos;
  40965. private _maxYawSin;
  40966. private _maxYawCos;
  40967. private _midYawConstraint;
  40968. private _minPitchTan;
  40969. private _maxPitchTan;
  40970. private _boneQuat;
  40971. private _slerping;
  40972. private _transformYawPitch;
  40973. private _transformYawPitchInv;
  40974. private _firstFrameSkipped;
  40975. private _yawRange;
  40976. private _fowardAxis;
  40977. /**
  40978. * Gets or sets the minimum yaw angle that the bone can look to
  40979. */
  40980. get minYaw(): number;
  40981. set minYaw(value: number);
  40982. /**
  40983. * Gets or sets the maximum yaw angle that the bone can look to
  40984. */
  40985. get maxYaw(): number;
  40986. set maxYaw(value: number);
  40987. /**
  40988. * Gets or sets the minimum pitch angle that the bone can look to
  40989. */
  40990. get minPitch(): number;
  40991. set minPitch(value: number);
  40992. /**
  40993. * Gets or sets the maximum pitch angle that the bone can look to
  40994. */
  40995. get maxPitch(): number;
  40996. set maxPitch(value: number);
  40997. /**
  40998. * Create a BoneLookController
  40999. * @param mesh the mesh that the bone belongs to
  41000. * @param bone the bone that will be looking to the target
  41001. * @param target the target Vector3 to look at
  41002. * @param options optional settings:
  41003. * * maxYaw: the maximum angle the bone will yaw to
  41004. * * minYaw: the minimum angle the bone will yaw to
  41005. * * maxPitch: the maximum angle the bone will pitch to
  41006. * * minPitch: the minimum angle the bone will yaw to
  41007. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  41008. * * upAxis: the up axis of the coordinate system
  41009. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  41010. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  41011. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  41012. * * adjustYaw: used to make an adjustment to the yaw of the bone
  41013. * * adjustPitch: used to make an adjustment to the pitch of the bone
  41014. * * adjustRoll: used to make an adjustment to the roll of the bone
  41015. **/
  41016. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  41017. maxYaw?: number;
  41018. minYaw?: number;
  41019. maxPitch?: number;
  41020. minPitch?: number;
  41021. slerpAmount?: number;
  41022. upAxis?: Vector3;
  41023. upAxisSpace?: Space;
  41024. yawAxis?: Vector3;
  41025. pitchAxis?: Vector3;
  41026. adjustYaw?: number;
  41027. adjustPitch?: number;
  41028. adjustRoll?: number;
  41029. });
  41030. /**
  41031. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  41032. */
  41033. update(): void;
  41034. private _getAngleDiff;
  41035. private _getAngleBetween;
  41036. private _isAngleBetween;
  41037. }
  41038. }
  41039. declare module "babylonjs/Bones/index" {
  41040. export * from "babylonjs/Bones/bone";
  41041. export * from "babylonjs/Bones/boneIKController";
  41042. export * from "babylonjs/Bones/boneLookController";
  41043. export * from "babylonjs/Bones/skeleton";
  41044. }
  41045. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  41046. import { Nullable } from "babylonjs/types";
  41047. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41048. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41049. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41050. /**
  41051. * Manage the gamepad inputs to control an arc rotate camera.
  41052. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41053. */
  41054. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  41055. /**
  41056. * Defines the camera the input is attached to.
  41057. */
  41058. camera: ArcRotateCamera;
  41059. /**
  41060. * Defines the gamepad the input is gathering event from.
  41061. */
  41062. gamepad: Nullable<Gamepad>;
  41063. /**
  41064. * Defines the gamepad rotation sensiblity.
  41065. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41066. */
  41067. gamepadRotationSensibility: number;
  41068. /**
  41069. * Defines the gamepad move sensiblity.
  41070. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41071. */
  41072. gamepadMoveSensibility: number;
  41073. private _yAxisScale;
  41074. /**
  41075. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41076. */
  41077. get invertYAxis(): boolean;
  41078. set invertYAxis(value: boolean);
  41079. private _onGamepadConnectedObserver;
  41080. private _onGamepadDisconnectedObserver;
  41081. /**
  41082. * Attach the input controls to a specific dom element to get the input from.
  41083. * @param element Defines the element the controls should be listened from
  41084. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41085. */
  41086. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41087. /**
  41088. * Detach the current controls from the specified dom element.
  41089. * @param element Defines the element to stop listening the inputs from
  41090. */
  41091. detachControl(element: Nullable<HTMLElement>): void;
  41092. /**
  41093. * Update the current camera state depending on the inputs that have been used this frame.
  41094. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41095. */
  41096. checkInputs(): void;
  41097. /**
  41098. * Gets the class name of the current intput.
  41099. * @returns the class name
  41100. */
  41101. getClassName(): string;
  41102. /**
  41103. * Get the friendly name associated with the input class.
  41104. * @returns the input friendly name
  41105. */
  41106. getSimpleName(): string;
  41107. }
  41108. }
  41109. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  41110. import { Nullable } from "babylonjs/types";
  41111. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41112. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41113. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  41114. interface ArcRotateCameraInputsManager {
  41115. /**
  41116. * Add orientation input support to the input manager.
  41117. * @returns the current input manager
  41118. */
  41119. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  41120. }
  41121. }
  41122. /**
  41123. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  41124. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41125. */
  41126. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  41127. /**
  41128. * Defines the camera the input is attached to.
  41129. */
  41130. camera: ArcRotateCamera;
  41131. /**
  41132. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  41133. */
  41134. alphaCorrection: number;
  41135. /**
  41136. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  41137. */
  41138. gammaCorrection: number;
  41139. private _alpha;
  41140. private _gamma;
  41141. private _dirty;
  41142. private _deviceOrientationHandler;
  41143. /**
  41144. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  41145. */
  41146. constructor();
  41147. /**
  41148. * Attach the input controls to a specific dom element to get the input from.
  41149. * @param element Defines the element the controls should be listened from
  41150. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41151. */
  41152. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41153. /** @hidden */
  41154. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41155. /**
  41156. * Update the current camera state depending on the inputs that have been used this frame.
  41157. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41158. */
  41159. checkInputs(): void;
  41160. /**
  41161. * Detach the current controls from the specified dom element.
  41162. * @param element Defines the element to stop listening the inputs from
  41163. */
  41164. detachControl(element: Nullable<HTMLElement>): void;
  41165. /**
  41166. * Gets the class name of the current intput.
  41167. * @returns the class name
  41168. */
  41169. getClassName(): string;
  41170. /**
  41171. * Get the friendly name associated with the input class.
  41172. * @returns the input friendly name
  41173. */
  41174. getSimpleName(): string;
  41175. }
  41176. }
  41177. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  41178. import { Nullable } from "babylonjs/types";
  41179. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41180. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41181. /**
  41182. * Listen to mouse events to control the camera.
  41183. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41184. */
  41185. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41186. /**
  41187. * Defines the camera the input is attached to.
  41188. */
  41189. camera: FlyCamera;
  41190. /**
  41191. * Defines if touch is enabled. (Default is true.)
  41192. */
  41193. touchEnabled: boolean;
  41194. /**
  41195. * Defines the buttons associated with the input to handle camera rotation.
  41196. */
  41197. buttons: number[];
  41198. /**
  41199. * Assign buttons for Yaw control.
  41200. */
  41201. buttonsYaw: number[];
  41202. /**
  41203. * Assign buttons for Pitch control.
  41204. */
  41205. buttonsPitch: number[];
  41206. /**
  41207. * Assign buttons for Roll control.
  41208. */
  41209. buttonsRoll: number[];
  41210. /**
  41211. * Detect if any button is being pressed while mouse is moved.
  41212. * -1 = Mouse locked.
  41213. * 0 = Left button.
  41214. * 1 = Middle Button.
  41215. * 2 = Right Button.
  41216. */
  41217. activeButton: number;
  41218. /**
  41219. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41220. * Higher values reduce its sensitivity.
  41221. */
  41222. angularSensibility: number;
  41223. private _mousemoveCallback;
  41224. private _observer;
  41225. private _rollObserver;
  41226. private previousPosition;
  41227. private noPreventDefault;
  41228. private element;
  41229. /**
  41230. * Listen to mouse events to control the camera.
  41231. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41232. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41233. */
  41234. constructor(touchEnabled?: boolean);
  41235. /**
  41236. * Attach the mouse control to the HTML DOM element.
  41237. * @param element Defines the element that listens to the input events.
  41238. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41239. */
  41240. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41241. /**
  41242. * Detach the current controls from the specified dom element.
  41243. * @param element Defines the element to stop listening the inputs from
  41244. */
  41245. detachControl(element: Nullable<HTMLElement>): void;
  41246. /**
  41247. * Gets the class name of the current input.
  41248. * @returns the class name.
  41249. */
  41250. getClassName(): string;
  41251. /**
  41252. * Get the friendly name associated with the input class.
  41253. * @returns the input's friendly name.
  41254. */
  41255. getSimpleName(): string;
  41256. private _pointerInput;
  41257. private _onMouseMove;
  41258. /**
  41259. * Rotate camera by mouse offset.
  41260. */
  41261. private rotateCamera;
  41262. }
  41263. }
  41264. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  41265. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41266. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41267. /**
  41268. * Default Inputs manager for the FlyCamera.
  41269. * It groups all the default supported inputs for ease of use.
  41270. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41271. */
  41272. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  41273. /**
  41274. * Instantiates a new FlyCameraInputsManager.
  41275. * @param camera Defines the camera the inputs belong to.
  41276. */
  41277. constructor(camera: FlyCamera);
  41278. /**
  41279. * Add keyboard input support to the input manager.
  41280. * @returns the new FlyCameraKeyboardMoveInput().
  41281. */
  41282. addKeyboard(): FlyCameraInputsManager;
  41283. /**
  41284. * Add mouse input support to the input manager.
  41285. * @param touchEnabled Enable touch screen support.
  41286. * @returns the new FlyCameraMouseInput().
  41287. */
  41288. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  41289. }
  41290. }
  41291. declare module "babylonjs/Cameras/flyCamera" {
  41292. import { Scene } from "babylonjs/scene";
  41293. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  41294. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41295. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41296. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  41297. /**
  41298. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41299. * such as in a 3D Space Shooter or a Flight Simulator.
  41300. */
  41301. export class FlyCamera extends TargetCamera {
  41302. /**
  41303. * Define the collision ellipsoid of the camera.
  41304. * This is helpful for simulating a camera body, like a player's body.
  41305. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41306. */
  41307. ellipsoid: Vector3;
  41308. /**
  41309. * Define an offset for the position of the ellipsoid around the camera.
  41310. * This can be helpful if the camera is attached away from the player's body center,
  41311. * such as at its head.
  41312. */
  41313. ellipsoidOffset: Vector3;
  41314. /**
  41315. * Enable or disable collisions of the camera with the rest of the scene objects.
  41316. */
  41317. checkCollisions: boolean;
  41318. /**
  41319. * Enable or disable gravity on the camera.
  41320. */
  41321. applyGravity: boolean;
  41322. /**
  41323. * Define the current direction the camera is moving to.
  41324. */
  41325. cameraDirection: Vector3;
  41326. /**
  41327. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  41328. * This overrides and empties cameraRotation.
  41329. */
  41330. rotationQuaternion: Quaternion;
  41331. /**
  41332. * Track Roll to maintain the wanted Rolling when looking around.
  41333. */
  41334. _trackRoll: number;
  41335. /**
  41336. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  41337. */
  41338. rollCorrect: number;
  41339. /**
  41340. * Mimic a banked turn, Rolling the camera when Yawing.
  41341. * It's recommended to use rollCorrect = 10 for faster banking correction.
  41342. */
  41343. bankedTurn: boolean;
  41344. /**
  41345. * Limit in radians for how much Roll banking will add. (Default: 90°)
  41346. */
  41347. bankedTurnLimit: number;
  41348. /**
  41349. * Value of 0 disables the banked Roll.
  41350. * Value of 1 is equal to the Yaw angle in radians.
  41351. */
  41352. bankedTurnMultiplier: number;
  41353. /**
  41354. * The inputs manager loads all the input sources, such as keyboard and mouse.
  41355. */
  41356. inputs: FlyCameraInputsManager;
  41357. /**
  41358. * Gets the input sensibility for mouse input.
  41359. * Higher values reduce sensitivity.
  41360. */
  41361. get angularSensibility(): number;
  41362. /**
  41363. * Sets the input sensibility for a mouse input.
  41364. * Higher values reduce sensitivity.
  41365. */
  41366. set angularSensibility(value: number);
  41367. /**
  41368. * Get the keys for camera movement forward.
  41369. */
  41370. get keysForward(): number[];
  41371. /**
  41372. * Set the keys for camera movement forward.
  41373. */
  41374. set keysForward(value: number[]);
  41375. /**
  41376. * Get the keys for camera movement backward.
  41377. */
  41378. get keysBackward(): number[];
  41379. set keysBackward(value: number[]);
  41380. /**
  41381. * Get the keys for camera movement up.
  41382. */
  41383. get keysUp(): number[];
  41384. /**
  41385. * Set the keys for camera movement up.
  41386. */
  41387. set keysUp(value: number[]);
  41388. /**
  41389. * Get the keys for camera movement down.
  41390. */
  41391. get keysDown(): number[];
  41392. /**
  41393. * Set the keys for camera movement down.
  41394. */
  41395. set keysDown(value: number[]);
  41396. /**
  41397. * Get the keys for camera movement left.
  41398. */
  41399. get keysLeft(): number[];
  41400. /**
  41401. * Set the keys for camera movement left.
  41402. */
  41403. set keysLeft(value: number[]);
  41404. /**
  41405. * Set the keys for camera movement right.
  41406. */
  41407. get keysRight(): number[];
  41408. /**
  41409. * Set the keys for camera movement right.
  41410. */
  41411. set keysRight(value: number[]);
  41412. /**
  41413. * Event raised when the camera collides with a mesh in the scene.
  41414. */
  41415. onCollide: (collidedMesh: AbstractMesh) => void;
  41416. private _collider;
  41417. private _needMoveForGravity;
  41418. private _oldPosition;
  41419. private _diffPosition;
  41420. private _newPosition;
  41421. /** @hidden */
  41422. _localDirection: Vector3;
  41423. /** @hidden */
  41424. _transformedDirection: Vector3;
  41425. /**
  41426. * Instantiates a FlyCamera.
  41427. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41428. * such as in a 3D Space Shooter or a Flight Simulator.
  41429. * @param name Define the name of the camera in the scene.
  41430. * @param position Define the starting position of the camera in the scene.
  41431. * @param scene Define the scene the camera belongs to.
  41432. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41433. */
  41434. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41435. /**
  41436. * Attach a control to the HTML DOM element.
  41437. * @param element Defines the element that listens to the input events.
  41438. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41439. */
  41440. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41441. /**
  41442. * Detach a control from the HTML DOM element.
  41443. * The camera will stop reacting to that input.
  41444. * @param element Defines the element that listens to the input events.
  41445. */
  41446. detachControl(element: HTMLElement): void;
  41447. private _collisionMask;
  41448. /**
  41449. * Get the mask that the camera ignores in collision events.
  41450. */
  41451. get collisionMask(): number;
  41452. /**
  41453. * Set the mask that the camera ignores in collision events.
  41454. */
  41455. set collisionMask(mask: number);
  41456. /** @hidden */
  41457. _collideWithWorld(displacement: Vector3): void;
  41458. /** @hidden */
  41459. private _onCollisionPositionChange;
  41460. /** @hidden */
  41461. _checkInputs(): void;
  41462. /** @hidden */
  41463. _decideIfNeedsToMove(): boolean;
  41464. /** @hidden */
  41465. _updatePosition(): void;
  41466. /**
  41467. * Restore the Roll to its target value at the rate specified.
  41468. * @param rate - Higher means slower restoring.
  41469. * @hidden
  41470. */
  41471. restoreRoll(rate: number): void;
  41472. /**
  41473. * Destroy the camera and release the current resources held by it.
  41474. */
  41475. dispose(): void;
  41476. /**
  41477. * Get the current object class name.
  41478. * @returns the class name.
  41479. */
  41480. getClassName(): string;
  41481. }
  41482. }
  41483. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41484. import { Nullable } from "babylonjs/types";
  41485. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41486. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41487. /**
  41488. * Listen to keyboard events to control the camera.
  41489. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41490. */
  41491. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41492. /**
  41493. * Defines the camera the input is attached to.
  41494. */
  41495. camera: FlyCamera;
  41496. /**
  41497. * The list of keyboard keys used to control the forward move of the camera.
  41498. */
  41499. keysForward: number[];
  41500. /**
  41501. * The list of keyboard keys used to control the backward move of the camera.
  41502. */
  41503. keysBackward: number[];
  41504. /**
  41505. * The list of keyboard keys used to control the forward move of the camera.
  41506. */
  41507. keysUp: number[];
  41508. /**
  41509. * The list of keyboard keys used to control the backward move of the camera.
  41510. */
  41511. keysDown: number[];
  41512. /**
  41513. * The list of keyboard keys used to control the right strafe move of the camera.
  41514. */
  41515. keysRight: number[];
  41516. /**
  41517. * The list of keyboard keys used to control the left strafe move of the camera.
  41518. */
  41519. keysLeft: number[];
  41520. private _keys;
  41521. private _onCanvasBlurObserver;
  41522. private _onKeyboardObserver;
  41523. private _engine;
  41524. private _scene;
  41525. /**
  41526. * Attach the input controls to a specific dom element to get the input from.
  41527. * @param element Defines the element the controls should be listened from
  41528. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41529. */
  41530. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41531. /**
  41532. * Detach the current controls from the specified dom element.
  41533. * @param element Defines the element to stop listening the inputs from
  41534. */
  41535. detachControl(element: Nullable<HTMLElement>): void;
  41536. /**
  41537. * Gets the class name of the current intput.
  41538. * @returns the class name
  41539. */
  41540. getClassName(): string;
  41541. /** @hidden */
  41542. _onLostFocus(e: FocusEvent): void;
  41543. /**
  41544. * Get the friendly name associated with the input class.
  41545. * @returns the input friendly name
  41546. */
  41547. getSimpleName(): string;
  41548. /**
  41549. * Update the current camera state depending on the inputs that have been used this frame.
  41550. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41551. */
  41552. checkInputs(): void;
  41553. }
  41554. }
  41555. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41556. import { Nullable } from "babylonjs/types";
  41557. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41558. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41559. /**
  41560. * Manage the mouse wheel inputs to control a follow camera.
  41561. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41562. */
  41563. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41564. /**
  41565. * Defines the camera the input is attached to.
  41566. */
  41567. camera: FollowCamera;
  41568. /**
  41569. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41570. */
  41571. axisControlRadius: boolean;
  41572. /**
  41573. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41574. */
  41575. axisControlHeight: boolean;
  41576. /**
  41577. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41578. */
  41579. axisControlRotation: boolean;
  41580. /**
  41581. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41582. * relation to mouseWheel events.
  41583. */
  41584. wheelPrecision: number;
  41585. /**
  41586. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41587. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41588. */
  41589. wheelDeltaPercentage: number;
  41590. private _wheel;
  41591. private _observer;
  41592. /**
  41593. * Attach the input controls to a specific dom element to get the input from.
  41594. * @param element Defines the element the controls should be listened from
  41595. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41596. */
  41597. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41598. /**
  41599. * Detach the current controls from the specified dom element.
  41600. * @param element Defines the element to stop listening the inputs from
  41601. */
  41602. detachControl(element: Nullable<HTMLElement>): void;
  41603. /**
  41604. * Gets the class name of the current intput.
  41605. * @returns the class name
  41606. */
  41607. getClassName(): string;
  41608. /**
  41609. * Get the friendly name associated with the input class.
  41610. * @returns the input friendly name
  41611. */
  41612. getSimpleName(): string;
  41613. }
  41614. }
  41615. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41616. import { Nullable } from "babylonjs/types";
  41617. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41618. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41619. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41620. /**
  41621. * Manage the pointers inputs to control an follow camera.
  41622. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41623. */
  41624. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41625. /**
  41626. * Defines the camera the input is attached to.
  41627. */
  41628. camera: FollowCamera;
  41629. /**
  41630. * Gets the class name of the current input.
  41631. * @returns the class name
  41632. */
  41633. getClassName(): string;
  41634. /**
  41635. * Defines the pointer angular sensibility along the X axis or how fast is
  41636. * the camera rotating.
  41637. * A negative number will reverse the axis direction.
  41638. */
  41639. angularSensibilityX: number;
  41640. /**
  41641. * Defines the pointer angular sensibility along the Y axis or how fast is
  41642. * the camera rotating.
  41643. * A negative number will reverse the axis direction.
  41644. */
  41645. angularSensibilityY: number;
  41646. /**
  41647. * Defines the pointer pinch precision or how fast is the camera zooming.
  41648. * A negative number will reverse the axis direction.
  41649. */
  41650. pinchPrecision: number;
  41651. /**
  41652. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41653. * from 0.
  41654. * It defines the percentage of current camera.radius to use as delta when
  41655. * pinch zoom is used.
  41656. */
  41657. pinchDeltaPercentage: number;
  41658. /**
  41659. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41660. */
  41661. axisXControlRadius: boolean;
  41662. /**
  41663. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41664. */
  41665. axisXControlHeight: boolean;
  41666. /**
  41667. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41668. */
  41669. axisXControlRotation: boolean;
  41670. /**
  41671. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41672. */
  41673. axisYControlRadius: boolean;
  41674. /**
  41675. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41676. */
  41677. axisYControlHeight: boolean;
  41678. /**
  41679. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41680. */
  41681. axisYControlRotation: boolean;
  41682. /**
  41683. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41684. */
  41685. axisPinchControlRadius: boolean;
  41686. /**
  41687. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41688. */
  41689. axisPinchControlHeight: boolean;
  41690. /**
  41691. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41692. */
  41693. axisPinchControlRotation: boolean;
  41694. /**
  41695. * Log error messages if basic misconfiguration has occurred.
  41696. */
  41697. warningEnable: boolean;
  41698. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41699. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41700. private _warningCounter;
  41701. private _warning;
  41702. }
  41703. }
  41704. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41705. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41706. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41707. /**
  41708. * Default Inputs manager for the FollowCamera.
  41709. * It groups all the default supported inputs for ease of use.
  41710. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41711. */
  41712. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41713. /**
  41714. * Instantiates a new FollowCameraInputsManager.
  41715. * @param camera Defines the camera the inputs belong to
  41716. */
  41717. constructor(camera: FollowCamera);
  41718. /**
  41719. * Add keyboard input support to the input manager.
  41720. * @returns the current input manager
  41721. */
  41722. addKeyboard(): FollowCameraInputsManager;
  41723. /**
  41724. * Add mouse wheel input support to the input manager.
  41725. * @returns the current input manager
  41726. */
  41727. addMouseWheel(): FollowCameraInputsManager;
  41728. /**
  41729. * Add pointers input support to the input manager.
  41730. * @returns the current input manager
  41731. */
  41732. addPointers(): FollowCameraInputsManager;
  41733. /**
  41734. * Add orientation input support to the input manager.
  41735. * @returns the current input manager
  41736. */
  41737. addVRDeviceOrientation(): FollowCameraInputsManager;
  41738. }
  41739. }
  41740. declare module "babylonjs/Cameras/followCamera" {
  41741. import { Nullable } from "babylonjs/types";
  41742. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41743. import { Scene } from "babylonjs/scene";
  41744. import { Vector3 } from "babylonjs/Maths/math.vector";
  41745. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41746. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41747. /**
  41748. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41749. * an arc rotate version arcFollowCamera are available.
  41750. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41751. */
  41752. export class FollowCamera extends TargetCamera {
  41753. /**
  41754. * Distance the follow camera should follow an object at
  41755. */
  41756. radius: number;
  41757. /**
  41758. * Minimum allowed distance of the camera to the axis of rotation
  41759. * (The camera can not get closer).
  41760. * This can help limiting how the Camera is able to move in the scene.
  41761. */
  41762. lowerRadiusLimit: Nullable<number>;
  41763. /**
  41764. * Maximum allowed distance of the camera to the axis of rotation
  41765. * (The camera can not get further).
  41766. * This can help limiting how the Camera is able to move in the scene.
  41767. */
  41768. upperRadiusLimit: Nullable<number>;
  41769. /**
  41770. * Define a rotation offset between the camera and the object it follows
  41771. */
  41772. rotationOffset: number;
  41773. /**
  41774. * Minimum allowed angle to camera position relative to target object.
  41775. * This can help limiting how the Camera is able to move in the scene.
  41776. */
  41777. lowerRotationOffsetLimit: Nullable<number>;
  41778. /**
  41779. * Maximum allowed angle to camera position relative to target object.
  41780. * This can help limiting how the Camera is able to move in the scene.
  41781. */
  41782. upperRotationOffsetLimit: Nullable<number>;
  41783. /**
  41784. * Define a height offset between the camera and the object it follows.
  41785. * It can help following an object from the top (like a car chaing a plane)
  41786. */
  41787. heightOffset: number;
  41788. /**
  41789. * Minimum allowed height of camera position relative to target object.
  41790. * This can help limiting how the Camera is able to move in the scene.
  41791. */
  41792. lowerHeightOffsetLimit: Nullable<number>;
  41793. /**
  41794. * Maximum allowed height of camera position relative to target object.
  41795. * This can help limiting how the Camera is able to move in the scene.
  41796. */
  41797. upperHeightOffsetLimit: Nullable<number>;
  41798. /**
  41799. * Define how fast the camera can accelerate to follow it s target.
  41800. */
  41801. cameraAcceleration: number;
  41802. /**
  41803. * Define the speed limit of the camera following an object.
  41804. */
  41805. maxCameraSpeed: number;
  41806. /**
  41807. * Define the target of the camera.
  41808. */
  41809. lockedTarget: Nullable<AbstractMesh>;
  41810. /**
  41811. * Defines the input associated with the camera.
  41812. */
  41813. inputs: FollowCameraInputsManager;
  41814. /**
  41815. * Instantiates the follow camera.
  41816. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41817. * @param name Define the name of the camera in the scene
  41818. * @param position Define the position of the camera
  41819. * @param scene Define the scene the camera belong to
  41820. * @param lockedTarget Define the target of the camera
  41821. */
  41822. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  41823. private _follow;
  41824. /**
  41825. * Attached controls to the current camera.
  41826. * @param element Defines the element the controls should be listened from
  41827. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41828. */
  41829. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41830. /**
  41831. * Detach the current controls from the camera.
  41832. * The camera will stop reacting to inputs.
  41833. * @param element Defines the element to stop listening the inputs from
  41834. */
  41835. detachControl(element: HTMLElement): void;
  41836. /** @hidden */
  41837. _checkInputs(): void;
  41838. private _checkLimits;
  41839. /**
  41840. * Gets the camera class name.
  41841. * @returns the class name
  41842. */
  41843. getClassName(): string;
  41844. }
  41845. /**
  41846. * Arc Rotate version of the follow camera.
  41847. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41848. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41849. */
  41850. export class ArcFollowCamera extends TargetCamera {
  41851. /** The longitudinal angle of the camera */
  41852. alpha: number;
  41853. /** The latitudinal angle of the camera */
  41854. beta: number;
  41855. /** The radius of the camera from its target */
  41856. radius: number;
  41857. /** Define the camera target (the messh it should follow) */
  41858. target: Nullable<AbstractMesh>;
  41859. private _cartesianCoordinates;
  41860. /**
  41861. * Instantiates a new ArcFollowCamera
  41862. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41863. * @param name Define the name of the camera
  41864. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41865. * @param beta Define the rotation angle of the camera around the elevation axis
  41866. * @param radius Define the radius of the camera from its target point
  41867. * @param target Define the target of the camera
  41868. * @param scene Define the scene the camera belongs to
  41869. */
  41870. constructor(name: string,
  41871. /** The longitudinal angle of the camera */
  41872. alpha: number,
  41873. /** The latitudinal angle of the camera */
  41874. beta: number,
  41875. /** The radius of the camera from its target */
  41876. radius: number,
  41877. /** Define the camera target (the messh it should follow) */
  41878. target: Nullable<AbstractMesh>, scene: Scene);
  41879. private _follow;
  41880. /** @hidden */
  41881. _checkInputs(): void;
  41882. /**
  41883. * Returns the class name of the object.
  41884. * It is mostly used internally for serialization purposes.
  41885. */
  41886. getClassName(): string;
  41887. }
  41888. }
  41889. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  41890. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41891. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41892. import { Nullable } from "babylonjs/types";
  41893. /**
  41894. * Manage the keyboard inputs to control the movement of a follow camera.
  41895. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41896. */
  41897. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41898. /**
  41899. * Defines the camera the input is attached to.
  41900. */
  41901. camera: FollowCamera;
  41902. /**
  41903. * Defines the list of key codes associated with the up action (increase heightOffset)
  41904. */
  41905. keysHeightOffsetIncr: number[];
  41906. /**
  41907. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41908. */
  41909. keysHeightOffsetDecr: number[];
  41910. /**
  41911. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41912. */
  41913. keysHeightOffsetModifierAlt: boolean;
  41914. /**
  41915. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41916. */
  41917. keysHeightOffsetModifierCtrl: boolean;
  41918. /**
  41919. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41920. */
  41921. keysHeightOffsetModifierShift: boolean;
  41922. /**
  41923. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41924. */
  41925. keysRotationOffsetIncr: number[];
  41926. /**
  41927. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41928. */
  41929. keysRotationOffsetDecr: number[];
  41930. /**
  41931. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41932. */
  41933. keysRotationOffsetModifierAlt: boolean;
  41934. /**
  41935. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41936. */
  41937. keysRotationOffsetModifierCtrl: boolean;
  41938. /**
  41939. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41940. */
  41941. keysRotationOffsetModifierShift: boolean;
  41942. /**
  41943. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41944. */
  41945. keysRadiusIncr: number[];
  41946. /**
  41947. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41948. */
  41949. keysRadiusDecr: number[];
  41950. /**
  41951. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41952. */
  41953. keysRadiusModifierAlt: boolean;
  41954. /**
  41955. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41956. */
  41957. keysRadiusModifierCtrl: boolean;
  41958. /**
  41959. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41960. */
  41961. keysRadiusModifierShift: boolean;
  41962. /**
  41963. * Defines the rate of change of heightOffset.
  41964. */
  41965. heightSensibility: number;
  41966. /**
  41967. * Defines the rate of change of rotationOffset.
  41968. */
  41969. rotationSensibility: number;
  41970. /**
  41971. * Defines the rate of change of radius.
  41972. */
  41973. radiusSensibility: number;
  41974. private _keys;
  41975. private _ctrlPressed;
  41976. private _altPressed;
  41977. private _shiftPressed;
  41978. private _onCanvasBlurObserver;
  41979. private _onKeyboardObserver;
  41980. private _engine;
  41981. private _scene;
  41982. /**
  41983. * Attach the input controls to a specific dom element to get the input from.
  41984. * @param element Defines the element the controls should be listened from
  41985. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41986. */
  41987. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41988. /**
  41989. * Detach the current controls from the specified dom element.
  41990. * @param element Defines the element to stop listening the inputs from
  41991. */
  41992. detachControl(element: Nullable<HTMLElement>): void;
  41993. /**
  41994. * Update the current camera state depending on the inputs that have been used this frame.
  41995. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41996. */
  41997. checkInputs(): void;
  41998. /**
  41999. * Gets the class name of the current input.
  42000. * @returns the class name
  42001. */
  42002. getClassName(): string;
  42003. /**
  42004. * Get the friendly name associated with the input class.
  42005. * @returns the input friendly name
  42006. */
  42007. getSimpleName(): string;
  42008. /**
  42009. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42010. * allow modification of the heightOffset value.
  42011. */
  42012. private _modifierHeightOffset;
  42013. /**
  42014. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42015. * allow modification of the rotationOffset value.
  42016. */
  42017. private _modifierRotationOffset;
  42018. /**
  42019. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42020. * allow modification of the radius value.
  42021. */
  42022. private _modifierRadius;
  42023. }
  42024. }
  42025. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  42026. import { Nullable } from "babylonjs/types";
  42027. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42028. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42029. import { Observable } from "babylonjs/Misc/observable";
  42030. module "babylonjs/Cameras/freeCameraInputsManager" {
  42031. interface FreeCameraInputsManager {
  42032. /**
  42033. * @hidden
  42034. */
  42035. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  42036. /**
  42037. * Add orientation input support to the input manager.
  42038. * @returns the current input manager
  42039. */
  42040. addDeviceOrientation(): FreeCameraInputsManager;
  42041. }
  42042. }
  42043. /**
  42044. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  42045. * Screen rotation is taken into account.
  42046. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42047. */
  42048. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  42049. private _camera;
  42050. private _screenOrientationAngle;
  42051. private _constantTranform;
  42052. private _screenQuaternion;
  42053. private _alpha;
  42054. private _beta;
  42055. private _gamma;
  42056. /**
  42057. * Can be used to detect if a device orientation sensor is available on a device
  42058. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  42059. * @returns a promise that will resolve on orientation change
  42060. */
  42061. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  42062. /**
  42063. * @hidden
  42064. */
  42065. _onDeviceOrientationChangedObservable: Observable<void>;
  42066. /**
  42067. * Instantiates a new input
  42068. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42069. */
  42070. constructor();
  42071. /**
  42072. * Define the camera controlled by the input.
  42073. */
  42074. get camera(): FreeCamera;
  42075. set camera(camera: FreeCamera);
  42076. /**
  42077. * Attach the input controls to a specific dom element to get the input from.
  42078. * @param element Defines the element the controls should be listened from
  42079. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42080. */
  42081. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42082. private _orientationChanged;
  42083. private _deviceOrientation;
  42084. /**
  42085. * Detach the current controls from the specified dom element.
  42086. * @param element Defines the element to stop listening the inputs from
  42087. */
  42088. detachControl(element: Nullable<HTMLElement>): void;
  42089. /**
  42090. * Update the current camera state depending on the inputs that have been used this frame.
  42091. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42092. */
  42093. checkInputs(): void;
  42094. /**
  42095. * Gets the class name of the current intput.
  42096. * @returns the class name
  42097. */
  42098. getClassName(): string;
  42099. /**
  42100. * Get the friendly name associated with the input class.
  42101. * @returns the input friendly name
  42102. */
  42103. getSimpleName(): string;
  42104. }
  42105. }
  42106. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  42107. import { Nullable } from "babylonjs/types";
  42108. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42109. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42110. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42111. /**
  42112. * Manage the gamepad inputs to control a free camera.
  42113. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42114. */
  42115. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  42116. /**
  42117. * Define the camera the input is attached to.
  42118. */
  42119. camera: FreeCamera;
  42120. /**
  42121. * Define the Gamepad controlling the input
  42122. */
  42123. gamepad: Nullable<Gamepad>;
  42124. /**
  42125. * Defines the gamepad rotation sensiblity.
  42126. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42127. */
  42128. gamepadAngularSensibility: number;
  42129. /**
  42130. * Defines the gamepad move sensiblity.
  42131. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42132. */
  42133. gamepadMoveSensibility: number;
  42134. private _yAxisScale;
  42135. /**
  42136. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  42137. */
  42138. get invertYAxis(): boolean;
  42139. set invertYAxis(value: boolean);
  42140. private _onGamepadConnectedObserver;
  42141. private _onGamepadDisconnectedObserver;
  42142. private _cameraTransform;
  42143. private _deltaTransform;
  42144. private _vector3;
  42145. private _vector2;
  42146. /**
  42147. * Attach the input controls to a specific dom element to get the input from.
  42148. * @param element Defines the element the controls should be listened from
  42149. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42150. */
  42151. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42152. /**
  42153. * Detach the current controls from the specified dom element.
  42154. * @param element Defines the element to stop listening the inputs from
  42155. */
  42156. detachControl(element: Nullable<HTMLElement>): void;
  42157. /**
  42158. * Update the current camera state depending on the inputs that have been used this frame.
  42159. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42160. */
  42161. checkInputs(): void;
  42162. /**
  42163. * Gets the class name of the current intput.
  42164. * @returns the class name
  42165. */
  42166. getClassName(): string;
  42167. /**
  42168. * Get the friendly name associated with the input class.
  42169. * @returns the input friendly name
  42170. */
  42171. getSimpleName(): string;
  42172. }
  42173. }
  42174. declare module "babylonjs/Misc/virtualJoystick" {
  42175. import { Nullable } from "babylonjs/types";
  42176. import { Vector3 } from "babylonjs/Maths/math.vector";
  42177. /**
  42178. * Defines the potential axis of a Joystick
  42179. */
  42180. export enum JoystickAxis {
  42181. /** X axis */
  42182. X = 0,
  42183. /** Y axis */
  42184. Y = 1,
  42185. /** Z axis */
  42186. Z = 2
  42187. }
  42188. /**
  42189. * Class used to define virtual joystick (used in touch mode)
  42190. */
  42191. export class VirtualJoystick {
  42192. /**
  42193. * Gets or sets a boolean indicating that left and right values must be inverted
  42194. */
  42195. reverseLeftRight: boolean;
  42196. /**
  42197. * Gets or sets a boolean indicating that up and down values must be inverted
  42198. */
  42199. reverseUpDown: boolean;
  42200. /**
  42201. * Gets the offset value for the position (ie. the change of the position value)
  42202. */
  42203. deltaPosition: Vector3;
  42204. /**
  42205. * Gets a boolean indicating if the virtual joystick was pressed
  42206. */
  42207. pressed: boolean;
  42208. /**
  42209. * Canvas the virtual joystick will render onto, default z-index of this is 5
  42210. */
  42211. static Canvas: Nullable<HTMLCanvasElement>;
  42212. private static _globalJoystickIndex;
  42213. private static vjCanvasContext;
  42214. private static vjCanvasWidth;
  42215. private static vjCanvasHeight;
  42216. private static halfWidth;
  42217. private _action;
  42218. private _axisTargetedByLeftAndRight;
  42219. private _axisTargetedByUpAndDown;
  42220. private _joystickSensibility;
  42221. private _inversedSensibility;
  42222. private _joystickPointerID;
  42223. private _joystickColor;
  42224. private _joystickPointerPos;
  42225. private _joystickPreviousPointerPos;
  42226. private _joystickPointerStartPos;
  42227. private _deltaJoystickVector;
  42228. private _leftJoystick;
  42229. private _touches;
  42230. private _onPointerDownHandlerRef;
  42231. private _onPointerMoveHandlerRef;
  42232. private _onPointerUpHandlerRef;
  42233. private _onResize;
  42234. /**
  42235. * Creates a new virtual joystick
  42236. * @param leftJoystick defines that the joystick is for left hand (false by default)
  42237. */
  42238. constructor(leftJoystick?: boolean);
  42239. /**
  42240. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  42241. * @param newJoystickSensibility defines the new sensibility
  42242. */
  42243. setJoystickSensibility(newJoystickSensibility: number): void;
  42244. private _onPointerDown;
  42245. private _onPointerMove;
  42246. private _onPointerUp;
  42247. /**
  42248. * Change the color of the virtual joystick
  42249. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  42250. */
  42251. setJoystickColor(newColor: string): void;
  42252. /**
  42253. * Defines a callback to call when the joystick is touched
  42254. * @param action defines the callback
  42255. */
  42256. setActionOnTouch(action: () => any): void;
  42257. /**
  42258. * Defines which axis you'd like to control for left & right
  42259. * @param axis defines the axis to use
  42260. */
  42261. setAxisForLeftRight(axis: JoystickAxis): void;
  42262. /**
  42263. * Defines which axis you'd like to control for up & down
  42264. * @param axis defines the axis to use
  42265. */
  42266. setAxisForUpDown(axis: JoystickAxis): void;
  42267. private _drawVirtualJoystick;
  42268. /**
  42269. * Release internal HTML canvas
  42270. */
  42271. releaseCanvas(): void;
  42272. }
  42273. }
  42274. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  42275. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  42276. import { Nullable } from "babylonjs/types";
  42277. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42278. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42279. module "babylonjs/Cameras/freeCameraInputsManager" {
  42280. interface FreeCameraInputsManager {
  42281. /**
  42282. * Add virtual joystick input support to the input manager.
  42283. * @returns the current input manager
  42284. */
  42285. addVirtualJoystick(): FreeCameraInputsManager;
  42286. }
  42287. }
  42288. /**
  42289. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42290. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42291. */
  42292. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42293. /**
  42294. * Defines the camera the input is attached to.
  42295. */
  42296. camera: FreeCamera;
  42297. private _leftjoystick;
  42298. private _rightjoystick;
  42299. /**
  42300. * Gets the left stick of the virtual joystick.
  42301. * @returns The virtual Joystick
  42302. */
  42303. getLeftJoystick(): VirtualJoystick;
  42304. /**
  42305. * Gets the right stick of the virtual joystick.
  42306. * @returns The virtual Joystick
  42307. */
  42308. getRightJoystick(): VirtualJoystick;
  42309. /**
  42310. * Update the current camera state depending on the inputs that have been used this frame.
  42311. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42312. */
  42313. checkInputs(): void;
  42314. /**
  42315. * Attach the input controls to a specific dom element to get the input from.
  42316. * @param element Defines the element the controls should be listened from
  42317. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42318. */
  42319. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42320. /**
  42321. * Detach the current controls from the specified dom element.
  42322. * @param element Defines the element to stop listening the inputs from
  42323. */
  42324. detachControl(element: Nullable<HTMLElement>): void;
  42325. /**
  42326. * Gets the class name of the current intput.
  42327. * @returns the class name
  42328. */
  42329. getClassName(): string;
  42330. /**
  42331. * Get the friendly name associated with the input class.
  42332. * @returns the input friendly name
  42333. */
  42334. getSimpleName(): string;
  42335. }
  42336. }
  42337. declare module "babylonjs/Cameras/Inputs/index" {
  42338. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  42339. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  42340. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  42341. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  42342. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42343. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  42344. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  42345. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  42346. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  42347. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  42348. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42349. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  42350. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  42351. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  42352. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  42353. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42354. }
  42355. declare module "babylonjs/Cameras/touchCamera" {
  42356. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42357. import { Scene } from "babylonjs/scene";
  42358. import { Vector3 } from "babylonjs/Maths/math.vector";
  42359. /**
  42360. * This represents a FPS type of camera controlled by touch.
  42361. * This is like a universal camera minus the Gamepad controls.
  42362. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42363. */
  42364. export class TouchCamera extends FreeCamera {
  42365. /**
  42366. * Defines the touch sensibility for rotation.
  42367. * The higher the faster.
  42368. */
  42369. get touchAngularSensibility(): number;
  42370. set touchAngularSensibility(value: number);
  42371. /**
  42372. * Defines the touch sensibility for move.
  42373. * The higher the faster.
  42374. */
  42375. get touchMoveSensibility(): number;
  42376. set touchMoveSensibility(value: number);
  42377. /**
  42378. * Instantiates a new touch camera.
  42379. * This represents a FPS type of camera controlled by touch.
  42380. * This is like a universal camera minus the Gamepad controls.
  42381. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42382. * @param name Define the name of the camera in the scene
  42383. * @param position Define the start position of the camera in the scene
  42384. * @param scene Define the scene the camera belongs to
  42385. */
  42386. constructor(name: string, position: Vector3, scene: Scene);
  42387. /**
  42388. * Gets the current object class name.
  42389. * @return the class name
  42390. */
  42391. getClassName(): string;
  42392. /** @hidden */
  42393. _setupInputs(): void;
  42394. }
  42395. }
  42396. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  42397. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42398. import { Scene } from "babylonjs/scene";
  42399. import { Vector3 } from "babylonjs/Maths/math.vector";
  42400. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42401. import { Axis } from "babylonjs/Maths/math.axis";
  42402. /**
  42403. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  42404. * being tilted forward or back and left or right.
  42405. */
  42406. export class DeviceOrientationCamera extends FreeCamera {
  42407. private _initialQuaternion;
  42408. private _quaternionCache;
  42409. private _tmpDragQuaternion;
  42410. private _disablePointerInputWhenUsingDeviceOrientation;
  42411. /**
  42412. * Creates a new device orientation camera
  42413. * @param name The name of the camera
  42414. * @param position The start position camera
  42415. * @param scene The scene the camera belongs to
  42416. */
  42417. constructor(name: string, position: Vector3, scene: Scene);
  42418. /**
  42419. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42420. */
  42421. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42422. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42423. private _dragFactor;
  42424. /**
  42425. * Enabled turning on the y axis when the orientation sensor is active
  42426. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42427. */
  42428. enableHorizontalDragging(dragFactor?: number): void;
  42429. /**
  42430. * Gets the current instance class name ("DeviceOrientationCamera").
  42431. * This helps avoiding instanceof at run time.
  42432. * @returns the class name
  42433. */
  42434. getClassName(): string;
  42435. /**
  42436. * @hidden
  42437. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42438. */
  42439. _checkInputs(): void;
  42440. /**
  42441. * Reset the camera to its default orientation on the specified axis only.
  42442. * @param axis The axis to reset
  42443. */
  42444. resetToCurrentRotation(axis?: Axis): void;
  42445. }
  42446. }
  42447. declare module "babylonjs/Gamepads/xboxGamepad" {
  42448. import { Observable } from "babylonjs/Misc/observable";
  42449. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42450. /**
  42451. * Defines supported buttons for XBox360 compatible gamepads
  42452. */
  42453. export enum Xbox360Button {
  42454. /** A */
  42455. A = 0,
  42456. /** B */
  42457. B = 1,
  42458. /** X */
  42459. X = 2,
  42460. /** Y */
  42461. Y = 3,
  42462. /** Left button */
  42463. LB = 4,
  42464. /** Right button */
  42465. RB = 5,
  42466. /** Back */
  42467. Back = 8,
  42468. /** Start */
  42469. Start = 9,
  42470. /** Left stick */
  42471. LeftStick = 10,
  42472. /** Right stick */
  42473. RightStick = 11
  42474. }
  42475. /** Defines values for XBox360 DPad */
  42476. export enum Xbox360Dpad {
  42477. /** Up */
  42478. Up = 12,
  42479. /** Down */
  42480. Down = 13,
  42481. /** Left */
  42482. Left = 14,
  42483. /** Right */
  42484. Right = 15
  42485. }
  42486. /**
  42487. * Defines a XBox360 gamepad
  42488. */
  42489. export class Xbox360Pad extends Gamepad {
  42490. private _leftTrigger;
  42491. private _rightTrigger;
  42492. private _onlefttriggerchanged;
  42493. private _onrighttriggerchanged;
  42494. private _onbuttondown;
  42495. private _onbuttonup;
  42496. private _ondpaddown;
  42497. private _ondpadup;
  42498. /** Observable raised when a button is pressed */
  42499. onButtonDownObservable: Observable<Xbox360Button>;
  42500. /** Observable raised when a button is released */
  42501. onButtonUpObservable: Observable<Xbox360Button>;
  42502. /** Observable raised when a pad is pressed */
  42503. onPadDownObservable: Observable<Xbox360Dpad>;
  42504. /** Observable raised when a pad is released */
  42505. onPadUpObservable: Observable<Xbox360Dpad>;
  42506. private _buttonA;
  42507. private _buttonB;
  42508. private _buttonX;
  42509. private _buttonY;
  42510. private _buttonBack;
  42511. private _buttonStart;
  42512. private _buttonLB;
  42513. private _buttonRB;
  42514. private _buttonLeftStick;
  42515. private _buttonRightStick;
  42516. private _dPadUp;
  42517. private _dPadDown;
  42518. private _dPadLeft;
  42519. private _dPadRight;
  42520. private _isXboxOnePad;
  42521. /**
  42522. * Creates a new XBox360 gamepad object
  42523. * @param id defines the id of this gamepad
  42524. * @param index defines its index
  42525. * @param gamepad defines the internal HTML gamepad object
  42526. * @param xboxOne defines if it is a XBox One gamepad
  42527. */
  42528. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42529. /**
  42530. * Defines the callback to call when left trigger is pressed
  42531. * @param callback defines the callback to use
  42532. */
  42533. onlefttriggerchanged(callback: (value: number) => void): void;
  42534. /**
  42535. * Defines the callback to call when right trigger is pressed
  42536. * @param callback defines the callback to use
  42537. */
  42538. onrighttriggerchanged(callback: (value: number) => void): void;
  42539. /**
  42540. * Gets the left trigger value
  42541. */
  42542. get leftTrigger(): number;
  42543. /**
  42544. * Sets the left trigger value
  42545. */
  42546. set leftTrigger(newValue: number);
  42547. /**
  42548. * Gets the right trigger value
  42549. */
  42550. get rightTrigger(): number;
  42551. /**
  42552. * Sets the right trigger value
  42553. */
  42554. set rightTrigger(newValue: number);
  42555. /**
  42556. * Defines the callback to call when a button is pressed
  42557. * @param callback defines the callback to use
  42558. */
  42559. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42560. /**
  42561. * Defines the callback to call when a button is released
  42562. * @param callback defines the callback to use
  42563. */
  42564. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42565. /**
  42566. * Defines the callback to call when a pad is pressed
  42567. * @param callback defines the callback to use
  42568. */
  42569. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42570. /**
  42571. * Defines the callback to call when a pad is released
  42572. * @param callback defines the callback to use
  42573. */
  42574. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42575. private _setButtonValue;
  42576. private _setDPadValue;
  42577. /**
  42578. * Gets the value of the `A` button
  42579. */
  42580. get buttonA(): number;
  42581. /**
  42582. * Sets the value of the `A` button
  42583. */
  42584. set buttonA(value: number);
  42585. /**
  42586. * Gets the value of the `B` button
  42587. */
  42588. get buttonB(): number;
  42589. /**
  42590. * Sets the value of the `B` button
  42591. */
  42592. set buttonB(value: number);
  42593. /**
  42594. * Gets the value of the `X` button
  42595. */
  42596. get buttonX(): number;
  42597. /**
  42598. * Sets the value of the `X` button
  42599. */
  42600. set buttonX(value: number);
  42601. /**
  42602. * Gets the value of the `Y` button
  42603. */
  42604. get buttonY(): number;
  42605. /**
  42606. * Sets the value of the `Y` button
  42607. */
  42608. set buttonY(value: number);
  42609. /**
  42610. * Gets the value of the `Start` button
  42611. */
  42612. get buttonStart(): number;
  42613. /**
  42614. * Sets the value of the `Start` button
  42615. */
  42616. set buttonStart(value: number);
  42617. /**
  42618. * Gets the value of the `Back` button
  42619. */
  42620. get buttonBack(): number;
  42621. /**
  42622. * Sets the value of the `Back` button
  42623. */
  42624. set buttonBack(value: number);
  42625. /**
  42626. * Gets the value of the `Left` button
  42627. */
  42628. get buttonLB(): number;
  42629. /**
  42630. * Sets the value of the `Left` button
  42631. */
  42632. set buttonLB(value: number);
  42633. /**
  42634. * Gets the value of the `Right` button
  42635. */
  42636. get buttonRB(): number;
  42637. /**
  42638. * Sets the value of the `Right` button
  42639. */
  42640. set buttonRB(value: number);
  42641. /**
  42642. * Gets the value of the Left joystick
  42643. */
  42644. get buttonLeftStick(): number;
  42645. /**
  42646. * Sets the value of the Left joystick
  42647. */
  42648. set buttonLeftStick(value: number);
  42649. /**
  42650. * Gets the value of the Right joystick
  42651. */
  42652. get buttonRightStick(): number;
  42653. /**
  42654. * Sets the value of the Right joystick
  42655. */
  42656. set buttonRightStick(value: number);
  42657. /**
  42658. * Gets the value of D-pad up
  42659. */
  42660. get dPadUp(): number;
  42661. /**
  42662. * Sets the value of D-pad up
  42663. */
  42664. set dPadUp(value: number);
  42665. /**
  42666. * Gets the value of D-pad down
  42667. */
  42668. get dPadDown(): number;
  42669. /**
  42670. * Sets the value of D-pad down
  42671. */
  42672. set dPadDown(value: number);
  42673. /**
  42674. * Gets the value of D-pad left
  42675. */
  42676. get dPadLeft(): number;
  42677. /**
  42678. * Sets the value of D-pad left
  42679. */
  42680. set dPadLeft(value: number);
  42681. /**
  42682. * Gets the value of D-pad right
  42683. */
  42684. get dPadRight(): number;
  42685. /**
  42686. * Sets the value of D-pad right
  42687. */
  42688. set dPadRight(value: number);
  42689. /**
  42690. * Force the gamepad to synchronize with device values
  42691. */
  42692. update(): void;
  42693. /**
  42694. * Disposes the gamepad
  42695. */
  42696. dispose(): void;
  42697. }
  42698. }
  42699. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42700. import { Observable } from "babylonjs/Misc/observable";
  42701. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42702. /**
  42703. * Defines supported buttons for DualShock compatible gamepads
  42704. */
  42705. export enum DualShockButton {
  42706. /** Cross */
  42707. Cross = 0,
  42708. /** Circle */
  42709. Circle = 1,
  42710. /** Square */
  42711. Square = 2,
  42712. /** Triangle */
  42713. Triangle = 3,
  42714. /** L1 */
  42715. L1 = 4,
  42716. /** R1 */
  42717. R1 = 5,
  42718. /** Share */
  42719. Share = 8,
  42720. /** Options */
  42721. Options = 9,
  42722. /** Left stick */
  42723. LeftStick = 10,
  42724. /** Right stick */
  42725. RightStick = 11
  42726. }
  42727. /** Defines values for DualShock DPad */
  42728. export enum DualShockDpad {
  42729. /** Up */
  42730. Up = 12,
  42731. /** Down */
  42732. Down = 13,
  42733. /** Left */
  42734. Left = 14,
  42735. /** Right */
  42736. Right = 15
  42737. }
  42738. /**
  42739. * Defines a DualShock gamepad
  42740. */
  42741. export class DualShockPad extends Gamepad {
  42742. private _leftTrigger;
  42743. private _rightTrigger;
  42744. private _onlefttriggerchanged;
  42745. private _onrighttriggerchanged;
  42746. private _onbuttondown;
  42747. private _onbuttonup;
  42748. private _ondpaddown;
  42749. private _ondpadup;
  42750. /** Observable raised when a button is pressed */
  42751. onButtonDownObservable: Observable<DualShockButton>;
  42752. /** Observable raised when a button is released */
  42753. onButtonUpObservable: Observable<DualShockButton>;
  42754. /** Observable raised when a pad is pressed */
  42755. onPadDownObservable: Observable<DualShockDpad>;
  42756. /** Observable raised when a pad is released */
  42757. onPadUpObservable: Observable<DualShockDpad>;
  42758. private _buttonCross;
  42759. private _buttonCircle;
  42760. private _buttonSquare;
  42761. private _buttonTriangle;
  42762. private _buttonShare;
  42763. private _buttonOptions;
  42764. private _buttonL1;
  42765. private _buttonR1;
  42766. private _buttonLeftStick;
  42767. private _buttonRightStick;
  42768. private _dPadUp;
  42769. private _dPadDown;
  42770. private _dPadLeft;
  42771. private _dPadRight;
  42772. /**
  42773. * Creates a new DualShock gamepad object
  42774. * @param id defines the id of this gamepad
  42775. * @param index defines its index
  42776. * @param gamepad defines the internal HTML gamepad object
  42777. */
  42778. constructor(id: string, index: number, gamepad: any);
  42779. /**
  42780. * Defines the callback to call when left trigger is pressed
  42781. * @param callback defines the callback to use
  42782. */
  42783. onlefttriggerchanged(callback: (value: number) => void): void;
  42784. /**
  42785. * Defines the callback to call when right trigger is pressed
  42786. * @param callback defines the callback to use
  42787. */
  42788. onrighttriggerchanged(callback: (value: number) => void): void;
  42789. /**
  42790. * Gets the left trigger value
  42791. */
  42792. get leftTrigger(): number;
  42793. /**
  42794. * Sets the left trigger value
  42795. */
  42796. set leftTrigger(newValue: number);
  42797. /**
  42798. * Gets the right trigger value
  42799. */
  42800. get rightTrigger(): number;
  42801. /**
  42802. * Sets the right trigger value
  42803. */
  42804. set rightTrigger(newValue: number);
  42805. /**
  42806. * Defines the callback to call when a button is pressed
  42807. * @param callback defines the callback to use
  42808. */
  42809. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  42810. /**
  42811. * Defines the callback to call when a button is released
  42812. * @param callback defines the callback to use
  42813. */
  42814. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  42815. /**
  42816. * Defines the callback to call when a pad is pressed
  42817. * @param callback defines the callback to use
  42818. */
  42819. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  42820. /**
  42821. * Defines the callback to call when a pad is released
  42822. * @param callback defines the callback to use
  42823. */
  42824. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  42825. private _setButtonValue;
  42826. private _setDPadValue;
  42827. /**
  42828. * Gets the value of the `Cross` button
  42829. */
  42830. get buttonCross(): number;
  42831. /**
  42832. * Sets the value of the `Cross` button
  42833. */
  42834. set buttonCross(value: number);
  42835. /**
  42836. * Gets the value of the `Circle` button
  42837. */
  42838. get buttonCircle(): number;
  42839. /**
  42840. * Sets the value of the `Circle` button
  42841. */
  42842. set buttonCircle(value: number);
  42843. /**
  42844. * Gets the value of the `Square` button
  42845. */
  42846. get buttonSquare(): number;
  42847. /**
  42848. * Sets the value of the `Square` button
  42849. */
  42850. set buttonSquare(value: number);
  42851. /**
  42852. * Gets the value of the `Triangle` button
  42853. */
  42854. get buttonTriangle(): number;
  42855. /**
  42856. * Sets the value of the `Triangle` button
  42857. */
  42858. set buttonTriangle(value: number);
  42859. /**
  42860. * Gets the value of the `Options` button
  42861. */
  42862. get buttonOptions(): number;
  42863. /**
  42864. * Sets the value of the `Options` button
  42865. */
  42866. set buttonOptions(value: number);
  42867. /**
  42868. * Gets the value of the `Share` button
  42869. */
  42870. get buttonShare(): number;
  42871. /**
  42872. * Sets the value of the `Share` button
  42873. */
  42874. set buttonShare(value: number);
  42875. /**
  42876. * Gets the value of the `L1` button
  42877. */
  42878. get buttonL1(): number;
  42879. /**
  42880. * Sets the value of the `L1` button
  42881. */
  42882. set buttonL1(value: number);
  42883. /**
  42884. * Gets the value of the `R1` button
  42885. */
  42886. get buttonR1(): number;
  42887. /**
  42888. * Sets the value of the `R1` button
  42889. */
  42890. set buttonR1(value: number);
  42891. /**
  42892. * Gets the value of the Left joystick
  42893. */
  42894. get buttonLeftStick(): number;
  42895. /**
  42896. * Sets the value of the Left joystick
  42897. */
  42898. set buttonLeftStick(value: number);
  42899. /**
  42900. * Gets the value of the Right joystick
  42901. */
  42902. get buttonRightStick(): number;
  42903. /**
  42904. * Sets the value of the Right joystick
  42905. */
  42906. set buttonRightStick(value: number);
  42907. /**
  42908. * Gets the value of D-pad up
  42909. */
  42910. get dPadUp(): number;
  42911. /**
  42912. * Sets the value of D-pad up
  42913. */
  42914. set dPadUp(value: number);
  42915. /**
  42916. * Gets the value of D-pad down
  42917. */
  42918. get dPadDown(): number;
  42919. /**
  42920. * Sets the value of D-pad down
  42921. */
  42922. set dPadDown(value: number);
  42923. /**
  42924. * Gets the value of D-pad left
  42925. */
  42926. get dPadLeft(): number;
  42927. /**
  42928. * Sets the value of D-pad left
  42929. */
  42930. set dPadLeft(value: number);
  42931. /**
  42932. * Gets the value of D-pad right
  42933. */
  42934. get dPadRight(): number;
  42935. /**
  42936. * Sets the value of D-pad right
  42937. */
  42938. set dPadRight(value: number);
  42939. /**
  42940. * Force the gamepad to synchronize with device values
  42941. */
  42942. update(): void;
  42943. /**
  42944. * Disposes the gamepad
  42945. */
  42946. dispose(): void;
  42947. }
  42948. }
  42949. declare module "babylonjs/Gamepads/gamepadManager" {
  42950. import { Observable } from "babylonjs/Misc/observable";
  42951. import { Nullable } from "babylonjs/types";
  42952. import { Scene } from "babylonjs/scene";
  42953. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42954. /**
  42955. * Manager for handling gamepads
  42956. */
  42957. export class GamepadManager {
  42958. private _scene?;
  42959. private _babylonGamepads;
  42960. private _oneGamepadConnected;
  42961. /** @hidden */
  42962. _isMonitoring: boolean;
  42963. private _gamepadEventSupported;
  42964. private _gamepadSupport?;
  42965. /**
  42966. * observable to be triggered when the gamepad controller has been connected
  42967. */
  42968. onGamepadConnectedObservable: Observable<Gamepad>;
  42969. /**
  42970. * observable to be triggered when the gamepad controller has been disconnected
  42971. */
  42972. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42973. private _onGamepadConnectedEvent;
  42974. private _onGamepadDisconnectedEvent;
  42975. /**
  42976. * Initializes the gamepad manager
  42977. * @param _scene BabylonJS scene
  42978. */
  42979. constructor(_scene?: Scene | undefined);
  42980. /**
  42981. * The gamepads in the game pad manager
  42982. */
  42983. get gamepads(): Gamepad[];
  42984. /**
  42985. * Get the gamepad controllers based on type
  42986. * @param type The type of gamepad controller
  42987. * @returns Nullable gamepad
  42988. */
  42989. getGamepadByType(type?: number): Nullable<Gamepad>;
  42990. /**
  42991. * Disposes the gamepad manager
  42992. */
  42993. dispose(): void;
  42994. private _addNewGamepad;
  42995. private _startMonitoringGamepads;
  42996. private _stopMonitoringGamepads;
  42997. /** @hidden */
  42998. _checkGamepadsStatus(): void;
  42999. private _updateGamepadObjects;
  43000. }
  43001. }
  43002. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  43003. import { Nullable } from "babylonjs/types";
  43004. import { Scene } from "babylonjs/scene";
  43005. import { ISceneComponent } from "babylonjs/sceneComponent";
  43006. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  43007. module "babylonjs/scene" {
  43008. interface Scene {
  43009. /** @hidden */
  43010. _gamepadManager: Nullable<GamepadManager>;
  43011. /**
  43012. * Gets the gamepad manager associated with the scene
  43013. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  43014. */
  43015. gamepadManager: GamepadManager;
  43016. }
  43017. }
  43018. module "babylonjs/Cameras/freeCameraInputsManager" {
  43019. /**
  43020. * Interface representing a free camera inputs manager
  43021. */
  43022. interface FreeCameraInputsManager {
  43023. /**
  43024. * Adds gamepad input support to the FreeCameraInputsManager.
  43025. * @returns the FreeCameraInputsManager
  43026. */
  43027. addGamepad(): FreeCameraInputsManager;
  43028. }
  43029. }
  43030. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  43031. /**
  43032. * Interface representing an arc rotate camera inputs manager
  43033. */
  43034. interface ArcRotateCameraInputsManager {
  43035. /**
  43036. * Adds gamepad input support to the ArcRotateCamera InputManager.
  43037. * @returns the camera inputs manager
  43038. */
  43039. addGamepad(): ArcRotateCameraInputsManager;
  43040. }
  43041. }
  43042. /**
  43043. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  43044. */
  43045. export class GamepadSystemSceneComponent implements ISceneComponent {
  43046. /**
  43047. * The component name helpfull to identify the component in the list of scene components.
  43048. */
  43049. readonly name: string;
  43050. /**
  43051. * The scene the component belongs to.
  43052. */
  43053. scene: Scene;
  43054. /**
  43055. * Creates a new instance of the component for the given scene
  43056. * @param scene Defines the scene to register the component in
  43057. */
  43058. constructor(scene: Scene);
  43059. /**
  43060. * Registers the component in a given scene
  43061. */
  43062. register(): void;
  43063. /**
  43064. * Rebuilds the elements related to this component in case of
  43065. * context lost for instance.
  43066. */
  43067. rebuild(): void;
  43068. /**
  43069. * Disposes the component and the associated ressources
  43070. */
  43071. dispose(): void;
  43072. private _beforeCameraUpdate;
  43073. }
  43074. }
  43075. declare module "babylonjs/Cameras/universalCamera" {
  43076. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  43077. import { Scene } from "babylonjs/scene";
  43078. import { Vector3 } from "babylonjs/Maths/math.vector";
  43079. import "babylonjs/Gamepads/gamepadSceneComponent";
  43080. /**
  43081. * 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,
  43082. * which still works and will still be found in many Playgrounds.
  43083. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43084. */
  43085. export class UniversalCamera extends TouchCamera {
  43086. /**
  43087. * Defines the gamepad rotation sensiblity.
  43088. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43089. */
  43090. get gamepadAngularSensibility(): number;
  43091. set gamepadAngularSensibility(value: number);
  43092. /**
  43093. * Defines the gamepad move sensiblity.
  43094. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43095. */
  43096. get gamepadMoveSensibility(): number;
  43097. set gamepadMoveSensibility(value: number);
  43098. /**
  43099. * 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,
  43100. * which still works and will still be found in many Playgrounds.
  43101. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43102. * @param name Define the name of the camera in the scene
  43103. * @param position Define the start position of the camera in the scene
  43104. * @param scene Define the scene the camera belongs to
  43105. */
  43106. constructor(name: string, position: Vector3, scene: Scene);
  43107. /**
  43108. * Gets the current object class name.
  43109. * @return the class name
  43110. */
  43111. getClassName(): string;
  43112. }
  43113. }
  43114. declare module "babylonjs/Cameras/gamepadCamera" {
  43115. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43116. import { Scene } from "babylonjs/scene";
  43117. import { Vector3 } from "babylonjs/Maths/math.vector";
  43118. /**
  43119. * This represents a FPS type of camera. This is only here for back compat purpose.
  43120. * Please use the UniversalCamera instead as both are identical.
  43121. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43122. */
  43123. export class GamepadCamera extends UniversalCamera {
  43124. /**
  43125. * Instantiates a new Gamepad Camera
  43126. * This represents a FPS type of camera. This is only here for back compat purpose.
  43127. * Please use the UniversalCamera instead as both are identical.
  43128. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43129. * @param name Define the name of the camera in the scene
  43130. * @param position Define the start position of the camera in the scene
  43131. * @param scene Define the scene the camera belongs to
  43132. */
  43133. constructor(name: string, position: Vector3, scene: Scene);
  43134. /**
  43135. * Gets the current object class name.
  43136. * @return the class name
  43137. */
  43138. getClassName(): string;
  43139. }
  43140. }
  43141. declare module "babylonjs/Shaders/pass.fragment" {
  43142. /** @hidden */
  43143. export var passPixelShader: {
  43144. name: string;
  43145. shader: string;
  43146. };
  43147. }
  43148. declare module "babylonjs/Shaders/passCube.fragment" {
  43149. /** @hidden */
  43150. export var passCubePixelShader: {
  43151. name: string;
  43152. shader: string;
  43153. };
  43154. }
  43155. declare module "babylonjs/PostProcesses/passPostProcess" {
  43156. import { Nullable } from "babylonjs/types";
  43157. import { Camera } from "babylonjs/Cameras/camera";
  43158. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43159. import { Engine } from "babylonjs/Engines/engine";
  43160. import "babylonjs/Shaders/pass.fragment";
  43161. import "babylonjs/Shaders/passCube.fragment";
  43162. /**
  43163. * PassPostProcess which produces an output the same as it's input
  43164. */
  43165. export class PassPostProcess extends PostProcess {
  43166. /**
  43167. * Creates the PassPostProcess
  43168. * @param name The name of the effect.
  43169. * @param options The required width/height ratio to downsize to before computing the render pass.
  43170. * @param camera The camera to apply the render pass to.
  43171. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43172. * @param engine The engine which the post process will be applied. (default: current engine)
  43173. * @param reusable If the post process can be reused on the same frame. (default: false)
  43174. * @param textureType The type of texture to be used when performing the post processing.
  43175. * @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)
  43176. */
  43177. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43178. }
  43179. /**
  43180. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  43181. */
  43182. export class PassCubePostProcess extends PostProcess {
  43183. private _face;
  43184. /**
  43185. * Gets or sets the cube face to display.
  43186. * * 0 is +X
  43187. * * 1 is -X
  43188. * * 2 is +Y
  43189. * * 3 is -Y
  43190. * * 4 is +Z
  43191. * * 5 is -Z
  43192. */
  43193. get face(): number;
  43194. set face(value: number);
  43195. /**
  43196. * Creates the PassCubePostProcess
  43197. * @param name The name of the effect.
  43198. * @param options The required width/height ratio to downsize to before computing the render pass.
  43199. * @param camera The camera to apply the render pass to.
  43200. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43201. * @param engine The engine which the post process will be applied. (default: current engine)
  43202. * @param reusable If the post process can be reused on the same frame. (default: false)
  43203. * @param textureType The type of texture to be used when performing the post processing.
  43204. * @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)
  43205. */
  43206. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43207. }
  43208. }
  43209. declare module "babylonjs/Shaders/anaglyph.fragment" {
  43210. /** @hidden */
  43211. export var anaglyphPixelShader: {
  43212. name: string;
  43213. shader: string;
  43214. };
  43215. }
  43216. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  43217. import { Engine } from "babylonjs/Engines/engine";
  43218. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43219. import { Camera } from "babylonjs/Cameras/camera";
  43220. import "babylonjs/Shaders/anaglyph.fragment";
  43221. /**
  43222. * Postprocess used to generate anaglyphic rendering
  43223. */
  43224. export class AnaglyphPostProcess extends PostProcess {
  43225. private _passedProcess;
  43226. /**
  43227. * Creates a new AnaglyphPostProcess
  43228. * @param name defines postprocess name
  43229. * @param options defines creation options or target ratio scale
  43230. * @param rigCameras defines cameras using this postprocess
  43231. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  43232. * @param engine defines hosting engine
  43233. * @param reusable defines if the postprocess will be reused multiple times per frame
  43234. */
  43235. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  43236. }
  43237. }
  43238. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  43239. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  43240. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43241. import { Scene } from "babylonjs/scene";
  43242. import { Vector3 } from "babylonjs/Maths/math.vector";
  43243. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43244. /**
  43245. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  43246. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43247. */
  43248. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  43249. /**
  43250. * Creates a new AnaglyphArcRotateCamera
  43251. * @param name defines camera name
  43252. * @param alpha defines alpha angle (in radians)
  43253. * @param beta defines beta angle (in radians)
  43254. * @param radius defines radius
  43255. * @param target defines camera target
  43256. * @param interaxialDistance defines distance between each color axis
  43257. * @param scene defines the hosting scene
  43258. */
  43259. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  43260. /**
  43261. * Gets camera class name
  43262. * @returns AnaglyphArcRotateCamera
  43263. */
  43264. getClassName(): string;
  43265. }
  43266. }
  43267. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  43268. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43269. import { Scene } from "babylonjs/scene";
  43270. import { Vector3 } from "babylonjs/Maths/math.vector";
  43271. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43272. /**
  43273. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  43274. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43275. */
  43276. export class AnaglyphFreeCamera extends FreeCamera {
  43277. /**
  43278. * Creates a new AnaglyphFreeCamera
  43279. * @param name defines camera name
  43280. * @param position defines initial position
  43281. * @param interaxialDistance defines distance between each color axis
  43282. * @param scene defines the hosting scene
  43283. */
  43284. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43285. /**
  43286. * Gets camera class name
  43287. * @returns AnaglyphFreeCamera
  43288. */
  43289. getClassName(): string;
  43290. }
  43291. }
  43292. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  43293. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43294. import { Scene } from "babylonjs/scene";
  43295. import { Vector3 } from "babylonjs/Maths/math.vector";
  43296. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43297. /**
  43298. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  43299. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43300. */
  43301. export class AnaglyphGamepadCamera extends GamepadCamera {
  43302. /**
  43303. * Creates a new AnaglyphGamepadCamera
  43304. * @param name defines camera name
  43305. * @param position defines initial position
  43306. * @param interaxialDistance defines distance between each color axis
  43307. * @param scene defines the hosting scene
  43308. */
  43309. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43310. /**
  43311. * Gets camera class name
  43312. * @returns AnaglyphGamepadCamera
  43313. */
  43314. getClassName(): string;
  43315. }
  43316. }
  43317. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  43318. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43319. import { Scene } from "babylonjs/scene";
  43320. import { Vector3 } from "babylonjs/Maths/math.vector";
  43321. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43322. /**
  43323. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  43324. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43325. */
  43326. export class AnaglyphUniversalCamera extends UniversalCamera {
  43327. /**
  43328. * Creates a new AnaglyphUniversalCamera
  43329. * @param name defines camera name
  43330. * @param position defines initial position
  43331. * @param interaxialDistance defines distance between each color axis
  43332. * @param scene defines the hosting scene
  43333. */
  43334. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43335. /**
  43336. * Gets camera class name
  43337. * @returns AnaglyphUniversalCamera
  43338. */
  43339. getClassName(): string;
  43340. }
  43341. }
  43342. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  43343. /** @hidden */
  43344. export var stereoscopicInterlacePixelShader: {
  43345. name: string;
  43346. shader: string;
  43347. };
  43348. }
  43349. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  43350. import { Camera } from "babylonjs/Cameras/camera";
  43351. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43352. import { Engine } from "babylonjs/Engines/engine";
  43353. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  43354. /**
  43355. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  43356. */
  43357. export class StereoscopicInterlacePostProcessI extends PostProcess {
  43358. private _stepSize;
  43359. private _passedProcess;
  43360. /**
  43361. * Initializes a StereoscopicInterlacePostProcessI
  43362. * @param name The name of the effect.
  43363. * @param rigCameras The rig cameras to be appled to the post process
  43364. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  43365. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  43366. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43367. * @param engine The engine which the post process will be applied. (default: current engine)
  43368. * @param reusable If the post process can be reused on the same frame. (default: false)
  43369. */
  43370. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43371. }
  43372. /**
  43373. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  43374. */
  43375. export class StereoscopicInterlacePostProcess extends PostProcess {
  43376. private _stepSize;
  43377. private _passedProcess;
  43378. /**
  43379. * Initializes a StereoscopicInterlacePostProcess
  43380. * @param name The name of the effect.
  43381. * @param rigCameras The rig cameras to be appled to the post process
  43382. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  43383. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43384. * @param engine The engine which the post process will be applied. (default: current engine)
  43385. * @param reusable If the post process can be reused on the same frame. (default: false)
  43386. */
  43387. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43388. }
  43389. }
  43390. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  43391. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  43392. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43393. import { Scene } from "babylonjs/scene";
  43394. import { Vector3 } from "babylonjs/Maths/math.vector";
  43395. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43396. /**
  43397. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  43398. * @see http://doc.babylonjs.com/features/cameras
  43399. */
  43400. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  43401. /**
  43402. * Creates a new StereoscopicArcRotateCamera
  43403. * @param name defines camera name
  43404. * @param alpha defines alpha angle (in radians)
  43405. * @param beta defines beta angle (in radians)
  43406. * @param radius defines radius
  43407. * @param target defines camera target
  43408. * @param interaxialDistance defines distance between each color axis
  43409. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43410. * @param scene defines the hosting scene
  43411. */
  43412. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43413. /**
  43414. * Gets camera class name
  43415. * @returns StereoscopicArcRotateCamera
  43416. */
  43417. getClassName(): string;
  43418. }
  43419. }
  43420. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  43421. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43422. import { Scene } from "babylonjs/scene";
  43423. import { Vector3 } from "babylonjs/Maths/math.vector";
  43424. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43425. /**
  43426. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  43427. * @see http://doc.babylonjs.com/features/cameras
  43428. */
  43429. export class StereoscopicFreeCamera extends FreeCamera {
  43430. /**
  43431. * Creates a new StereoscopicFreeCamera
  43432. * @param name defines camera name
  43433. * @param position defines initial position
  43434. * @param interaxialDistance defines distance between each color axis
  43435. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43436. * @param scene defines the hosting scene
  43437. */
  43438. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43439. /**
  43440. * Gets camera class name
  43441. * @returns StereoscopicFreeCamera
  43442. */
  43443. getClassName(): string;
  43444. }
  43445. }
  43446. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43447. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43448. import { Scene } from "babylonjs/scene";
  43449. import { Vector3 } from "babylonjs/Maths/math.vector";
  43450. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43451. /**
  43452. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43453. * @see http://doc.babylonjs.com/features/cameras
  43454. */
  43455. export class StereoscopicGamepadCamera extends GamepadCamera {
  43456. /**
  43457. * Creates a new StereoscopicGamepadCamera
  43458. * @param name defines camera name
  43459. * @param position defines initial position
  43460. * @param interaxialDistance defines distance between each color axis
  43461. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43462. * @param scene defines the hosting scene
  43463. */
  43464. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43465. /**
  43466. * Gets camera class name
  43467. * @returns StereoscopicGamepadCamera
  43468. */
  43469. getClassName(): string;
  43470. }
  43471. }
  43472. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43473. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43474. import { Scene } from "babylonjs/scene";
  43475. import { Vector3 } from "babylonjs/Maths/math.vector";
  43476. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43477. /**
  43478. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43479. * @see http://doc.babylonjs.com/features/cameras
  43480. */
  43481. export class StereoscopicUniversalCamera extends UniversalCamera {
  43482. /**
  43483. * Creates a new StereoscopicUniversalCamera
  43484. * @param name defines camera name
  43485. * @param position defines initial position
  43486. * @param interaxialDistance defines distance between each color axis
  43487. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43488. * @param scene defines the hosting scene
  43489. */
  43490. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43491. /**
  43492. * Gets camera class name
  43493. * @returns StereoscopicUniversalCamera
  43494. */
  43495. getClassName(): string;
  43496. }
  43497. }
  43498. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43499. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43500. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43501. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43502. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43503. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43504. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43505. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43506. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43507. }
  43508. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43509. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43510. import { Scene } from "babylonjs/scene";
  43511. import { Vector3 } from "babylonjs/Maths/math.vector";
  43512. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43513. /**
  43514. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43515. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43516. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43517. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43518. */
  43519. export class VirtualJoysticksCamera extends FreeCamera {
  43520. /**
  43521. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43522. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43523. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43524. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43525. * @param name Define the name of the camera in the scene
  43526. * @param position Define the start position of the camera in the scene
  43527. * @param scene Define the scene the camera belongs to
  43528. */
  43529. constructor(name: string, position: Vector3, scene: Scene);
  43530. /**
  43531. * Gets the current object class name.
  43532. * @return the class name
  43533. */
  43534. getClassName(): string;
  43535. }
  43536. }
  43537. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43538. import { Matrix } from "babylonjs/Maths/math.vector";
  43539. /**
  43540. * This represents all the required metrics to create a VR camera.
  43541. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43542. */
  43543. export class VRCameraMetrics {
  43544. /**
  43545. * Define the horizontal resolution off the screen.
  43546. */
  43547. hResolution: number;
  43548. /**
  43549. * Define the vertical resolution off the screen.
  43550. */
  43551. vResolution: number;
  43552. /**
  43553. * Define the horizontal screen size.
  43554. */
  43555. hScreenSize: number;
  43556. /**
  43557. * Define the vertical screen size.
  43558. */
  43559. vScreenSize: number;
  43560. /**
  43561. * Define the vertical screen center position.
  43562. */
  43563. vScreenCenter: number;
  43564. /**
  43565. * Define the distance of the eyes to the screen.
  43566. */
  43567. eyeToScreenDistance: number;
  43568. /**
  43569. * Define the distance between both lenses
  43570. */
  43571. lensSeparationDistance: number;
  43572. /**
  43573. * Define the distance between both viewer's eyes.
  43574. */
  43575. interpupillaryDistance: number;
  43576. /**
  43577. * Define the distortion factor of the VR postprocess.
  43578. * Please, touch with care.
  43579. */
  43580. distortionK: number[];
  43581. /**
  43582. * Define the chromatic aberration correction factors for the VR post process.
  43583. */
  43584. chromaAbCorrection: number[];
  43585. /**
  43586. * Define the scale factor of the post process.
  43587. * The smaller the better but the slower.
  43588. */
  43589. postProcessScaleFactor: number;
  43590. /**
  43591. * Define an offset for the lens center.
  43592. */
  43593. lensCenterOffset: number;
  43594. /**
  43595. * Define if the current vr camera should compensate the distortion of the lense or not.
  43596. */
  43597. compensateDistortion: boolean;
  43598. /**
  43599. * Defines if multiview should be enabled when rendering (Default: false)
  43600. */
  43601. multiviewEnabled: boolean;
  43602. /**
  43603. * Gets the rendering aspect ratio based on the provided resolutions.
  43604. */
  43605. get aspectRatio(): number;
  43606. /**
  43607. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43608. */
  43609. get aspectRatioFov(): number;
  43610. /**
  43611. * @hidden
  43612. */
  43613. get leftHMatrix(): Matrix;
  43614. /**
  43615. * @hidden
  43616. */
  43617. get rightHMatrix(): Matrix;
  43618. /**
  43619. * @hidden
  43620. */
  43621. get leftPreViewMatrix(): Matrix;
  43622. /**
  43623. * @hidden
  43624. */
  43625. get rightPreViewMatrix(): Matrix;
  43626. /**
  43627. * Get the default VRMetrics based on the most generic setup.
  43628. * @returns the default vr metrics
  43629. */
  43630. static GetDefault(): VRCameraMetrics;
  43631. }
  43632. }
  43633. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43634. /** @hidden */
  43635. export var vrDistortionCorrectionPixelShader: {
  43636. name: string;
  43637. shader: string;
  43638. };
  43639. }
  43640. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43641. import { Camera } from "babylonjs/Cameras/camera";
  43642. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43643. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43644. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43645. /**
  43646. * VRDistortionCorrectionPostProcess used for mobile VR
  43647. */
  43648. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43649. private _isRightEye;
  43650. private _distortionFactors;
  43651. private _postProcessScaleFactor;
  43652. private _lensCenterOffset;
  43653. private _scaleIn;
  43654. private _scaleFactor;
  43655. private _lensCenter;
  43656. /**
  43657. * Initializes the VRDistortionCorrectionPostProcess
  43658. * @param name The name of the effect.
  43659. * @param camera The camera to apply the render pass to.
  43660. * @param isRightEye If this is for the right eye distortion
  43661. * @param vrMetrics All the required metrics for the VR camera
  43662. */
  43663. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43664. }
  43665. }
  43666. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43667. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43668. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43669. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43670. import { Scene } from "babylonjs/scene";
  43671. import { Vector3 } from "babylonjs/Maths/math.vector";
  43672. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43673. import "babylonjs/Cameras/RigModes/vrRigMode";
  43674. /**
  43675. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43676. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43677. */
  43678. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43679. /**
  43680. * Creates a new VRDeviceOrientationArcRotateCamera
  43681. * @param name defines camera name
  43682. * @param alpha defines the camera rotation along the logitudinal axis
  43683. * @param beta defines the camera rotation along the latitudinal axis
  43684. * @param radius defines the camera distance from its target
  43685. * @param target defines the camera target
  43686. * @param scene defines the scene the camera belongs to
  43687. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43688. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43689. */
  43690. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43691. /**
  43692. * Gets camera class name
  43693. * @returns VRDeviceOrientationArcRotateCamera
  43694. */
  43695. getClassName(): string;
  43696. }
  43697. }
  43698. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43699. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43700. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43701. import { Scene } from "babylonjs/scene";
  43702. import { Vector3 } from "babylonjs/Maths/math.vector";
  43703. import "babylonjs/Cameras/RigModes/vrRigMode";
  43704. /**
  43705. * Camera used to simulate VR rendering (based on FreeCamera)
  43706. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43707. */
  43708. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43709. /**
  43710. * Creates a new VRDeviceOrientationFreeCamera
  43711. * @param name defines camera name
  43712. * @param position defines the start position of the camera
  43713. * @param scene defines the scene the camera belongs to
  43714. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43715. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43716. */
  43717. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43718. /**
  43719. * Gets camera class name
  43720. * @returns VRDeviceOrientationFreeCamera
  43721. */
  43722. getClassName(): string;
  43723. }
  43724. }
  43725. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43726. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43727. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43728. import { Scene } from "babylonjs/scene";
  43729. import { Vector3 } from "babylonjs/Maths/math.vector";
  43730. import "babylonjs/Gamepads/gamepadSceneComponent";
  43731. /**
  43732. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43733. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43734. */
  43735. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43736. /**
  43737. * Creates a new VRDeviceOrientationGamepadCamera
  43738. * @param name defines camera name
  43739. * @param position defines the start position of the camera
  43740. * @param scene defines the scene the camera belongs to
  43741. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43742. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43743. */
  43744. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43745. /**
  43746. * Gets camera class name
  43747. * @returns VRDeviceOrientationGamepadCamera
  43748. */
  43749. getClassName(): string;
  43750. }
  43751. }
  43752. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43753. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43754. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43755. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43756. /** @hidden */
  43757. export var imageProcessingPixelShader: {
  43758. name: string;
  43759. shader: string;
  43760. };
  43761. }
  43762. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  43763. import { Nullable } from "babylonjs/types";
  43764. import { Color4 } from "babylonjs/Maths/math.color";
  43765. import { Camera } from "babylonjs/Cameras/camera";
  43766. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43767. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43768. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43769. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43770. import { Engine } from "babylonjs/Engines/engine";
  43771. import "babylonjs/Shaders/imageProcessing.fragment";
  43772. import "babylonjs/Shaders/postprocess.vertex";
  43773. /**
  43774. * ImageProcessingPostProcess
  43775. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  43776. */
  43777. export class ImageProcessingPostProcess extends PostProcess {
  43778. /**
  43779. * Default configuration related to image processing available in the PBR Material.
  43780. */
  43781. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43782. /**
  43783. * Gets the image processing configuration used either in this material.
  43784. */
  43785. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43786. /**
  43787. * Sets the Default image processing configuration used either in the this material.
  43788. *
  43789. * If sets to null, the scene one is in use.
  43790. */
  43791. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  43792. /**
  43793. * Keep track of the image processing observer to allow dispose and replace.
  43794. */
  43795. private _imageProcessingObserver;
  43796. /**
  43797. * Attaches a new image processing configuration to the PBR Material.
  43798. * @param configuration
  43799. */
  43800. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  43801. /**
  43802. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43803. */
  43804. get colorCurves(): Nullable<ColorCurves>;
  43805. /**
  43806. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43807. */
  43808. set colorCurves(value: Nullable<ColorCurves>);
  43809. /**
  43810. * Gets wether the color curves effect is enabled.
  43811. */
  43812. get colorCurvesEnabled(): boolean;
  43813. /**
  43814. * Sets wether the color curves effect is enabled.
  43815. */
  43816. set colorCurvesEnabled(value: boolean);
  43817. /**
  43818. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43819. */
  43820. get colorGradingTexture(): Nullable<BaseTexture>;
  43821. /**
  43822. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43823. */
  43824. set colorGradingTexture(value: Nullable<BaseTexture>);
  43825. /**
  43826. * Gets wether the color grading effect is enabled.
  43827. */
  43828. get colorGradingEnabled(): boolean;
  43829. /**
  43830. * Gets wether the color grading effect is enabled.
  43831. */
  43832. set colorGradingEnabled(value: boolean);
  43833. /**
  43834. * Gets exposure used in the effect.
  43835. */
  43836. get exposure(): number;
  43837. /**
  43838. * Sets exposure used in the effect.
  43839. */
  43840. set exposure(value: number);
  43841. /**
  43842. * Gets wether tonemapping is enabled or not.
  43843. */
  43844. get toneMappingEnabled(): boolean;
  43845. /**
  43846. * Sets wether tonemapping is enabled or not
  43847. */
  43848. set toneMappingEnabled(value: boolean);
  43849. /**
  43850. * Gets the type of tone mapping effect.
  43851. */
  43852. get toneMappingType(): number;
  43853. /**
  43854. * Sets the type of tone mapping effect.
  43855. */
  43856. set toneMappingType(value: number);
  43857. /**
  43858. * Gets contrast used in the effect.
  43859. */
  43860. get contrast(): number;
  43861. /**
  43862. * Sets contrast used in the effect.
  43863. */
  43864. set contrast(value: number);
  43865. /**
  43866. * Gets Vignette stretch size.
  43867. */
  43868. get vignetteStretch(): number;
  43869. /**
  43870. * Sets Vignette stretch size.
  43871. */
  43872. set vignetteStretch(value: number);
  43873. /**
  43874. * Gets Vignette centre X Offset.
  43875. */
  43876. get vignetteCentreX(): number;
  43877. /**
  43878. * Sets Vignette centre X Offset.
  43879. */
  43880. set vignetteCentreX(value: number);
  43881. /**
  43882. * Gets Vignette centre Y Offset.
  43883. */
  43884. get vignetteCentreY(): number;
  43885. /**
  43886. * Sets Vignette centre Y Offset.
  43887. */
  43888. set vignetteCentreY(value: number);
  43889. /**
  43890. * Gets Vignette weight or intensity of the vignette effect.
  43891. */
  43892. get vignetteWeight(): number;
  43893. /**
  43894. * Sets Vignette weight or intensity of the vignette effect.
  43895. */
  43896. set vignetteWeight(value: number);
  43897. /**
  43898. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43899. * if vignetteEnabled is set to true.
  43900. */
  43901. get vignetteColor(): Color4;
  43902. /**
  43903. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43904. * if vignetteEnabled is set to true.
  43905. */
  43906. set vignetteColor(value: Color4);
  43907. /**
  43908. * Gets Camera field of view used by the Vignette effect.
  43909. */
  43910. get vignetteCameraFov(): number;
  43911. /**
  43912. * Sets Camera field of view used by the Vignette effect.
  43913. */
  43914. set vignetteCameraFov(value: number);
  43915. /**
  43916. * Gets the vignette blend mode allowing different kind of effect.
  43917. */
  43918. get vignetteBlendMode(): number;
  43919. /**
  43920. * Sets the vignette blend mode allowing different kind of effect.
  43921. */
  43922. set vignetteBlendMode(value: number);
  43923. /**
  43924. * Gets wether the vignette effect is enabled.
  43925. */
  43926. get vignetteEnabled(): boolean;
  43927. /**
  43928. * Sets wether the vignette effect is enabled.
  43929. */
  43930. set vignetteEnabled(value: boolean);
  43931. private _fromLinearSpace;
  43932. /**
  43933. * Gets wether the input of the processing is in Gamma or Linear Space.
  43934. */
  43935. get fromLinearSpace(): boolean;
  43936. /**
  43937. * Sets wether the input of the processing is in Gamma or Linear Space.
  43938. */
  43939. set fromLinearSpace(value: boolean);
  43940. /**
  43941. * Defines cache preventing GC.
  43942. */
  43943. private _defines;
  43944. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  43945. /**
  43946. * "ImageProcessingPostProcess"
  43947. * @returns "ImageProcessingPostProcess"
  43948. */
  43949. getClassName(): string;
  43950. protected _updateParameters(): void;
  43951. dispose(camera?: Camera): void;
  43952. }
  43953. }
  43954. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  43955. import { Scene } from "babylonjs/scene";
  43956. import { Color3 } from "babylonjs/Maths/math.color";
  43957. import { Mesh } from "babylonjs/Meshes/mesh";
  43958. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  43959. import { Nullable } from "babylonjs/types";
  43960. /**
  43961. * Class containing static functions to help procedurally build meshes
  43962. */
  43963. export class GroundBuilder {
  43964. /**
  43965. * Creates a ground mesh
  43966. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  43967. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  43968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43969. * @param name defines the name of the mesh
  43970. * @param options defines the options used to create the mesh
  43971. * @param scene defines the hosting scene
  43972. * @returns the ground mesh
  43973. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  43974. */
  43975. static CreateGround(name: string, options: {
  43976. width?: number;
  43977. height?: number;
  43978. subdivisions?: number;
  43979. subdivisionsX?: number;
  43980. subdivisionsY?: number;
  43981. updatable?: boolean;
  43982. }, scene: any): Mesh;
  43983. /**
  43984. * Creates a tiled ground mesh
  43985. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  43986. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  43987. * * 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
  43988. * * 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
  43989. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43990. * @param name defines the name of the mesh
  43991. * @param options defines the options used to create the mesh
  43992. * @param scene defines the hosting scene
  43993. * @returns the tiled ground mesh
  43994. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43995. */
  43996. static CreateTiledGround(name: string, options: {
  43997. xmin: number;
  43998. zmin: number;
  43999. xmax: number;
  44000. zmax: number;
  44001. subdivisions?: {
  44002. w: number;
  44003. h: number;
  44004. };
  44005. precision?: {
  44006. w: number;
  44007. h: number;
  44008. };
  44009. updatable?: boolean;
  44010. }, scene?: Nullable<Scene>): Mesh;
  44011. /**
  44012. * Creates a ground mesh from a height map
  44013. * * The parameter `url` sets the URL of the height map image resource.
  44014. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  44015. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  44016. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  44017. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  44018. * * 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.
  44019. * * 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).
  44020. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  44021. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44022. * @param name defines the name of the mesh
  44023. * @param url defines the url to the height map
  44024. * @param options defines the options used to create the mesh
  44025. * @param scene defines the hosting scene
  44026. * @returns the ground mesh
  44027. * @see https://doc.babylonjs.com/babylon101/height_map
  44028. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  44029. */
  44030. static CreateGroundFromHeightMap(name: string, url: string, options: {
  44031. width?: number;
  44032. height?: number;
  44033. subdivisions?: number;
  44034. minHeight?: number;
  44035. maxHeight?: number;
  44036. colorFilter?: Color3;
  44037. alphaFilter?: number;
  44038. updatable?: boolean;
  44039. onReady?: (mesh: GroundMesh) => void;
  44040. }, scene?: Nullable<Scene>): GroundMesh;
  44041. }
  44042. }
  44043. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  44044. import { Vector4 } from "babylonjs/Maths/math.vector";
  44045. import { Mesh } from "babylonjs/Meshes/mesh";
  44046. /**
  44047. * Class containing static functions to help procedurally build meshes
  44048. */
  44049. export class TorusBuilder {
  44050. /**
  44051. * Creates a torus mesh
  44052. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  44053. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  44054. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  44055. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44056. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44057. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44058. * @param name defines the name of the mesh
  44059. * @param options defines the options used to create the mesh
  44060. * @param scene defines the hosting scene
  44061. * @returns the torus mesh
  44062. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  44063. */
  44064. static CreateTorus(name: string, options: {
  44065. diameter?: number;
  44066. thickness?: number;
  44067. tessellation?: number;
  44068. updatable?: boolean;
  44069. sideOrientation?: number;
  44070. frontUVs?: Vector4;
  44071. backUVs?: Vector4;
  44072. }, scene: any): Mesh;
  44073. }
  44074. }
  44075. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  44076. import { Vector4 } from "babylonjs/Maths/math.vector";
  44077. import { Color4 } from "babylonjs/Maths/math.color";
  44078. import { Mesh } from "babylonjs/Meshes/mesh";
  44079. /**
  44080. * Class containing static functions to help procedurally build meshes
  44081. */
  44082. export class CylinderBuilder {
  44083. /**
  44084. * Creates a cylinder or a cone mesh
  44085. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  44086. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  44087. * * 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.
  44088. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  44089. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  44090. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  44091. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  44092. * * 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).
  44093. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  44094. * * 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).
  44095. * * 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
  44096. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  44097. * * 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
  44098. * * 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.
  44099. * * If `enclose` is false, a ring surface is one element.
  44100. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  44101. * * 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
  44102. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44103. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44104. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44105. * @param name defines the name of the mesh
  44106. * @param options defines the options used to create the mesh
  44107. * @param scene defines the hosting scene
  44108. * @returns the cylinder mesh
  44109. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  44110. */
  44111. static CreateCylinder(name: string, options: {
  44112. height?: number;
  44113. diameterTop?: number;
  44114. diameterBottom?: number;
  44115. diameter?: number;
  44116. tessellation?: number;
  44117. subdivisions?: number;
  44118. arc?: number;
  44119. faceColors?: Color4[];
  44120. faceUV?: Vector4[];
  44121. updatable?: boolean;
  44122. hasRings?: boolean;
  44123. enclose?: boolean;
  44124. cap?: number;
  44125. sideOrientation?: number;
  44126. frontUVs?: Vector4;
  44127. backUVs?: Vector4;
  44128. }, scene: any): Mesh;
  44129. }
  44130. }
  44131. declare module "babylonjs/XR/webXRTypes" {
  44132. import { Nullable } from "babylonjs/types";
  44133. import { IDisposable } from "babylonjs/scene";
  44134. /**
  44135. * States of the webXR experience
  44136. */
  44137. export enum WebXRState {
  44138. /**
  44139. * Transitioning to being in XR mode
  44140. */
  44141. ENTERING_XR = 0,
  44142. /**
  44143. * Transitioning to non XR mode
  44144. */
  44145. EXITING_XR = 1,
  44146. /**
  44147. * In XR mode and presenting
  44148. */
  44149. IN_XR = 2,
  44150. /**
  44151. * Not entered XR mode
  44152. */
  44153. NOT_IN_XR = 3
  44154. }
  44155. /**
  44156. * Abstraction of the XR render target
  44157. */
  44158. export interface WebXRRenderTarget extends IDisposable {
  44159. /**
  44160. * xrpresent context of the canvas which can be used to display/mirror xr content
  44161. */
  44162. canvasContext: WebGLRenderingContext;
  44163. /**
  44164. * xr layer for the canvas
  44165. */
  44166. xrLayer: Nullable<XRWebGLLayer>;
  44167. /**
  44168. * Initializes the xr layer for the session
  44169. * @param xrSession xr session
  44170. * @returns a promise that will resolve once the XR Layer has been created
  44171. */
  44172. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44173. }
  44174. }
  44175. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  44176. import { Nullable } from "babylonjs/types";
  44177. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44178. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44179. /**
  44180. * COnfiguration object for WebXR output canvas
  44181. */
  44182. export class WebXRManagedOutputCanvasOptions {
  44183. /**
  44184. * An optional canvas in case you wish to create it yourself and provide it here.
  44185. * If not provided, a new canvas will be created
  44186. */
  44187. canvasElement?: HTMLCanvasElement;
  44188. /**
  44189. * Options for this XR Layer output
  44190. */
  44191. canvasOptions?: XRWebGLLayerOptions;
  44192. /**
  44193. * CSS styling for a newly created canvas (if not provided)
  44194. */
  44195. newCanvasCssStyle?: string;
  44196. /**
  44197. * Get the default values of the configuration object
  44198. * @returns default values of this configuration object
  44199. */
  44200. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  44201. }
  44202. /**
  44203. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  44204. */
  44205. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  44206. private _options;
  44207. private _canvas;
  44208. private _engine;
  44209. /**
  44210. * Rendering context of the canvas which can be used to display/mirror xr content
  44211. */
  44212. canvasContext: WebGLRenderingContext;
  44213. /**
  44214. * xr layer for the canvas
  44215. */
  44216. xrLayer: Nullable<XRWebGLLayer>;
  44217. /**
  44218. * Initializes the canvas to be added/removed upon entering/exiting xr
  44219. * @param _xrSessionManager The XR Session manager
  44220. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  44221. */
  44222. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  44223. /**
  44224. * Disposes of the object
  44225. */
  44226. dispose(): void;
  44227. /**
  44228. * Initializes the xr layer for the session
  44229. * @param xrSession xr session
  44230. * @returns a promise that will resolve once the XR Layer has been created
  44231. */
  44232. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44233. private _addCanvas;
  44234. private _removeCanvas;
  44235. private _setManagedOutputCanvas;
  44236. }
  44237. }
  44238. declare module "babylonjs/XR/webXRSessionManager" {
  44239. import { Observable } from "babylonjs/Misc/observable";
  44240. import { Nullable } from "babylonjs/types";
  44241. import { IDisposable, Scene } from "babylonjs/scene";
  44242. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44243. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44244. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  44245. /**
  44246. * Manages an XRSession to work with Babylon's engine
  44247. * @see https://doc.babylonjs.com/how_to/webxr
  44248. */
  44249. export class WebXRSessionManager implements IDisposable {
  44250. /** The scene which the session should be created for */
  44251. scene: Scene;
  44252. private _referenceSpace;
  44253. private _rttProvider;
  44254. private _sessionEnded;
  44255. private _xrNavigator;
  44256. private baseLayer;
  44257. /**
  44258. * The base reference space from which the session started. good if you want to reset your
  44259. * reference space
  44260. */
  44261. baseReferenceSpace: XRReferenceSpace;
  44262. /**
  44263. * Current XR frame
  44264. */
  44265. currentFrame: Nullable<XRFrame>;
  44266. /** WebXR timestamp updated every frame */
  44267. currentTimestamp: number;
  44268. /**
  44269. * Used just in case of a failure to initialize an immersive session.
  44270. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  44271. */
  44272. defaultHeightCompensation: number;
  44273. /**
  44274. * Fires every time a new xrFrame arrives which can be used to update the camera
  44275. */
  44276. onXRFrameObservable: Observable<XRFrame>;
  44277. /**
  44278. * Fires when the reference space changed
  44279. */
  44280. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  44281. /**
  44282. * Fires when the xr session is ended either by the device or manually done
  44283. */
  44284. onXRSessionEnded: Observable<any>;
  44285. /**
  44286. * Fires when the xr session is ended either by the device or manually done
  44287. */
  44288. onXRSessionInit: Observable<XRSession>;
  44289. /**
  44290. * Underlying xr session
  44291. */
  44292. session: XRSession;
  44293. /**
  44294. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  44295. * or get the offset the player is currently at.
  44296. */
  44297. viewerReferenceSpace: XRReferenceSpace;
  44298. /**
  44299. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  44300. * @param scene The scene which the session should be created for
  44301. */
  44302. constructor(
  44303. /** The scene which the session should be created for */
  44304. scene: Scene);
  44305. /**
  44306. * The current reference space used in this session. This reference space can constantly change!
  44307. * It is mainly used to offset the camera's position.
  44308. */
  44309. get referenceSpace(): XRReferenceSpace;
  44310. /**
  44311. * Set a new reference space and triggers the observable
  44312. */
  44313. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  44314. /**
  44315. * Disposes of the session manager
  44316. */
  44317. dispose(): void;
  44318. /**
  44319. * Stops the xrSession and restores the render loop
  44320. * @returns Promise which resolves after it exits XR
  44321. */
  44322. exitXRAsync(): Promise<void>;
  44323. /**
  44324. * Gets the correct render target texture to be rendered this frame for this eye
  44325. * @param eye the eye for which to get the render target
  44326. * @returns the render target for the specified eye
  44327. */
  44328. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  44329. /**
  44330. * Creates a WebXRRenderTarget object for the XR session
  44331. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  44332. * @param options optional options to provide when creating a new render target
  44333. * @returns a WebXR render target to which the session can render
  44334. */
  44335. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  44336. /**
  44337. * Initializes the manager
  44338. * After initialization enterXR can be called to start an XR session
  44339. * @returns Promise which resolves after it is initialized
  44340. */
  44341. initializeAsync(): Promise<void>;
  44342. /**
  44343. * Initializes an xr session
  44344. * @param xrSessionMode mode to initialize
  44345. * @param xrSessionInit defines optional and required values to pass to the session builder
  44346. * @returns a promise which will resolve once the session has been initialized
  44347. */
  44348. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  44349. /**
  44350. * Checks if a session would be supported for the creation options specified
  44351. * @param sessionMode session mode to check if supported eg. immersive-vr
  44352. * @returns A Promise that resolves to true if supported and false if not
  44353. */
  44354. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44355. /**
  44356. * Resets the reference space to the one started the session
  44357. */
  44358. resetReferenceSpace(): void;
  44359. /**
  44360. * Starts rendering to the xr layer
  44361. */
  44362. runXRRenderLoop(): void;
  44363. /**
  44364. * Sets the reference space on the xr session
  44365. * @param referenceSpaceType space to set
  44366. * @returns a promise that will resolve once the reference space has been set
  44367. */
  44368. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  44369. /**
  44370. * Updates the render state of the session
  44371. * @param state state to set
  44372. * @returns a promise that resolves once the render state has been updated
  44373. */
  44374. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  44375. /**
  44376. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  44377. * @param sessionMode defines the session to test
  44378. * @returns a promise with boolean as final value
  44379. */
  44380. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44381. private _createRenderTargetTexture;
  44382. }
  44383. }
  44384. declare module "babylonjs/XR/webXRCamera" {
  44385. import { Scene } from "babylonjs/scene";
  44386. import { Camera } from "babylonjs/Cameras/camera";
  44387. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  44388. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44389. /**
  44390. * WebXR Camera which holds the views for the xrSession
  44391. * @see https://doc.babylonjs.com/how_to/webxr_camera
  44392. */
  44393. export class WebXRCamera extends FreeCamera {
  44394. private _xrSessionManager;
  44395. private _firstFrame;
  44396. private _referenceQuaternion;
  44397. private _referencedPosition;
  44398. private _xrInvPositionCache;
  44399. private _xrInvQuaternionCache;
  44400. /**
  44401. * Should position compensation execute on first frame.
  44402. * This is used when copying the position from a native (non XR) camera
  44403. */
  44404. compensateOnFirstFrame: boolean;
  44405. /**
  44406. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  44407. * @param name the name of the camera
  44408. * @param scene the scene to add the camera to
  44409. * @param _xrSessionManager a constructed xr session manager
  44410. */
  44411. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  44412. /**
  44413. * Return the user's height, unrelated to the current ground.
  44414. * This will be the y position of this camera, when ground level is 0.
  44415. */
  44416. get realWorldHeight(): number;
  44417. /** @hidden */
  44418. _updateForDualEyeDebugging(): void;
  44419. /**
  44420. * Sets this camera's transformation based on a non-vr camera
  44421. * @param otherCamera the non-vr camera to copy the transformation from
  44422. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  44423. */
  44424. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  44425. /**
  44426. * Gets the current instance class name ("WebXRCamera").
  44427. * @returns the class name
  44428. */
  44429. getClassName(): string;
  44430. private _updateFromXRSession;
  44431. private _updateNumberOfRigCameras;
  44432. private _updateReferenceSpace;
  44433. private _updateReferenceSpaceOffset;
  44434. }
  44435. }
  44436. declare module "babylonjs/XR/webXRFeaturesManager" {
  44437. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44438. import { IDisposable } from "babylonjs/scene";
  44439. /**
  44440. * Defining the interface required for a (webxr) feature
  44441. */
  44442. export interface IWebXRFeature extends IDisposable {
  44443. /**
  44444. * Is this feature attached
  44445. */
  44446. attached: boolean;
  44447. /**
  44448. * Should auto-attach be disabled?
  44449. */
  44450. disableAutoAttach: boolean;
  44451. /**
  44452. * Attach the feature to the session
  44453. * Will usually be called by the features manager
  44454. *
  44455. * @param force should attachment be forced (even when already attached)
  44456. * @returns true if successful.
  44457. */
  44458. attach(force?: boolean): boolean;
  44459. /**
  44460. * Detach the feature from the session
  44461. * Will usually be called by the features manager
  44462. *
  44463. * @returns true if successful.
  44464. */
  44465. detach(): boolean;
  44466. }
  44467. /**
  44468. * A list of the currently available features without referencing them
  44469. */
  44470. export class WebXRFeatureName {
  44471. /**
  44472. * The name of the anchor system feature
  44473. */
  44474. static ANCHOR_SYSTEM: string;
  44475. /**
  44476. * The name of the background remover feature
  44477. */
  44478. static BACKGROUND_REMOVER: string;
  44479. /**
  44480. * The name of the hit test feature
  44481. */
  44482. static HIT_TEST: string;
  44483. /**
  44484. * physics impostors for xr controllers feature
  44485. */
  44486. static PHYSICS_CONTROLLERS: string;
  44487. /**
  44488. * The name of the plane detection feature
  44489. */
  44490. static PLANE_DETECTION: string;
  44491. /**
  44492. * The name of the pointer selection feature
  44493. */
  44494. static POINTER_SELECTION: string;
  44495. /**
  44496. * The name of the teleportation feature
  44497. */
  44498. static TELEPORTATION: string;
  44499. }
  44500. /**
  44501. * Defining the constructor of a feature. Used to register the modules.
  44502. */
  44503. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  44504. /**
  44505. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44506. * It is mainly used in AR sessions.
  44507. *
  44508. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44509. */
  44510. export class WebXRFeaturesManager implements IDisposable {
  44511. private _xrSessionManager;
  44512. private static readonly _AvailableFeatures;
  44513. private _features;
  44514. /**
  44515. * constructs a new features manages.
  44516. *
  44517. * @param _xrSessionManager an instance of WebXRSessionManager
  44518. */
  44519. constructor(_xrSessionManager: WebXRSessionManager);
  44520. /**
  44521. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44522. * Mainly used internally.
  44523. *
  44524. * @param featureName the name of the feature to register
  44525. * @param constructorFunction the function used to construct the module
  44526. * @param version the (babylon) version of the module
  44527. * @param stable is that a stable version of this module
  44528. */
  44529. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44530. /**
  44531. * Returns a constructor of a specific feature.
  44532. *
  44533. * @param featureName the name of the feature to construct
  44534. * @param version the version of the feature to load
  44535. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44536. * @param options optional options provided to the module.
  44537. * @returns a function that, when called, will return a new instance of this feature
  44538. */
  44539. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44540. /**
  44541. * Can be used to return the list of features currently registered
  44542. *
  44543. * @returns an Array of available features
  44544. */
  44545. static GetAvailableFeatures(): string[];
  44546. /**
  44547. * Gets the versions available for a specific feature
  44548. * @param featureName the name of the feature
  44549. * @returns an array with the available versions
  44550. */
  44551. static GetAvailableVersions(featureName: string): string[];
  44552. /**
  44553. * Return the latest unstable version of this feature
  44554. * @param featureName the name of the feature to search
  44555. * @returns the version number. if not found will return -1
  44556. */
  44557. static GetLatestVersionOfFeature(featureName: string): number;
  44558. /**
  44559. * Return the latest stable version of this feature
  44560. * @param featureName the name of the feature to search
  44561. * @returns the version number. if not found will return -1
  44562. */
  44563. static GetStableVersionOfFeature(featureName: string): number;
  44564. /**
  44565. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44566. * Can be used during a session to start a feature
  44567. * @param featureName the name of feature to attach
  44568. */
  44569. attachFeature(featureName: string): void;
  44570. /**
  44571. * Can be used inside a session or when the session ends to detach a specific feature
  44572. * @param featureName the name of the feature to detach
  44573. */
  44574. detachFeature(featureName: string): void;
  44575. /**
  44576. * Used to disable an already-enabled feature
  44577. * The feature will be disposed and will be recreated once enabled.
  44578. * @param featureName the feature to disable
  44579. * @returns true if disable was successful
  44580. */
  44581. disableFeature(featureName: string | {
  44582. Name: string;
  44583. }): boolean;
  44584. /**
  44585. * dispose this features manager
  44586. */
  44587. dispose(): void;
  44588. /**
  44589. * 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.
  44590. * 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.
  44591. *
  44592. * @param featureName the name of the feature to load or the class of the feature
  44593. * @param version optional version to load. if not provided the latest version will be enabled
  44594. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44595. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44596. * @returns a new constructed feature or throws an error if feature not found.
  44597. */
  44598. enableFeature(featureName: string | {
  44599. Name: string;
  44600. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  44601. /**
  44602. * get the implementation of an enabled feature.
  44603. * @param featureName the name of the feature to load
  44604. * @returns the feature class, if found
  44605. */
  44606. getEnabledFeature(featureName: string): IWebXRFeature;
  44607. /**
  44608. * Get the list of enabled features
  44609. * @returns an array of enabled features
  44610. */
  44611. getEnabledFeatures(): string[];
  44612. }
  44613. }
  44614. declare module "babylonjs/XR/webXRExperienceHelper" {
  44615. import { Observable } from "babylonjs/Misc/observable";
  44616. import { IDisposable, Scene } from "babylonjs/scene";
  44617. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44618. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  44619. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44620. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  44621. /**
  44622. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  44623. * @see https://doc.babylonjs.com/how_to/webxr
  44624. */
  44625. export class WebXRExperienceHelper implements IDisposable {
  44626. private scene;
  44627. private _nonVRCamera;
  44628. private _originalSceneAutoClear;
  44629. private _supported;
  44630. /**
  44631. * Camera used to render xr content
  44632. */
  44633. camera: WebXRCamera;
  44634. /** A features manager for this xr session */
  44635. featuresManager: WebXRFeaturesManager;
  44636. /**
  44637. * Observers registered here will be triggered after the camera's initial transformation is set
  44638. * This can be used to set a different ground level or an extra rotation.
  44639. *
  44640. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  44641. * to the position set after this observable is done executing.
  44642. */
  44643. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  44644. /**
  44645. * Fires when the state of the experience helper has changed
  44646. */
  44647. onStateChangedObservable: Observable<WebXRState>;
  44648. /** Session manager used to keep track of xr session */
  44649. sessionManager: WebXRSessionManager;
  44650. /**
  44651. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44652. */
  44653. state: WebXRState;
  44654. /**
  44655. * Creates a WebXRExperienceHelper
  44656. * @param scene The scene the helper should be created in
  44657. */
  44658. private constructor();
  44659. /**
  44660. * Creates the experience helper
  44661. * @param scene the scene to attach the experience helper to
  44662. * @returns a promise for the experience helper
  44663. */
  44664. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  44665. /**
  44666. * Disposes of the experience helper
  44667. */
  44668. dispose(): void;
  44669. /**
  44670. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44671. * @param sessionMode options for the XR session
  44672. * @param referenceSpaceType frame of reference of the XR session
  44673. * @param renderTarget the output canvas that will be used to enter XR mode
  44674. * @returns promise that resolves after xr mode has entered
  44675. */
  44676. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44677. /**
  44678. * Exits XR mode and returns the scene to its original state
  44679. * @returns promise that resolves after xr mode has exited
  44680. */
  44681. exitXRAsync(): Promise<void>;
  44682. private _nonXRToXRCamera;
  44683. private _setState;
  44684. }
  44685. }
  44686. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  44687. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  44688. import { Observable } from "babylonjs/Misc/observable";
  44689. import { IDisposable } from "babylonjs/scene";
  44690. /**
  44691. * X-Y values for axes in WebXR
  44692. */
  44693. export interface IWebXRMotionControllerAxesValue {
  44694. /**
  44695. * The value of the x axis
  44696. */
  44697. x: number;
  44698. /**
  44699. * The value of the y-axis
  44700. */
  44701. y: number;
  44702. }
  44703. /**
  44704. * changed / previous values for the values of this component
  44705. */
  44706. export interface IWebXRMotionControllerComponentChangesValues<T> {
  44707. /**
  44708. * current (this frame) value
  44709. */
  44710. current: T;
  44711. /**
  44712. * previous (last change) value
  44713. */
  44714. previous: T;
  44715. }
  44716. /**
  44717. * Represents changes in the component between current frame and last values recorded
  44718. */
  44719. export interface IWebXRMotionControllerComponentChanges {
  44720. /**
  44721. * will be populated with previous and current values if axes changed
  44722. */
  44723. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  44724. /**
  44725. * will be populated with previous and current values if pressed changed
  44726. */
  44727. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44728. /**
  44729. * will be populated with previous and current values if touched changed
  44730. */
  44731. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44732. /**
  44733. * will be populated with previous and current values if value changed
  44734. */
  44735. value?: IWebXRMotionControllerComponentChangesValues<number>;
  44736. }
  44737. /**
  44738. * This class represents a single component (for example button or thumbstick) of a motion controller
  44739. */
  44740. export class WebXRControllerComponent implements IDisposable {
  44741. /**
  44742. * the id of this component
  44743. */
  44744. id: string;
  44745. /**
  44746. * the type of the component
  44747. */
  44748. type: MotionControllerComponentType;
  44749. private _buttonIndex;
  44750. private _axesIndices;
  44751. private _axes;
  44752. private _changes;
  44753. private _currentValue;
  44754. private _hasChanges;
  44755. private _pressed;
  44756. private _touched;
  44757. /**
  44758. * button component type
  44759. */
  44760. static BUTTON_TYPE: MotionControllerComponentType;
  44761. /**
  44762. * squeeze component type
  44763. */
  44764. static SQUEEZE_TYPE: MotionControllerComponentType;
  44765. /**
  44766. * Thumbstick component type
  44767. */
  44768. static THUMBSTICK_TYPE: MotionControllerComponentType;
  44769. /**
  44770. * Touchpad component type
  44771. */
  44772. static TOUCHPAD_TYPE: MotionControllerComponentType;
  44773. /**
  44774. * trigger component type
  44775. */
  44776. static TRIGGER_TYPE: MotionControllerComponentType;
  44777. /**
  44778. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  44779. * the axes data changes
  44780. */
  44781. onAxisValueChangedObservable: Observable<{
  44782. x: number;
  44783. y: number;
  44784. }>;
  44785. /**
  44786. * Observers registered here will be triggered when the state of a button changes
  44787. * State change is either pressed / touched / value
  44788. */
  44789. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  44790. /**
  44791. * Creates a new component for a motion controller.
  44792. * It is created by the motion controller itself
  44793. *
  44794. * @param id the id of this component
  44795. * @param type the type of the component
  44796. * @param _buttonIndex index in the buttons array of the gamepad
  44797. * @param _axesIndices indices of the values in the axes array of the gamepad
  44798. */
  44799. constructor(
  44800. /**
  44801. * the id of this component
  44802. */
  44803. id: string,
  44804. /**
  44805. * the type of the component
  44806. */
  44807. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  44808. /**
  44809. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  44810. */
  44811. get axes(): IWebXRMotionControllerAxesValue;
  44812. /**
  44813. * Get the changes. Elements will be populated only if they changed with their previous and current value
  44814. */
  44815. get changes(): IWebXRMotionControllerComponentChanges;
  44816. /**
  44817. * Return whether or not the component changed the last frame
  44818. */
  44819. get hasChanges(): boolean;
  44820. /**
  44821. * is the button currently pressed
  44822. */
  44823. get pressed(): boolean;
  44824. /**
  44825. * is the button currently touched
  44826. */
  44827. get touched(): boolean;
  44828. /**
  44829. * Get the current value of this component
  44830. */
  44831. get value(): number;
  44832. /**
  44833. * Dispose this component
  44834. */
  44835. dispose(): void;
  44836. /**
  44837. * Are there axes correlating to this component
  44838. * @return true is axes data is available
  44839. */
  44840. isAxes(): boolean;
  44841. /**
  44842. * Is this component a button (hence - pressable)
  44843. * @returns true if can be pressed
  44844. */
  44845. isButton(): boolean;
  44846. /**
  44847. * update this component using the gamepad object it is in. Called on every frame
  44848. * @param nativeController the native gamepad controller object
  44849. */
  44850. update(nativeController: IMinimalMotionControllerObject): void;
  44851. }
  44852. }
  44853. declare module "babylonjs/Loading/sceneLoader" {
  44854. import { Observable } from "babylonjs/Misc/observable";
  44855. import { Nullable } from "babylonjs/types";
  44856. import { Scene } from "babylonjs/scene";
  44857. import { Engine } from "babylonjs/Engines/engine";
  44858. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44859. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44860. import { AssetContainer } from "babylonjs/assetContainer";
  44861. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44862. import { Skeleton } from "babylonjs/Bones/skeleton";
  44863. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44864. import { WebRequest } from "babylonjs/Misc/webRequest";
  44865. /**
  44866. * Class used to represent data loading progression
  44867. */
  44868. export class SceneLoaderProgressEvent {
  44869. /** defines if data length to load can be evaluated */
  44870. readonly lengthComputable: boolean;
  44871. /** defines the loaded data length */
  44872. readonly loaded: number;
  44873. /** defines the data length to load */
  44874. readonly total: number;
  44875. /**
  44876. * Create a new progress event
  44877. * @param lengthComputable defines if data length to load can be evaluated
  44878. * @param loaded defines the loaded data length
  44879. * @param total defines the data length to load
  44880. */
  44881. constructor(
  44882. /** defines if data length to load can be evaluated */
  44883. lengthComputable: boolean,
  44884. /** defines the loaded data length */
  44885. loaded: number,
  44886. /** defines the data length to load */
  44887. total: number);
  44888. /**
  44889. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44890. * @param event defines the source event
  44891. * @returns a new SceneLoaderProgressEvent
  44892. */
  44893. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44894. }
  44895. /**
  44896. * Interface used by SceneLoader plugins to define supported file extensions
  44897. */
  44898. export interface ISceneLoaderPluginExtensions {
  44899. /**
  44900. * Defines the list of supported extensions
  44901. */
  44902. [extension: string]: {
  44903. isBinary: boolean;
  44904. };
  44905. }
  44906. /**
  44907. * Interface used by SceneLoader plugin factory
  44908. */
  44909. export interface ISceneLoaderPluginFactory {
  44910. /**
  44911. * Defines the name of the factory
  44912. */
  44913. name: string;
  44914. /**
  44915. * Function called to create a new plugin
  44916. * @return the new plugin
  44917. */
  44918. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44919. /**
  44920. * The callback that returns true if the data can be directly loaded.
  44921. * @param data string containing the file data
  44922. * @returns if the data can be loaded directly
  44923. */
  44924. canDirectLoad?(data: string): boolean;
  44925. }
  44926. /**
  44927. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  44928. */
  44929. export interface ISceneLoaderPluginBase {
  44930. /**
  44931. * The friendly name of this plugin.
  44932. */
  44933. name: string;
  44934. /**
  44935. * The file extensions supported by this plugin.
  44936. */
  44937. extensions: string | ISceneLoaderPluginExtensions;
  44938. /**
  44939. * The callback called when loading from a url.
  44940. * @param scene scene loading this url
  44941. * @param url url to load
  44942. * @param onSuccess callback called when the file successfully loads
  44943. * @param onProgress callback called while file is loading (if the server supports this mode)
  44944. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44945. * @param onError callback called when the file fails to load
  44946. * @returns a file request object
  44947. */
  44948. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44949. /**
  44950. * The callback called when loading from a file object.
  44951. * @param scene scene loading this file
  44952. * @param file defines the file to load
  44953. * @param onSuccess defines the callback to call when data is loaded
  44954. * @param onProgress defines the callback to call during loading process
  44955. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44956. * @param onError defines the callback to call when an error occurs
  44957. * @returns a file request object
  44958. */
  44959. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44960. /**
  44961. * The callback that returns true if the data can be directly loaded.
  44962. * @param data string containing the file data
  44963. * @returns if the data can be loaded directly
  44964. */
  44965. canDirectLoad?(data: string): boolean;
  44966. /**
  44967. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  44968. * @param scene scene loading this data
  44969. * @param data string containing the data
  44970. * @returns data to pass to the plugin
  44971. */
  44972. directLoad?(scene: Scene, data: string): any;
  44973. /**
  44974. * The callback that allows custom handling of the root url based on the response url.
  44975. * @param rootUrl the original root url
  44976. * @param responseURL the response url if available
  44977. * @returns the new root url
  44978. */
  44979. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  44980. }
  44981. /**
  44982. * Interface used to define a SceneLoader plugin
  44983. */
  44984. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  44985. /**
  44986. * Import meshes into a scene.
  44987. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44988. * @param scene The scene to import into
  44989. * @param data The data to import
  44990. * @param rootUrl The root url for scene and resources
  44991. * @param meshes The meshes array to import into
  44992. * @param particleSystems The particle systems array to import into
  44993. * @param skeletons The skeletons array to import into
  44994. * @param onError The callback when import fails
  44995. * @returns True if successful or false otherwise
  44996. */
  44997. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44998. /**
  44999. * Load into a scene.
  45000. * @param scene The scene to load into
  45001. * @param data The data to import
  45002. * @param rootUrl The root url for scene and resources
  45003. * @param onError The callback when import fails
  45004. * @returns True if successful or false otherwise
  45005. */
  45006. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  45007. /**
  45008. * Load into an asset container.
  45009. * @param scene The scene to load into
  45010. * @param data The data to import
  45011. * @param rootUrl The root url for scene and resources
  45012. * @param onError The callback when import fails
  45013. * @returns The loaded asset container
  45014. */
  45015. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  45016. }
  45017. /**
  45018. * Interface used to define an async SceneLoader plugin
  45019. */
  45020. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  45021. /**
  45022. * Import meshes into a scene.
  45023. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45024. * @param scene The scene to import into
  45025. * @param data The data to import
  45026. * @param rootUrl The root url for scene and resources
  45027. * @param onProgress The callback when the load progresses
  45028. * @param fileName Defines the name of the file to load
  45029. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  45030. */
  45031. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  45032. meshes: AbstractMesh[];
  45033. particleSystems: IParticleSystem[];
  45034. skeletons: Skeleton[];
  45035. animationGroups: AnimationGroup[];
  45036. }>;
  45037. /**
  45038. * Load into a scene.
  45039. * @param scene The scene to load into
  45040. * @param data The data to import
  45041. * @param rootUrl The root url for scene and resources
  45042. * @param onProgress The callback when the load progresses
  45043. * @param fileName Defines the name of the file to load
  45044. * @returns Nothing
  45045. */
  45046. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  45047. /**
  45048. * Load into an asset container.
  45049. * @param scene The scene to load into
  45050. * @param data The data to import
  45051. * @param rootUrl The root url for scene and resources
  45052. * @param onProgress The callback when the load progresses
  45053. * @param fileName Defines the name of the file to load
  45054. * @returns The loaded asset container
  45055. */
  45056. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  45057. }
  45058. /**
  45059. * Mode that determines how to handle old animation groups before loading new ones.
  45060. */
  45061. export enum SceneLoaderAnimationGroupLoadingMode {
  45062. /**
  45063. * Reset all old animations to initial state then dispose them.
  45064. */
  45065. Clean = 0,
  45066. /**
  45067. * Stop all old animations.
  45068. */
  45069. Stop = 1,
  45070. /**
  45071. * Restart old animations from first frame.
  45072. */
  45073. Sync = 2,
  45074. /**
  45075. * Old animations remains untouched.
  45076. */
  45077. NoSync = 3
  45078. }
  45079. /**
  45080. * Class used to load scene from various file formats using registered plugins
  45081. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  45082. */
  45083. export class SceneLoader {
  45084. /**
  45085. * No logging while loading
  45086. */
  45087. static readonly NO_LOGGING: number;
  45088. /**
  45089. * Minimal logging while loading
  45090. */
  45091. static readonly MINIMAL_LOGGING: number;
  45092. /**
  45093. * Summary logging while loading
  45094. */
  45095. static readonly SUMMARY_LOGGING: number;
  45096. /**
  45097. * Detailled logging while loading
  45098. */
  45099. static readonly DETAILED_LOGGING: number;
  45100. /**
  45101. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  45102. */
  45103. static get ForceFullSceneLoadingForIncremental(): boolean;
  45104. static set ForceFullSceneLoadingForIncremental(value: boolean);
  45105. /**
  45106. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  45107. */
  45108. static get ShowLoadingScreen(): boolean;
  45109. static set ShowLoadingScreen(value: boolean);
  45110. /**
  45111. * Defines the current logging level (while loading the scene)
  45112. * @ignorenaming
  45113. */
  45114. static get loggingLevel(): number;
  45115. static set loggingLevel(value: number);
  45116. /**
  45117. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  45118. */
  45119. static get CleanBoneMatrixWeights(): boolean;
  45120. static set CleanBoneMatrixWeights(value: boolean);
  45121. /**
  45122. * Event raised when a plugin is used to load a scene
  45123. */
  45124. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  45125. private static _registeredPlugins;
  45126. private static _getDefaultPlugin;
  45127. private static _getPluginForExtension;
  45128. private static _getPluginForDirectLoad;
  45129. private static _getPluginForFilename;
  45130. private static _getDirectLoad;
  45131. private static _loadData;
  45132. private static _getFileInfo;
  45133. /**
  45134. * Gets a plugin that can load the given extension
  45135. * @param extension defines the extension to load
  45136. * @returns a plugin or null if none works
  45137. */
  45138. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  45139. /**
  45140. * Gets a boolean indicating that the given extension can be loaded
  45141. * @param extension defines the extension to load
  45142. * @returns true if the extension is supported
  45143. */
  45144. static IsPluginForExtensionAvailable(extension: string): boolean;
  45145. /**
  45146. * Adds a new plugin to the list of registered plugins
  45147. * @param plugin defines the plugin to add
  45148. */
  45149. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  45150. /**
  45151. * Import meshes into a scene
  45152. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45153. * @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)
  45154. * @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)
  45155. * @param scene the instance of BABYLON.Scene to append to
  45156. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  45157. * @param onProgress a callback with a progress event for each file being loaded
  45158. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45159. * @param pluginExtension the extension used to determine the plugin
  45160. * @returns The loaded plugin
  45161. */
  45162. 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>;
  45163. /**
  45164. * Import meshes into a scene
  45165. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45166. * @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)
  45167. * @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)
  45168. * @param scene the instance of BABYLON.Scene to append to
  45169. * @param onProgress a callback with a progress event for each file being loaded
  45170. * @param pluginExtension the extension used to determine the plugin
  45171. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  45172. */
  45173. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  45174. meshes: AbstractMesh[];
  45175. particleSystems: IParticleSystem[];
  45176. skeletons: Skeleton[];
  45177. animationGroups: AnimationGroup[];
  45178. }>;
  45179. /**
  45180. * Load a scene
  45181. * @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)
  45182. * @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)
  45183. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45184. * @param onSuccess a callback with the scene when import succeeds
  45185. * @param onProgress a callback with a progress event for each file being loaded
  45186. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45187. * @param pluginExtension the extension used to determine the plugin
  45188. * @returns The loaded plugin
  45189. */
  45190. 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>;
  45191. /**
  45192. * Load a scene
  45193. * @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)
  45194. * @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)
  45195. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45196. * @param onProgress a callback with a progress event for each file being loaded
  45197. * @param pluginExtension the extension used to determine the plugin
  45198. * @returns The loaded scene
  45199. */
  45200. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45201. /**
  45202. * Append a scene
  45203. * @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)
  45204. * @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)
  45205. * @param scene is the instance of BABYLON.Scene to append to
  45206. * @param onSuccess a callback with the scene when import succeeds
  45207. * @param onProgress a callback with a progress event for each file being loaded
  45208. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45209. * @param pluginExtension the extension used to determine the plugin
  45210. * @returns The loaded plugin
  45211. */
  45212. 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>;
  45213. /**
  45214. * Append a scene
  45215. * @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)
  45216. * @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)
  45217. * @param scene is the instance of BABYLON.Scene to append to
  45218. * @param onProgress a callback with a progress event for each file being loaded
  45219. * @param pluginExtension the extension used to determine the plugin
  45220. * @returns The given scene
  45221. */
  45222. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45223. /**
  45224. * Load a scene into an asset container
  45225. * @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)
  45226. * @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)
  45227. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45228. * @param onSuccess a callback with the scene when import succeeds
  45229. * @param onProgress a callback with a progress event for each file being loaded
  45230. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45231. * @param pluginExtension the extension used to determine the plugin
  45232. * @returns The loaded plugin
  45233. */
  45234. 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>;
  45235. /**
  45236. * Load a scene into an asset container
  45237. * @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)
  45238. * @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)
  45239. * @param scene is the instance of Scene to append to
  45240. * @param onProgress a callback with a progress event for each file being loaded
  45241. * @param pluginExtension the extension used to determine the plugin
  45242. * @returns The loaded asset container
  45243. */
  45244. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  45245. /**
  45246. * Import animations from a file into a scene
  45247. * @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)
  45248. * @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)
  45249. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45250. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45251. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45252. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45253. * @param onSuccess a callback with the scene when import succeeds
  45254. * @param onProgress a callback with a progress event for each file being loaded
  45255. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45256. */
  45257. 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;
  45258. /**
  45259. * Import animations from a file into a scene
  45260. * @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)
  45261. * @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)
  45262. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45263. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45264. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45265. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45266. * @param onSuccess a callback with the scene when import succeeds
  45267. * @param onProgress a callback with a progress event for each file being loaded
  45268. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45269. * @returns the updated scene with imported animations
  45270. */
  45271. 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>;
  45272. }
  45273. }
  45274. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  45275. import { IDisposable, Scene } from "babylonjs/scene";
  45276. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  45277. import { Observable } from "babylonjs/Misc/observable";
  45278. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45279. import { Nullable } from "babylonjs/types";
  45280. /**
  45281. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  45282. */
  45283. export type MotionControllerHandness = "none" | "left" | "right";
  45284. /**
  45285. * The type of components available in motion controllers.
  45286. * This is not the name of the component.
  45287. */
  45288. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  45289. /**
  45290. * The state of a controller component
  45291. */
  45292. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  45293. /**
  45294. * The schema of motion controller layout.
  45295. * No object will be initialized using this interface
  45296. * This is used just to define the profile.
  45297. */
  45298. export interface IMotionControllerLayout {
  45299. /**
  45300. * Path to load the assets. Usually relative to the base path
  45301. */
  45302. assetPath: string;
  45303. /**
  45304. * Available components (unsorted)
  45305. */
  45306. components: {
  45307. /**
  45308. * A map of component Ids
  45309. */
  45310. [componentId: string]: {
  45311. /**
  45312. * The type of input the component outputs
  45313. */
  45314. type: MotionControllerComponentType;
  45315. /**
  45316. * The indices of this component in the gamepad object
  45317. */
  45318. gamepadIndices: {
  45319. /**
  45320. * Index of button
  45321. */
  45322. button?: number;
  45323. /**
  45324. * If available, index of x-axis
  45325. */
  45326. xAxis?: number;
  45327. /**
  45328. * If available, index of y-axis
  45329. */
  45330. yAxis?: number;
  45331. };
  45332. /**
  45333. * The mesh's root node name
  45334. */
  45335. rootNodeName: string;
  45336. /**
  45337. * Animation definitions for this model
  45338. */
  45339. visualResponses: {
  45340. [stateKey: string]: {
  45341. /**
  45342. * What property will be animated
  45343. */
  45344. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  45345. /**
  45346. * What states influence this visual response
  45347. */
  45348. states: MotionControllerComponentStateType[];
  45349. /**
  45350. * Type of animation - movement or visibility
  45351. */
  45352. valueNodeProperty: "transform" | "visibility";
  45353. /**
  45354. * Base node name to move. Its position will be calculated according to the min and max nodes
  45355. */
  45356. valueNodeName?: string;
  45357. /**
  45358. * Minimum movement node
  45359. */
  45360. minNodeName?: string;
  45361. /**
  45362. * Max movement node
  45363. */
  45364. maxNodeName?: string;
  45365. };
  45366. };
  45367. /**
  45368. * If touch enabled, what is the name of node to display user feedback
  45369. */
  45370. touchPointNodeName?: string;
  45371. };
  45372. };
  45373. /**
  45374. * Is it xr standard mapping or not
  45375. */
  45376. gamepadMapping: "" | "xr-standard";
  45377. /**
  45378. * Base root node of this entire model
  45379. */
  45380. rootNodeName: string;
  45381. /**
  45382. * Defines the main button component id
  45383. */
  45384. selectComponentId: string;
  45385. }
  45386. /**
  45387. * A definition for the layout map in the input profile
  45388. */
  45389. export interface IMotionControllerLayoutMap {
  45390. /**
  45391. * Layouts with handness type as a key
  45392. */
  45393. [handness: string]: IMotionControllerLayout;
  45394. }
  45395. /**
  45396. * The XR Input profile schema
  45397. * Profiles can be found here:
  45398. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  45399. */
  45400. export interface IMotionControllerProfile {
  45401. /**
  45402. * fallback profiles for this profileId
  45403. */
  45404. fallbackProfileIds: string[];
  45405. /**
  45406. * The layout map, with handness as key
  45407. */
  45408. layouts: IMotionControllerLayoutMap;
  45409. /**
  45410. * The id of this profile
  45411. * correlates to the profile(s) in the xrInput.profiles array
  45412. */
  45413. profileId: string;
  45414. }
  45415. /**
  45416. * A helper-interface for the 3 meshes needed for controller button animation
  45417. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  45418. */
  45419. export interface IMotionControllerButtonMeshMap {
  45420. /**
  45421. * the mesh that defines the pressed value mesh position.
  45422. * This is used to find the max-position of this button
  45423. */
  45424. pressedMesh: AbstractMesh;
  45425. /**
  45426. * the mesh that defines the unpressed value mesh position.
  45427. * This is used to find the min (or initial) position of this button
  45428. */
  45429. unpressedMesh: AbstractMesh;
  45430. /**
  45431. * The mesh that will be changed when value changes
  45432. */
  45433. valueMesh: AbstractMesh;
  45434. }
  45435. /**
  45436. * A helper-interface for the 3 meshes needed for controller axis animation.
  45437. * This will be expanded when touchpad animations are fully supported
  45438. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  45439. */
  45440. export interface IMotionControllerMeshMap {
  45441. /**
  45442. * the mesh that defines the maximum value mesh position.
  45443. */
  45444. maxMesh?: AbstractMesh;
  45445. /**
  45446. * the mesh that defines the minimum value mesh position.
  45447. */
  45448. minMesh?: AbstractMesh;
  45449. /**
  45450. * The mesh that will be changed when axis value changes
  45451. */
  45452. valueMesh: AbstractMesh;
  45453. }
  45454. /**
  45455. * The elements needed for change-detection of the gamepad objects in motion controllers
  45456. */
  45457. export interface IMinimalMotionControllerObject {
  45458. /**
  45459. * Available axes of this controller
  45460. */
  45461. axes: number[];
  45462. /**
  45463. * An array of available buttons
  45464. */
  45465. buttons: Array<{
  45466. /**
  45467. * Value of the button/trigger
  45468. */
  45469. value: number;
  45470. /**
  45471. * If the button/trigger is currently touched
  45472. */
  45473. touched: boolean;
  45474. /**
  45475. * If the button/trigger is currently pressed
  45476. */
  45477. pressed: boolean;
  45478. }>;
  45479. }
  45480. /**
  45481. * An Abstract Motion controller
  45482. * This class receives an xrInput and a profile layout and uses those to initialize the components
  45483. * Each component has an observable to check for changes in value and state
  45484. */
  45485. export abstract class WebXRAbstractMotionController implements IDisposable {
  45486. protected scene: Scene;
  45487. protected layout: IMotionControllerLayout;
  45488. /**
  45489. * The gamepad object correlating to this controller
  45490. */
  45491. gamepadObject: IMinimalMotionControllerObject;
  45492. /**
  45493. * handness (left/right/none) of this controller
  45494. */
  45495. handness: MotionControllerHandness;
  45496. private _initComponent;
  45497. private _modelReady;
  45498. /**
  45499. * A map of components (WebXRControllerComponent) in this motion controller
  45500. * Components have a ComponentType and can also have both button and axis definitions
  45501. */
  45502. readonly components: {
  45503. [id: string]: WebXRControllerComponent;
  45504. };
  45505. /**
  45506. * Disable the model's animation. Can be set at any time.
  45507. */
  45508. disableAnimation: boolean;
  45509. /**
  45510. * Observers registered here will be triggered when the model of this controller is done loading
  45511. */
  45512. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  45513. /**
  45514. * The profile id of this motion controller
  45515. */
  45516. abstract profileId: string;
  45517. /**
  45518. * The root mesh of the model. It is null if the model was not yet initialized
  45519. */
  45520. rootMesh: Nullable<AbstractMesh>;
  45521. /**
  45522. * constructs a new abstract motion controller
  45523. * @param scene the scene to which the model of the controller will be added
  45524. * @param layout The profile layout to load
  45525. * @param gamepadObject The gamepad object correlating to this controller
  45526. * @param handness handness (left/right/none) of this controller
  45527. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  45528. */
  45529. constructor(scene: Scene, layout: IMotionControllerLayout,
  45530. /**
  45531. * The gamepad object correlating to this controller
  45532. */
  45533. gamepadObject: IMinimalMotionControllerObject,
  45534. /**
  45535. * handness (left/right/none) of this controller
  45536. */
  45537. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  45538. /**
  45539. * Dispose this controller, the model mesh and all its components
  45540. */
  45541. dispose(): void;
  45542. /**
  45543. * Returns all components of specific type
  45544. * @param type the type to search for
  45545. * @return an array of components with this type
  45546. */
  45547. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  45548. /**
  45549. * get a component based an its component id as defined in layout.components
  45550. * @param id the id of the component
  45551. * @returns the component correlates to the id or undefined if not found
  45552. */
  45553. getComponent(id: string): WebXRControllerComponent;
  45554. /**
  45555. * Get the list of components available in this motion controller
  45556. * @returns an array of strings correlating to available components
  45557. */
  45558. getComponentIds(): string[];
  45559. /**
  45560. * Get the first component of specific type
  45561. * @param type type of component to find
  45562. * @return a controller component or null if not found
  45563. */
  45564. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  45565. /**
  45566. * Get the main (Select) component of this controller as defined in the layout
  45567. * @returns the main component of this controller
  45568. */
  45569. getMainComponent(): WebXRControllerComponent;
  45570. /**
  45571. * Loads the model correlating to this controller
  45572. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  45573. * @returns A promise fulfilled with the result of the model loading
  45574. */
  45575. loadModel(): Promise<boolean>;
  45576. /**
  45577. * Update this model using the current XRFrame
  45578. * @param xrFrame the current xr frame to use and update the model
  45579. */
  45580. updateFromXRFrame(xrFrame: XRFrame): void;
  45581. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45582. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45583. /**
  45584. * Moves the axis on the controller mesh based on its current state
  45585. * @param axis the index of the axis
  45586. * @param axisValue the value of the axis which determines the meshes new position
  45587. * @hidden
  45588. */
  45589. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  45590. /**
  45591. * Update the model itself with the current frame data
  45592. * @param xrFrame the frame to use for updating the model mesh
  45593. */
  45594. protected updateModel(xrFrame: XRFrame): void;
  45595. /**
  45596. * Get the filename and path for this controller's model
  45597. * @returns a map of filename and path
  45598. */
  45599. protected abstract _getFilenameAndPath(): {
  45600. filename: string;
  45601. path: string;
  45602. };
  45603. /**
  45604. * This function is called before the mesh is loaded. It checks for loading constraints.
  45605. * For example, this function can check if the GLB loader is available
  45606. * If this function returns false, the generic controller will be loaded instead
  45607. * @returns Is the client ready to load the mesh
  45608. */
  45609. protected abstract _getModelLoadingConstraints(): boolean;
  45610. /**
  45611. * This function will be called after the model was successfully loaded and can be used
  45612. * for mesh transformations before it is available for the user
  45613. * @param meshes the loaded meshes
  45614. */
  45615. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  45616. /**
  45617. * Set the root mesh for this controller. Important for the WebXR controller class
  45618. * @param meshes the loaded meshes
  45619. */
  45620. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  45621. /**
  45622. * A function executed each frame that updates the mesh (if needed)
  45623. * @param xrFrame the current xrFrame
  45624. */
  45625. protected abstract _updateModel(xrFrame: XRFrame): void;
  45626. private _getGenericFilenameAndPath;
  45627. private _getGenericParentMesh;
  45628. }
  45629. }
  45630. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  45631. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45632. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45633. import { Scene } from "babylonjs/scene";
  45634. /**
  45635. * A generic trigger-only motion controller for WebXR
  45636. */
  45637. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  45638. /**
  45639. * Static version of the profile id of this controller
  45640. */
  45641. static ProfileId: string;
  45642. profileId: string;
  45643. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45644. protected _getFilenameAndPath(): {
  45645. filename: string;
  45646. path: string;
  45647. };
  45648. protected _getModelLoadingConstraints(): boolean;
  45649. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  45650. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45651. protected _updateModel(): void;
  45652. }
  45653. }
  45654. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45655. import { Vector4 } from "babylonjs/Maths/math.vector";
  45656. import { Mesh } from "babylonjs/Meshes/mesh";
  45657. import { Scene } from "babylonjs/scene";
  45658. import { Nullable } from "babylonjs/types";
  45659. /**
  45660. * Class containing static functions to help procedurally build meshes
  45661. */
  45662. export class SphereBuilder {
  45663. /**
  45664. * Creates a sphere mesh
  45665. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45666. * * 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`)
  45667. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45668. * * 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
  45669. * * 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)
  45670. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45671. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45673. * @param name defines the name of the mesh
  45674. * @param options defines the options used to create the mesh
  45675. * @param scene defines the hosting scene
  45676. * @returns the sphere mesh
  45677. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45678. */
  45679. static CreateSphere(name: string, options: {
  45680. segments?: number;
  45681. diameter?: number;
  45682. diameterX?: number;
  45683. diameterY?: number;
  45684. diameterZ?: number;
  45685. arc?: number;
  45686. slice?: number;
  45687. sideOrientation?: number;
  45688. frontUVs?: Vector4;
  45689. backUVs?: Vector4;
  45690. updatable?: boolean;
  45691. }, scene?: Nullable<Scene>): Mesh;
  45692. }
  45693. }
  45694. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  45695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45696. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45697. import { Scene } from "babylonjs/scene";
  45698. /**
  45699. * A profiled motion controller has its profile loaded from an online repository.
  45700. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  45701. */
  45702. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  45703. private _repositoryUrl;
  45704. private _buttonMeshMapping;
  45705. private _touchDots;
  45706. /**
  45707. * The profile ID of this controller. Will be populated when the controller initializes.
  45708. */
  45709. profileId: string;
  45710. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  45711. dispose(): void;
  45712. protected _getFilenameAndPath(): {
  45713. filename: string;
  45714. path: string;
  45715. };
  45716. protected _getModelLoadingConstraints(): boolean;
  45717. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45718. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45719. protected _updateModel(_xrFrame: XRFrame): void;
  45720. }
  45721. }
  45722. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  45723. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45724. import { Scene } from "babylonjs/scene";
  45725. /**
  45726. * A construction function type to create a new controller based on an xrInput object
  45727. */
  45728. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  45729. /**
  45730. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  45731. *
  45732. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  45733. * it should be replaced with auto-loaded controllers.
  45734. *
  45735. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  45736. */
  45737. export class WebXRMotionControllerManager {
  45738. private static _AvailableControllers;
  45739. private static _Fallbacks;
  45740. private static _ProfileLoadingPromises;
  45741. private static _ProfilesList;
  45742. /**
  45743. * The base URL of the online controller repository. Can be changed at any time.
  45744. */
  45745. static BaseRepositoryUrl: string;
  45746. /**
  45747. * Which repository gets priority - local or online
  45748. */
  45749. static PrioritizeOnlineRepository: boolean;
  45750. /**
  45751. * Use the online repository, or use only locally-defined controllers
  45752. */
  45753. static UseOnlineRepository: boolean;
  45754. /**
  45755. * Clear the cache used for profile loading and reload when requested again
  45756. */
  45757. static ClearProfilesCache(): void;
  45758. /**
  45759. * Register the default fallbacks.
  45760. * This function is called automatically when this file is imported.
  45761. */
  45762. static DefaultFallbacks(): void;
  45763. /**
  45764. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  45765. * @param profileId the profile to which a fallback needs to be found
  45766. * @return an array with corresponding fallback profiles
  45767. */
  45768. static FindFallbackWithProfileId(profileId: string): string[];
  45769. /**
  45770. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  45771. * The order of search:
  45772. *
  45773. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  45774. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  45775. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  45776. * 4) return the generic trigger controller if none were found
  45777. *
  45778. * @param xrInput the xrInput to which a new controller is initialized
  45779. * @param scene the scene to which the model will be added
  45780. * @param forceProfile force a certain profile for this controller
  45781. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  45782. */
  45783. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  45784. /**
  45785. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  45786. *
  45787. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  45788. *
  45789. * @param type the profile type to register
  45790. * @param constructFunction the function to be called when loading this profile
  45791. */
  45792. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  45793. /**
  45794. * Register a fallback to a specific profile.
  45795. * @param profileId the profileId that will receive the fallbacks
  45796. * @param fallbacks A list of fallback profiles
  45797. */
  45798. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  45799. /**
  45800. * Will update the list of profiles available in the repository
  45801. * @return a promise that resolves to a map of profiles available online
  45802. */
  45803. static UpdateProfilesList(): Promise<{
  45804. [profile: string]: string;
  45805. }>;
  45806. private static _LoadProfileFromRepository;
  45807. private static _LoadProfilesFromAvailableControllers;
  45808. }
  45809. }
  45810. declare module "babylonjs/XR/webXRInputSource" {
  45811. import { Observable } from "babylonjs/Misc/observable";
  45812. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45813. import { Ray } from "babylonjs/Culling/ray";
  45814. import { Scene } from "babylonjs/scene";
  45815. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45816. /**
  45817. * Configuration options for the WebXR controller creation
  45818. */
  45819. export interface IWebXRControllerOptions {
  45820. /**
  45821. * Should the controller mesh be animated when a user interacts with it
  45822. * The pressed buttons / thumbstick and touchpad animations will be disabled
  45823. */
  45824. disableMotionControllerAnimation?: boolean;
  45825. /**
  45826. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  45827. */
  45828. doNotLoadControllerMesh?: boolean;
  45829. /**
  45830. * Force a specific controller type for this controller.
  45831. * This can be used when creating your own profile or when testing different controllers
  45832. */
  45833. forceControllerProfile?: string;
  45834. }
  45835. /**
  45836. * Represents an XR controller
  45837. */
  45838. export class WebXRInputSource {
  45839. private _scene;
  45840. /** The underlying input source for the controller */
  45841. inputSource: XRInputSource;
  45842. private _options;
  45843. private _tmpQuaternion;
  45844. private _tmpVector;
  45845. private _uniqueId;
  45846. /**
  45847. * 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
  45848. */
  45849. grip?: AbstractMesh;
  45850. /**
  45851. * If available, this is the gamepad object related to this controller.
  45852. * Using this object it is possible to get click events and trackpad changes of the
  45853. * webxr controller that is currently being used.
  45854. */
  45855. motionController?: WebXRAbstractMotionController;
  45856. /**
  45857. * Event that fires when the controller is removed/disposed.
  45858. * The object provided as event data is this controller, after associated assets were disposed.
  45859. * uniqueId is still available.
  45860. */
  45861. onDisposeObservable: Observable<WebXRInputSource>;
  45862. /**
  45863. * Will be triggered when the mesh associated with the motion controller is done loading.
  45864. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  45865. * A shortened version of controller -> motion controller -> on mesh loaded.
  45866. */
  45867. onMeshLoadedObservable: Observable<AbstractMesh>;
  45868. /**
  45869. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  45870. */
  45871. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  45872. /**
  45873. * Pointer which can be used to select objects or attach a visible laser to
  45874. */
  45875. pointer: AbstractMesh;
  45876. /**
  45877. * Creates the controller
  45878. * @see https://doc.babylonjs.com/how_to/webxr
  45879. * @param _scene the scene which the controller should be associated to
  45880. * @param inputSource the underlying input source for the controller
  45881. * @param _options options for this controller creation
  45882. */
  45883. constructor(_scene: Scene,
  45884. /** The underlying input source for the controller */
  45885. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  45886. /**
  45887. * Get this controllers unique id
  45888. */
  45889. get uniqueId(): string;
  45890. /**
  45891. * Disposes of the object
  45892. */
  45893. dispose(): void;
  45894. /**
  45895. * Gets a world space ray coming from the pointer or grip
  45896. * @param result the resulting ray
  45897. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  45898. */
  45899. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  45900. /**
  45901. * Updates the controller pose based on the given XRFrame
  45902. * @param xrFrame xr frame to update the pose with
  45903. * @param referenceSpace reference space to use
  45904. */
  45905. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  45906. }
  45907. }
  45908. declare module "babylonjs/XR/webXRInput" {
  45909. import { Observable } from "babylonjs/Misc/observable";
  45910. import { IDisposable } from "babylonjs/scene";
  45911. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  45912. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45913. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  45914. /**
  45915. * The schema for initialization options of the XR Input class
  45916. */
  45917. export interface IWebXRInputOptions {
  45918. /**
  45919. * If set to true no model will be automatically loaded
  45920. */
  45921. doNotLoadControllerMeshes?: boolean;
  45922. /**
  45923. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  45924. * If not found, the xr input profile data will be used.
  45925. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  45926. */
  45927. forceInputProfile?: string;
  45928. /**
  45929. * Do not send a request to the controller repository to load the profile.
  45930. *
  45931. * Instead, use the controllers available in babylon itself.
  45932. */
  45933. disableOnlineControllerRepository?: boolean;
  45934. /**
  45935. * A custom URL for the controllers repository
  45936. */
  45937. customControllersRepositoryURL?: string;
  45938. /**
  45939. * Should the controller model's components not move according to the user input
  45940. */
  45941. disableControllerAnimation?: boolean;
  45942. }
  45943. /**
  45944. * XR input used to track XR inputs such as controllers/rays
  45945. */
  45946. export class WebXRInput implements IDisposable {
  45947. /**
  45948. * the xr session manager for this session
  45949. */
  45950. xrSessionManager: WebXRSessionManager;
  45951. /**
  45952. * the WebXR camera for this session. Mainly used for teleportation
  45953. */
  45954. xrCamera: WebXRCamera;
  45955. private readonly options;
  45956. /**
  45957. * XR controllers being tracked
  45958. */
  45959. controllers: Array<WebXRInputSource>;
  45960. private _frameObserver;
  45961. private _sessionEndedObserver;
  45962. private _sessionInitObserver;
  45963. /**
  45964. * Event when a controller has been connected/added
  45965. */
  45966. onControllerAddedObservable: Observable<WebXRInputSource>;
  45967. /**
  45968. * Event when a controller has been removed/disconnected
  45969. */
  45970. onControllerRemovedObservable: Observable<WebXRInputSource>;
  45971. /**
  45972. * Initializes the WebXRInput
  45973. * @param xrSessionManager the xr session manager for this session
  45974. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  45975. * @param options = initialization options for this xr input
  45976. */
  45977. constructor(
  45978. /**
  45979. * the xr session manager for this session
  45980. */
  45981. xrSessionManager: WebXRSessionManager,
  45982. /**
  45983. * the WebXR camera for this session. Mainly used for teleportation
  45984. */
  45985. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  45986. private _onInputSourcesChange;
  45987. private _addAndRemoveControllers;
  45988. /**
  45989. * Disposes of the object
  45990. */
  45991. dispose(): void;
  45992. }
  45993. }
  45994. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  45995. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  45996. import { Observable, EventState } from "babylonjs/Misc/observable";
  45997. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45998. /**
  45999. * This is the base class for all WebXR features.
  46000. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  46001. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  46002. */
  46003. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  46004. protected _xrSessionManager: WebXRSessionManager;
  46005. private _attached;
  46006. private _removeOnDetach;
  46007. /**
  46008. * Should auto-attach be disabled?
  46009. */
  46010. disableAutoAttach: boolean;
  46011. /**
  46012. * Construct a new (abstract) WebXR feature
  46013. * @param _xrSessionManager the xr session manager for this feature
  46014. */
  46015. constructor(_xrSessionManager: WebXRSessionManager);
  46016. /**
  46017. * Is this feature attached
  46018. */
  46019. get attached(): boolean;
  46020. /**
  46021. * attach this feature
  46022. *
  46023. * @param force should attachment be forced (even when already attached)
  46024. * @returns true if successful, false is failed or already attached
  46025. */
  46026. attach(force?: boolean): boolean;
  46027. /**
  46028. * detach this feature.
  46029. *
  46030. * @returns true if successful, false if failed or already detached
  46031. */
  46032. detach(): boolean;
  46033. /**
  46034. * Dispose this feature and all of the resources attached
  46035. */
  46036. dispose(): void;
  46037. /**
  46038. * This is used to register callbacks that will automatically be removed when detach is called.
  46039. * @param observable the observable to which the observer will be attached
  46040. * @param callback the callback to register
  46041. */
  46042. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  46043. /**
  46044. * Code in this function will be executed on each xrFrame received from the browser.
  46045. * This function will not execute after the feature is detached.
  46046. * @param _xrFrame the current frame
  46047. */
  46048. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  46049. }
  46050. }
  46051. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  46052. import { IDisposable, Scene } from "babylonjs/scene";
  46053. import { Nullable } from "babylonjs/types";
  46054. import { Observable } from "babylonjs/Misc/observable";
  46055. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46056. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  46057. import { Camera } from "babylonjs/Cameras/camera";
  46058. /**
  46059. * Renders a layer on top of an existing scene
  46060. */
  46061. export class UtilityLayerRenderer implements IDisposable {
  46062. /** the original scene that will be rendered on top of */
  46063. originalScene: Scene;
  46064. private _pointerCaptures;
  46065. private _lastPointerEvents;
  46066. private static _DefaultUtilityLayer;
  46067. private static _DefaultKeepDepthUtilityLayer;
  46068. private _sharedGizmoLight;
  46069. private _renderCamera;
  46070. /**
  46071. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  46072. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  46073. * @returns the camera that is used when rendering the utility layer
  46074. */
  46075. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  46076. /**
  46077. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  46078. * @param cam the camera that should be used when rendering the utility layer
  46079. */
  46080. setRenderCamera(cam: Nullable<Camera>): void;
  46081. /**
  46082. * @hidden
  46083. * Light which used by gizmos to get light shading
  46084. */
  46085. _getSharedGizmoLight(): HemisphericLight;
  46086. /**
  46087. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  46088. */
  46089. pickUtilitySceneFirst: boolean;
  46090. /**
  46091. * 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)
  46092. */
  46093. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  46094. /**
  46095. * 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)
  46096. */
  46097. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  46098. /**
  46099. * The scene that is rendered on top of the original scene
  46100. */
  46101. utilityLayerScene: Scene;
  46102. /**
  46103. * If the utility layer should automatically be rendered on top of existing scene
  46104. */
  46105. shouldRender: boolean;
  46106. /**
  46107. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  46108. */
  46109. onlyCheckPointerDownEvents: boolean;
  46110. /**
  46111. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  46112. */
  46113. processAllEvents: boolean;
  46114. /**
  46115. * Observable raised when the pointer move from the utility layer scene to the main scene
  46116. */
  46117. onPointerOutObservable: Observable<number>;
  46118. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  46119. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  46120. private _afterRenderObserver;
  46121. private _sceneDisposeObserver;
  46122. private _originalPointerObserver;
  46123. /**
  46124. * Instantiates a UtilityLayerRenderer
  46125. * @param originalScene the original scene that will be rendered on top of
  46126. * @param handleEvents boolean indicating if the utility layer should handle events
  46127. */
  46128. constructor(
  46129. /** the original scene that will be rendered on top of */
  46130. originalScene: Scene, handleEvents?: boolean);
  46131. private _notifyObservers;
  46132. /**
  46133. * Renders the utility layers scene on top of the original scene
  46134. */
  46135. render(): void;
  46136. /**
  46137. * Disposes of the renderer
  46138. */
  46139. dispose(): void;
  46140. private _updateCamera;
  46141. }
  46142. }
  46143. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  46144. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46145. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46146. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46147. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  46148. import { Scene } from "babylonjs/scene";
  46149. import { Nullable } from "babylonjs/types";
  46150. import { Color3 } from "babylonjs/Maths/math.color";
  46151. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46152. /**
  46153. * Options interface for the pointer selection module
  46154. */
  46155. export interface IWebXRControllerPointerSelectionOptions {
  46156. /**
  46157. * if provided, this scene will be used to render meshes.
  46158. */
  46159. customUtilityLayerScene?: Scene;
  46160. /**
  46161. * 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)
  46162. * If not disabled, the last picked point will be used to execute a pointer up event
  46163. * If disabled, pointer up event will be triggered right after the pointer down event.
  46164. * Used in screen and gaze target ray mode only
  46165. */
  46166. disablePointerUpOnTouchOut: boolean;
  46167. /**
  46168. * For gaze mode (time to select instead of press)
  46169. */
  46170. forceGazeMode: boolean;
  46171. /**
  46172. * 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
  46173. * to start a new countdown to the pointer down event.
  46174. * Defaults to 1.
  46175. */
  46176. gazeModePointerMovedFactor?: number;
  46177. /**
  46178. * Different button type to use instead of the main component
  46179. */
  46180. overrideButtonId?: string;
  46181. /**
  46182. * use this rendering group id for the meshes (optional)
  46183. */
  46184. renderingGroupId?: number;
  46185. /**
  46186. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  46187. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  46188. * 3000 means 3 seconds between pointing at something and selecting it
  46189. */
  46190. timeToSelect?: number;
  46191. /**
  46192. * Should meshes created here be added to a utility layer or the main scene
  46193. */
  46194. useUtilityLayer?: boolean;
  46195. /**
  46196. * the xr input to use with this pointer selection
  46197. */
  46198. xrInput: WebXRInput;
  46199. }
  46200. /**
  46201. * A module that will enable pointer selection for motion controllers of XR Input Sources
  46202. */
  46203. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  46204. private readonly _options;
  46205. private static _idCounter;
  46206. private _attachController;
  46207. private _controllers;
  46208. private _scene;
  46209. private _tmpVectorForPickCompare;
  46210. /**
  46211. * The module's name
  46212. */
  46213. static readonly Name: string;
  46214. /**
  46215. * The (Babylon) version of this module.
  46216. * This is an integer representing the implementation version.
  46217. * This number does not correspond to the WebXR specs version
  46218. */
  46219. static readonly Version: number;
  46220. /**
  46221. * Disable lighting on the laser pointer (so it will always be visible)
  46222. */
  46223. disablePointerLighting: boolean;
  46224. /**
  46225. * Disable lighting on the selection mesh (so it will always be visible)
  46226. */
  46227. disableSelectionMeshLighting: boolean;
  46228. /**
  46229. * Should the laser pointer be displayed
  46230. */
  46231. displayLaserPointer: boolean;
  46232. /**
  46233. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  46234. */
  46235. displaySelectionMesh: boolean;
  46236. /**
  46237. * This color will be set to the laser pointer when selection is triggered
  46238. */
  46239. laserPointerPickedColor: Color3;
  46240. /**
  46241. * Default color of the laser pointer
  46242. */
  46243. lasterPointerDefaultColor: Color3;
  46244. /**
  46245. * default color of the selection ring
  46246. */
  46247. selectionMeshDefaultColor: Color3;
  46248. /**
  46249. * This color will be applied to the selection ring when selection is triggered
  46250. */
  46251. selectionMeshPickedColor: Color3;
  46252. /**
  46253. * Optional filter to be used for ray selection. This predicate shares behavior with
  46254. * scene.pointerMovePredicate which takes priority if it is also assigned.
  46255. */
  46256. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  46257. /**
  46258. * constructs a new background remover module
  46259. * @param _xrSessionManager the session manager for this module
  46260. * @param _options read-only options to be used in this module
  46261. */
  46262. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  46263. /**
  46264. * attach this feature
  46265. * Will usually be called by the features manager
  46266. *
  46267. * @returns true if successful.
  46268. */
  46269. attach(): boolean;
  46270. /**
  46271. * detach this feature.
  46272. * Will usually be called by the features manager
  46273. *
  46274. * @returns true if successful.
  46275. */
  46276. detach(): boolean;
  46277. /**
  46278. * Will get the mesh under a specific pointer.
  46279. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  46280. * @param controllerId the controllerId to check
  46281. * @returns The mesh under pointer or null if no mesh is under the pointer
  46282. */
  46283. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  46284. /**
  46285. * Get the xr controller that correlates to the pointer id in the pointer event
  46286. *
  46287. * @param id the pointer id to search for
  46288. * @returns the controller that correlates to this id or null if not found
  46289. */
  46290. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  46291. protected _onXRFrame(_xrFrame: XRFrame): void;
  46292. private _attachGazeMode;
  46293. private _attachScreenRayMode;
  46294. private _attachTrackedPointerRayMode;
  46295. private _convertNormalToDirectionOfRay;
  46296. private _detachController;
  46297. private _generateNewMeshPair;
  46298. private _pickingMoved;
  46299. private _updatePointerDistance;
  46300. }
  46301. }
  46302. declare module "babylonjs/XR/webXREnterExitUI" {
  46303. import { Nullable } from "babylonjs/types";
  46304. import { Observable } from "babylonjs/Misc/observable";
  46305. import { IDisposable, Scene } from "babylonjs/scene";
  46306. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46307. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46308. /**
  46309. * Button which can be used to enter a different mode of XR
  46310. */
  46311. export class WebXREnterExitUIButton {
  46312. /** button element */
  46313. element: HTMLElement;
  46314. /** XR initialization options for the button */
  46315. sessionMode: XRSessionMode;
  46316. /** Reference space type */
  46317. referenceSpaceType: XRReferenceSpaceType;
  46318. /**
  46319. * Creates a WebXREnterExitUIButton
  46320. * @param element button element
  46321. * @param sessionMode XR initialization session mode
  46322. * @param referenceSpaceType the type of reference space to be used
  46323. */
  46324. constructor(
  46325. /** button element */
  46326. element: HTMLElement,
  46327. /** XR initialization options for the button */
  46328. sessionMode: XRSessionMode,
  46329. /** Reference space type */
  46330. referenceSpaceType: XRReferenceSpaceType);
  46331. /**
  46332. * Extendable function which can be used to update the button's visuals when the state changes
  46333. * @param activeButton the current active button in the UI
  46334. */
  46335. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  46336. }
  46337. /**
  46338. * Options to create the webXR UI
  46339. */
  46340. export class WebXREnterExitUIOptions {
  46341. /**
  46342. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  46343. */
  46344. customButtons?: Array<WebXREnterExitUIButton>;
  46345. /**
  46346. * A reference space type to use when creating the default button.
  46347. * Default is local-floor
  46348. */
  46349. referenceSpaceType?: XRReferenceSpaceType;
  46350. /**
  46351. * Context to enter xr with
  46352. */
  46353. renderTarget?: Nullable<WebXRRenderTarget>;
  46354. /**
  46355. * A session mode to use when creating the default button.
  46356. * Default is immersive-vr
  46357. */
  46358. sessionMode?: XRSessionMode;
  46359. }
  46360. /**
  46361. * UI to allow the user to enter/exit XR mode
  46362. */
  46363. export class WebXREnterExitUI implements IDisposable {
  46364. private scene;
  46365. /** version of the options passed to this UI */
  46366. options: WebXREnterExitUIOptions;
  46367. private _activeButton;
  46368. private _buttons;
  46369. private _overlay;
  46370. /**
  46371. * Fired every time the active button is changed.
  46372. *
  46373. * When xr is entered via a button that launches xr that button will be the callback parameter
  46374. *
  46375. * When exiting xr the callback parameter will be null)
  46376. */
  46377. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  46378. /**
  46379. *
  46380. * @param scene babylon scene object to use
  46381. * @param options (read-only) version of the options passed to this UI
  46382. */
  46383. private constructor();
  46384. /**
  46385. * Creates UI to allow the user to enter/exit XR mode
  46386. * @param scene the scene to add the ui to
  46387. * @param helper the xr experience helper to enter/exit xr with
  46388. * @param options options to configure the UI
  46389. * @returns the created ui
  46390. */
  46391. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  46392. /**
  46393. * Disposes of the XR UI component
  46394. */
  46395. dispose(): void;
  46396. private _updateButtons;
  46397. }
  46398. }
  46399. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46400. import { Vector3 } from "babylonjs/Maths/math.vector";
  46401. import { Color4 } from "babylonjs/Maths/math.color";
  46402. import { Nullable } from "babylonjs/types";
  46403. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46404. import { Scene } from "babylonjs/scene";
  46405. /**
  46406. * Class containing static functions to help procedurally build meshes
  46407. */
  46408. export class LinesBuilder {
  46409. /**
  46410. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46411. * * 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
  46412. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46413. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46414. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46415. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46416. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46417. * * 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
  46418. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46419. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46420. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46421. * @param name defines the name of the new line system
  46422. * @param options defines the options used to create the line system
  46423. * @param scene defines the hosting scene
  46424. * @returns a new line system mesh
  46425. */
  46426. static CreateLineSystem(name: string, options: {
  46427. lines: Vector3[][];
  46428. updatable?: boolean;
  46429. instance?: Nullable<LinesMesh>;
  46430. colors?: Nullable<Color4[][]>;
  46431. useVertexAlpha?: boolean;
  46432. }, scene: Nullable<Scene>): LinesMesh;
  46433. /**
  46434. * Creates a line mesh
  46435. * 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
  46436. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46437. * * The parameter `points` is an array successive Vector3
  46438. * * 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
  46439. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46440. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46441. * * When updating an instance, remember that only point positions can change, not the number of points
  46442. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46443. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46444. * @param name defines the name of the new line system
  46445. * @param options defines the options used to create the line system
  46446. * @param scene defines the hosting scene
  46447. * @returns a new line mesh
  46448. */
  46449. static CreateLines(name: string, options: {
  46450. points: Vector3[];
  46451. updatable?: boolean;
  46452. instance?: Nullable<LinesMesh>;
  46453. colors?: Color4[];
  46454. useVertexAlpha?: boolean;
  46455. }, scene?: Nullable<Scene>): LinesMesh;
  46456. /**
  46457. * Creates a dashed line mesh
  46458. * * 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
  46459. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46460. * * The parameter `points` is an array successive Vector3
  46461. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46462. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46463. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46464. * * 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
  46465. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46466. * * When updating an instance, remember that only point positions can change, not the number of points
  46467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46468. * @param name defines the name of the mesh
  46469. * @param options defines the options used to create the mesh
  46470. * @param scene defines the hosting scene
  46471. * @returns the dashed line mesh
  46472. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46473. */
  46474. static CreateDashedLines(name: string, options: {
  46475. points: Vector3[];
  46476. dashSize?: number;
  46477. gapSize?: number;
  46478. dashNb?: number;
  46479. updatable?: boolean;
  46480. instance?: LinesMesh;
  46481. useVertexAlpha?: boolean;
  46482. }, scene?: Nullable<Scene>): LinesMesh;
  46483. }
  46484. }
  46485. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  46486. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46487. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46488. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46489. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46490. import { Vector3 } from "babylonjs/Maths/math.vector";
  46491. import { Material } from "babylonjs/Materials/material";
  46492. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46493. import { Scene } from "babylonjs/scene";
  46494. /**
  46495. * The options container for the teleportation module
  46496. */
  46497. export interface IWebXRTeleportationOptions {
  46498. /**
  46499. * if provided, this scene will be used to render meshes.
  46500. */
  46501. customUtilityLayerScene?: Scene;
  46502. /**
  46503. * Values to configure the default target mesh
  46504. */
  46505. defaultTargetMeshOptions?: {
  46506. /**
  46507. * Fill color of the teleportation area
  46508. */
  46509. teleportationFillColor?: string;
  46510. /**
  46511. * Border color for the teleportation area
  46512. */
  46513. teleportationBorderColor?: string;
  46514. /**
  46515. * Disable the mesh's animation sequence
  46516. */
  46517. disableAnimation?: boolean;
  46518. /**
  46519. * Disable lighting on the material or the ring and arrow
  46520. */
  46521. disableLighting?: boolean;
  46522. /**
  46523. * Override the default material of the torus and arrow
  46524. */
  46525. torusArrowMaterial?: Material;
  46526. };
  46527. /**
  46528. * A list of meshes to use as floor meshes.
  46529. * Meshes can be added and removed after initializing the feature using the
  46530. * addFloorMesh and removeFloorMesh functions
  46531. * If empty, rotation will still work
  46532. */
  46533. floorMeshes?: AbstractMesh[];
  46534. /**
  46535. * use this rendering group id for the meshes (optional)
  46536. */
  46537. renderingGroupId?: number;
  46538. /**
  46539. * Should teleportation move only to snap points
  46540. */
  46541. snapPointsOnly?: boolean;
  46542. /**
  46543. * An array of points to which the teleportation will snap to.
  46544. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  46545. */
  46546. snapPositions?: Vector3[];
  46547. /**
  46548. * How close should the teleportation ray be in order to snap to position.
  46549. * Default to 0.8 units (meters)
  46550. */
  46551. snapToPositionRadius?: number;
  46552. /**
  46553. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  46554. * If you want to support rotation, make sure your mesh has a direction indicator.
  46555. *
  46556. * When left untouched, the default mesh will be initialized.
  46557. */
  46558. teleportationTargetMesh?: AbstractMesh;
  46559. /**
  46560. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  46561. */
  46562. timeToTeleport?: number;
  46563. /**
  46564. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  46565. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  46566. */
  46567. useMainComponentOnly?: boolean;
  46568. /**
  46569. * Should meshes created here be added to a utility layer or the main scene
  46570. */
  46571. useUtilityLayer?: boolean;
  46572. /**
  46573. * Babylon XR Input class for controller
  46574. */
  46575. xrInput: WebXRInput;
  46576. }
  46577. /**
  46578. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  46579. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  46580. * the input of the attached controllers.
  46581. */
  46582. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  46583. private _options;
  46584. private _controllers;
  46585. private _currentTeleportationControllerId;
  46586. private _floorMeshes;
  46587. private _quadraticBezierCurve;
  46588. private _selectionFeature;
  46589. private _snapToPositions;
  46590. private _snappedToPoint;
  46591. private _teleportationRingMaterial?;
  46592. private _tmpRay;
  46593. private _tmpVector;
  46594. /**
  46595. * The module's name
  46596. */
  46597. static readonly Name: string;
  46598. /**
  46599. * The (Babylon) version of this module.
  46600. * This is an integer representing the implementation version.
  46601. * This number does not correspond to the webxr specs version
  46602. */
  46603. static readonly Version: number;
  46604. /**
  46605. * Is movement backwards enabled
  46606. */
  46607. backwardsMovementEnabled: boolean;
  46608. /**
  46609. * Distance to travel when moving backwards
  46610. */
  46611. backwardsTeleportationDistance: number;
  46612. /**
  46613. * The distance from the user to the inspection point in the direction of the controller
  46614. * A higher number will allow the user to move further
  46615. * defaults to 5 (meters, in xr units)
  46616. */
  46617. parabolicCheckRadius: number;
  46618. /**
  46619. * Should the module support parabolic ray on top of direct ray
  46620. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  46621. * Very helpful when moving between floors / different heights
  46622. */
  46623. parabolicRayEnabled: boolean;
  46624. /**
  46625. * How much rotation should be applied when rotating right and left
  46626. */
  46627. rotationAngle: number;
  46628. /**
  46629. * Is rotation enabled when moving forward?
  46630. * Disabling this feature will prevent the user from deciding the direction when teleporting
  46631. */
  46632. rotationEnabled: boolean;
  46633. /**
  46634. * constructs a new anchor system
  46635. * @param _xrSessionManager an instance of WebXRSessionManager
  46636. * @param _options configuration object for this feature
  46637. */
  46638. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  46639. /**
  46640. * Get the snapPointsOnly flag
  46641. */
  46642. get snapPointsOnly(): boolean;
  46643. /**
  46644. * Sets the snapPointsOnly flag
  46645. * @param snapToPoints should teleportation be exclusively to snap points
  46646. */
  46647. set snapPointsOnly(snapToPoints: boolean);
  46648. /**
  46649. * Add a new mesh to the floor meshes array
  46650. * @param mesh the mesh to use as floor mesh
  46651. */
  46652. addFloorMesh(mesh: AbstractMesh): void;
  46653. /**
  46654. * Add a new snap-to point to fix teleportation to this position
  46655. * @param newSnapPoint The new Snap-To point
  46656. */
  46657. addSnapPoint(newSnapPoint: Vector3): void;
  46658. attach(): boolean;
  46659. detach(): boolean;
  46660. dispose(): void;
  46661. /**
  46662. * Remove a mesh from the floor meshes array
  46663. * @param mesh the mesh to remove
  46664. */
  46665. removeFloorMesh(mesh: AbstractMesh): void;
  46666. /**
  46667. * Remove a mesh from the floor meshes array using its name
  46668. * @param name the mesh name to remove
  46669. */
  46670. removeFloorMeshByName(name: string): void;
  46671. /**
  46672. * 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
  46673. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  46674. * @returns was the point found and removed or not
  46675. */
  46676. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  46677. /**
  46678. * This function sets a selection feature that will be disabled when
  46679. * the forward ray is shown and will be reattached when hidden.
  46680. * This is used to remove the selection rays when moving.
  46681. * @param selectionFeature the feature to disable when forward movement is enabled
  46682. */
  46683. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  46684. protected _onXRFrame(_xrFrame: XRFrame): void;
  46685. private _attachController;
  46686. private _createDefaultTargetMesh;
  46687. private _detachController;
  46688. private _findClosestSnapPointWithRadius;
  46689. private _setTargetMeshPosition;
  46690. private _setTargetMeshVisibility;
  46691. private _showParabolicPath;
  46692. private _teleportForward;
  46693. }
  46694. }
  46695. declare module "babylonjs/XR/webXRDefaultExperience" {
  46696. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46697. import { Scene } from "babylonjs/scene";
  46698. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  46699. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  46700. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46701. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  46702. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46703. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  46704. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  46705. /**
  46706. * Options for the default xr helper
  46707. */
  46708. export class WebXRDefaultExperienceOptions {
  46709. /**
  46710. * Enable or disable default UI to enter XR
  46711. */
  46712. disableDefaultUI?: boolean;
  46713. /**
  46714. * Should teleportation not initialize. defaults to false.
  46715. */
  46716. disableTeleportation?: boolean;
  46717. /**
  46718. * Floor meshes that will be used for teleport
  46719. */
  46720. floorMeshes?: Array<AbstractMesh>;
  46721. /**
  46722. * If set to true, the first frame will not be used to reset position
  46723. * The first frame is mainly used when copying transformation from the old camera
  46724. * Mainly used in AR
  46725. */
  46726. ignoreNativeCameraTransformation?: boolean;
  46727. /**
  46728. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  46729. */
  46730. inputOptions?: IWebXRInputOptions;
  46731. /**
  46732. * optional configuration for the output canvas
  46733. */
  46734. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  46735. /**
  46736. * optional UI options. This can be used among other to change session mode and reference space type
  46737. */
  46738. uiOptions?: WebXREnterExitUIOptions;
  46739. /**
  46740. * When loading teleportation and pointer select, use stable versions instead of latest.
  46741. */
  46742. useStablePlugins?: boolean;
  46743. }
  46744. /**
  46745. * Default experience which provides a similar setup to the previous webVRExperience
  46746. */
  46747. export class WebXRDefaultExperience {
  46748. /**
  46749. * Base experience
  46750. */
  46751. baseExperience: WebXRExperienceHelper;
  46752. /**
  46753. * Enables ui for entering/exiting xr
  46754. */
  46755. enterExitUI: WebXREnterExitUI;
  46756. /**
  46757. * Input experience extension
  46758. */
  46759. input: WebXRInput;
  46760. /**
  46761. * Enables laser pointer and selection
  46762. */
  46763. pointerSelection: WebXRControllerPointerSelection;
  46764. /**
  46765. * Default target xr should render to
  46766. */
  46767. renderTarget: WebXRRenderTarget;
  46768. /**
  46769. * Enables teleportation
  46770. */
  46771. teleportation: WebXRMotionControllerTeleportation;
  46772. private constructor();
  46773. /**
  46774. * Creates the default xr experience
  46775. * @param scene scene
  46776. * @param options options for basic configuration
  46777. * @returns resulting WebXRDefaultExperience
  46778. */
  46779. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  46780. /**
  46781. * DIsposes of the experience helper
  46782. */
  46783. dispose(): void;
  46784. }
  46785. }
  46786. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  46787. import { Observable } from "babylonjs/Misc/observable";
  46788. import { Nullable } from "babylonjs/types";
  46789. import { Camera } from "babylonjs/Cameras/camera";
  46790. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  46791. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  46792. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  46793. import { Scene } from "babylonjs/scene";
  46794. import { Vector3 } from "babylonjs/Maths/math.vector";
  46795. import { Color3 } from "babylonjs/Maths/math.color";
  46796. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46797. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46798. import { Mesh } from "babylonjs/Meshes/mesh";
  46799. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  46800. import { EasingFunction } from "babylonjs/Animations/easing";
  46801. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46802. import "babylonjs/Meshes/Builders/groundBuilder";
  46803. import "babylonjs/Meshes/Builders/torusBuilder";
  46804. import "babylonjs/Meshes/Builders/cylinderBuilder";
  46805. import "babylonjs/Gamepads/gamepadSceneComponent";
  46806. import "babylonjs/Animations/animatable";
  46807. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  46808. /**
  46809. * Options to modify the vr teleportation behavior.
  46810. */
  46811. export interface VRTeleportationOptions {
  46812. /**
  46813. * The name of the mesh which should be used as the teleportation floor. (default: null)
  46814. */
  46815. floorMeshName?: string;
  46816. /**
  46817. * A list of meshes to be used as the teleportation floor. (default: empty)
  46818. */
  46819. floorMeshes?: Mesh[];
  46820. /**
  46821. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  46822. */
  46823. teleportationMode?: number;
  46824. /**
  46825. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  46826. */
  46827. teleportationTime?: number;
  46828. /**
  46829. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  46830. */
  46831. teleportationSpeed?: number;
  46832. /**
  46833. * The easing function used in the animation or null for Linear. (default CircleEase)
  46834. */
  46835. easingFunction?: EasingFunction;
  46836. }
  46837. /**
  46838. * Options to modify the vr experience helper's behavior.
  46839. */
  46840. export interface VRExperienceHelperOptions extends WebVROptions {
  46841. /**
  46842. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  46843. */
  46844. createDeviceOrientationCamera?: boolean;
  46845. /**
  46846. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  46847. */
  46848. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  46849. /**
  46850. * Uses the main button on the controller to toggle the laser casted. (default: true)
  46851. */
  46852. laserToggle?: boolean;
  46853. /**
  46854. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  46855. */
  46856. floorMeshes?: Mesh[];
  46857. /**
  46858. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  46859. */
  46860. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  46861. /**
  46862. * Defines if WebXR should be used instead of WebVR (if available)
  46863. */
  46864. useXR?: boolean;
  46865. }
  46866. /**
  46867. * Event containing information after VR has been entered
  46868. */
  46869. export class OnAfterEnteringVRObservableEvent {
  46870. /**
  46871. * If entering vr was successful
  46872. */
  46873. success: boolean;
  46874. }
  46875. /**
  46876. * Helps to quickly add VR support to an existing scene.
  46877. * See http://doc.babylonjs.com/how_to/webvr_helper
  46878. */
  46879. export class VRExperienceHelper {
  46880. /** Options to modify the vr experience helper's behavior. */
  46881. webVROptions: VRExperienceHelperOptions;
  46882. private _scene;
  46883. private _position;
  46884. private _btnVR;
  46885. private _btnVRDisplayed;
  46886. private _webVRsupported;
  46887. private _webVRready;
  46888. private _webVRrequesting;
  46889. private _webVRpresenting;
  46890. private _hasEnteredVR;
  46891. private _fullscreenVRpresenting;
  46892. private _inputElement;
  46893. private _webVRCamera;
  46894. private _vrDeviceOrientationCamera;
  46895. private _deviceOrientationCamera;
  46896. private _existingCamera;
  46897. private _onKeyDown;
  46898. private _onVrDisplayPresentChange;
  46899. private _onVRDisplayChanged;
  46900. private _onVRRequestPresentStart;
  46901. private _onVRRequestPresentComplete;
  46902. /**
  46903. * 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)
  46904. */
  46905. enableGazeEvenWhenNoPointerLock: boolean;
  46906. /**
  46907. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  46908. */
  46909. exitVROnDoubleTap: boolean;
  46910. /**
  46911. * Observable raised right before entering VR.
  46912. */
  46913. onEnteringVRObservable: Observable<VRExperienceHelper>;
  46914. /**
  46915. * Observable raised when entering VR has completed.
  46916. */
  46917. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  46918. /**
  46919. * Observable raised when exiting VR.
  46920. */
  46921. onExitingVRObservable: Observable<VRExperienceHelper>;
  46922. /**
  46923. * Observable raised when controller mesh is loaded.
  46924. */
  46925. onControllerMeshLoadedObservable: Observable<WebVRController>;
  46926. /** Return this.onEnteringVRObservable
  46927. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  46928. */
  46929. get onEnteringVR(): Observable<VRExperienceHelper>;
  46930. /** Return this.onExitingVRObservable
  46931. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  46932. */
  46933. get onExitingVR(): Observable<VRExperienceHelper>;
  46934. /** Return this.onControllerMeshLoadedObservable
  46935. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  46936. */
  46937. get onControllerMeshLoaded(): Observable<WebVRController>;
  46938. private _rayLength;
  46939. private _useCustomVRButton;
  46940. private _teleportationRequested;
  46941. private _teleportActive;
  46942. private _floorMeshName;
  46943. private _floorMeshesCollection;
  46944. private _teleportationMode;
  46945. private _teleportationTime;
  46946. private _teleportationSpeed;
  46947. private _teleportationEasing;
  46948. private _rotationAllowed;
  46949. private _teleportBackwardsVector;
  46950. private _teleportationTarget;
  46951. private _isDefaultTeleportationTarget;
  46952. private _postProcessMove;
  46953. private _teleportationFillColor;
  46954. private _teleportationBorderColor;
  46955. private _rotationAngle;
  46956. private _haloCenter;
  46957. private _cameraGazer;
  46958. private _padSensibilityUp;
  46959. private _padSensibilityDown;
  46960. private _leftController;
  46961. private _rightController;
  46962. private _gazeColor;
  46963. private _laserColor;
  46964. private _pickedLaserColor;
  46965. private _pickedGazeColor;
  46966. /**
  46967. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  46968. */
  46969. onNewMeshSelected: Observable<AbstractMesh>;
  46970. /**
  46971. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  46972. * This observable will provide the mesh and the controller used to select the mesh
  46973. */
  46974. onMeshSelectedWithController: Observable<{
  46975. mesh: AbstractMesh;
  46976. controller: WebVRController;
  46977. }>;
  46978. /**
  46979. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  46980. */
  46981. onNewMeshPicked: Observable<PickingInfo>;
  46982. private _circleEase;
  46983. /**
  46984. * Observable raised before camera teleportation
  46985. */
  46986. onBeforeCameraTeleport: Observable<Vector3>;
  46987. /**
  46988. * Observable raised after camera teleportation
  46989. */
  46990. onAfterCameraTeleport: Observable<Vector3>;
  46991. /**
  46992. * Observable raised when current selected mesh gets unselected
  46993. */
  46994. onSelectedMeshUnselected: Observable<AbstractMesh>;
  46995. private _raySelectionPredicate;
  46996. /**
  46997. * To be optionaly changed by user to define custom ray selection
  46998. */
  46999. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  47000. /**
  47001. * To be optionaly changed by user to define custom selection logic (after ray selection)
  47002. */
  47003. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47004. /**
  47005. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  47006. */
  47007. teleportationEnabled: boolean;
  47008. private _defaultHeight;
  47009. private _teleportationInitialized;
  47010. private _interactionsEnabled;
  47011. private _interactionsRequested;
  47012. private _displayGaze;
  47013. private _displayLaserPointer;
  47014. /**
  47015. * The mesh used to display where the user is going to teleport.
  47016. */
  47017. get teleportationTarget(): Mesh;
  47018. /**
  47019. * Sets the mesh to be used to display where the user is going to teleport.
  47020. */
  47021. set teleportationTarget(value: Mesh);
  47022. /**
  47023. * 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
  47024. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  47025. * See http://doc.babylonjs.com/resources/baking_transformations
  47026. */
  47027. get gazeTrackerMesh(): Mesh;
  47028. set gazeTrackerMesh(value: Mesh);
  47029. /**
  47030. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  47031. */
  47032. updateGazeTrackerScale: boolean;
  47033. /**
  47034. * If the gaze trackers color should be updated when selecting meshes
  47035. */
  47036. updateGazeTrackerColor: boolean;
  47037. /**
  47038. * If the controller laser color should be updated when selecting meshes
  47039. */
  47040. updateControllerLaserColor: boolean;
  47041. /**
  47042. * The gaze tracking mesh corresponding to the left controller
  47043. */
  47044. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  47045. /**
  47046. * The gaze tracking mesh corresponding to the right controller
  47047. */
  47048. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  47049. /**
  47050. * If the ray of the gaze should be displayed.
  47051. */
  47052. get displayGaze(): boolean;
  47053. /**
  47054. * Sets if the ray of the gaze should be displayed.
  47055. */
  47056. set displayGaze(value: boolean);
  47057. /**
  47058. * If the ray of the LaserPointer should be displayed.
  47059. */
  47060. get displayLaserPointer(): boolean;
  47061. /**
  47062. * Sets if the ray of the LaserPointer should be displayed.
  47063. */
  47064. set displayLaserPointer(value: boolean);
  47065. /**
  47066. * The deviceOrientationCamera used as the camera when not in VR.
  47067. */
  47068. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  47069. /**
  47070. * Based on the current WebVR support, returns the current VR camera used.
  47071. */
  47072. get currentVRCamera(): Nullable<Camera>;
  47073. /**
  47074. * The webVRCamera which is used when in VR.
  47075. */
  47076. get webVRCamera(): WebVRFreeCamera;
  47077. /**
  47078. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  47079. */
  47080. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  47081. /**
  47082. * The html button that is used to trigger entering into VR.
  47083. */
  47084. get vrButton(): Nullable<HTMLButtonElement>;
  47085. private get _teleportationRequestInitiated();
  47086. /**
  47087. * Defines whether or not Pointer lock should be requested when switching to
  47088. * full screen.
  47089. */
  47090. requestPointerLockOnFullScreen: boolean;
  47091. /**
  47092. * If asking to force XR, this will be populated with the default xr experience
  47093. */
  47094. xr: WebXRDefaultExperience;
  47095. /**
  47096. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  47097. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  47098. */
  47099. xrTestDone: boolean;
  47100. /**
  47101. * Instantiates a VRExperienceHelper.
  47102. * Helps to quickly add VR support to an existing scene.
  47103. * @param scene The scene the VRExperienceHelper belongs to.
  47104. * @param webVROptions Options to modify the vr experience helper's behavior.
  47105. */
  47106. constructor(scene: Scene,
  47107. /** Options to modify the vr experience helper's behavior. */
  47108. webVROptions?: VRExperienceHelperOptions);
  47109. private completeVRInit;
  47110. private _onDefaultMeshLoaded;
  47111. private _onResize;
  47112. private _onFullscreenChange;
  47113. /**
  47114. * Gets a value indicating if we are currently in VR mode.
  47115. */
  47116. get isInVRMode(): boolean;
  47117. private onVrDisplayPresentChange;
  47118. private onVRDisplayChanged;
  47119. private moveButtonToBottomRight;
  47120. private displayVRButton;
  47121. private updateButtonVisibility;
  47122. private _cachedAngularSensibility;
  47123. /**
  47124. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  47125. * Otherwise, will use the fullscreen API.
  47126. */
  47127. enterVR(): void;
  47128. /**
  47129. * Attempt to exit VR, or fullscreen.
  47130. */
  47131. exitVR(): void;
  47132. /**
  47133. * The position of the vr experience helper.
  47134. */
  47135. get position(): Vector3;
  47136. /**
  47137. * Sets the position of the vr experience helper.
  47138. */
  47139. set position(value: Vector3);
  47140. /**
  47141. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  47142. */
  47143. enableInteractions(): void;
  47144. private get _noControllerIsActive();
  47145. private beforeRender;
  47146. private _isTeleportationFloor;
  47147. /**
  47148. * Adds a floor mesh to be used for teleportation.
  47149. * @param floorMesh the mesh to be used for teleportation.
  47150. */
  47151. addFloorMesh(floorMesh: Mesh): void;
  47152. /**
  47153. * Removes a floor mesh from being used for teleportation.
  47154. * @param floorMesh the mesh to be removed.
  47155. */
  47156. removeFloorMesh(floorMesh: Mesh): void;
  47157. /**
  47158. * Enables interactions and teleportation using the VR controllers and gaze.
  47159. * @param vrTeleportationOptions options to modify teleportation behavior.
  47160. */
  47161. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  47162. private _onNewGamepadConnected;
  47163. private _tryEnableInteractionOnController;
  47164. private _onNewGamepadDisconnected;
  47165. private _enableInteractionOnController;
  47166. private _checkTeleportWithRay;
  47167. private _checkRotate;
  47168. private _checkTeleportBackwards;
  47169. private _enableTeleportationOnController;
  47170. private _createTeleportationCircles;
  47171. private _displayTeleportationTarget;
  47172. private _hideTeleportationTarget;
  47173. private _rotateCamera;
  47174. private _moveTeleportationSelectorTo;
  47175. private _workingVector;
  47176. private _workingQuaternion;
  47177. private _workingMatrix;
  47178. /**
  47179. * Time Constant Teleportation Mode
  47180. */
  47181. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  47182. /**
  47183. * Speed Constant Teleportation Mode
  47184. */
  47185. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  47186. /**
  47187. * Teleports the users feet to the desired location
  47188. * @param location The location where the user's feet should be placed
  47189. */
  47190. teleportCamera(location: Vector3): void;
  47191. private _convertNormalToDirectionOfRay;
  47192. private _castRayAndSelectObject;
  47193. private _notifySelectedMeshUnselected;
  47194. /**
  47195. * Permanently set new colors for the laser pointer
  47196. * @param color the new laser color
  47197. * @param pickedColor the new laser color when picked mesh detected
  47198. */
  47199. setLaserColor(color: Color3, pickedColor?: Color3): void;
  47200. /**
  47201. * Set lighting enabled / disabled on the laser pointer of both controllers
  47202. * @param enabled should the lighting be enabled on the laser pointer
  47203. */
  47204. setLaserLightingState(enabled?: boolean): void;
  47205. /**
  47206. * Permanently set new colors for the gaze pointer
  47207. * @param color the new gaze color
  47208. * @param pickedColor the new gaze color when picked mesh detected
  47209. */
  47210. setGazeColor(color: Color3, pickedColor?: Color3): void;
  47211. /**
  47212. * Sets the color of the laser ray from the vr controllers.
  47213. * @param color new color for the ray.
  47214. */
  47215. changeLaserColor(color: Color3): void;
  47216. /**
  47217. * Sets the color of the ray from the vr headsets gaze.
  47218. * @param color new color for the ray.
  47219. */
  47220. changeGazeColor(color: Color3): void;
  47221. /**
  47222. * Exits VR and disposes of the vr experience helper
  47223. */
  47224. dispose(): void;
  47225. /**
  47226. * Gets the name of the VRExperienceHelper class
  47227. * @returns "VRExperienceHelper"
  47228. */
  47229. getClassName(): string;
  47230. }
  47231. }
  47232. declare module "babylonjs/Cameras/VR/index" {
  47233. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  47234. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  47235. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47236. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  47237. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  47238. export * from "babylonjs/Cameras/VR/webVRCamera";
  47239. }
  47240. declare module "babylonjs/Cameras/RigModes/index" {
  47241. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47242. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47243. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  47244. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  47245. }
  47246. declare module "babylonjs/Cameras/index" {
  47247. export * from "babylonjs/Cameras/Inputs/index";
  47248. export * from "babylonjs/Cameras/cameraInputsManager";
  47249. export * from "babylonjs/Cameras/camera";
  47250. export * from "babylonjs/Cameras/targetCamera";
  47251. export * from "babylonjs/Cameras/freeCamera";
  47252. export * from "babylonjs/Cameras/freeCameraInputsManager";
  47253. export * from "babylonjs/Cameras/touchCamera";
  47254. export * from "babylonjs/Cameras/arcRotateCamera";
  47255. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47256. export * from "babylonjs/Cameras/deviceOrientationCamera";
  47257. export * from "babylonjs/Cameras/flyCamera";
  47258. export * from "babylonjs/Cameras/flyCameraInputsManager";
  47259. export * from "babylonjs/Cameras/followCamera";
  47260. export * from "babylonjs/Cameras/followCameraInputsManager";
  47261. export * from "babylonjs/Cameras/gamepadCamera";
  47262. export * from "babylonjs/Cameras/Stereoscopic/index";
  47263. export * from "babylonjs/Cameras/universalCamera";
  47264. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  47265. export * from "babylonjs/Cameras/VR/index";
  47266. export * from "babylonjs/Cameras/RigModes/index";
  47267. }
  47268. declare module "babylonjs/Collisions/index" {
  47269. export * from "babylonjs/Collisions/collider";
  47270. export * from "babylonjs/Collisions/collisionCoordinator";
  47271. export * from "babylonjs/Collisions/pickingInfo";
  47272. export * from "babylonjs/Collisions/intersectionInfo";
  47273. export * from "babylonjs/Collisions/meshCollisionData";
  47274. }
  47275. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  47276. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  47277. import { Vector3 } from "babylonjs/Maths/math.vector";
  47278. import { Ray } from "babylonjs/Culling/ray";
  47279. import { Plane } from "babylonjs/Maths/math.plane";
  47280. /**
  47281. * Contains an array of blocks representing the octree
  47282. */
  47283. export interface IOctreeContainer<T> {
  47284. /**
  47285. * Blocks within the octree
  47286. */
  47287. blocks: Array<OctreeBlock<T>>;
  47288. }
  47289. /**
  47290. * Class used to store a cell in an octree
  47291. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47292. */
  47293. export class OctreeBlock<T> {
  47294. /**
  47295. * Gets the content of the current block
  47296. */
  47297. entries: T[];
  47298. /**
  47299. * Gets the list of block children
  47300. */
  47301. blocks: Array<OctreeBlock<T>>;
  47302. private _depth;
  47303. private _maxDepth;
  47304. private _capacity;
  47305. private _minPoint;
  47306. private _maxPoint;
  47307. private _boundingVectors;
  47308. private _creationFunc;
  47309. /**
  47310. * Creates a new block
  47311. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  47312. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  47313. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47314. * @param depth defines the current depth of this block in the octree
  47315. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  47316. * @param creationFunc defines a callback to call when an element is added to the block
  47317. */
  47318. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  47319. /**
  47320. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47321. */
  47322. get capacity(): number;
  47323. /**
  47324. * Gets the minimum vector (in world space) of the block's bounding box
  47325. */
  47326. get minPoint(): Vector3;
  47327. /**
  47328. * Gets the maximum vector (in world space) of the block's bounding box
  47329. */
  47330. get maxPoint(): Vector3;
  47331. /**
  47332. * Add a new element to this block
  47333. * @param entry defines the element to add
  47334. */
  47335. addEntry(entry: T): void;
  47336. /**
  47337. * Remove an element from this block
  47338. * @param entry defines the element to remove
  47339. */
  47340. removeEntry(entry: T): void;
  47341. /**
  47342. * Add an array of elements to this block
  47343. * @param entries defines the array of elements to add
  47344. */
  47345. addEntries(entries: T[]): void;
  47346. /**
  47347. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  47348. * @param frustumPlanes defines the frustum planes to test
  47349. * @param selection defines the array to store current content if selection is positive
  47350. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47351. */
  47352. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47353. /**
  47354. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  47355. * @param sphereCenter defines the bounding sphere center
  47356. * @param sphereRadius defines the bounding sphere radius
  47357. * @param selection defines the array to store current content if selection is positive
  47358. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47359. */
  47360. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47361. /**
  47362. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  47363. * @param ray defines the ray to test with
  47364. * @param selection defines the array to store current content if selection is positive
  47365. */
  47366. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  47367. /**
  47368. * Subdivide the content into child blocks (this block will then be empty)
  47369. */
  47370. createInnerBlocks(): void;
  47371. /**
  47372. * @hidden
  47373. */
  47374. 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;
  47375. }
  47376. }
  47377. declare module "babylonjs/Culling/Octrees/octree" {
  47378. import { SmartArray } from "babylonjs/Misc/smartArray";
  47379. import { Vector3 } from "babylonjs/Maths/math.vector";
  47380. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47381. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47382. import { Ray } from "babylonjs/Culling/ray";
  47383. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  47384. import { Plane } from "babylonjs/Maths/math.plane";
  47385. /**
  47386. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  47387. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47388. */
  47389. export class Octree<T> {
  47390. /** 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.) */
  47391. maxDepth: number;
  47392. /**
  47393. * Blocks within the octree containing objects
  47394. */
  47395. blocks: Array<OctreeBlock<T>>;
  47396. /**
  47397. * Content stored in the octree
  47398. */
  47399. dynamicContent: T[];
  47400. private _maxBlockCapacity;
  47401. private _selectionContent;
  47402. private _creationFunc;
  47403. /**
  47404. * Creates a octree
  47405. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47406. * @param creationFunc function to be used to instatiate the octree
  47407. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  47408. * @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.)
  47409. */
  47410. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  47411. /** 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.) */
  47412. maxDepth?: number);
  47413. /**
  47414. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  47415. * @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);
  47416. * @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);
  47417. * @param entries meshes to be added to the octree blocks
  47418. */
  47419. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  47420. /**
  47421. * Adds a mesh to the octree
  47422. * @param entry Mesh to add to the octree
  47423. */
  47424. addMesh(entry: T): void;
  47425. /**
  47426. * Remove an element from the octree
  47427. * @param entry defines the element to remove
  47428. */
  47429. removeMesh(entry: T): void;
  47430. /**
  47431. * Selects an array of meshes within the frustum
  47432. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  47433. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  47434. * @returns array of meshes within the frustum
  47435. */
  47436. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  47437. /**
  47438. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  47439. * @param sphereCenter defines the bounding sphere center
  47440. * @param sphereRadius defines the bounding sphere radius
  47441. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47442. * @returns an array of objects that intersect the sphere
  47443. */
  47444. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  47445. /**
  47446. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  47447. * @param ray defines the ray to test with
  47448. * @returns array of intersected objects
  47449. */
  47450. intersectsRay(ray: Ray): SmartArray<T>;
  47451. /**
  47452. * Adds a mesh into the octree block if it intersects the block
  47453. */
  47454. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  47455. /**
  47456. * Adds a submesh into the octree block if it intersects the block
  47457. */
  47458. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  47459. }
  47460. }
  47461. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  47462. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47463. import { Scene } from "babylonjs/scene";
  47464. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47465. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47466. import { Ray } from "babylonjs/Culling/ray";
  47467. import { Octree } from "babylonjs/Culling/Octrees/octree";
  47468. import { Collider } from "babylonjs/Collisions/collider";
  47469. module "babylonjs/scene" {
  47470. interface Scene {
  47471. /**
  47472. * @hidden
  47473. * Backing Filed
  47474. */
  47475. _selectionOctree: Octree<AbstractMesh>;
  47476. /**
  47477. * Gets the octree used to boost mesh selection (picking)
  47478. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47479. */
  47480. selectionOctree: Octree<AbstractMesh>;
  47481. /**
  47482. * Creates or updates the octree used to boost selection (picking)
  47483. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47484. * @param maxCapacity defines the maximum capacity per leaf
  47485. * @param maxDepth defines the maximum depth of the octree
  47486. * @returns an octree of AbstractMesh
  47487. */
  47488. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  47489. }
  47490. }
  47491. module "babylonjs/Meshes/abstractMesh" {
  47492. interface AbstractMesh {
  47493. /**
  47494. * @hidden
  47495. * Backing Field
  47496. */
  47497. _submeshesOctree: Octree<SubMesh>;
  47498. /**
  47499. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  47500. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  47501. * @param maxCapacity defines the maximum size of each block (64 by default)
  47502. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  47503. * @returns the new octree
  47504. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  47505. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47506. */
  47507. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  47508. }
  47509. }
  47510. /**
  47511. * Defines the octree scene component responsible to manage any octrees
  47512. * in a given scene.
  47513. */
  47514. export class OctreeSceneComponent {
  47515. /**
  47516. * The component name help to identify the component in the list of scene components.
  47517. */
  47518. readonly name: string;
  47519. /**
  47520. * The scene the component belongs to.
  47521. */
  47522. scene: Scene;
  47523. /**
  47524. * Indicates if the meshes have been checked to make sure they are isEnabled()
  47525. */
  47526. readonly checksIsEnabled: boolean;
  47527. /**
  47528. * Creates a new instance of the component for the given scene
  47529. * @param scene Defines the scene to register the component in
  47530. */
  47531. constructor(scene: Scene);
  47532. /**
  47533. * Registers the component in a given scene
  47534. */
  47535. register(): void;
  47536. /**
  47537. * Return the list of active meshes
  47538. * @returns the list of active meshes
  47539. */
  47540. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47541. /**
  47542. * Return the list of active sub meshes
  47543. * @param mesh The mesh to get the candidates sub meshes from
  47544. * @returns the list of active sub meshes
  47545. */
  47546. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47547. private _tempRay;
  47548. /**
  47549. * Return the list of sub meshes intersecting with a given local ray
  47550. * @param mesh defines the mesh to find the submesh for
  47551. * @param localRay defines the ray in local space
  47552. * @returns the list of intersecting sub meshes
  47553. */
  47554. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  47555. /**
  47556. * Return the list of sub meshes colliding with a collider
  47557. * @param mesh defines the mesh to find the submesh for
  47558. * @param collider defines the collider to evaluate the collision against
  47559. * @returns the list of colliding sub meshes
  47560. */
  47561. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  47562. /**
  47563. * Rebuilds the elements related to this component in case of
  47564. * context lost for instance.
  47565. */
  47566. rebuild(): void;
  47567. /**
  47568. * Disposes the component and the associated ressources.
  47569. */
  47570. dispose(): void;
  47571. }
  47572. }
  47573. declare module "babylonjs/Culling/Octrees/index" {
  47574. export * from "babylonjs/Culling/Octrees/octree";
  47575. export * from "babylonjs/Culling/Octrees/octreeBlock";
  47576. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  47577. }
  47578. declare module "babylonjs/Culling/index" {
  47579. export * from "babylonjs/Culling/boundingBox";
  47580. export * from "babylonjs/Culling/boundingInfo";
  47581. export * from "babylonjs/Culling/boundingSphere";
  47582. export * from "babylonjs/Culling/Octrees/index";
  47583. export * from "babylonjs/Culling/ray";
  47584. }
  47585. declare module "babylonjs/Gizmos/gizmo" {
  47586. import { Nullable } from "babylonjs/types";
  47587. import { IDisposable } from "babylonjs/scene";
  47588. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47589. import { Mesh } from "babylonjs/Meshes/mesh";
  47590. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47591. /**
  47592. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  47593. */
  47594. export class Gizmo implements IDisposable {
  47595. /** The utility layer the gizmo will be added to */
  47596. gizmoLayer: UtilityLayerRenderer;
  47597. /**
  47598. * The root mesh of the gizmo
  47599. */
  47600. _rootMesh: Mesh;
  47601. private _attachedMesh;
  47602. /**
  47603. * Ratio for the scale of the gizmo (Default: 1)
  47604. */
  47605. scaleRatio: number;
  47606. /**
  47607. * If a custom mesh has been set (Default: false)
  47608. */
  47609. protected _customMeshSet: boolean;
  47610. /**
  47611. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  47612. * * When set, interactions will be enabled
  47613. */
  47614. get attachedMesh(): Nullable<AbstractMesh>;
  47615. set attachedMesh(value: Nullable<AbstractMesh>);
  47616. /**
  47617. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47618. * @param mesh The mesh to replace the default mesh of the gizmo
  47619. */
  47620. setCustomMesh(mesh: Mesh): void;
  47621. /**
  47622. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  47623. */
  47624. updateGizmoRotationToMatchAttachedMesh: boolean;
  47625. /**
  47626. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  47627. */
  47628. updateGizmoPositionToMatchAttachedMesh: boolean;
  47629. /**
  47630. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  47631. */
  47632. updateScale: boolean;
  47633. protected _interactionsEnabled: boolean;
  47634. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47635. private _beforeRenderObserver;
  47636. private _tempVector;
  47637. /**
  47638. * Creates a gizmo
  47639. * @param gizmoLayer The utility layer the gizmo will be added to
  47640. */
  47641. constructor(
  47642. /** The utility layer the gizmo will be added to */
  47643. gizmoLayer?: UtilityLayerRenderer);
  47644. /**
  47645. * Updates the gizmo to match the attached mesh's position/rotation
  47646. */
  47647. protected _update(): void;
  47648. /**
  47649. * Disposes of the gizmo
  47650. */
  47651. dispose(): void;
  47652. }
  47653. }
  47654. declare module "babylonjs/Gizmos/planeDragGizmo" {
  47655. import { Observable } from "babylonjs/Misc/observable";
  47656. import { Nullable } from "babylonjs/types";
  47657. import { Vector3 } from "babylonjs/Maths/math.vector";
  47658. import { Color3 } from "babylonjs/Maths/math.color";
  47659. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47660. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47661. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47662. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47663. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47664. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47665. import { Scene } from "babylonjs/scene";
  47666. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47667. /**
  47668. * Single plane drag gizmo
  47669. */
  47670. export class PlaneDragGizmo extends Gizmo {
  47671. /**
  47672. * Drag behavior responsible for the gizmos dragging interactions
  47673. */
  47674. dragBehavior: PointerDragBehavior;
  47675. private _pointerObserver;
  47676. /**
  47677. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47678. */
  47679. snapDistance: number;
  47680. /**
  47681. * Event that fires each time the gizmo snaps to a new location.
  47682. * * snapDistance is the the change in distance
  47683. */
  47684. onSnapObservable: Observable<{
  47685. snapDistance: number;
  47686. }>;
  47687. private _plane;
  47688. private _coloredMaterial;
  47689. private _hoverMaterial;
  47690. private _isEnabled;
  47691. private _parent;
  47692. /** @hidden */
  47693. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  47694. /** @hidden */
  47695. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47696. /**
  47697. * Creates a PlaneDragGizmo
  47698. * @param gizmoLayer The utility layer the gizmo will be added to
  47699. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  47700. * @param color The color of the gizmo
  47701. */
  47702. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47703. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47704. /**
  47705. * If the gizmo is enabled
  47706. */
  47707. set isEnabled(value: boolean);
  47708. get isEnabled(): boolean;
  47709. /**
  47710. * Disposes of the gizmo
  47711. */
  47712. dispose(): void;
  47713. }
  47714. }
  47715. declare module "babylonjs/Gizmos/positionGizmo" {
  47716. import { Observable } from "babylonjs/Misc/observable";
  47717. import { Nullable } from "babylonjs/types";
  47718. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47719. import { Mesh } from "babylonjs/Meshes/mesh";
  47720. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47721. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  47722. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  47723. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47724. /**
  47725. * Gizmo that enables dragging a mesh along 3 axis
  47726. */
  47727. export class PositionGizmo extends Gizmo {
  47728. /**
  47729. * Internal gizmo used for interactions on the x axis
  47730. */
  47731. xGizmo: AxisDragGizmo;
  47732. /**
  47733. * Internal gizmo used for interactions on the y axis
  47734. */
  47735. yGizmo: AxisDragGizmo;
  47736. /**
  47737. * Internal gizmo used for interactions on the z axis
  47738. */
  47739. zGizmo: AxisDragGizmo;
  47740. /**
  47741. * Internal gizmo used for interactions on the yz plane
  47742. */
  47743. xPlaneGizmo: PlaneDragGizmo;
  47744. /**
  47745. * Internal gizmo used for interactions on the xz plane
  47746. */
  47747. yPlaneGizmo: PlaneDragGizmo;
  47748. /**
  47749. * Internal gizmo used for interactions on the xy plane
  47750. */
  47751. zPlaneGizmo: PlaneDragGizmo;
  47752. /**
  47753. * private variables
  47754. */
  47755. private _meshAttached;
  47756. private _updateGizmoRotationToMatchAttachedMesh;
  47757. private _snapDistance;
  47758. private _scaleRatio;
  47759. /** Fires an event when any of it's sub gizmos are dragged */
  47760. onDragStartObservable: Observable<unknown>;
  47761. /** Fires an event when any of it's sub gizmos are released from dragging */
  47762. onDragEndObservable: Observable<unknown>;
  47763. /**
  47764. * If set to true, planar drag is enabled
  47765. */
  47766. private _planarGizmoEnabled;
  47767. get attachedMesh(): Nullable<AbstractMesh>;
  47768. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47769. /**
  47770. * Creates a PositionGizmo
  47771. * @param gizmoLayer The utility layer the gizmo will be added to
  47772. */
  47773. constructor(gizmoLayer?: UtilityLayerRenderer);
  47774. /**
  47775. * If the planar drag gizmo is enabled
  47776. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  47777. */
  47778. set planarGizmoEnabled(value: boolean);
  47779. get planarGizmoEnabled(): boolean;
  47780. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  47781. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  47782. /**
  47783. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47784. */
  47785. set snapDistance(value: number);
  47786. get snapDistance(): number;
  47787. /**
  47788. * Ratio for the scale of the gizmo (Default: 1)
  47789. */
  47790. set scaleRatio(value: number);
  47791. get scaleRatio(): number;
  47792. /**
  47793. * Disposes of the gizmo
  47794. */
  47795. dispose(): void;
  47796. /**
  47797. * CustomMeshes are not supported by this gizmo
  47798. * @param mesh The mesh to replace the default mesh of the gizmo
  47799. */
  47800. setCustomMesh(mesh: Mesh): void;
  47801. }
  47802. }
  47803. declare module "babylonjs/Gizmos/axisDragGizmo" {
  47804. import { Observable } from "babylonjs/Misc/observable";
  47805. import { Nullable } from "babylonjs/types";
  47806. import { Vector3 } from "babylonjs/Maths/math.vector";
  47807. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47808. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47809. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47810. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47811. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47812. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47813. import { Scene } from "babylonjs/scene";
  47814. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47815. import { Color3 } from "babylonjs/Maths/math.color";
  47816. /**
  47817. * Single axis drag gizmo
  47818. */
  47819. export class AxisDragGizmo extends Gizmo {
  47820. /**
  47821. * Drag behavior responsible for the gizmos dragging interactions
  47822. */
  47823. dragBehavior: PointerDragBehavior;
  47824. private _pointerObserver;
  47825. /**
  47826. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47827. */
  47828. snapDistance: number;
  47829. /**
  47830. * Event that fires each time the gizmo snaps to a new location.
  47831. * * snapDistance is the the change in distance
  47832. */
  47833. onSnapObservable: Observable<{
  47834. snapDistance: number;
  47835. }>;
  47836. private _isEnabled;
  47837. private _parent;
  47838. private _arrow;
  47839. private _coloredMaterial;
  47840. private _hoverMaterial;
  47841. /** @hidden */
  47842. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  47843. /** @hidden */
  47844. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47845. /**
  47846. * Creates an AxisDragGizmo
  47847. * @param gizmoLayer The utility layer the gizmo will be added to
  47848. * @param dragAxis The axis which the gizmo will be able to drag on
  47849. * @param color The color of the gizmo
  47850. */
  47851. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47852. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47853. /**
  47854. * If the gizmo is enabled
  47855. */
  47856. set isEnabled(value: boolean);
  47857. get isEnabled(): boolean;
  47858. /**
  47859. * Disposes of the gizmo
  47860. */
  47861. dispose(): void;
  47862. }
  47863. }
  47864. declare module "babylonjs/Debug/axesViewer" {
  47865. import { Vector3 } from "babylonjs/Maths/math.vector";
  47866. import { Nullable } from "babylonjs/types";
  47867. import { Scene } from "babylonjs/scene";
  47868. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47869. /**
  47870. * The Axes viewer will show 3 axes in a specific point in space
  47871. */
  47872. export class AxesViewer {
  47873. private _xAxis;
  47874. private _yAxis;
  47875. private _zAxis;
  47876. private _scaleLinesFactor;
  47877. private _instanced;
  47878. /**
  47879. * Gets the hosting scene
  47880. */
  47881. scene: Scene;
  47882. /**
  47883. * Gets or sets a number used to scale line length
  47884. */
  47885. scaleLines: number;
  47886. /** Gets the node hierarchy used to render x-axis */
  47887. get xAxis(): TransformNode;
  47888. /** Gets the node hierarchy used to render y-axis */
  47889. get yAxis(): TransformNode;
  47890. /** Gets the node hierarchy used to render z-axis */
  47891. get zAxis(): TransformNode;
  47892. /**
  47893. * Creates a new AxesViewer
  47894. * @param scene defines the hosting scene
  47895. * @param scaleLines defines a number used to scale line length (1 by default)
  47896. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  47897. * @param xAxis defines the node hierarchy used to render the x-axis
  47898. * @param yAxis defines the node hierarchy used to render the y-axis
  47899. * @param zAxis defines the node hierarchy used to render the z-axis
  47900. */
  47901. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  47902. /**
  47903. * Force the viewer to update
  47904. * @param position defines the position of the viewer
  47905. * @param xaxis defines the x axis of the viewer
  47906. * @param yaxis defines the y axis of the viewer
  47907. * @param zaxis defines the z axis of the viewer
  47908. */
  47909. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  47910. /**
  47911. * Creates an instance of this axes viewer.
  47912. * @returns a new axes viewer with instanced meshes
  47913. */
  47914. createInstance(): AxesViewer;
  47915. /** Releases resources */
  47916. dispose(): void;
  47917. private static _SetRenderingGroupId;
  47918. }
  47919. }
  47920. declare module "babylonjs/Debug/boneAxesViewer" {
  47921. import { Nullable } from "babylonjs/types";
  47922. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  47923. import { Vector3 } from "babylonjs/Maths/math.vector";
  47924. import { Mesh } from "babylonjs/Meshes/mesh";
  47925. import { Bone } from "babylonjs/Bones/bone";
  47926. import { Scene } from "babylonjs/scene";
  47927. /**
  47928. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  47929. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  47930. */
  47931. export class BoneAxesViewer extends AxesViewer {
  47932. /**
  47933. * Gets or sets the target mesh where to display the axes viewer
  47934. */
  47935. mesh: Nullable<Mesh>;
  47936. /**
  47937. * Gets or sets the target bone where to display the axes viewer
  47938. */
  47939. bone: Nullable<Bone>;
  47940. /** Gets current position */
  47941. pos: Vector3;
  47942. /** Gets direction of X axis */
  47943. xaxis: Vector3;
  47944. /** Gets direction of Y axis */
  47945. yaxis: Vector3;
  47946. /** Gets direction of Z axis */
  47947. zaxis: Vector3;
  47948. /**
  47949. * Creates a new BoneAxesViewer
  47950. * @param scene defines the hosting scene
  47951. * @param bone defines the target bone
  47952. * @param mesh defines the target mesh
  47953. * @param scaleLines defines a scaling factor for line length (1 by default)
  47954. */
  47955. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  47956. /**
  47957. * Force the viewer to update
  47958. */
  47959. update(): void;
  47960. /** Releases resources */
  47961. dispose(): void;
  47962. }
  47963. }
  47964. declare module "babylonjs/Debug/debugLayer" {
  47965. import { Scene } from "babylonjs/scene";
  47966. /**
  47967. * Interface used to define scene explorer extensibility option
  47968. */
  47969. export interface IExplorerExtensibilityOption {
  47970. /**
  47971. * Define the option label
  47972. */
  47973. label: string;
  47974. /**
  47975. * Defines the action to execute on click
  47976. */
  47977. action: (entity: any) => void;
  47978. }
  47979. /**
  47980. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  47981. */
  47982. export interface IExplorerExtensibilityGroup {
  47983. /**
  47984. * Defines a predicate to test if a given type mut be extended
  47985. */
  47986. predicate: (entity: any) => boolean;
  47987. /**
  47988. * Gets the list of options added to a type
  47989. */
  47990. entries: IExplorerExtensibilityOption[];
  47991. }
  47992. /**
  47993. * Interface used to define the options to use to create the Inspector
  47994. */
  47995. export interface IInspectorOptions {
  47996. /**
  47997. * Display in overlay mode (default: false)
  47998. */
  47999. overlay?: boolean;
  48000. /**
  48001. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  48002. */
  48003. globalRoot?: HTMLElement;
  48004. /**
  48005. * Display the Scene explorer
  48006. */
  48007. showExplorer?: boolean;
  48008. /**
  48009. * Display the property inspector
  48010. */
  48011. showInspector?: boolean;
  48012. /**
  48013. * Display in embed mode (both panes on the right)
  48014. */
  48015. embedMode?: boolean;
  48016. /**
  48017. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  48018. */
  48019. handleResize?: boolean;
  48020. /**
  48021. * Allow the panes to popup (default: true)
  48022. */
  48023. enablePopup?: boolean;
  48024. /**
  48025. * Allow the panes to be closed by users (default: true)
  48026. */
  48027. enableClose?: boolean;
  48028. /**
  48029. * Optional list of extensibility entries
  48030. */
  48031. explorerExtensibility?: IExplorerExtensibilityGroup[];
  48032. /**
  48033. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  48034. */
  48035. inspectorURL?: string;
  48036. /**
  48037. * Optional initial tab (default to DebugLayerTab.Properties)
  48038. */
  48039. initialTab?: DebugLayerTab;
  48040. }
  48041. module "babylonjs/scene" {
  48042. interface Scene {
  48043. /**
  48044. * @hidden
  48045. * Backing field
  48046. */
  48047. _debugLayer: DebugLayer;
  48048. /**
  48049. * Gets the debug layer (aka Inspector) associated with the scene
  48050. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48051. */
  48052. debugLayer: DebugLayer;
  48053. }
  48054. }
  48055. /**
  48056. * Enum of inspector action tab
  48057. */
  48058. export enum DebugLayerTab {
  48059. /**
  48060. * Properties tag (default)
  48061. */
  48062. Properties = 0,
  48063. /**
  48064. * Debug tab
  48065. */
  48066. Debug = 1,
  48067. /**
  48068. * Statistics tab
  48069. */
  48070. Statistics = 2,
  48071. /**
  48072. * Tools tab
  48073. */
  48074. Tools = 3,
  48075. /**
  48076. * Settings tab
  48077. */
  48078. Settings = 4
  48079. }
  48080. /**
  48081. * The debug layer (aka Inspector) is the go to tool in order to better understand
  48082. * what is happening in your scene
  48083. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48084. */
  48085. export class DebugLayer {
  48086. /**
  48087. * Define the url to get the inspector script from.
  48088. * By default it uses the babylonjs CDN.
  48089. * @ignoreNaming
  48090. */
  48091. static InspectorURL: string;
  48092. private _scene;
  48093. private BJSINSPECTOR;
  48094. private _onPropertyChangedObservable?;
  48095. /**
  48096. * Observable triggered when a property is changed through the inspector.
  48097. */
  48098. get onPropertyChangedObservable(): any;
  48099. /**
  48100. * Instantiates a new debug layer.
  48101. * The debug layer (aka Inspector) is the go to tool in order to better understand
  48102. * what is happening in your scene
  48103. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48104. * @param scene Defines the scene to inspect
  48105. */
  48106. constructor(scene: Scene);
  48107. /** Creates the inspector window. */
  48108. private _createInspector;
  48109. /**
  48110. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  48111. * @param entity defines the entity to select
  48112. * @param lineContainerTitle defines the specific block to highlight
  48113. */
  48114. select(entity: any, lineContainerTitle?: string): void;
  48115. /** Get the inspector from bundle or global */
  48116. private _getGlobalInspector;
  48117. /**
  48118. * Get if the inspector is visible or not.
  48119. * @returns true if visible otherwise, false
  48120. */
  48121. isVisible(): boolean;
  48122. /**
  48123. * Hide the inspector and close its window.
  48124. */
  48125. hide(): void;
  48126. /**
  48127. * Launch the debugLayer.
  48128. * @param config Define the configuration of the inspector
  48129. * @return a promise fulfilled when the debug layer is visible
  48130. */
  48131. show(config?: IInspectorOptions): Promise<DebugLayer>;
  48132. }
  48133. }
  48134. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  48135. import { Nullable } from "babylonjs/types";
  48136. import { Scene } from "babylonjs/scene";
  48137. import { Vector4 } from "babylonjs/Maths/math.vector";
  48138. import { Color4 } from "babylonjs/Maths/math.color";
  48139. import { Mesh } from "babylonjs/Meshes/mesh";
  48140. /**
  48141. * Class containing static functions to help procedurally build meshes
  48142. */
  48143. export class BoxBuilder {
  48144. /**
  48145. * Creates a box mesh
  48146. * * The parameter `size` sets the size (float) of each box side (default 1)
  48147. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  48148. * * 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)
  48149. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  48150. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48151. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48153. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  48154. * @param name defines the name of the mesh
  48155. * @param options defines the options used to create the mesh
  48156. * @param scene defines the hosting scene
  48157. * @returns the box mesh
  48158. */
  48159. static CreateBox(name: string, options: {
  48160. size?: number;
  48161. width?: number;
  48162. height?: number;
  48163. depth?: number;
  48164. faceUV?: Vector4[];
  48165. faceColors?: Color4[];
  48166. sideOrientation?: number;
  48167. frontUVs?: Vector4;
  48168. backUVs?: Vector4;
  48169. wrap?: boolean;
  48170. topBaseAt?: number;
  48171. bottomBaseAt?: number;
  48172. updatable?: boolean;
  48173. }, scene?: Nullable<Scene>): Mesh;
  48174. }
  48175. }
  48176. declare module "babylonjs/Debug/physicsViewer" {
  48177. import { Nullable } from "babylonjs/types";
  48178. import { Scene } from "babylonjs/scene";
  48179. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48180. import { Mesh } from "babylonjs/Meshes/mesh";
  48181. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48182. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48183. /**
  48184. * Used to show the physics impostor around the specific mesh
  48185. */
  48186. export class PhysicsViewer {
  48187. /** @hidden */
  48188. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  48189. /** @hidden */
  48190. protected _meshes: Array<Nullable<AbstractMesh>>;
  48191. /** @hidden */
  48192. protected _scene: Nullable<Scene>;
  48193. /** @hidden */
  48194. protected _numMeshes: number;
  48195. /** @hidden */
  48196. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  48197. private _renderFunction;
  48198. private _utilityLayer;
  48199. private _debugBoxMesh;
  48200. private _debugSphereMesh;
  48201. private _debugCylinderMesh;
  48202. private _debugMaterial;
  48203. private _debugMeshMeshes;
  48204. /**
  48205. * Creates a new PhysicsViewer
  48206. * @param scene defines the hosting scene
  48207. */
  48208. constructor(scene: Scene);
  48209. /** @hidden */
  48210. protected _updateDebugMeshes(): void;
  48211. /**
  48212. * Renders a specified physic impostor
  48213. * @param impostor defines the impostor to render
  48214. * @param targetMesh defines the mesh represented by the impostor
  48215. * @returns the new debug mesh used to render the impostor
  48216. */
  48217. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  48218. /**
  48219. * Hides a specified physic impostor
  48220. * @param impostor defines the impostor to hide
  48221. */
  48222. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  48223. private _getDebugMaterial;
  48224. private _getDebugBoxMesh;
  48225. private _getDebugSphereMesh;
  48226. private _getDebugCylinderMesh;
  48227. private _getDebugMeshMesh;
  48228. private _getDebugMesh;
  48229. /** Releases all resources */
  48230. dispose(): void;
  48231. }
  48232. }
  48233. declare module "babylonjs/Debug/rayHelper" {
  48234. import { Nullable } from "babylonjs/types";
  48235. import { Ray } from "babylonjs/Culling/ray";
  48236. import { Vector3 } from "babylonjs/Maths/math.vector";
  48237. import { Color3 } from "babylonjs/Maths/math.color";
  48238. import { Scene } from "babylonjs/scene";
  48239. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48240. import "babylonjs/Meshes/Builders/linesBuilder";
  48241. /**
  48242. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48243. * in order to better appreciate the issue one might have.
  48244. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48245. */
  48246. export class RayHelper {
  48247. /**
  48248. * Defines the ray we are currently tryin to visualize.
  48249. */
  48250. ray: Nullable<Ray>;
  48251. private _renderPoints;
  48252. private _renderLine;
  48253. private _renderFunction;
  48254. private _scene;
  48255. private _updateToMeshFunction;
  48256. private _attachedToMesh;
  48257. private _meshSpaceDirection;
  48258. private _meshSpaceOrigin;
  48259. /**
  48260. * Helper function to create a colored helper in a scene in one line.
  48261. * @param ray Defines the ray we are currently tryin to visualize
  48262. * @param scene Defines the scene the ray is used in
  48263. * @param color Defines the color we want to see the ray in
  48264. * @returns The newly created ray helper.
  48265. */
  48266. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  48267. /**
  48268. * Instantiate a new ray helper.
  48269. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48270. * in order to better appreciate the issue one might have.
  48271. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48272. * @param ray Defines the ray we are currently tryin to visualize
  48273. */
  48274. constructor(ray: Ray);
  48275. /**
  48276. * Shows the ray we are willing to debug.
  48277. * @param scene Defines the scene the ray needs to be rendered in
  48278. * @param color Defines the color the ray needs to be rendered in
  48279. */
  48280. show(scene: Scene, color?: Color3): void;
  48281. /**
  48282. * Hides the ray we are debugging.
  48283. */
  48284. hide(): void;
  48285. private _render;
  48286. /**
  48287. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  48288. * @param mesh Defines the mesh we want the helper attached to
  48289. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  48290. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  48291. * @param length Defines the length of the ray
  48292. */
  48293. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  48294. /**
  48295. * Detach the ray helper from the mesh it has previously been attached to.
  48296. */
  48297. detachFromMesh(): void;
  48298. private _updateToMesh;
  48299. /**
  48300. * Dispose the helper and release its associated resources.
  48301. */
  48302. dispose(): void;
  48303. }
  48304. }
  48305. declare module "babylonjs/Debug/skeletonViewer" {
  48306. import { Color3 } from "babylonjs/Maths/math.color";
  48307. import { Scene } from "babylonjs/scene";
  48308. import { Nullable } from "babylonjs/types";
  48309. import { Skeleton } from "babylonjs/Bones/skeleton";
  48310. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48311. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  48312. /**
  48313. * Class used to render a debug view of a given skeleton
  48314. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  48315. */
  48316. export class SkeletonViewer {
  48317. /** defines the skeleton to render */
  48318. skeleton: Skeleton;
  48319. /** defines the mesh attached to the skeleton */
  48320. mesh: AbstractMesh;
  48321. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48322. autoUpdateBonesMatrices: boolean;
  48323. /** defines the rendering group id to use with the viewer */
  48324. renderingGroupId: number;
  48325. /** Gets or sets the color used to render the skeleton */
  48326. color: Color3;
  48327. private _scene;
  48328. private _debugLines;
  48329. private _debugMesh;
  48330. private _isEnabled;
  48331. private _renderFunction;
  48332. private _utilityLayer;
  48333. /**
  48334. * Returns the mesh used to render the bones
  48335. */
  48336. get debugMesh(): Nullable<LinesMesh>;
  48337. /**
  48338. * Creates a new SkeletonViewer
  48339. * @param skeleton defines the skeleton to render
  48340. * @param mesh defines the mesh attached to the skeleton
  48341. * @param scene defines the hosting scene
  48342. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  48343. * @param renderingGroupId defines the rendering group id to use with the viewer
  48344. */
  48345. constructor(
  48346. /** defines the skeleton to render */
  48347. skeleton: Skeleton,
  48348. /** defines the mesh attached to the skeleton */
  48349. mesh: AbstractMesh, scene: Scene,
  48350. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48351. autoUpdateBonesMatrices?: boolean,
  48352. /** defines the rendering group id to use with the viewer */
  48353. renderingGroupId?: number);
  48354. /** Gets or sets a boolean indicating if the viewer is enabled */
  48355. set isEnabled(value: boolean);
  48356. get isEnabled(): boolean;
  48357. private _getBonePosition;
  48358. private _getLinesForBonesWithLength;
  48359. private _getLinesForBonesNoLength;
  48360. /** Update the viewer to sync with current skeleton state */
  48361. update(): void;
  48362. /** Release associated resources */
  48363. dispose(): void;
  48364. }
  48365. }
  48366. declare module "babylonjs/Debug/index" {
  48367. export * from "babylonjs/Debug/axesViewer";
  48368. export * from "babylonjs/Debug/boneAxesViewer";
  48369. export * from "babylonjs/Debug/debugLayer";
  48370. export * from "babylonjs/Debug/physicsViewer";
  48371. export * from "babylonjs/Debug/rayHelper";
  48372. export * from "babylonjs/Debug/skeletonViewer";
  48373. }
  48374. declare module "babylonjs/Engines/nullEngine" {
  48375. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  48376. import { Engine } from "babylonjs/Engines/engine";
  48377. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48378. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48379. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48380. import { Effect } from "babylonjs/Materials/effect";
  48381. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48382. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48383. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  48384. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  48385. /**
  48386. * Options to create the null engine
  48387. */
  48388. export class NullEngineOptions {
  48389. /**
  48390. * Render width (Default: 512)
  48391. */
  48392. renderWidth: number;
  48393. /**
  48394. * Render height (Default: 256)
  48395. */
  48396. renderHeight: number;
  48397. /**
  48398. * Texture size (Default: 512)
  48399. */
  48400. textureSize: number;
  48401. /**
  48402. * If delta time between frames should be constant
  48403. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48404. */
  48405. deterministicLockstep: boolean;
  48406. /**
  48407. * Maximum about of steps between frames (Default: 4)
  48408. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48409. */
  48410. lockstepMaxSteps: number;
  48411. }
  48412. /**
  48413. * The null engine class provides support for headless version of babylon.js.
  48414. * This can be used in server side scenario or for testing purposes
  48415. */
  48416. export class NullEngine extends Engine {
  48417. private _options;
  48418. /**
  48419. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  48420. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48421. * @returns true if engine is in deterministic lock step mode
  48422. */
  48423. isDeterministicLockStep(): boolean;
  48424. /**
  48425. * Gets the max steps when engine is running in deterministic lock step
  48426. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48427. * @returns the max steps
  48428. */
  48429. getLockstepMaxSteps(): number;
  48430. /**
  48431. * Gets the current hardware scaling level.
  48432. * By default the hardware scaling level is computed from the window device ratio.
  48433. * 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.
  48434. * @returns a number indicating the current hardware scaling level
  48435. */
  48436. getHardwareScalingLevel(): number;
  48437. constructor(options?: NullEngineOptions);
  48438. /**
  48439. * Creates a vertex buffer
  48440. * @param vertices the data for the vertex buffer
  48441. * @returns the new WebGL static buffer
  48442. */
  48443. createVertexBuffer(vertices: FloatArray): DataBuffer;
  48444. /**
  48445. * Creates a new index buffer
  48446. * @param indices defines the content of the index buffer
  48447. * @param updatable defines if the index buffer must be updatable
  48448. * @returns a new webGL buffer
  48449. */
  48450. createIndexBuffer(indices: IndicesArray): DataBuffer;
  48451. /**
  48452. * Clear the current render buffer or the current render target (if any is set up)
  48453. * @param color defines the color to use
  48454. * @param backBuffer defines if the back buffer must be cleared
  48455. * @param depth defines if the depth buffer must be cleared
  48456. * @param stencil defines if the stencil buffer must be cleared
  48457. */
  48458. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48459. /**
  48460. * Gets the current render width
  48461. * @param useScreen defines if screen size must be used (or the current render target if any)
  48462. * @returns a number defining the current render width
  48463. */
  48464. getRenderWidth(useScreen?: boolean): number;
  48465. /**
  48466. * Gets the current render height
  48467. * @param useScreen defines if screen size must be used (or the current render target if any)
  48468. * @returns a number defining the current render height
  48469. */
  48470. getRenderHeight(useScreen?: boolean): number;
  48471. /**
  48472. * Set the WebGL's viewport
  48473. * @param viewport defines the viewport element to be used
  48474. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  48475. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  48476. */
  48477. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  48478. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  48479. /**
  48480. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  48481. * @param pipelineContext defines the pipeline context to use
  48482. * @param uniformsNames defines the list of uniform names
  48483. * @returns an array of webGL uniform locations
  48484. */
  48485. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  48486. /**
  48487. * Gets the lsit of active attributes for a given webGL program
  48488. * @param pipelineContext defines the pipeline context to use
  48489. * @param attributesNames defines the list of attribute names to get
  48490. * @returns an array of indices indicating the offset of each attribute
  48491. */
  48492. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48493. /**
  48494. * Binds an effect to the webGL context
  48495. * @param effect defines the effect to bind
  48496. */
  48497. bindSamplers(effect: Effect): void;
  48498. /**
  48499. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  48500. * @param effect defines the effect to activate
  48501. */
  48502. enableEffect(effect: Effect): void;
  48503. /**
  48504. * Set various states to the webGL context
  48505. * @param culling defines backface culling state
  48506. * @param zOffset defines the value to apply to zOffset (0 by default)
  48507. * @param force defines if states must be applied even if cache is up to date
  48508. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  48509. */
  48510. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48511. /**
  48512. * Set the value of an uniform to an array of int32
  48513. * @param uniform defines the webGL uniform location where to store the value
  48514. * @param array defines the array of int32 to store
  48515. */
  48516. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48517. /**
  48518. * Set the value of an uniform to an array of int32 (stored as vec2)
  48519. * @param uniform defines the webGL uniform location where to store the value
  48520. * @param array defines the array of int32 to store
  48521. */
  48522. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48523. /**
  48524. * Set the value of an uniform to an array of int32 (stored as vec3)
  48525. * @param uniform defines the webGL uniform location where to store the value
  48526. * @param array defines the array of int32 to store
  48527. */
  48528. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48529. /**
  48530. * Set the value of an uniform to an array of int32 (stored as vec4)
  48531. * @param uniform defines the webGL uniform location where to store the value
  48532. * @param array defines the array of int32 to store
  48533. */
  48534. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48535. /**
  48536. * Set the value of an uniform to an array of float32
  48537. * @param uniform defines the webGL uniform location where to store the value
  48538. * @param array defines the array of float32 to store
  48539. */
  48540. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48541. /**
  48542. * Set the value of an uniform to an array of float32 (stored as vec2)
  48543. * @param uniform defines the webGL uniform location where to store the value
  48544. * @param array defines the array of float32 to store
  48545. */
  48546. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48547. /**
  48548. * Set the value of an uniform to an array of float32 (stored as vec3)
  48549. * @param uniform defines the webGL uniform location where to store the value
  48550. * @param array defines the array of float32 to store
  48551. */
  48552. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48553. /**
  48554. * Set the value of an uniform to an array of float32 (stored as vec4)
  48555. * @param uniform defines the webGL uniform location where to store the value
  48556. * @param array defines the array of float32 to store
  48557. */
  48558. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48559. /**
  48560. * Set the value of an uniform to an array of number
  48561. * @param uniform defines the webGL uniform location where to store the value
  48562. * @param array defines the array of number to store
  48563. */
  48564. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48565. /**
  48566. * Set the value of an uniform to an array of number (stored as vec2)
  48567. * @param uniform defines the webGL uniform location where to store the value
  48568. * @param array defines the array of number to store
  48569. */
  48570. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48571. /**
  48572. * Set the value of an uniform to an array of number (stored as vec3)
  48573. * @param uniform defines the webGL uniform location where to store the value
  48574. * @param array defines the array of number to store
  48575. */
  48576. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48577. /**
  48578. * Set the value of an uniform to an array of number (stored as vec4)
  48579. * @param uniform defines the webGL uniform location where to store the value
  48580. * @param array defines the array of number to store
  48581. */
  48582. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48583. /**
  48584. * Set the value of an uniform to an array of float32 (stored as matrices)
  48585. * @param uniform defines the webGL uniform location where to store the value
  48586. * @param matrices defines the array of float32 to store
  48587. */
  48588. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48589. /**
  48590. * Set the value of an uniform to a matrix (3x3)
  48591. * @param uniform defines the webGL uniform location where to store the value
  48592. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  48593. */
  48594. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48595. /**
  48596. * Set the value of an uniform to a matrix (2x2)
  48597. * @param uniform defines the webGL uniform location where to store the value
  48598. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  48599. */
  48600. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48601. /**
  48602. * Set the value of an uniform to a number (float)
  48603. * @param uniform defines the webGL uniform location where to store the value
  48604. * @param value defines the float number to store
  48605. */
  48606. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48607. /**
  48608. * Set the value of an uniform to a vec2
  48609. * @param uniform defines the webGL uniform location where to store the value
  48610. * @param x defines the 1st component of the value
  48611. * @param y defines the 2nd component of the value
  48612. */
  48613. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48614. /**
  48615. * Set the value of an uniform to a vec3
  48616. * @param uniform defines the webGL uniform location where to store the value
  48617. * @param x defines the 1st component of the value
  48618. * @param y defines the 2nd component of the value
  48619. * @param z defines the 3rd component of the value
  48620. */
  48621. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48622. /**
  48623. * Set the value of an uniform to a boolean
  48624. * @param uniform defines the webGL uniform location where to store the value
  48625. * @param bool defines the boolean to store
  48626. */
  48627. setBool(uniform: WebGLUniformLocation, bool: number): void;
  48628. /**
  48629. * Set the value of an uniform to a vec4
  48630. * @param uniform defines the webGL uniform location where to store the value
  48631. * @param x defines the 1st component of the value
  48632. * @param y defines the 2nd component of the value
  48633. * @param z defines the 3rd component of the value
  48634. * @param w defines the 4th component of the value
  48635. */
  48636. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48637. /**
  48638. * Sets the current alpha mode
  48639. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  48640. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48641. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48642. */
  48643. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48644. /**
  48645. * Bind webGl buffers directly to the webGL context
  48646. * @param vertexBuffers defines the vertex buffer to bind
  48647. * @param indexBuffer defines the index buffer to bind
  48648. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  48649. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  48650. * @param effect defines the effect associated with the vertex buffer
  48651. */
  48652. bindBuffers(vertexBuffers: {
  48653. [key: string]: VertexBuffer;
  48654. }, indexBuffer: DataBuffer, effect: Effect): void;
  48655. /**
  48656. * Force the entire cache to be cleared
  48657. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  48658. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  48659. */
  48660. wipeCaches(bruteForce?: boolean): void;
  48661. /**
  48662. * Send a draw order
  48663. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  48664. * @param indexStart defines the starting index
  48665. * @param indexCount defines the number of index to draw
  48666. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48667. */
  48668. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  48669. /**
  48670. * Draw a list of indexed primitives
  48671. * @param fillMode defines the primitive to use
  48672. * @param indexStart defines the starting index
  48673. * @param indexCount defines the number of index to draw
  48674. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48675. */
  48676. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48677. /**
  48678. * Draw a list of unindexed primitives
  48679. * @param fillMode defines the primitive to use
  48680. * @param verticesStart defines the index of first vertex to draw
  48681. * @param verticesCount defines the count of vertices to draw
  48682. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48683. */
  48684. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48685. /** @hidden */
  48686. _createTexture(): WebGLTexture;
  48687. /** @hidden */
  48688. _releaseTexture(texture: InternalTexture): void;
  48689. /**
  48690. * Usually called from Texture.ts.
  48691. * Passed information to create a WebGLTexture
  48692. * @param urlArg defines a value which contains one of the following:
  48693. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48694. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48695. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48696. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48697. * @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)
  48698. * @param scene needed for loading to the correct scene
  48699. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48700. * @param onLoad optional callback to be called upon successful completion
  48701. * @param onError optional callback to be called upon failure
  48702. * @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
  48703. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48704. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48705. * @param forcedExtension defines the extension to use to pick the right loader
  48706. * @param mimeType defines an optional mime type
  48707. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48708. */
  48709. 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;
  48710. /**
  48711. * Creates a new render target texture
  48712. * @param size defines the size of the texture
  48713. * @param options defines the options used to create the texture
  48714. * @returns a new render target texture stored in an InternalTexture
  48715. */
  48716. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  48717. /**
  48718. * Update the sampling mode of a given texture
  48719. * @param samplingMode defines the required sampling mode
  48720. * @param texture defines the texture to update
  48721. */
  48722. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48723. /**
  48724. * Binds the frame buffer to the specified texture.
  48725. * @param texture The texture to render to or null for the default canvas
  48726. * @param faceIndex The face of the texture to render to in case of cube texture
  48727. * @param requiredWidth The width of the target to render to
  48728. * @param requiredHeight The height of the target to render to
  48729. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  48730. * @param lodLevel defines le lod level to bind to the frame buffer
  48731. */
  48732. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48733. /**
  48734. * Unbind the current render target texture from the webGL context
  48735. * @param texture defines the render target texture to unbind
  48736. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48737. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48738. */
  48739. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48740. /**
  48741. * Creates a dynamic vertex buffer
  48742. * @param vertices the data for the dynamic vertex buffer
  48743. * @returns the new WebGL dynamic buffer
  48744. */
  48745. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  48746. /**
  48747. * Update the content of a dynamic texture
  48748. * @param texture defines the texture to update
  48749. * @param canvas defines the canvas containing the source
  48750. * @param invertY defines if data must be stored with Y axis inverted
  48751. * @param premulAlpha defines if alpha is stored as premultiplied
  48752. * @param format defines the format of the data
  48753. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  48754. */
  48755. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  48756. /**
  48757. * Gets a boolean indicating if all created effects are ready
  48758. * @returns true if all effects are ready
  48759. */
  48760. areAllEffectsReady(): boolean;
  48761. /**
  48762. * @hidden
  48763. * Get the current error code of the webGL context
  48764. * @returns the error code
  48765. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  48766. */
  48767. getError(): number;
  48768. /** @hidden */
  48769. _getUnpackAlignement(): number;
  48770. /** @hidden */
  48771. _unpackFlipY(value: boolean): void;
  48772. /**
  48773. * Update a dynamic index buffer
  48774. * @param indexBuffer defines the target index buffer
  48775. * @param indices defines the data to update
  48776. * @param offset defines the offset in the target index buffer where update should start
  48777. */
  48778. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  48779. /**
  48780. * Updates a dynamic vertex buffer.
  48781. * @param vertexBuffer the vertex buffer to update
  48782. * @param vertices the data used to update the vertex buffer
  48783. * @param byteOffset the byte offset of the data (optional)
  48784. * @param byteLength the byte length of the data (optional)
  48785. */
  48786. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  48787. /** @hidden */
  48788. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  48789. /** @hidden */
  48790. _bindTexture(channel: number, texture: InternalTexture): void;
  48791. protected _deleteBuffer(buffer: WebGLBuffer): void;
  48792. /**
  48793. * 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
  48794. */
  48795. releaseEffects(): void;
  48796. displayLoadingUI(): void;
  48797. hideLoadingUI(): void;
  48798. /** @hidden */
  48799. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48800. /** @hidden */
  48801. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48802. /** @hidden */
  48803. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48804. /** @hidden */
  48805. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48806. }
  48807. }
  48808. declare module "babylonjs/Instrumentation/timeToken" {
  48809. import { Nullable } from "babylonjs/types";
  48810. /**
  48811. * @hidden
  48812. **/
  48813. export class _TimeToken {
  48814. _startTimeQuery: Nullable<WebGLQuery>;
  48815. _endTimeQuery: Nullable<WebGLQuery>;
  48816. _timeElapsedQuery: Nullable<WebGLQuery>;
  48817. _timeElapsedQueryEnded: boolean;
  48818. }
  48819. }
  48820. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  48821. import { Nullable, int } from "babylonjs/types";
  48822. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  48823. /** @hidden */
  48824. export class _OcclusionDataStorage {
  48825. /** @hidden */
  48826. occlusionInternalRetryCounter: number;
  48827. /** @hidden */
  48828. isOcclusionQueryInProgress: boolean;
  48829. /** @hidden */
  48830. isOccluded: boolean;
  48831. /** @hidden */
  48832. occlusionRetryCount: number;
  48833. /** @hidden */
  48834. occlusionType: number;
  48835. /** @hidden */
  48836. occlusionQueryAlgorithmType: number;
  48837. }
  48838. module "babylonjs/Engines/engine" {
  48839. interface Engine {
  48840. /**
  48841. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  48842. * @return the new query
  48843. */
  48844. createQuery(): WebGLQuery;
  48845. /**
  48846. * Delete and release a webGL query
  48847. * @param query defines the query to delete
  48848. * @return the current engine
  48849. */
  48850. deleteQuery(query: WebGLQuery): Engine;
  48851. /**
  48852. * Check if a given query has resolved and got its value
  48853. * @param query defines the query to check
  48854. * @returns true if the query got its value
  48855. */
  48856. isQueryResultAvailable(query: WebGLQuery): boolean;
  48857. /**
  48858. * Gets the value of a given query
  48859. * @param query defines the query to check
  48860. * @returns the value of the query
  48861. */
  48862. getQueryResult(query: WebGLQuery): number;
  48863. /**
  48864. * Initiates an occlusion query
  48865. * @param algorithmType defines the algorithm to use
  48866. * @param query defines the query to use
  48867. * @returns the current engine
  48868. * @see http://doc.babylonjs.com/features/occlusionquery
  48869. */
  48870. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  48871. /**
  48872. * Ends an occlusion query
  48873. * @see http://doc.babylonjs.com/features/occlusionquery
  48874. * @param algorithmType defines the algorithm to use
  48875. * @returns the current engine
  48876. */
  48877. endOcclusionQuery(algorithmType: number): Engine;
  48878. /**
  48879. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  48880. * Please note that only one query can be issued at a time
  48881. * @returns a time token used to track the time span
  48882. */
  48883. startTimeQuery(): Nullable<_TimeToken>;
  48884. /**
  48885. * Ends a time query
  48886. * @param token defines the token used to measure the time span
  48887. * @returns the time spent (in ns)
  48888. */
  48889. endTimeQuery(token: _TimeToken): int;
  48890. /** @hidden */
  48891. _currentNonTimestampToken: Nullable<_TimeToken>;
  48892. /** @hidden */
  48893. _createTimeQuery(): WebGLQuery;
  48894. /** @hidden */
  48895. _deleteTimeQuery(query: WebGLQuery): void;
  48896. /** @hidden */
  48897. _getGlAlgorithmType(algorithmType: number): number;
  48898. /** @hidden */
  48899. _getTimeQueryResult(query: WebGLQuery): any;
  48900. /** @hidden */
  48901. _getTimeQueryAvailability(query: WebGLQuery): any;
  48902. }
  48903. }
  48904. module "babylonjs/Meshes/abstractMesh" {
  48905. interface AbstractMesh {
  48906. /**
  48907. * Backing filed
  48908. * @hidden
  48909. */
  48910. __occlusionDataStorage: _OcclusionDataStorage;
  48911. /**
  48912. * Access property
  48913. * @hidden
  48914. */
  48915. _occlusionDataStorage: _OcclusionDataStorage;
  48916. /**
  48917. * 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.
  48918. * The default value is -1 which means don't break the query and wait till the result
  48919. * @see http://doc.babylonjs.com/features/occlusionquery
  48920. */
  48921. occlusionRetryCount: number;
  48922. /**
  48923. * 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:
  48924. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  48925. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  48926. * * 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.
  48927. * @see http://doc.babylonjs.com/features/occlusionquery
  48928. */
  48929. occlusionType: number;
  48930. /**
  48931. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  48932. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  48933. * * 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.
  48934. * @see http://doc.babylonjs.com/features/occlusionquery
  48935. */
  48936. occlusionQueryAlgorithmType: number;
  48937. /**
  48938. * 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
  48939. * @see http://doc.babylonjs.com/features/occlusionquery
  48940. */
  48941. isOccluded: boolean;
  48942. /**
  48943. * Flag to check the progress status of the query
  48944. * @see http://doc.babylonjs.com/features/occlusionquery
  48945. */
  48946. isOcclusionQueryInProgress: boolean;
  48947. }
  48948. }
  48949. }
  48950. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  48951. import { Nullable } from "babylonjs/types";
  48952. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48953. /** @hidden */
  48954. export var _forceTransformFeedbackToBundle: boolean;
  48955. module "babylonjs/Engines/engine" {
  48956. interface Engine {
  48957. /**
  48958. * Creates a webGL transform feedback object
  48959. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  48960. * @returns the webGL transform feedback object
  48961. */
  48962. createTransformFeedback(): WebGLTransformFeedback;
  48963. /**
  48964. * Delete a webGL transform feedback object
  48965. * @param value defines the webGL transform feedback object to delete
  48966. */
  48967. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  48968. /**
  48969. * Bind a webGL transform feedback object to the webgl context
  48970. * @param value defines the webGL transform feedback object to bind
  48971. */
  48972. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  48973. /**
  48974. * Begins a transform feedback operation
  48975. * @param usePoints defines if points or triangles must be used
  48976. */
  48977. beginTransformFeedback(usePoints: boolean): void;
  48978. /**
  48979. * Ends a transform feedback operation
  48980. */
  48981. endTransformFeedback(): void;
  48982. /**
  48983. * Specify the varyings to use with transform feedback
  48984. * @param program defines the associated webGL program
  48985. * @param value defines the list of strings representing the varying names
  48986. */
  48987. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  48988. /**
  48989. * Bind a webGL buffer for a transform feedback operation
  48990. * @param value defines the webGL buffer to bind
  48991. */
  48992. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  48993. }
  48994. }
  48995. }
  48996. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  48997. import { Scene } from "babylonjs/scene";
  48998. import { Engine } from "babylonjs/Engines/engine";
  48999. import { Texture } from "babylonjs/Materials/Textures/texture";
  49000. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49001. import "babylonjs/Engines/Extensions/engine.multiRender";
  49002. /**
  49003. * Creation options of the multi render target texture.
  49004. */
  49005. export interface IMultiRenderTargetOptions {
  49006. /**
  49007. * Define if the texture needs to create mip maps after render.
  49008. */
  49009. generateMipMaps?: boolean;
  49010. /**
  49011. * Define the types of all the draw buffers we want to create
  49012. */
  49013. types?: number[];
  49014. /**
  49015. * Define the sampling modes of all the draw buffers we want to create
  49016. */
  49017. samplingModes?: number[];
  49018. /**
  49019. * Define if a depth buffer is required
  49020. */
  49021. generateDepthBuffer?: boolean;
  49022. /**
  49023. * Define if a stencil buffer is required
  49024. */
  49025. generateStencilBuffer?: boolean;
  49026. /**
  49027. * Define if a depth texture is required instead of a depth buffer
  49028. */
  49029. generateDepthTexture?: boolean;
  49030. /**
  49031. * Define the number of desired draw buffers
  49032. */
  49033. textureCount?: number;
  49034. /**
  49035. * Define if aspect ratio should be adapted to the texture or stay the scene one
  49036. */
  49037. doNotChangeAspectRatio?: boolean;
  49038. /**
  49039. * Define the default type of the buffers we are creating
  49040. */
  49041. defaultType?: number;
  49042. }
  49043. /**
  49044. * A multi render target, like a render target provides the ability to render to a texture.
  49045. * Unlike the render target, it can render to several draw buffers in one draw.
  49046. * This is specially interesting in deferred rendering or for any effects requiring more than
  49047. * just one color from a single pass.
  49048. */
  49049. export class MultiRenderTarget extends RenderTargetTexture {
  49050. private _internalTextures;
  49051. private _textures;
  49052. private _multiRenderTargetOptions;
  49053. /**
  49054. * Get if draw buffers are currently supported by the used hardware and browser.
  49055. */
  49056. get isSupported(): boolean;
  49057. /**
  49058. * Get the list of textures generated by the multi render target.
  49059. */
  49060. get textures(): Texture[];
  49061. /**
  49062. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  49063. */
  49064. get depthTexture(): Texture;
  49065. /**
  49066. * Set the wrapping mode on U of all the textures we are rendering to.
  49067. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  49068. */
  49069. set wrapU(wrap: number);
  49070. /**
  49071. * Set the wrapping mode on V of all the textures we are rendering to.
  49072. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  49073. */
  49074. set wrapV(wrap: number);
  49075. /**
  49076. * Instantiate a new multi render target texture.
  49077. * A multi render target, like a render target provides the ability to render to a texture.
  49078. * Unlike the render target, it can render to several draw buffers in one draw.
  49079. * This is specially interesting in deferred rendering or for any effects requiring more than
  49080. * just one color from a single pass.
  49081. * @param name Define the name of the texture
  49082. * @param size Define the size of the buffers to render to
  49083. * @param count Define the number of target we are rendering into
  49084. * @param scene Define the scene the texture belongs to
  49085. * @param options Define the options used to create the multi render target
  49086. */
  49087. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  49088. /** @hidden */
  49089. _rebuild(): void;
  49090. private _createInternalTextures;
  49091. private _createTextures;
  49092. /**
  49093. * Define the number of samples used if MSAA is enabled.
  49094. */
  49095. get samples(): number;
  49096. set samples(value: number);
  49097. /**
  49098. * Resize all the textures in the multi render target.
  49099. * Be carrefull as it will recreate all the data in the new texture.
  49100. * @param size Define the new size
  49101. */
  49102. resize(size: any): void;
  49103. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  49104. /**
  49105. * Dispose the render targets and their associated resources
  49106. */
  49107. dispose(): void;
  49108. /**
  49109. * Release all the underlying texture used as draw buffers.
  49110. */
  49111. releaseInternalTextures(): void;
  49112. }
  49113. }
  49114. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  49115. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49116. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  49117. import { Nullable } from "babylonjs/types";
  49118. module "babylonjs/Engines/thinEngine" {
  49119. interface ThinEngine {
  49120. /**
  49121. * Unbind a list of render target textures from the webGL context
  49122. * This is used only when drawBuffer extension or webGL2 are active
  49123. * @param textures defines the render target textures to unbind
  49124. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  49125. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  49126. */
  49127. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  49128. /**
  49129. * Create a multi render target texture
  49130. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  49131. * @param size defines the size of the texture
  49132. * @param options defines the creation options
  49133. * @returns the cube texture as an InternalTexture
  49134. */
  49135. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  49136. /**
  49137. * Update the sample count for a given multiple render target texture
  49138. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  49139. * @param textures defines the textures to update
  49140. * @param samples defines the sample count to set
  49141. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  49142. */
  49143. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  49144. }
  49145. }
  49146. }
  49147. declare module "babylonjs/Engines/Extensions/engine.views" {
  49148. import { Camera } from "babylonjs/Cameras/camera";
  49149. import { Nullable } from "babylonjs/types";
  49150. /**
  49151. * Class used to define an additional view for the engine
  49152. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49153. */
  49154. export class EngineView {
  49155. /** Defines the canvas where to render the view */
  49156. target: HTMLCanvasElement;
  49157. /** Defines an optional camera used to render the view (will use active camera else) */
  49158. camera?: Camera;
  49159. }
  49160. module "babylonjs/Engines/engine" {
  49161. interface Engine {
  49162. /**
  49163. * Gets or sets the HTML element to use for attaching events
  49164. */
  49165. inputElement: Nullable<HTMLElement>;
  49166. /**
  49167. * Gets the current engine view
  49168. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49169. */
  49170. activeView: Nullable<EngineView>;
  49171. /** Gets or sets the list of views */
  49172. views: EngineView[];
  49173. /**
  49174. * Register a new child canvas
  49175. * @param canvas defines the canvas to register
  49176. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  49177. * @returns the associated view
  49178. */
  49179. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  49180. /**
  49181. * Remove a registered child canvas
  49182. * @param canvas defines the canvas to remove
  49183. * @returns the current engine
  49184. */
  49185. unRegisterView(canvas: HTMLCanvasElement): Engine;
  49186. }
  49187. }
  49188. }
  49189. declare module "babylonjs/Engines/Extensions/index" {
  49190. export * from "babylonjs/Engines/Extensions/engine.alpha";
  49191. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  49192. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  49193. export * from "babylonjs/Engines/Extensions/engine.multiview";
  49194. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  49195. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  49196. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  49197. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  49198. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  49199. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  49200. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49201. export * from "babylonjs/Engines/Extensions/engine.webVR";
  49202. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  49203. export * from "babylonjs/Engines/Extensions/engine.views";
  49204. }
  49205. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  49206. import { Nullable } from "babylonjs/types";
  49207. /**
  49208. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49209. */
  49210. export interface CubeMapInfo {
  49211. /**
  49212. * The pixel array for the front face.
  49213. * This is stored in format, left to right, up to down format.
  49214. */
  49215. front: Nullable<ArrayBufferView>;
  49216. /**
  49217. * The pixel array for the back face.
  49218. * This is stored in format, left to right, up to down format.
  49219. */
  49220. back: Nullable<ArrayBufferView>;
  49221. /**
  49222. * The pixel array for the left face.
  49223. * This is stored in format, left to right, up to down format.
  49224. */
  49225. left: Nullable<ArrayBufferView>;
  49226. /**
  49227. * The pixel array for the right face.
  49228. * This is stored in format, left to right, up to down format.
  49229. */
  49230. right: Nullable<ArrayBufferView>;
  49231. /**
  49232. * The pixel array for the up face.
  49233. * This is stored in format, left to right, up to down format.
  49234. */
  49235. up: Nullable<ArrayBufferView>;
  49236. /**
  49237. * The pixel array for the down face.
  49238. * This is stored in format, left to right, up to down format.
  49239. */
  49240. down: Nullable<ArrayBufferView>;
  49241. /**
  49242. * The size of the cubemap stored.
  49243. *
  49244. * Each faces will be size * size pixels.
  49245. */
  49246. size: number;
  49247. /**
  49248. * The format of the texture.
  49249. *
  49250. * RGBA, RGB.
  49251. */
  49252. format: number;
  49253. /**
  49254. * The type of the texture data.
  49255. *
  49256. * UNSIGNED_INT, FLOAT.
  49257. */
  49258. type: number;
  49259. /**
  49260. * Specifies whether the texture is in gamma space.
  49261. */
  49262. gammaSpace: boolean;
  49263. }
  49264. /**
  49265. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49266. */
  49267. export class PanoramaToCubeMapTools {
  49268. private static FACE_FRONT;
  49269. private static FACE_BACK;
  49270. private static FACE_RIGHT;
  49271. private static FACE_LEFT;
  49272. private static FACE_DOWN;
  49273. private static FACE_UP;
  49274. /**
  49275. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49276. *
  49277. * @param float32Array The source data.
  49278. * @param inputWidth The width of the input panorama.
  49279. * @param inputHeight The height of the input panorama.
  49280. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49281. * @return The cubemap data
  49282. */
  49283. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49284. private static CreateCubemapTexture;
  49285. private static CalcProjectionSpherical;
  49286. }
  49287. }
  49288. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  49289. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49290. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49291. import { Nullable } from "babylonjs/types";
  49292. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49293. /**
  49294. * Helper class dealing with the extraction of spherical polynomial dataArray
  49295. * from a cube map.
  49296. */
  49297. export class CubeMapToSphericalPolynomialTools {
  49298. private static FileFaces;
  49299. /**
  49300. * Converts a texture to the according Spherical Polynomial data.
  49301. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49302. *
  49303. * @param texture The texture to extract the information from.
  49304. * @return The Spherical Polynomial data.
  49305. */
  49306. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49307. /**
  49308. * Converts a cubemap to the according Spherical Polynomial data.
  49309. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49310. *
  49311. * @param cubeInfo The Cube map to extract the information from.
  49312. * @return The Spherical Polynomial data.
  49313. */
  49314. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49315. }
  49316. }
  49317. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  49318. import { Nullable } from "babylonjs/types";
  49319. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49320. module "babylonjs/Materials/Textures/baseTexture" {
  49321. interface BaseTexture {
  49322. /**
  49323. * Get the polynomial representation of the texture data.
  49324. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  49325. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  49326. */
  49327. sphericalPolynomial: Nullable<SphericalPolynomial>;
  49328. }
  49329. }
  49330. }
  49331. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49332. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49333. /** @hidden */
  49334. export var rgbdEncodePixelShader: {
  49335. name: string;
  49336. shader: string;
  49337. };
  49338. }
  49339. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  49340. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49341. /** @hidden */
  49342. export var rgbdDecodePixelShader: {
  49343. name: string;
  49344. shader: string;
  49345. };
  49346. }
  49347. declare module "babylonjs/Misc/environmentTextureTools" {
  49348. import { Nullable } from "babylonjs/types";
  49349. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49350. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49351. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49352. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49353. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49354. import "babylonjs/Shaders/rgbdEncode.fragment";
  49355. import "babylonjs/Shaders/rgbdDecode.fragment";
  49356. /**
  49357. * Raw texture data and descriptor sufficient for WebGL texture upload
  49358. */
  49359. export interface EnvironmentTextureInfo {
  49360. /**
  49361. * Version of the environment map
  49362. */
  49363. version: number;
  49364. /**
  49365. * Width of image
  49366. */
  49367. width: number;
  49368. /**
  49369. * Irradiance information stored in the file.
  49370. */
  49371. irradiance: any;
  49372. /**
  49373. * Specular information stored in the file.
  49374. */
  49375. specular: any;
  49376. }
  49377. /**
  49378. * Defines One Image in the file. It requires only the position in the file
  49379. * as well as the length.
  49380. */
  49381. interface BufferImageData {
  49382. /**
  49383. * Length of the image data.
  49384. */
  49385. length: number;
  49386. /**
  49387. * Position of the data from the null terminator delimiting the end of the JSON.
  49388. */
  49389. position: number;
  49390. }
  49391. /**
  49392. * Defines the specular data enclosed in the file.
  49393. * This corresponds to the version 1 of the data.
  49394. */
  49395. export interface EnvironmentTextureSpecularInfoV1 {
  49396. /**
  49397. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  49398. */
  49399. specularDataPosition?: number;
  49400. /**
  49401. * This contains all the images data needed to reconstruct the cubemap.
  49402. */
  49403. mipmaps: Array<BufferImageData>;
  49404. /**
  49405. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  49406. */
  49407. lodGenerationScale: number;
  49408. }
  49409. /**
  49410. * Sets of helpers addressing the serialization and deserialization of environment texture
  49411. * stored in a BabylonJS env file.
  49412. * Those files are usually stored as .env files.
  49413. */
  49414. export class EnvironmentTextureTools {
  49415. /**
  49416. * Magic number identifying the env file.
  49417. */
  49418. private static _MagicBytes;
  49419. /**
  49420. * Gets the environment info from an env file.
  49421. * @param data The array buffer containing the .env bytes.
  49422. * @returns the environment file info (the json header) if successfully parsed.
  49423. */
  49424. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  49425. /**
  49426. * Creates an environment texture from a loaded cube texture.
  49427. * @param texture defines the cube texture to convert in env file
  49428. * @return a promise containing the environment data if succesfull.
  49429. */
  49430. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49431. /**
  49432. * Creates a JSON representation of the spherical data.
  49433. * @param texture defines the texture containing the polynomials
  49434. * @return the JSON representation of the spherical info
  49435. */
  49436. private static _CreateEnvTextureIrradiance;
  49437. /**
  49438. * Creates the ArrayBufferViews used for initializing environment texture image data.
  49439. * @param data the image data
  49440. * @param info parameters that determine what views will be created for accessing the underlying buffer
  49441. * @return the views described by info providing access to the underlying buffer
  49442. */
  49443. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  49444. /**
  49445. * Uploads the texture info contained in the env file to the GPU.
  49446. * @param texture defines the internal texture to upload to
  49447. * @param data defines the data to load
  49448. * @param info defines the texture info retrieved through the GetEnvInfo method
  49449. * @returns a promise
  49450. */
  49451. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  49452. private static _OnImageReadyAsync;
  49453. /**
  49454. * Uploads the levels of image data to the GPU.
  49455. * @param texture defines the internal texture to upload to
  49456. * @param imageData defines the array buffer views of image data [mipmap][face]
  49457. * @returns a promise
  49458. */
  49459. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49460. /**
  49461. * Uploads spherical polynomials information to the texture.
  49462. * @param texture defines the texture we are trying to upload the information to
  49463. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49464. */
  49465. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49466. /** @hidden */
  49467. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49468. }
  49469. }
  49470. declare module "babylonjs/Maths/math.vertexFormat" {
  49471. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  49472. /**
  49473. * Contains position and normal vectors for a vertex
  49474. */
  49475. export class PositionNormalVertex {
  49476. /** the position of the vertex (defaut: 0,0,0) */
  49477. position: Vector3;
  49478. /** the normal of the vertex (defaut: 0,1,0) */
  49479. normal: Vector3;
  49480. /**
  49481. * Creates a PositionNormalVertex
  49482. * @param position the position of the vertex (defaut: 0,0,0)
  49483. * @param normal the normal of the vertex (defaut: 0,1,0)
  49484. */
  49485. constructor(
  49486. /** the position of the vertex (defaut: 0,0,0) */
  49487. position?: Vector3,
  49488. /** the normal of the vertex (defaut: 0,1,0) */
  49489. normal?: Vector3);
  49490. /**
  49491. * Clones the PositionNormalVertex
  49492. * @returns the cloned PositionNormalVertex
  49493. */
  49494. clone(): PositionNormalVertex;
  49495. }
  49496. /**
  49497. * Contains position, normal and uv vectors for a vertex
  49498. */
  49499. export class PositionNormalTextureVertex {
  49500. /** the position of the vertex (defaut: 0,0,0) */
  49501. position: Vector3;
  49502. /** the normal of the vertex (defaut: 0,1,0) */
  49503. normal: Vector3;
  49504. /** the uv of the vertex (default: 0,0) */
  49505. uv: Vector2;
  49506. /**
  49507. * Creates a PositionNormalTextureVertex
  49508. * @param position the position of the vertex (defaut: 0,0,0)
  49509. * @param normal the normal of the vertex (defaut: 0,1,0)
  49510. * @param uv the uv of the vertex (default: 0,0)
  49511. */
  49512. constructor(
  49513. /** the position of the vertex (defaut: 0,0,0) */
  49514. position?: Vector3,
  49515. /** the normal of the vertex (defaut: 0,1,0) */
  49516. normal?: Vector3,
  49517. /** the uv of the vertex (default: 0,0) */
  49518. uv?: Vector2);
  49519. /**
  49520. * Clones the PositionNormalTextureVertex
  49521. * @returns the cloned PositionNormalTextureVertex
  49522. */
  49523. clone(): PositionNormalTextureVertex;
  49524. }
  49525. }
  49526. declare module "babylonjs/Maths/math" {
  49527. export * from "babylonjs/Maths/math.axis";
  49528. export * from "babylonjs/Maths/math.color";
  49529. export * from "babylonjs/Maths/math.constants";
  49530. export * from "babylonjs/Maths/math.frustum";
  49531. export * from "babylonjs/Maths/math.path";
  49532. export * from "babylonjs/Maths/math.plane";
  49533. export * from "babylonjs/Maths/math.size";
  49534. export * from "babylonjs/Maths/math.vector";
  49535. export * from "babylonjs/Maths/math.vertexFormat";
  49536. export * from "babylonjs/Maths/math.viewport";
  49537. }
  49538. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  49539. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49540. /** @hidden */
  49541. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  49542. private _genericAttributeLocation;
  49543. private _varyingLocationCount;
  49544. private _varyingLocationMap;
  49545. private _replacements;
  49546. private _textureCount;
  49547. private _uniforms;
  49548. lineProcessor(line: string): string;
  49549. attributeProcessor(attribute: string): string;
  49550. varyingProcessor(varying: string, isFragment: boolean): string;
  49551. uniformProcessor(uniform: string): string;
  49552. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  49553. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  49554. }
  49555. }
  49556. declare module "babylonjs/Engines/nativeEngine" {
  49557. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  49558. import { Engine } from "babylonjs/Engines/engine";
  49559. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  49560. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49561. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49562. import { Effect } from "babylonjs/Materials/effect";
  49563. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49564. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  49565. import { IColor4Like } from "babylonjs/Maths/math.like";
  49566. import { Scene } from "babylonjs/scene";
  49567. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  49568. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  49569. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  49570. /**
  49571. * Container for accessors for natively-stored mesh data buffers.
  49572. */
  49573. class NativeDataBuffer extends DataBuffer {
  49574. /**
  49575. * Accessor value used to identify/retrieve a natively-stored index buffer.
  49576. */
  49577. nativeIndexBuffer?: any;
  49578. /**
  49579. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  49580. */
  49581. nativeVertexBuffer?: any;
  49582. }
  49583. /** @hidden */
  49584. class NativeTexture extends InternalTexture {
  49585. getInternalTexture(): InternalTexture;
  49586. getViewCount(): number;
  49587. }
  49588. /** @hidden */
  49589. export class NativeEngine extends Engine {
  49590. private readonly _native;
  49591. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  49592. private readonly INVALID_HANDLE;
  49593. getHardwareScalingLevel(): number;
  49594. constructor();
  49595. /**
  49596. * Can be used to override the current requestAnimationFrame requester.
  49597. * @hidden
  49598. */
  49599. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  49600. /**
  49601. * Override default engine behavior.
  49602. * @param color
  49603. * @param backBuffer
  49604. * @param depth
  49605. * @param stencil
  49606. */
  49607. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  49608. /**
  49609. * Gets host document
  49610. * @returns the host document object
  49611. */
  49612. getHostDocument(): Nullable<Document>;
  49613. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49614. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  49615. createVertexBuffer(data: DataArray): NativeDataBuffer;
  49616. recordVertexArrayObject(vertexBuffers: {
  49617. [key: string]: VertexBuffer;
  49618. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  49619. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49620. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49621. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49622. /**
  49623. * Draw a list of indexed primitives
  49624. * @param fillMode defines the primitive to use
  49625. * @param indexStart defines the starting index
  49626. * @param indexCount defines the number of index to draw
  49627. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49628. */
  49629. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49630. /**
  49631. * Draw a list of unindexed primitives
  49632. * @param fillMode defines the primitive to use
  49633. * @param verticesStart defines the index of first vertex to draw
  49634. * @param verticesCount defines the count of vertices to draw
  49635. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49636. */
  49637. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49638. createPipelineContext(): IPipelineContext;
  49639. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  49640. /** @hidden */
  49641. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  49642. /** @hidden */
  49643. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  49644. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49645. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49646. protected _setProgram(program: WebGLProgram): void;
  49647. _releaseEffect(effect: Effect): void;
  49648. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  49649. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  49650. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  49651. bindSamplers(effect: Effect): void;
  49652. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  49653. getRenderWidth(useScreen?: boolean): number;
  49654. getRenderHeight(useScreen?: boolean): number;
  49655. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  49656. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  49657. /**
  49658. * Set the z offset to apply to current rendering
  49659. * @param value defines the offset to apply
  49660. */
  49661. setZOffset(value: number): void;
  49662. /**
  49663. * Gets the current value of the zOffset
  49664. * @returns the current zOffset state
  49665. */
  49666. getZOffset(): number;
  49667. /**
  49668. * Enable or disable depth buffering
  49669. * @param enable defines the state to set
  49670. */
  49671. setDepthBuffer(enable: boolean): void;
  49672. /**
  49673. * Gets a boolean indicating if depth writing is enabled
  49674. * @returns the current depth writing state
  49675. */
  49676. getDepthWrite(): boolean;
  49677. /**
  49678. * Enable or disable depth writing
  49679. * @param enable defines the state to set
  49680. */
  49681. setDepthWrite(enable: boolean): void;
  49682. /**
  49683. * Enable or disable color writing
  49684. * @param enable defines the state to set
  49685. */
  49686. setColorWrite(enable: boolean): void;
  49687. /**
  49688. * Gets a boolean indicating if color writing is enabled
  49689. * @returns the current color writing state
  49690. */
  49691. getColorWrite(): boolean;
  49692. /**
  49693. * Sets alpha constants used by some alpha blending modes
  49694. * @param r defines the red component
  49695. * @param g defines the green component
  49696. * @param b defines the blue component
  49697. * @param a defines the alpha component
  49698. */
  49699. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  49700. /**
  49701. * Sets the current alpha mode
  49702. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  49703. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49704. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49705. */
  49706. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49707. /**
  49708. * Gets the current alpha mode
  49709. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49710. * @returns the current alpha mode
  49711. */
  49712. getAlphaMode(): number;
  49713. setInt(uniform: WebGLUniformLocation, int: number): void;
  49714. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  49715. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  49716. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  49717. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  49718. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  49719. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  49720. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  49721. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  49722. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  49723. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  49724. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  49725. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  49726. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  49727. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49728. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49729. setFloat(uniform: WebGLUniformLocation, value: number): void;
  49730. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  49731. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  49732. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  49733. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  49734. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  49735. wipeCaches(bruteForce?: boolean): void;
  49736. _createTexture(): WebGLTexture;
  49737. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  49738. /**
  49739. * Usually called from Texture.ts.
  49740. * Passed information to create a WebGLTexture
  49741. * @param urlArg defines a value which contains one of the following:
  49742. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  49743. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  49744. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  49745. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  49746. * @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)
  49747. * @param scene needed for loading to the correct scene
  49748. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  49749. * @param onLoad optional callback to be called upon successful completion
  49750. * @param onError optional callback to be called upon failure
  49751. * @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
  49752. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  49753. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  49754. * @param forcedExtension defines the extension to use to pick the right loader
  49755. * @param mimeType defines an optional mime type
  49756. * @returns a InternalTexture for assignment back into BABYLON.Texture
  49757. */
  49758. 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;
  49759. /**
  49760. * Creates a cube texture
  49761. * @param rootUrl defines the url where the files to load is located
  49762. * @param scene defines the current scene
  49763. * @param files defines the list of files to load (1 per face)
  49764. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  49765. * @param onLoad defines an optional callback raised when the texture is loaded
  49766. * @param onError defines an optional callback raised if there is an issue to load the texture
  49767. * @param format defines the format of the data
  49768. * @param forcedExtension defines the extension to use to pick the right loader
  49769. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  49770. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49771. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49772. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  49773. * @returns the cube texture as an InternalTexture
  49774. */
  49775. 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;
  49776. private _getSamplingFilter;
  49777. private static _GetNativeTextureFormat;
  49778. createRenderTargetTexture(size: number | {
  49779. width: number;
  49780. height: number;
  49781. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  49782. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  49783. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  49784. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  49785. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  49786. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  49787. /**
  49788. * Updates a dynamic vertex buffer.
  49789. * @param vertexBuffer the vertex buffer to update
  49790. * @param data the data used to update the vertex buffer
  49791. * @param byteOffset the byte offset of the data (optional)
  49792. * @param byteLength the byte length of the data (optional)
  49793. */
  49794. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  49795. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  49796. private _updateAnisotropicLevel;
  49797. private _getAddressMode;
  49798. /** @hidden */
  49799. _bindTexture(channel: number, texture: InternalTexture): void;
  49800. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  49801. releaseEffects(): void;
  49802. /** @hidden */
  49803. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49804. /** @hidden */
  49805. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49806. /** @hidden */
  49807. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49808. /** @hidden */
  49809. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49810. }
  49811. }
  49812. declare module "babylonjs/Engines/index" {
  49813. export * from "babylonjs/Engines/constants";
  49814. export * from "babylonjs/Engines/engineCapabilities";
  49815. export * from "babylonjs/Engines/instancingAttributeInfo";
  49816. export * from "babylonjs/Engines/thinEngine";
  49817. export * from "babylonjs/Engines/engine";
  49818. export * from "babylonjs/Engines/engineStore";
  49819. export * from "babylonjs/Engines/nullEngine";
  49820. export * from "babylonjs/Engines/Extensions/index";
  49821. export * from "babylonjs/Engines/IPipelineContext";
  49822. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  49823. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49824. export * from "babylonjs/Engines/nativeEngine";
  49825. }
  49826. declare module "babylonjs/Events/clipboardEvents" {
  49827. /**
  49828. * Gather the list of clipboard event types as constants.
  49829. */
  49830. export class ClipboardEventTypes {
  49831. /**
  49832. * The clipboard event is fired when a copy command is active (pressed).
  49833. */
  49834. static readonly COPY: number;
  49835. /**
  49836. * The clipboard event is fired when a cut command is active (pressed).
  49837. */
  49838. static readonly CUT: number;
  49839. /**
  49840. * The clipboard event is fired when a paste command is active (pressed).
  49841. */
  49842. static readonly PASTE: number;
  49843. }
  49844. /**
  49845. * This class is used to store clipboard related info for the onClipboardObservable event.
  49846. */
  49847. export class ClipboardInfo {
  49848. /**
  49849. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49850. */
  49851. type: number;
  49852. /**
  49853. * Defines the related dom event
  49854. */
  49855. event: ClipboardEvent;
  49856. /**
  49857. *Creates an instance of ClipboardInfo.
  49858. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  49859. * @param event Defines the related dom event
  49860. */
  49861. constructor(
  49862. /**
  49863. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49864. */
  49865. type: number,
  49866. /**
  49867. * Defines the related dom event
  49868. */
  49869. event: ClipboardEvent);
  49870. /**
  49871. * Get the clipboard event's type from the keycode.
  49872. * @param keyCode Defines the keyCode for the current keyboard event.
  49873. * @return {number}
  49874. */
  49875. static GetTypeFromCharacter(keyCode: number): number;
  49876. }
  49877. }
  49878. declare module "babylonjs/Events/index" {
  49879. export * from "babylonjs/Events/keyboardEvents";
  49880. export * from "babylonjs/Events/pointerEvents";
  49881. export * from "babylonjs/Events/clipboardEvents";
  49882. }
  49883. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  49884. import { Scene } from "babylonjs/scene";
  49885. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49886. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49887. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49888. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49889. /**
  49890. * Google Daydream controller
  49891. */
  49892. export class DaydreamController extends WebVRController {
  49893. /**
  49894. * Base Url for the controller model.
  49895. */
  49896. static MODEL_BASE_URL: string;
  49897. /**
  49898. * File name for the controller model.
  49899. */
  49900. static MODEL_FILENAME: string;
  49901. /**
  49902. * Gamepad Id prefix used to identify Daydream Controller.
  49903. */
  49904. static readonly GAMEPAD_ID_PREFIX: string;
  49905. /**
  49906. * Creates a new DaydreamController from a gamepad
  49907. * @param vrGamepad the gamepad that the controller should be created from
  49908. */
  49909. constructor(vrGamepad: any);
  49910. /**
  49911. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49912. * @param scene scene in which to add meshes
  49913. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49914. */
  49915. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49916. /**
  49917. * Called once for each button that changed state since the last frame
  49918. * @param buttonIdx Which button index changed
  49919. * @param state New state of the button
  49920. * @param changes Which properties on the state changed since last frame
  49921. */
  49922. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49923. }
  49924. }
  49925. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  49926. import { Scene } from "babylonjs/scene";
  49927. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49928. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49929. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49930. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49931. /**
  49932. * Gear VR Controller
  49933. */
  49934. export class GearVRController extends WebVRController {
  49935. /**
  49936. * Base Url for the controller model.
  49937. */
  49938. static MODEL_BASE_URL: string;
  49939. /**
  49940. * File name for the controller model.
  49941. */
  49942. static MODEL_FILENAME: string;
  49943. /**
  49944. * Gamepad Id prefix used to identify this controller.
  49945. */
  49946. static readonly GAMEPAD_ID_PREFIX: string;
  49947. private readonly _buttonIndexToObservableNameMap;
  49948. /**
  49949. * Creates a new GearVRController from a gamepad
  49950. * @param vrGamepad the gamepad that the controller should be created from
  49951. */
  49952. constructor(vrGamepad: any);
  49953. /**
  49954. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49955. * @param scene scene in which to add meshes
  49956. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49957. */
  49958. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49959. /**
  49960. * Called once for each button that changed state since the last frame
  49961. * @param buttonIdx Which button index changed
  49962. * @param state New state of the button
  49963. * @param changes Which properties on the state changed since last frame
  49964. */
  49965. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49966. }
  49967. }
  49968. declare module "babylonjs/Gamepads/Controllers/genericController" {
  49969. import { Scene } from "babylonjs/scene";
  49970. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49971. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49972. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49973. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49974. /**
  49975. * Generic Controller
  49976. */
  49977. export class GenericController extends WebVRController {
  49978. /**
  49979. * Base Url for the controller model.
  49980. */
  49981. static readonly MODEL_BASE_URL: string;
  49982. /**
  49983. * File name for the controller model.
  49984. */
  49985. static readonly MODEL_FILENAME: string;
  49986. /**
  49987. * Creates a new GenericController from a gamepad
  49988. * @param vrGamepad the gamepad that the controller should be created from
  49989. */
  49990. constructor(vrGamepad: any);
  49991. /**
  49992. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49993. * @param scene scene in which to add meshes
  49994. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49995. */
  49996. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49997. /**
  49998. * Called once for each button that changed state since the last frame
  49999. * @param buttonIdx Which button index changed
  50000. * @param state New state of the button
  50001. * @param changes Which properties on the state changed since last frame
  50002. */
  50003. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50004. }
  50005. }
  50006. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  50007. import { Observable } from "babylonjs/Misc/observable";
  50008. import { Scene } from "babylonjs/scene";
  50009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50010. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50011. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50012. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50013. /**
  50014. * Oculus Touch Controller
  50015. */
  50016. export class OculusTouchController extends WebVRController {
  50017. /**
  50018. * Base Url for the controller model.
  50019. */
  50020. static MODEL_BASE_URL: string;
  50021. /**
  50022. * File name for the left controller model.
  50023. */
  50024. static MODEL_LEFT_FILENAME: string;
  50025. /**
  50026. * File name for the right controller model.
  50027. */
  50028. static MODEL_RIGHT_FILENAME: string;
  50029. /**
  50030. * Base Url for the Quest controller model.
  50031. */
  50032. static QUEST_MODEL_BASE_URL: string;
  50033. /**
  50034. * @hidden
  50035. * If the controllers are running on a device that needs the updated Quest controller models
  50036. */
  50037. static _IsQuest: boolean;
  50038. /**
  50039. * Fired when the secondary trigger on this controller is modified
  50040. */
  50041. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  50042. /**
  50043. * Fired when the thumb rest on this controller is modified
  50044. */
  50045. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  50046. /**
  50047. * Creates a new OculusTouchController from a gamepad
  50048. * @param vrGamepad the gamepad that the controller should be created from
  50049. */
  50050. constructor(vrGamepad: any);
  50051. /**
  50052. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50053. * @param scene scene in which to add meshes
  50054. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50055. */
  50056. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50057. /**
  50058. * Fired when the A button on this controller is modified
  50059. */
  50060. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50061. /**
  50062. * Fired when the B button on this controller is modified
  50063. */
  50064. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50065. /**
  50066. * Fired when the X button on this controller is modified
  50067. */
  50068. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50069. /**
  50070. * Fired when the Y button on this controller is modified
  50071. */
  50072. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50073. /**
  50074. * Called once for each button that changed state since the last frame
  50075. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  50076. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  50077. * 2) secondary trigger (same)
  50078. * 3) A (right) X (left), touch, pressed = value
  50079. * 4) B / Y
  50080. * 5) thumb rest
  50081. * @param buttonIdx Which button index changed
  50082. * @param state New state of the button
  50083. * @param changes Which properties on the state changed since last frame
  50084. */
  50085. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50086. }
  50087. }
  50088. declare module "babylonjs/Gamepads/Controllers/viveController" {
  50089. import { Scene } from "babylonjs/scene";
  50090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50091. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50092. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50093. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50094. import { Observable } from "babylonjs/Misc/observable";
  50095. /**
  50096. * Vive Controller
  50097. */
  50098. export class ViveController extends WebVRController {
  50099. /**
  50100. * Base Url for the controller model.
  50101. */
  50102. static MODEL_BASE_URL: string;
  50103. /**
  50104. * File name for the controller model.
  50105. */
  50106. static MODEL_FILENAME: string;
  50107. /**
  50108. * Creates a new ViveController from a gamepad
  50109. * @param vrGamepad the gamepad that the controller should be created from
  50110. */
  50111. constructor(vrGamepad: any);
  50112. /**
  50113. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50114. * @param scene scene in which to add meshes
  50115. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50116. */
  50117. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50118. /**
  50119. * Fired when the left button on this controller is modified
  50120. */
  50121. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50122. /**
  50123. * Fired when the right button on this controller is modified
  50124. */
  50125. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50126. /**
  50127. * Fired when the menu button on this controller is modified
  50128. */
  50129. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50130. /**
  50131. * Called once for each button that changed state since the last frame
  50132. * Vive mapping:
  50133. * 0: touchpad
  50134. * 1: trigger
  50135. * 2: left AND right buttons
  50136. * 3: menu button
  50137. * @param buttonIdx Which button index changed
  50138. * @param state New state of the button
  50139. * @param changes Which properties on the state changed since last frame
  50140. */
  50141. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50142. }
  50143. }
  50144. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  50145. import { Observable } from "babylonjs/Misc/observable";
  50146. import { Scene } from "babylonjs/scene";
  50147. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50148. import { Ray } from "babylonjs/Culling/ray";
  50149. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50150. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50151. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50152. /**
  50153. * Defines the WindowsMotionController object that the state of the windows motion controller
  50154. */
  50155. export class WindowsMotionController extends WebVRController {
  50156. /**
  50157. * The base url used to load the left and right controller models
  50158. */
  50159. static MODEL_BASE_URL: string;
  50160. /**
  50161. * The name of the left controller model file
  50162. */
  50163. static MODEL_LEFT_FILENAME: string;
  50164. /**
  50165. * The name of the right controller model file
  50166. */
  50167. static MODEL_RIGHT_FILENAME: string;
  50168. /**
  50169. * The controller name prefix for this controller type
  50170. */
  50171. static readonly GAMEPAD_ID_PREFIX: string;
  50172. /**
  50173. * The controller id pattern for this controller type
  50174. */
  50175. private static readonly GAMEPAD_ID_PATTERN;
  50176. private _loadedMeshInfo;
  50177. protected readonly _mapping: {
  50178. buttons: string[];
  50179. buttonMeshNames: {
  50180. 'trigger': string;
  50181. 'menu': string;
  50182. 'grip': string;
  50183. 'thumbstick': string;
  50184. 'trackpad': string;
  50185. };
  50186. buttonObservableNames: {
  50187. 'trigger': string;
  50188. 'menu': string;
  50189. 'grip': string;
  50190. 'thumbstick': string;
  50191. 'trackpad': string;
  50192. };
  50193. axisMeshNames: string[];
  50194. pointingPoseMeshName: string;
  50195. };
  50196. /**
  50197. * Fired when the trackpad on this controller is clicked
  50198. */
  50199. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50200. /**
  50201. * Fired when the trackpad on this controller is modified
  50202. */
  50203. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50204. /**
  50205. * The current x and y values of this controller's trackpad
  50206. */
  50207. trackpad: StickValues;
  50208. /**
  50209. * Creates a new WindowsMotionController from a gamepad
  50210. * @param vrGamepad the gamepad that the controller should be created from
  50211. */
  50212. constructor(vrGamepad: any);
  50213. /**
  50214. * Fired when the trigger on this controller is modified
  50215. */
  50216. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50217. /**
  50218. * Fired when the menu button on this controller is modified
  50219. */
  50220. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50221. /**
  50222. * Fired when the grip button on this controller is modified
  50223. */
  50224. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50225. /**
  50226. * Fired when the thumbstick button on this controller is modified
  50227. */
  50228. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50229. /**
  50230. * Fired when the touchpad button on this controller is modified
  50231. */
  50232. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50233. /**
  50234. * Fired when the touchpad values on this controller are modified
  50235. */
  50236. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  50237. protected _updateTrackpad(): void;
  50238. /**
  50239. * Called once per frame by the engine.
  50240. */
  50241. update(): void;
  50242. /**
  50243. * Called once for each button that changed state since the last frame
  50244. * @param buttonIdx Which button index changed
  50245. * @param state New state of the button
  50246. * @param changes Which properties on the state changed since last frame
  50247. */
  50248. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50249. /**
  50250. * Moves the buttons on the controller mesh based on their current state
  50251. * @param buttonName the name of the button to move
  50252. * @param buttonValue the value of the button which determines the buttons new position
  50253. */
  50254. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  50255. /**
  50256. * Moves the axis on the controller mesh based on its current state
  50257. * @param axis the index of the axis
  50258. * @param axisValue the value of the axis which determines the meshes new position
  50259. * @hidden
  50260. */
  50261. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  50262. /**
  50263. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50264. * @param scene scene in which to add meshes
  50265. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50266. */
  50267. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  50268. /**
  50269. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  50270. * can be transformed by button presses and axes values, based on this._mapping.
  50271. *
  50272. * @param scene scene in which the meshes exist
  50273. * @param meshes list of meshes that make up the controller model to process
  50274. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  50275. */
  50276. private processModel;
  50277. private createMeshInfo;
  50278. /**
  50279. * Gets the ray of the controller in the direction the controller is pointing
  50280. * @param length the length the resulting ray should be
  50281. * @returns a ray in the direction the controller is pointing
  50282. */
  50283. getForwardRay(length?: number): Ray;
  50284. /**
  50285. * Disposes of the controller
  50286. */
  50287. dispose(): void;
  50288. }
  50289. /**
  50290. * This class represents a new windows motion controller in XR.
  50291. */
  50292. export class XRWindowsMotionController extends WindowsMotionController {
  50293. /**
  50294. * Changing the original WIndowsMotionController mapping to fir the new mapping
  50295. */
  50296. protected readonly _mapping: {
  50297. buttons: string[];
  50298. buttonMeshNames: {
  50299. 'trigger': string;
  50300. 'menu': string;
  50301. 'grip': string;
  50302. 'thumbstick': string;
  50303. 'trackpad': string;
  50304. };
  50305. buttonObservableNames: {
  50306. 'trigger': string;
  50307. 'menu': string;
  50308. 'grip': string;
  50309. 'thumbstick': string;
  50310. 'trackpad': string;
  50311. };
  50312. axisMeshNames: string[];
  50313. pointingPoseMeshName: string;
  50314. };
  50315. /**
  50316. * Construct a new XR-Based windows motion controller
  50317. *
  50318. * @param gamepadInfo the gamepad object from the browser
  50319. */
  50320. constructor(gamepadInfo: any);
  50321. /**
  50322. * holds the thumbstick values (X,Y)
  50323. */
  50324. thumbstickValues: StickValues;
  50325. /**
  50326. * Fired when the thumbstick on this controller is clicked
  50327. */
  50328. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  50329. /**
  50330. * Fired when the thumbstick on this controller is modified
  50331. */
  50332. onThumbstickValuesChangedObservable: Observable<StickValues>;
  50333. /**
  50334. * Fired when the touchpad button on this controller is modified
  50335. */
  50336. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50337. /**
  50338. * Fired when the touchpad values on this controller are modified
  50339. */
  50340. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50341. /**
  50342. * Fired when the thumbstick button on this controller is modified
  50343. * here to prevent breaking changes
  50344. */
  50345. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50346. /**
  50347. * updating the thumbstick(!) and not the trackpad.
  50348. * This is named this way due to the difference between WebVR and XR and to avoid
  50349. * changing the parent class.
  50350. */
  50351. protected _updateTrackpad(): void;
  50352. /**
  50353. * Disposes the class with joy
  50354. */
  50355. dispose(): void;
  50356. }
  50357. }
  50358. declare module "babylonjs/Gamepads/Controllers/index" {
  50359. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  50360. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  50361. export * from "babylonjs/Gamepads/Controllers/genericController";
  50362. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  50363. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50364. export * from "babylonjs/Gamepads/Controllers/viveController";
  50365. export * from "babylonjs/Gamepads/Controllers/webVRController";
  50366. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  50367. }
  50368. declare module "babylonjs/Gamepads/index" {
  50369. export * from "babylonjs/Gamepads/Controllers/index";
  50370. export * from "babylonjs/Gamepads/gamepad";
  50371. export * from "babylonjs/Gamepads/gamepadManager";
  50372. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  50373. export * from "babylonjs/Gamepads/xboxGamepad";
  50374. export * from "babylonjs/Gamepads/dualShockGamepad";
  50375. }
  50376. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  50377. import { Scene } from "babylonjs/scene";
  50378. import { Vector4 } from "babylonjs/Maths/math.vector";
  50379. import { Color4 } from "babylonjs/Maths/math.color";
  50380. import { Mesh } from "babylonjs/Meshes/mesh";
  50381. import { Nullable } from "babylonjs/types";
  50382. /**
  50383. * Class containing static functions to help procedurally build meshes
  50384. */
  50385. export class PolyhedronBuilder {
  50386. /**
  50387. * Creates a polyhedron mesh
  50388. * * 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
  50389. * * The parameter `size` (positive float, default 1) sets the polygon size
  50390. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50391. * * 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`
  50392. * * 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
  50393. * * 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)`)
  50394. * * 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
  50395. * * 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
  50396. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50397. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50398. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50399. * @param name defines the name of the mesh
  50400. * @param options defines the options used to create the mesh
  50401. * @param scene defines the hosting scene
  50402. * @returns the polyhedron mesh
  50403. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50404. */
  50405. static CreatePolyhedron(name: string, options: {
  50406. type?: number;
  50407. size?: number;
  50408. sizeX?: number;
  50409. sizeY?: number;
  50410. sizeZ?: number;
  50411. custom?: any;
  50412. faceUV?: Vector4[];
  50413. faceColors?: Color4[];
  50414. flat?: boolean;
  50415. updatable?: boolean;
  50416. sideOrientation?: number;
  50417. frontUVs?: Vector4;
  50418. backUVs?: Vector4;
  50419. }, scene?: Nullable<Scene>): Mesh;
  50420. }
  50421. }
  50422. declare module "babylonjs/Gizmos/scaleGizmo" {
  50423. import { Observable } from "babylonjs/Misc/observable";
  50424. import { Nullable } from "babylonjs/types";
  50425. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50426. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50427. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  50428. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50429. /**
  50430. * Gizmo that enables scaling a mesh along 3 axis
  50431. */
  50432. export class ScaleGizmo extends Gizmo {
  50433. /**
  50434. * Internal gizmo used for interactions on the x axis
  50435. */
  50436. xGizmo: AxisScaleGizmo;
  50437. /**
  50438. * Internal gizmo used for interactions on the y axis
  50439. */
  50440. yGizmo: AxisScaleGizmo;
  50441. /**
  50442. * Internal gizmo used for interactions on the z axis
  50443. */
  50444. zGizmo: AxisScaleGizmo;
  50445. /**
  50446. * Internal gizmo used to scale all axis equally
  50447. */
  50448. uniformScaleGizmo: AxisScaleGizmo;
  50449. private _meshAttached;
  50450. private _updateGizmoRotationToMatchAttachedMesh;
  50451. private _snapDistance;
  50452. private _scaleRatio;
  50453. private _uniformScalingMesh;
  50454. private _octahedron;
  50455. private _sensitivity;
  50456. /** Fires an event when any of it's sub gizmos are dragged */
  50457. onDragStartObservable: Observable<unknown>;
  50458. /** Fires an event when any of it's sub gizmos are released from dragging */
  50459. onDragEndObservable: Observable<unknown>;
  50460. get attachedMesh(): Nullable<AbstractMesh>;
  50461. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50462. /**
  50463. * Creates a ScaleGizmo
  50464. * @param gizmoLayer The utility layer the gizmo will be added to
  50465. */
  50466. constructor(gizmoLayer?: UtilityLayerRenderer);
  50467. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50468. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50469. /**
  50470. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50471. */
  50472. set snapDistance(value: number);
  50473. get snapDistance(): number;
  50474. /**
  50475. * Ratio for the scale of the gizmo (Default: 1)
  50476. */
  50477. set scaleRatio(value: number);
  50478. get scaleRatio(): number;
  50479. /**
  50480. * Sensitivity factor for dragging (Default: 1)
  50481. */
  50482. set sensitivity(value: number);
  50483. get sensitivity(): number;
  50484. /**
  50485. * Disposes of the gizmo
  50486. */
  50487. dispose(): void;
  50488. }
  50489. }
  50490. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  50491. import { Observable } from "babylonjs/Misc/observable";
  50492. import { Nullable } from "babylonjs/types";
  50493. import { Vector3 } from "babylonjs/Maths/math.vector";
  50494. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50495. import { Mesh } from "babylonjs/Meshes/mesh";
  50496. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50497. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50498. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50499. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50500. import { Color3 } from "babylonjs/Maths/math.color";
  50501. /**
  50502. * Single axis scale gizmo
  50503. */
  50504. export class AxisScaleGizmo extends Gizmo {
  50505. /**
  50506. * Drag behavior responsible for the gizmos dragging interactions
  50507. */
  50508. dragBehavior: PointerDragBehavior;
  50509. private _pointerObserver;
  50510. /**
  50511. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50512. */
  50513. snapDistance: number;
  50514. /**
  50515. * Event that fires each time the gizmo snaps to a new location.
  50516. * * snapDistance is the the change in distance
  50517. */
  50518. onSnapObservable: Observable<{
  50519. snapDistance: number;
  50520. }>;
  50521. /**
  50522. * If the scaling operation should be done on all axis (default: false)
  50523. */
  50524. uniformScaling: boolean;
  50525. /**
  50526. * Custom sensitivity value for the drag strength
  50527. */
  50528. sensitivity: number;
  50529. private _isEnabled;
  50530. private _parent;
  50531. private _arrow;
  50532. private _coloredMaterial;
  50533. private _hoverMaterial;
  50534. /**
  50535. * Creates an AxisScaleGizmo
  50536. * @param gizmoLayer The utility layer the gizmo will be added to
  50537. * @param dragAxis The axis which the gizmo will be able to scale on
  50538. * @param color The color of the gizmo
  50539. */
  50540. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  50541. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50542. /**
  50543. * If the gizmo is enabled
  50544. */
  50545. set isEnabled(value: boolean);
  50546. get isEnabled(): boolean;
  50547. /**
  50548. * Disposes of the gizmo
  50549. */
  50550. dispose(): void;
  50551. /**
  50552. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50553. * @param mesh The mesh to replace the default mesh of the gizmo
  50554. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  50555. */
  50556. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  50557. }
  50558. }
  50559. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  50560. import { Observable } from "babylonjs/Misc/observable";
  50561. import { Nullable } from "babylonjs/types";
  50562. import { Vector3 } from "babylonjs/Maths/math.vector";
  50563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50564. import { Mesh } from "babylonjs/Meshes/mesh";
  50565. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50566. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50567. import { Color3 } from "babylonjs/Maths/math.color";
  50568. import "babylonjs/Meshes/Builders/boxBuilder";
  50569. /**
  50570. * Bounding box gizmo
  50571. */
  50572. export class BoundingBoxGizmo extends Gizmo {
  50573. private _lineBoundingBox;
  50574. private _rotateSpheresParent;
  50575. private _scaleBoxesParent;
  50576. private _boundingDimensions;
  50577. private _renderObserver;
  50578. private _pointerObserver;
  50579. private _scaleDragSpeed;
  50580. private _tmpQuaternion;
  50581. private _tmpVector;
  50582. private _tmpRotationMatrix;
  50583. /**
  50584. * 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)
  50585. */
  50586. ignoreChildren: boolean;
  50587. /**
  50588. * 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)
  50589. */
  50590. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  50591. /**
  50592. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  50593. */
  50594. rotationSphereSize: number;
  50595. /**
  50596. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  50597. */
  50598. scaleBoxSize: number;
  50599. /**
  50600. * 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)
  50601. */
  50602. fixedDragMeshScreenSize: boolean;
  50603. /**
  50604. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  50605. */
  50606. fixedDragMeshScreenSizeDistanceFactor: number;
  50607. /**
  50608. * Fired when a rotation sphere or scale box is dragged
  50609. */
  50610. onDragStartObservable: Observable<{}>;
  50611. /**
  50612. * Fired when a scale box is dragged
  50613. */
  50614. onScaleBoxDragObservable: Observable<{}>;
  50615. /**
  50616. * Fired when a scale box drag is ended
  50617. */
  50618. onScaleBoxDragEndObservable: Observable<{}>;
  50619. /**
  50620. * Fired when a rotation sphere is dragged
  50621. */
  50622. onRotationSphereDragObservable: Observable<{}>;
  50623. /**
  50624. * Fired when a rotation sphere drag is ended
  50625. */
  50626. onRotationSphereDragEndObservable: Observable<{}>;
  50627. /**
  50628. * 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)
  50629. */
  50630. scalePivot: Nullable<Vector3>;
  50631. /**
  50632. * Mesh used as a pivot to rotate the attached mesh
  50633. */
  50634. private _anchorMesh;
  50635. private _existingMeshScale;
  50636. private _dragMesh;
  50637. private pointerDragBehavior;
  50638. private coloredMaterial;
  50639. private hoverColoredMaterial;
  50640. /**
  50641. * Sets the color of the bounding box gizmo
  50642. * @param color the color to set
  50643. */
  50644. setColor(color: Color3): void;
  50645. /**
  50646. * Creates an BoundingBoxGizmo
  50647. * @param gizmoLayer The utility layer the gizmo will be added to
  50648. * @param color The color of the gizmo
  50649. */
  50650. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  50651. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50652. private _selectNode;
  50653. /**
  50654. * Updates the bounding box information for the Gizmo
  50655. */
  50656. updateBoundingBox(): void;
  50657. private _updateRotationSpheres;
  50658. private _updateScaleBoxes;
  50659. /**
  50660. * Enables rotation on the specified axis and disables rotation on the others
  50661. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  50662. */
  50663. setEnabledRotationAxis(axis: string): void;
  50664. /**
  50665. * Enables/disables scaling
  50666. * @param enable if scaling should be enabled
  50667. */
  50668. setEnabledScaling(enable: boolean): void;
  50669. private _updateDummy;
  50670. /**
  50671. * Enables a pointer drag behavior on the bounding box of the gizmo
  50672. */
  50673. enableDragBehavior(): void;
  50674. /**
  50675. * Disposes of the gizmo
  50676. */
  50677. dispose(): void;
  50678. /**
  50679. * 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)
  50680. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  50681. * @returns the bounding box mesh with the passed in mesh as a child
  50682. */
  50683. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  50684. /**
  50685. * CustomMeshes are not supported by this gizmo
  50686. * @param mesh The mesh to replace the default mesh of the gizmo
  50687. */
  50688. setCustomMesh(mesh: Mesh): void;
  50689. }
  50690. }
  50691. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  50692. import { Observable } from "babylonjs/Misc/observable";
  50693. import { Nullable } from "babylonjs/types";
  50694. import { Vector3 } from "babylonjs/Maths/math.vector";
  50695. import { Color3 } from "babylonjs/Maths/math.color";
  50696. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50697. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50698. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50699. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50700. import "babylonjs/Meshes/Builders/linesBuilder";
  50701. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50702. /**
  50703. * Single plane rotation gizmo
  50704. */
  50705. export class PlaneRotationGizmo extends Gizmo {
  50706. /**
  50707. * Drag behavior responsible for the gizmos dragging interactions
  50708. */
  50709. dragBehavior: PointerDragBehavior;
  50710. private _pointerObserver;
  50711. /**
  50712. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  50713. */
  50714. snapDistance: number;
  50715. /**
  50716. * Event that fires each time the gizmo snaps to a new location.
  50717. * * snapDistance is the the change in distance
  50718. */
  50719. onSnapObservable: Observable<{
  50720. snapDistance: number;
  50721. }>;
  50722. private _isEnabled;
  50723. private _parent;
  50724. /**
  50725. * Creates a PlaneRotationGizmo
  50726. * @param gizmoLayer The utility layer the gizmo will be added to
  50727. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  50728. * @param color The color of the gizmo
  50729. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50730. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50731. */
  50732. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  50733. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50734. /**
  50735. * If the gizmo is enabled
  50736. */
  50737. set isEnabled(value: boolean);
  50738. get isEnabled(): boolean;
  50739. /**
  50740. * Disposes of the gizmo
  50741. */
  50742. dispose(): void;
  50743. }
  50744. }
  50745. declare module "babylonjs/Gizmos/rotationGizmo" {
  50746. import { Observable } from "babylonjs/Misc/observable";
  50747. import { Nullable } from "babylonjs/types";
  50748. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50749. import { Mesh } from "babylonjs/Meshes/mesh";
  50750. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50751. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  50752. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50753. /**
  50754. * Gizmo that enables rotating a mesh along 3 axis
  50755. */
  50756. export class RotationGizmo extends Gizmo {
  50757. /**
  50758. * Internal gizmo used for interactions on the x axis
  50759. */
  50760. xGizmo: PlaneRotationGizmo;
  50761. /**
  50762. * Internal gizmo used for interactions on the y axis
  50763. */
  50764. yGizmo: PlaneRotationGizmo;
  50765. /**
  50766. * Internal gizmo used for interactions on the z axis
  50767. */
  50768. zGizmo: PlaneRotationGizmo;
  50769. /** Fires an event when any of it's sub gizmos are dragged */
  50770. onDragStartObservable: Observable<unknown>;
  50771. /** Fires an event when any of it's sub gizmos are released from dragging */
  50772. onDragEndObservable: Observable<unknown>;
  50773. private _meshAttached;
  50774. get attachedMesh(): Nullable<AbstractMesh>;
  50775. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50776. /**
  50777. * Creates a RotationGizmo
  50778. * @param gizmoLayer The utility layer the gizmo will be added to
  50779. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50780. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50781. */
  50782. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  50783. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50784. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50785. /**
  50786. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50787. */
  50788. set snapDistance(value: number);
  50789. get snapDistance(): number;
  50790. /**
  50791. * Ratio for the scale of the gizmo (Default: 1)
  50792. */
  50793. set scaleRatio(value: number);
  50794. get scaleRatio(): number;
  50795. /**
  50796. * Disposes of the gizmo
  50797. */
  50798. dispose(): void;
  50799. /**
  50800. * CustomMeshes are not supported by this gizmo
  50801. * @param mesh The mesh to replace the default mesh of the gizmo
  50802. */
  50803. setCustomMesh(mesh: Mesh): void;
  50804. }
  50805. }
  50806. declare module "babylonjs/Gizmos/gizmoManager" {
  50807. import { Observable } from "babylonjs/Misc/observable";
  50808. import { Nullable } from "babylonjs/types";
  50809. import { Scene, IDisposable } from "babylonjs/scene";
  50810. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50811. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50812. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  50813. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50814. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  50815. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50816. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  50817. /**
  50818. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  50819. */
  50820. export class GizmoManager implements IDisposable {
  50821. private scene;
  50822. /**
  50823. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  50824. */
  50825. gizmos: {
  50826. positionGizmo: Nullable<PositionGizmo>;
  50827. rotationGizmo: Nullable<RotationGizmo>;
  50828. scaleGizmo: Nullable<ScaleGizmo>;
  50829. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  50830. };
  50831. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  50832. clearGizmoOnEmptyPointerEvent: boolean;
  50833. /** Fires an event when the manager is attached to a mesh */
  50834. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  50835. private _gizmosEnabled;
  50836. private _pointerObserver;
  50837. private _attachedMesh;
  50838. private _boundingBoxColor;
  50839. private _defaultUtilityLayer;
  50840. private _defaultKeepDepthUtilityLayer;
  50841. /**
  50842. * When bounding box gizmo is enabled, this can be used to track drag/end events
  50843. */
  50844. boundingBoxDragBehavior: SixDofDragBehavior;
  50845. /**
  50846. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  50847. */
  50848. attachableMeshes: Nullable<Array<AbstractMesh>>;
  50849. /**
  50850. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  50851. */
  50852. usePointerToAttachGizmos: boolean;
  50853. /**
  50854. * Utility layer that the bounding box gizmo belongs to
  50855. */
  50856. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  50857. /**
  50858. * Utility layer that all gizmos besides bounding box belong to
  50859. */
  50860. get utilityLayer(): UtilityLayerRenderer;
  50861. /**
  50862. * Instatiates a gizmo manager
  50863. * @param scene the scene to overlay the gizmos on top of
  50864. */
  50865. constructor(scene: Scene);
  50866. /**
  50867. * Attaches a set of gizmos to the specified mesh
  50868. * @param mesh The mesh the gizmo's should be attached to
  50869. */
  50870. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50871. /**
  50872. * If the position gizmo is enabled
  50873. */
  50874. set positionGizmoEnabled(value: boolean);
  50875. get positionGizmoEnabled(): boolean;
  50876. /**
  50877. * If the rotation gizmo is enabled
  50878. */
  50879. set rotationGizmoEnabled(value: boolean);
  50880. get rotationGizmoEnabled(): boolean;
  50881. /**
  50882. * If the scale gizmo is enabled
  50883. */
  50884. set scaleGizmoEnabled(value: boolean);
  50885. get scaleGizmoEnabled(): boolean;
  50886. /**
  50887. * If the boundingBox gizmo is enabled
  50888. */
  50889. set boundingBoxGizmoEnabled(value: boolean);
  50890. get boundingBoxGizmoEnabled(): boolean;
  50891. /**
  50892. * Disposes of the gizmo manager
  50893. */
  50894. dispose(): void;
  50895. }
  50896. }
  50897. declare module "babylonjs/Lights/directionalLight" {
  50898. import { Camera } from "babylonjs/Cameras/camera";
  50899. import { Scene } from "babylonjs/scene";
  50900. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50902. import { Light } from "babylonjs/Lights/light";
  50903. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50904. import { Effect } from "babylonjs/Materials/effect";
  50905. /**
  50906. * A directional light is defined by a direction (what a surprise!).
  50907. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  50908. * 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.
  50909. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50910. */
  50911. export class DirectionalLight extends ShadowLight {
  50912. private _shadowFrustumSize;
  50913. /**
  50914. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  50915. */
  50916. get shadowFrustumSize(): number;
  50917. /**
  50918. * Specifies a fix frustum size for the shadow generation.
  50919. */
  50920. set shadowFrustumSize(value: number);
  50921. private _shadowOrthoScale;
  50922. /**
  50923. * Gets the shadow projection scale against the optimal computed one.
  50924. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50925. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50926. */
  50927. get shadowOrthoScale(): number;
  50928. /**
  50929. * Sets the shadow projection scale against the optimal computed one.
  50930. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50931. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50932. */
  50933. set shadowOrthoScale(value: number);
  50934. /**
  50935. * Automatically compute the projection matrix to best fit (including all the casters)
  50936. * on each frame.
  50937. */
  50938. autoUpdateExtends: boolean;
  50939. /**
  50940. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  50941. * on each frame. autoUpdateExtends must be set to true for this to work
  50942. */
  50943. autoCalcShadowZBounds: boolean;
  50944. private _orthoLeft;
  50945. private _orthoRight;
  50946. private _orthoTop;
  50947. private _orthoBottom;
  50948. /**
  50949. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  50950. * The directional light is emitted from everywhere in the given direction.
  50951. * It can cast shadows.
  50952. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50953. * @param name The friendly name of the light
  50954. * @param direction The direction of the light
  50955. * @param scene The scene the light belongs to
  50956. */
  50957. constructor(name: string, direction: Vector3, scene: Scene);
  50958. /**
  50959. * Returns the string "DirectionalLight".
  50960. * @return The class name
  50961. */
  50962. getClassName(): string;
  50963. /**
  50964. * Returns the integer 1.
  50965. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50966. */
  50967. getTypeID(): number;
  50968. /**
  50969. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  50970. * Returns the DirectionalLight Shadow projection matrix.
  50971. */
  50972. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50973. /**
  50974. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  50975. * Returns the DirectionalLight Shadow projection matrix.
  50976. */
  50977. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  50978. /**
  50979. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  50980. * Returns the DirectionalLight Shadow projection matrix.
  50981. */
  50982. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50983. protected _buildUniformLayout(): void;
  50984. /**
  50985. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  50986. * @param effect The effect to update
  50987. * @param lightIndex The index of the light in the effect to update
  50988. * @returns The directional light
  50989. */
  50990. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  50991. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  50992. /**
  50993. * Gets the minZ used for shadow according to both the scene and the light.
  50994. *
  50995. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50996. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50997. * @param activeCamera The camera we are returning the min for
  50998. * @returns the depth min z
  50999. */
  51000. getDepthMinZ(activeCamera: Camera): number;
  51001. /**
  51002. * Gets the maxZ used for shadow according to both the scene and the light.
  51003. *
  51004. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  51005. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  51006. * @param activeCamera The camera we are returning the max for
  51007. * @returns the depth max z
  51008. */
  51009. getDepthMaxZ(activeCamera: Camera): number;
  51010. /**
  51011. * Prepares the list of defines specific to the light type.
  51012. * @param defines the list of defines
  51013. * @param lightIndex defines the index of the light for the effect
  51014. */
  51015. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51016. }
  51017. }
  51018. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  51019. import { Mesh } from "babylonjs/Meshes/mesh";
  51020. /**
  51021. * Class containing static functions to help procedurally build meshes
  51022. */
  51023. export class HemisphereBuilder {
  51024. /**
  51025. * Creates a hemisphere mesh
  51026. * @param name defines the name of the mesh
  51027. * @param options defines the options used to create the mesh
  51028. * @param scene defines the hosting scene
  51029. * @returns the hemisphere mesh
  51030. */
  51031. static CreateHemisphere(name: string, options: {
  51032. segments?: number;
  51033. diameter?: number;
  51034. sideOrientation?: number;
  51035. }, scene: any): Mesh;
  51036. }
  51037. }
  51038. declare module "babylonjs/Lights/spotLight" {
  51039. import { Nullable } from "babylonjs/types";
  51040. import { Scene } from "babylonjs/scene";
  51041. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51042. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51043. import { Effect } from "babylonjs/Materials/effect";
  51044. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51045. import { Light } from "babylonjs/Lights/light";
  51046. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51047. /**
  51048. * A spot light is defined by a position, a direction, an angle, and an exponent.
  51049. * These values define a cone of light starting from the position, emitting toward the direction.
  51050. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  51051. * and the exponent defines the speed of the decay of the light with distance (reach).
  51052. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51053. */
  51054. export class SpotLight extends ShadowLight {
  51055. private _angle;
  51056. private _innerAngle;
  51057. private _cosHalfAngle;
  51058. private _lightAngleScale;
  51059. private _lightAngleOffset;
  51060. /**
  51061. * Gets the cone angle of the spot light in Radians.
  51062. */
  51063. get angle(): number;
  51064. /**
  51065. * Sets the cone angle of the spot light in Radians.
  51066. */
  51067. set angle(value: number);
  51068. /**
  51069. * Only used in gltf falloff mode, this defines the angle where
  51070. * the directional falloff will start before cutting at angle which could be seen
  51071. * as outer angle.
  51072. */
  51073. get innerAngle(): number;
  51074. /**
  51075. * Only used in gltf falloff mode, this defines the angle where
  51076. * the directional falloff will start before cutting at angle which could be seen
  51077. * as outer angle.
  51078. */
  51079. set innerAngle(value: number);
  51080. private _shadowAngleScale;
  51081. /**
  51082. * Allows scaling the angle of the light for shadow generation only.
  51083. */
  51084. get shadowAngleScale(): number;
  51085. /**
  51086. * Allows scaling the angle of the light for shadow generation only.
  51087. */
  51088. set shadowAngleScale(value: number);
  51089. /**
  51090. * The light decay speed with the distance from the emission spot.
  51091. */
  51092. exponent: number;
  51093. private _projectionTextureMatrix;
  51094. /**
  51095. * Allows reading the projecton texture
  51096. */
  51097. get projectionTextureMatrix(): Matrix;
  51098. protected _projectionTextureLightNear: number;
  51099. /**
  51100. * Gets the near clip of the Spotlight for texture projection.
  51101. */
  51102. get projectionTextureLightNear(): number;
  51103. /**
  51104. * Sets the near clip of the Spotlight for texture projection.
  51105. */
  51106. set projectionTextureLightNear(value: number);
  51107. protected _projectionTextureLightFar: number;
  51108. /**
  51109. * Gets the far clip of the Spotlight for texture projection.
  51110. */
  51111. get projectionTextureLightFar(): number;
  51112. /**
  51113. * Sets the far clip of the Spotlight for texture projection.
  51114. */
  51115. set projectionTextureLightFar(value: number);
  51116. protected _projectionTextureUpDirection: Vector3;
  51117. /**
  51118. * Gets the Up vector of the Spotlight for texture projection.
  51119. */
  51120. get projectionTextureUpDirection(): Vector3;
  51121. /**
  51122. * Sets the Up vector of the Spotlight for texture projection.
  51123. */
  51124. set projectionTextureUpDirection(value: Vector3);
  51125. private _projectionTexture;
  51126. /**
  51127. * Gets the projection texture of the light.
  51128. */
  51129. get projectionTexture(): Nullable<BaseTexture>;
  51130. /**
  51131. * Sets the projection texture of the light.
  51132. */
  51133. set projectionTexture(value: Nullable<BaseTexture>);
  51134. private _projectionTextureViewLightDirty;
  51135. private _projectionTextureProjectionLightDirty;
  51136. private _projectionTextureDirty;
  51137. private _projectionTextureViewTargetVector;
  51138. private _projectionTextureViewLightMatrix;
  51139. private _projectionTextureProjectionLightMatrix;
  51140. private _projectionTextureScalingMatrix;
  51141. /**
  51142. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  51143. * It can cast shadows.
  51144. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51145. * @param name The light friendly name
  51146. * @param position The position of the spot light in the scene
  51147. * @param direction The direction of the light in the scene
  51148. * @param angle The cone angle of the light in Radians
  51149. * @param exponent The light decay speed with the distance from the emission spot
  51150. * @param scene The scene the lights belongs to
  51151. */
  51152. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  51153. /**
  51154. * Returns the string "SpotLight".
  51155. * @returns the class name
  51156. */
  51157. getClassName(): string;
  51158. /**
  51159. * Returns the integer 2.
  51160. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51161. */
  51162. getTypeID(): number;
  51163. /**
  51164. * Overrides the direction setter to recompute the projection texture view light Matrix.
  51165. */
  51166. protected _setDirection(value: Vector3): void;
  51167. /**
  51168. * Overrides the position setter to recompute the projection texture view light Matrix.
  51169. */
  51170. protected _setPosition(value: Vector3): void;
  51171. /**
  51172. * 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.
  51173. * Returns the SpotLight.
  51174. */
  51175. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51176. protected _computeProjectionTextureViewLightMatrix(): void;
  51177. protected _computeProjectionTextureProjectionLightMatrix(): void;
  51178. /**
  51179. * Main function for light texture projection matrix computing.
  51180. */
  51181. protected _computeProjectionTextureMatrix(): void;
  51182. protected _buildUniformLayout(): void;
  51183. private _computeAngleValues;
  51184. /**
  51185. * Sets the passed Effect "effect" with the Light textures.
  51186. * @param effect The effect to update
  51187. * @param lightIndex The index of the light in the effect to update
  51188. * @returns The light
  51189. */
  51190. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  51191. /**
  51192. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  51193. * @param effect The effect to update
  51194. * @param lightIndex The index of the light in the effect to update
  51195. * @returns The spot light
  51196. */
  51197. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  51198. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  51199. /**
  51200. * Disposes the light and the associated resources.
  51201. */
  51202. dispose(): void;
  51203. /**
  51204. * Prepares the list of defines specific to the light type.
  51205. * @param defines the list of defines
  51206. * @param lightIndex defines the index of the light for the effect
  51207. */
  51208. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51209. }
  51210. }
  51211. declare module "babylonjs/Gizmos/lightGizmo" {
  51212. import { Nullable } from "babylonjs/types";
  51213. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51214. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51215. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51216. import { Light } from "babylonjs/Lights/light";
  51217. /**
  51218. * Gizmo that enables viewing a light
  51219. */
  51220. export class LightGizmo extends Gizmo {
  51221. private _lightMesh;
  51222. private _material;
  51223. private _cachedPosition;
  51224. private _cachedForward;
  51225. private _attachedMeshParent;
  51226. /**
  51227. * Creates a LightGizmo
  51228. * @param gizmoLayer The utility layer the gizmo will be added to
  51229. */
  51230. constructor(gizmoLayer?: UtilityLayerRenderer);
  51231. private _light;
  51232. /**
  51233. * The light that the gizmo is attached to
  51234. */
  51235. set light(light: Nullable<Light>);
  51236. get light(): Nullable<Light>;
  51237. /**
  51238. * Gets the material used to render the light gizmo
  51239. */
  51240. get material(): StandardMaterial;
  51241. /**
  51242. * @hidden
  51243. * Updates the gizmo to match the attached mesh's position/rotation
  51244. */
  51245. protected _update(): void;
  51246. private static _Scale;
  51247. /**
  51248. * Creates the lines for a light mesh
  51249. */
  51250. private static _CreateLightLines;
  51251. /**
  51252. * Disposes of the light gizmo
  51253. */
  51254. dispose(): void;
  51255. private static _CreateHemisphericLightMesh;
  51256. private static _CreatePointLightMesh;
  51257. private static _CreateSpotLightMesh;
  51258. private static _CreateDirectionalLightMesh;
  51259. }
  51260. }
  51261. declare module "babylonjs/Gizmos/index" {
  51262. export * from "babylonjs/Gizmos/axisDragGizmo";
  51263. export * from "babylonjs/Gizmos/axisScaleGizmo";
  51264. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  51265. export * from "babylonjs/Gizmos/gizmo";
  51266. export * from "babylonjs/Gizmos/gizmoManager";
  51267. export * from "babylonjs/Gizmos/planeRotationGizmo";
  51268. export * from "babylonjs/Gizmos/positionGizmo";
  51269. export * from "babylonjs/Gizmos/rotationGizmo";
  51270. export * from "babylonjs/Gizmos/scaleGizmo";
  51271. export * from "babylonjs/Gizmos/lightGizmo";
  51272. export * from "babylonjs/Gizmos/planeDragGizmo";
  51273. }
  51274. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  51275. /** @hidden */
  51276. export var backgroundFragmentDeclaration: {
  51277. name: string;
  51278. shader: string;
  51279. };
  51280. }
  51281. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  51282. /** @hidden */
  51283. export var backgroundUboDeclaration: {
  51284. name: string;
  51285. shader: string;
  51286. };
  51287. }
  51288. declare module "babylonjs/Shaders/background.fragment" {
  51289. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  51290. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51291. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51292. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51293. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51294. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51295. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51296. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  51297. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51298. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51299. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51300. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51301. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51302. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51303. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51304. /** @hidden */
  51305. export var backgroundPixelShader: {
  51306. name: string;
  51307. shader: string;
  51308. };
  51309. }
  51310. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  51311. /** @hidden */
  51312. export var backgroundVertexDeclaration: {
  51313. name: string;
  51314. shader: string;
  51315. };
  51316. }
  51317. declare module "babylonjs/Shaders/background.vertex" {
  51318. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  51319. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51320. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51321. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51322. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51323. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51324. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51325. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51326. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51327. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51328. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51329. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51330. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51331. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51332. /** @hidden */
  51333. export var backgroundVertexShader: {
  51334. name: string;
  51335. shader: string;
  51336. };
  51337. }
  51338. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  51339. import { Nullable, int, float } from "babylonjs/types";
  51340. import { Scene } from "babylonjs/scene";
  51341. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51342. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51343. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51344. import { Mesh } from "babylonjs/Meshes/mesh";
  51345. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51346. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51347. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51348. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51349. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  51350. import { Color3 } from "babylonjs/Maths/math.color";
  51351. import "babylonjs/Shaders/background.fragment";
  51352. import "babylonjs/Shaders/background.vertex";
  51353. /**
  51354. * Background material used to create an efficient environement around your scene.
  51355. */
  51356. export class BackgroundMaterial extends PushMaterial {
  51357. /**
  51358. * Standard reflectance value at parallel view angle.
  51359. */
  51360. static StandardReflectance0: number;
  51361. /**
  51362. * Standard reflectance value at grazing angle.
  51363. */
  51364. static StandardReflectance90: number;
  51365. protected _primaryColor: Color3;
  51366. /**
  51367. * Key light Color (multiply against the environement texture)
  51368. */
  51369. primaryColor: Color3;
  51370. protected __perceptualColor: Nullable<Color3>;
  51371. /**
  51372. * Experimental Internal Use Only.
  51373. *
  51374. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  51375. * This acts as a helper to set the primary color to a more "human friendly" value.
  51376. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  51377. * output color as close as possible from the chosen value.
  51378. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  51379. * part of lighting setup.)
  51380. */
  51381. get _perceptualColor(): Nullable<Color3>;
  51382. set _perceptualColor(value: Nullable<Color3>);
  51383. protected _primaryColorShadowLevel: float;
  51384. /**
  51385. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  51386. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  51387. */
  51388. get primaryColorShadowLevel(): float;
  51389. set primaryColorShadowLevel(value: float);
  51390. protected _primaryColorHighlightLevel: float;
  51391. /**
  51392. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  51393. * The primary color is used at the level chosen to define what the white area would look.
  51394. */
  51395. get primaryColorHighlightLevel(): float;
  51396. set primaryColorHighlightLevel(value: float);
  51397. protected _reflectionTexture: Nullable<BaseTexture>;
  51398. /**
  51399. * Reflection Texture used in the material.
  51400. * Should be author in a specific way for the best result (refer to the documentation).
  51401. */
  51402. reflectionTexture: Nullable<BaseTexture>;
  51403. protected _reflectionBlur: float;
  51404. /**
  51405. * Reflection Texture level of blur.
  51406. *
  51407. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  51408. * texture twice.
  51409. */
  51410. reflectionBlur: float;
  51411. protected _diffuseTexture: Nullable<BaseTexture>;
  51412. /**
  51413. * Diffuse Texture used in the material.
  51414. * Should be author in a specific way for the best result (refer to the documentation).
  51415. */
  51416. diffuseTexture: Nullable<BaseTexture>;
  51417. protected _shadowLights: Nullable<IShadowLight[]>;
  51418. /**
  51419. * Specify the list of lights casting shadow on the material.
  51420. * All scene shadow lights will be included if null.
  51421. */
  51422. shadowLights: Nullable<IShadowLight[]>;
  51423. protected _shadowLevel: float;
  51424. /**
  51425. * Helps adjusting the shadow to a softer level if required.
  51426. * 0 means black shadows and 1 means no shadows.
  51427. */
  51428. shadowLevel: float;
  51429. protected _sceneCenter: Vector3;
  51430. /**
  51431. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  51432. * It is usually zero but might be interesting to modify according to your setup.
  51433. */
  51434. sceneCenter: Vector3;
  51435. protected _opacityFresnel: boolean;
  51436. /**
  51437. * This helps specifying that the material is falling off to the sky box at grazing angle.
  51438. * This helps ensuring a nice transition when the camera goes under the ground.
  51439. */
  51440. opacityFresnel: boolean;
  51441. protected _reflectionFresnel: boolean;
  51442. /**
  51443. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  51444. * This helps adding a mirror texture on the ground.
  51445. */
  51446. reflectionFresnel: boolean;
  51447. protected _reflectionFalloffDistance: number;
  51448. /**
  51449. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  51450. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  51451. */
  51452. reflectionFalloffDistance: number;
  51453. protected _reflectionAmount: number;
  51454. /**
  51455. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  51456. */
  51457. reflectionAmount: number;
  51458. protected _reflectionReflectance0: number;
  51459. /**
  51460. * This specifies the weight of the reflection at grazing angle.
  51461. */
  51462. reflectionReflectance0: number;
  51463. protected _reflectionReflectance90: number;
  51464. /**
  51465. * This specifies the weight of the reflection at a perpendicular point of view.
  51466. */
  51467. reflectionReflectance90: number;
  51468. /**
  51469. * Sets the reflection reflectance fresnel values according to the default standard
  51470. * empirically know to work well :-)
  51471. */
  51472. set reflectionStandardFresnelWeight(value: number);
  51473. protected _useRGBColor: boolean;
  51474. /**
  51475. * Helps to directly use the maps channels instead of their level.
  51476. */
  51477. useRGBColor: boolean;
  51478. protected _enableNoise: boolean;
  51479. /**
  51480. * This helps reducing the banding effect that could occur on the background.
  51481. */
  51482. enableNoise: boolean;
  51483. /**
  51484. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51485. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  51486. * Recommended to be keep at 1.0 except for special cases.
  51487. */
  51488. get fovMultiplier(): number;
  51489. set fovMultiplier(value: number);
  51490. private _fovMultiplier;
  51491. /**
  51492. * Enable the FOV adjustment feature controlled by fovMultiplier.
  51493. */
  51494. useEquirectangularFOV: boolean;
  51495. private _maxSimultaneousLights;
  51496. /**
  51497. * Number of Simultaneous lights allowed on the material.
  51498. */
  51499. maxSimultaneousLights: int;
  51500. /**
  51501. * Default configuration related to image processing available in the Background Material.
  51502. */
  51503. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51504. /**
  51505. * Keep track of the image processing observer to allow dispose and replace.
  51506. */
  51507. private _imageProcessingObserver;
  51508. /**
  51509. * Attaches a new image processing configuration to the PBR Material.
  51510. * @param configuration (if null the scene configuration will be use)
  51511. */
  51512. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51513. /**
  51514. * Gets the image processing configuration used either in this material.
  51515. */
  51516. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  51517. /**
  51518. * Sets the Default image processing configuration used either in the this material.
  51519. *
  51520. * If sets to null, the scene one is in use.
  51521. */
  51522. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  51523. /**
  51524. * Gets wether the color curves effect is enabled.
  51525. */
  51526. get cameraColorCurvesEnabled(): boolean;
  51527. /**
  51528. * Sets wether the color curves effect is enabled.
  51529. */
  51530. set cameraColorCurvesEnabled(value: boolean);
  51531. /**
  51532. * Gets wether the color grading effect is enabled.
  51533. */
  51534. get cameraColorGradingEnabled(): boolean;
  51535. /**
  51536. * Gets wether the color grading effect is enabled.
  51537. */
  51538. set cameraColorGradingEnabled(value: boolean);
  51539. /**
  51540. * Gets wether tonemapping is enabled or not.
  51541. */
  51542. get cameraToneMappingEnabled(): boolean;
  51543. /**
  51544. * Sets wether tonemapping is enabled or not
  51545. */
  51546. set cameraToneMappingEnabled(value: boolean);
  51547. /**
  51548. * The camera exposure used on this material.
  51549. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51550. * This corresponds to a photographic exposure.
  51551. */
  51552. get cameraExposure(): float;
  51553. /**
  51554. * The camera exposure used on this material.
  51555. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51556. * This corresponds to a photographic exposure.
  51557. */
  51558. set cameraExposure(value: float);
  51559. /**
  51560. * Gets The camera contrast used on this material.
  51561. */
  51562. get cameraContrast(): float;
  51563. /**
  51564. * Sets The camera contrast used on this material.
  51565. */
  51566. set cameraContrast(value: float);
  51567. /**
  51568. * Gets the Color Grading 2D Lookup Texture.
  51569. */
  51570. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51571. /**
  51572. * Sets the Color Grading 2D Lookup Texture.
  51573. */
  51574. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51575. /**
  51576. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51577. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51578. * 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;
  51579. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51580. */
  51581. get cameraColorCurves(): Nullable<ColorCurves>;
  51582. /**
  51583. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51584. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51585. * 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;
  51586. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51587. */
  51588. set cameraColorCurves(value: Nullable<ColorCurves>);
  51589. /**
  51590. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  51591. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  51592. */
  51593. switchToBGR: boolean;
  51594. private _renderTargets;
  51595. private _reflectionControls;
  51596. private _white;
  51597. private _primaryShadowColor;
  51598. private _primaryHighlightColor;
  51599. /**
  51600. * Instantiates a Background Material in the given scene
  51601. * @param name The friendly name of the material
  51602. * @param scene The scene to add the material to
  51603. */
  51604. constructor(name: string, scene: Scene);
  51605. /**
  51606. * Gets a boolean indicating that current material needs to register RTT
  51607. */
  51608. get hasRenderTargetTextures(): boolean;
  51609. /**
  51610. * The entire material has been created in order to prevent overdraw.
  51611. * @returns false
  51612. */
  51613. needAlphaTesting(): boolean;
  51614. /**
  51615. * The entire material has been created in order to prevent overdraw.
  51616. * @returns true if blending is enable
  51617. */
  51618. needAlphaBlending(): boolean;
  51619. /**
  51620. * Checks wether the material is ready to be rendered for a given mesh.
  51621. * @param mesh The mesh to render
  51622. * @param subMesh The submesh to check against
  51623. * @param useInstances Specify wether or not the material is used with instances
  51624. * @returns true if all the dependencies are ready (Textures, Effects...)
  51625. */
  51626. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51627. /**
  51628. * Compute the primary color according to the chosen perceptual color.
  51629. */
  51630. private _computePrimaryColorFromPerceptualColor;
  51631. /**
  51632. * Compute the highlights and shadow colors according to their chosen levels.
  51633. */
  51634. private _computePrimaryColors;
  51635. /**
  51636. * Build the uniform buffer used in the material.
  51637. */
  51638. buildUniformLayout(): void;
  51639. /**
  51640. * Unbind the material.
  51641. */
  51642. unbind(): void;
  51643. /**
  51644. * Bind only the world matrix to the material.
  51645. * @param world The world matrix to bind.
  51646. */
  51647. bindOnlyWorldMatrix(world: Matrix): void;
  51648. /**
  51649. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  51650. * @param world The world matrix to bind.
  51651. * @param subMesh The submesh to bind for.
  51652. */
  51653. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51654. /**
  51655. * Checks to see if a texture is used in the material.
  51656. * @param texture - Base texture to use.
  51657. * @returns - Boolean specifying if a texture is used in the material.
  51658. */
  51659. hasTexture(texture: BaseTexture): boolean;
  51660. /**
  51661. * Dispose the material.
  51662. * @param forceDisposeEffect Force disposal of the associated effect.
  51663. * @param forceDisposeTextures Force disposal of the associated textures.
  51664. */
  51665. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51666. /**
  51667. * Clones the material.
  51668. * @param name The cloned name.
  51669. * @returns The cloned material.
  51670. */
  51671. clone(name: string): BackgroundMaterial;
  51672. /**
  51673. * Serializes the current material to its JSON representation.
  51674. * @returns The JSON representation.
  51675. */
  51676. serialize(): any;
  51677. /**
  51678. * Gets the class name of the material
  51679. * @returns "BackgroundMaterial"
  51680. */
  51681. getClassName(): string;
  51682. /**
  51683. * Parse a JSON input to create back a background material.
  51684. * @param source The JSON data to parse
  51685. * @param scene The scene to create the parsed material in
  51686. * @param rootUrl The root url of the assets the material depends upon
  51687. * @returns the instantiated BackgroundMaterial.
  51688. */
  51689. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  51690. }
  51691. }
  51692. declare module "babylonjs/Helpers/environmentHelper" {
  51693. import { Observable } from "babylonjs/Misc/observable";
  51694. import { Nullable } from "babylonjs/types";
  51695. import { Scene } from "babylonjs/scene";
  51696. import { Vector3 } from "babylonjs/Maths/math.vector";
  51697. import { Color3 } from "babylonjs/Maths/math.color";
  51698. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51699. import { Mesh } from "babylonjs/Meshes/mesh";
  51700. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51701. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  51702. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51703. import "babylonjs/Meshes/Builders/planeBuilder";
  51704. import "babylonjs/Meshes/Builders/boxBuilder";
  51705. /**
  51706. * Represents the different options available during the creation of
  51707. * a Environment helper.
  51708. *
  51709. * This can control the default ground, skybox and image processing setup of your scene.
  51710. */
  51711. export interface IEnvironmentHelperOptions {
  51712. /**
  51713. * Specifies whether or not to create a ground.
  51714. * True by default.
  51715. */
  51716. createGround: boolean;
  51717. /**
  51718. * Specifies the ground size.
  51719. * 15 by default.
  51720. */
  51721. groundSize: number;
  51722. /**
  51723. * The texture used on the ground for the main color.
  51724. * Comes from the BabylonJS CDN by default.
  51725. *
  51726. * Remarks: Can be either a texture or a url.
  51727. */
  51728. groundTexture: string | BaseTexture;
  51729. /**
  51730. * The color mixed in the ground texture by default.
  51731. * BabylonJS clearColor by default.
  51732. */
  51733. groundColor: Color3;
  51734. /**
  51735. * Specifies the ground opacity.
  51736. * 1 by default.
  51737. */
  51738. groundOpacity: number;
  51739. /**
  51740. * Enables the ground to receive shadows.
  51741. * True by default.
  51742. */
  51743. enableGroundShadow: boolean;
  51744. /**
  51745. * Helps preventing the shadow to be fully black on the ground.
  51746. * 0.5 by default.
  51747. */
  51748. groundShadowLevel: number;
  51749. /**
  51750. * Creates a mirror texture attach to the ground.
  51751. * false by default.
  51752. */
  51753. enableGroundMirror: boolean;
  51754. /**
  51755. * Specifies the ground mirror size ratio.
  51756. * 0.3 by default as the default kernel is 64.
  51757. */
  51758. groundMirrorSizeRatio: number;
  51759. /**
  51760. * Specifies the ground mirror blur kernel size.
  51761. * 64 by default.
  51762. */
  51763. groundMirrorBlurKernel: number;
  51764. /**
  51765. * Specifies the ground mirror visibility amount.
  51766. * 1 by default
  51767. */
  51768. groundMirrorAmount: number;
  51769. /**
  51770. * Specifies the ground mirror reflectance weight.
  51771. * This uses the standard weight of the background material to setup the fresnel effect
  51772. * of the mirror.
  51773. * 1 by default.
  51774. */
  51775. groundMirrorFresnelWeight: number;
  51776. /**
  51777. * Specifies the ground mirror Falloff distance.
  51778. * This can helps reducing the size of the reflection.
  51779. * 0 by Default.
  51780. */
  51781. groundMirrorFallOffDistance: number;
  51782. /**
  51783. * Specifies the ground mirror texture type.
  51784. * Unsigned Int by Default.
  51785. */
  51786. groundMirrorTextureType: number;
  51787. /**
  51788. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  51789. * the shown objects.
  51790. */
  51791. groundYBias: number;
  51792. /**
  51793. * Specifies whether or not to create a skybox.
  51794. * True by default.
  51795. */
  51796. createSkybox: boolean;
  51797. /**
  51798. * Specifies the skybox size.
  51799. * 20 by default.
  51800. */
  51801. skyboxSize: number;
  51802. /**
  51803. * The texture used on the skybox for the main color.
  51804. * Comes from the BabylonJS CDN by default.
  51805. *
  51806. * Remarks: Can be either a texture or a url.
  51807. */
  51808. skyboxTexture: string | BaseTexture;
  51809. /**
  51810. * The color mixed in the skybox texture by default.
  51811. * BabylonJS clearColor by default.
  51812. */
  51813. skyboxColor: Color3;
  51814. /**
  51815. * The background rotation around the Y axis of the scene.
  51816. * This helps aligning the key lights of your scene with the background.
  51817. * 0 by default.
  51818. */
  51819. backgroundYRotation: number;
  51820. /**
  51821. * Compute automatically the size of the elements to best fit with the scene.
  51822. */
  51823. sizeAuto: boolean;
  51824. /**
  51825. * Default position of the rootMesh if autoSize is not true.
  51826. */
  51827. rootPosition: Vector3;
  51828. /**
  51829. * Sets up the image processing in the scene.
  51830. * true by default.
  51831. */
  51832. setupImageProcessing: boolean;
  51833. /**
  51834. * The texture used as your environment texture in the scene.
  51835. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  51836. *
  51837. * Remarks: Can be either a texture or a url.
  51838. */
  51839. environmentTexture: string | BaseTexture;
  51840. /**
  51841. * The value of the exposure to apply to the scene.
  51842. * 0.6 by default if setupImageProcessing is true.
  51843. */
  51844. cameraExposure: number;
  51845. /**
  51846. * The value of the contrast to apply to the scene.
  51847. * 1.6 by default if setupImageProcessing is true.
  51848. */
  51849. cameraContrast: number;
  51850. /**
  51851. * Specifies whether or not tonemapping should be enabled in the scene.
  51852. * true by default if setupImageProcessing is true.
  51853. */
  51854. toneMappingEnabled: boolean;
  51855. }
  51856. /**
  51857. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  51858. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  51859. * It also helps with the default setup of your imageProcessing configuration.
  51860. */
  51861. export class EnvironmentHelper {
  51862. /**
  51863. * Default ground texture URL.
  51864. */
  51865. private static _groundTextureCDNUrl;
  51866. /**
  51867. * Default skybox texture URL.
  51868. */
  51869. private static _skyboxTextureCDNUrl;
  51870. /**
  51871. * Default environment texture URL.
  51872. */
  51873. private static _environmentTextureCDNUrl;
  51874. /**
  51875. * Creates the default options for the helper.
  51876. */
  51877. private static _getDefaultOptions;
  51878. private _rootMesh;
  51879. /**
  51880. * Gets the root mesh created by the helper.
  51881. */
  51882. get rootMesh(): Mesh;
  51883. private _skybox;
  51884. /**
  51885. * Gets the skybox created by the helper.
  51886. */
  51887. get skybox(): Nullable<Mesh>;
  51888. private _skyboxTexture;
  51889. /**
  51890. * Gets the skybox texture created by the helper.
  51891. */
  51892. get skyboxTexture(): Nullable<BaseTexture>;
  51893. private _skyboxMaterial;
  51894. /**
  51895. * Gets the skybox material created by the helper.
  51896. */
  51897. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  51898. private _ground;
  51899. /**
  51900. * Gets the ground mesh created by the helper.
  51901. */
  51902. get ground(): Nullable<Mesh>;
  51903. private _groundTexture;
  51904. /**
  51905. * Gets the ground texture created by the helper.
  51906. */
  51907. get groundTexture(): Nullable<BaseTexture>;
  51908. private _groundMirror;
  51909. /**
  51910. * Gets the ground mirror created by the helper.
  51911. */
  51912. get groundMirror(): Nullable<MirrorTexture>;
  51913. /**
  51914. * Gets the ground mirror render list to helps pushing the meshes
  51915. * you wish in the ground reflection.
  51916. */
  51917. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  51918. private _groundMaterial;
  51919. /**
  51920. * Gets the ground material created by the helper.
  51921. */
  51922. get groundMaterial(): Nullable<BackgroundMaterial>;
  51923. /**
  51924. * Stores the creation options.
  51925. */
  51926. private readonly _scene;
  51927. private _options;
  51928. /**
  51929. * This observable will be notified with any error during the creation of the environment,
  51930. * mainly texture creation errors.
  51931. */
  51932. onErrorObservable: Observable<{
  51933. message?: string;
  51934. exception?: any;
  51935. }>;
  51936. /**
  51937. * constructor
  51938. * @param options Defines the options we want to customize the helper
  51939. * @param scene The scene to add the material to
  51940. */
  51941. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  51942. /**
  51943. * Updates the background according to the new options
  51944. * @param options
  51945. */
  51946. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  51947. /**
  51948. * Sets the primary color of all the available elements.
  51949. * @param color the main color to affect to the ground and the background
  51950. */
  51951. setMainColor(color: Color3): void;
  51952. /**
  51953. * Setup the image processing according to the specified options.
  51954. */
  51955. private _setupImageProcessing;
  51956. /**
  51957. * Setup the environment texture according to the specified options.
  51958. */
  51959. private _setupEnvironmentTexture;
  51960. /**
  51961. * Setup the background according to the specified options.
  51962. */
  51963. private _setupBackground;
  51964. /**
  51965. * Get the scene sizes according to the setup.
  51966. */
  51967. private _getSceneSize;
  51968. /**
  51969. * Setup the ground according to the specified options.
  51970. */
  51971. private _setupGround;
  51972. /**
  51973. * Setup the ground material according to the specified options.
  51974. */
  51975. private _setupGroundMaterial;
  51976. /**
  51977. * Setup the ground diffuse texture according to the specified options.
  51978. */
  51979. private _setupGroundDiffuseTexture;
  51980. /**
  51981. * Setup the ground mirror texture according to the specified options.
  51982. */
  51983. private _setupGroundMirrorTexture;
  51984. /**
  51985. * Setup the ground to receive the mirror texture.
  51986. */
  51987. private _setupMirrorInGroundMaterial;
  51988. /**
  51989. * Setup the skybox according to the specified options.
  51990. */
  51991. private _setupSkybox;
  51992. /**
  51993. * Setup the skybox material according to the specified options.
  51994. */
  51995. private _setupSkyboxMaterial;
  51996. /**
  51997. * Setup the skybox reflection texture according to the specified options.
  51998. */
  51999. private _setupSkyboxReflectionTexture;
  52000. private _errorHandler;
  52001. /**
  52002. * Dispose all the elements created by the Helper.
  52003. */
  52004. dispose(): void;
  52005. }
  52006. }
  52007. declare module "babylonjs/Helpers/photoDome" {
  52008. import { Observable } from "babylonjs/Misc/observable";
  52009. import { Nullable } from "babylonjs/types";
  52010. import { Scene } from "babylonjs/scene";
  52011. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52012. import { Mesh } from "babylonjs/Meshes/mesh";
  52013. import { Texture } from "babylonjs/Materials/Textures/texture";
  52014. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  52015. import "babylonjs/Meshes/Builders/sphereBuilder";
  52016. /**
  52017. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  52018. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  52019. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  52020. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52021. */
  52022. export class PhotoDome extends TransformNode {
  52023. /**
  52024. * Define the image as a Monoscopic panoramic 360 image.
  52025. */
  52026. static readonly MODE_MONOSCOPIC: number;
  52027. /**
  52028. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  52029. */
  52030. static readonly MODE_TOPBOTTOM: number;
  52031. /**
  52032. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  52033. */
  52034. static readonly MODE_SIDEBYSIDE: number;
  52035. private _useDirectMapping;
  52036. /**
  52037. * The texture being displayed on the sphere
  52038. */
  52039. protected _photoTexture: Texture;
  52040. /**
  52041. * Gets or sets the texture being displayed on the sphere
  52042. */
  52043. get photoTexture(): Texture;
  52044. set photoTexture(value: Texture);
  52045. /**
  52046. * Observable raised when an error occured while loading the 360 image
  52047. */
  52048. onLoadErrorObservable: Observable<string>;
  52049. /**
  52050. * The skybox material
  52051. */
  52052. protected _material: BackgroundMaterial;
  52053. /**
  52054. * The surface used for the skybox
  52055. */
  52056. protected _mesh: Mesh;
  52057. /**
  52058. * Gets the mesh used for the skybox.
  52059. */
  52060. get mesh(): Mesh;
  52061. /**
  52062. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52063. * Also see the options.resolution property.
  52064. */
  52065. get fovMultiplier(): number;
  52066. set fovMultiplier(value: number);
  52067. private _imageMode;
  52068. /**
  52069. * Gets or set the current video mode for the video. It can be:
  52070. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  52071. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  52072. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  52073. */
  52074. get imageMode(): number;
  52075. set imageMode(value: number);
  52076. /**
  52077. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  52078. * @param name Element's name, child elements will append suffixes for their own names.
  52079. * @param urlsOfPhoto defines the url of the photo to display
  52080. * @param options defines an object containing optional or exposed sub element properties
  52081. * @param onError defines a callback called when an error occured while loading the texture
  52082. */
  52083. constructor(name: string, urlOfPhoto: string, options: {
  52084. resolution?: number;
  52085. size?: number;
  52086. useDirectMapping?: boolean;
  52087. faceForward?: boolean;
  52088. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  52089. private _onBeforeCameraRenderObserver;
  52090. private _changeImageMode;
  52091. /**
  52092. * Releases resources associated with this node.
  52093. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52094. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52095. */
  52096. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52097. }
  52098. }
  52099. declare module "babylonjs/Misc/rgbdTextureTools" {
  52100. import "babylonjs/Shaders/rgbdDecode.fragment";
  52101. import "babylonjs/Engines/Extensions/engine.renderTarget";
  52102. import { Texture } from "babylonjs/Materials/Textures/texture";
  52103. /**
  52104. * Class used to host RGBD texture specific utilities
  52105. */
  52106. export class RGBDTextureTools {
  52107. /**
  52108. * Expand the RGBD Texture from RGBD to Half Float if possible.
  52109. * @param texture the texture to expand.
  52110. */
  52111. static ExpandRGBDTexture(texture: Texture): void;
  52112. }
  52113. }
  52114. declare module "babylonjs/Misc/brdfTextureTools" {
  52115. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52116. import { Scene } from "babylonjs/scene";
  52117. /**
  52118. * Class used to host texture specific utilities
  52119. */
  52120. export class BRDFTextureTools {
  52121. /**
  52122. * Prevents texture cache collision
  52123. */
  52124. private static _instanceNumber;
  52125. /**
  52126. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  52127. * @param scene defines the hosting scene
  52128. * @returns the environment BRDF texture
  52129. */
  52130. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  52131. private static _environmentBRDFBase64Texture;
  52132. }
  52133. }
  52134. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  52135. import { Nullable } from "babylonjs/types";
  52136. import { Color3 } from "babylonjs/Maths/math.color";
  52137. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52138. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52139. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52140. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52141. import { Engine } from "babylonjs/Engines/engine";
  52142. import { Scene } from "babylonjs/scene";
  52143. /**
  52144. * @hidden
  52145. */
  52146. export interface IMaterialClearCoatDefines {
  52147. CLEARCOAT: boolean;
  52148. CLEARCOAT_DEFAULTIOR: boolean;
  52149. CLEARCOAT_TEXTURE: boolean;
  52150. CLEARCOAT_TEXTUREDIRECTUV: number;
  52151. CLEARCOAT_BUMP: boolean;
  52152. CLEARCOAT_BUMPDIRECTUV: number;
  52153. CLEARCOAT_TINT: boolean;
  52154. CLEARCOAT_TINT_TEXTURE: boolean;
  52155. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  52156. /** @hidden */
  52157. _areTexturesDirty: boolean;
  52158. }
  52159. /**
  52160. * Define the code related to the clear coat parameters of the pbr material.
  52161. */
  52162. export class PBRClearCoatConfiguration {
  52163. /**
  52164. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52165. * The default fits with a polyurethane material.
  52166. */
  52167. private static readonly _DefaultIndexOfRefraction;
  52168. private _isEnabled;
  52169. /**
  52170. * Defines if the clear coat is enabled in the material.
  52171. */
  52172. isEnabled: boolean;
  52173. /**
  52174. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  52175. */
  52176. intensity: number;
  52177. /**
  52178. * Defines the clear coat layer roughness.
  52179. */
  52180. roughness: number;
  52181. private _indexOfRefraction;
  52182. /**
  52183. * Defines the index of refraction of the clear coat.
  52184. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52185. * The default fits with a polyurethane material.
  52186. * Changing the default value is more performance intensive.
  52187. */
  52188. indexOfRefraction: number;
  52189. private _texture;
  52190. /**
  52191. * Stores the clear coat values in a texture.
  52192. */
  52193. texture: Nullable<BaseTexture>;
  52194. private _bumpTexture;
  52195. /**
  52196. * Define the clear coat specific bump texture.
  52197. */
  52198. bumpTexture: Nullable<BaseTexture>;
  52199. private _isTintEnabled;
  52200. /**
  52201. * Defines if the clear coat tint is enabled in the material.
  52202. */
  52203. isTintEnabled: boolean;
  52204. /**
  52205. * Defines the clear coat tint of the material.
  52206. * This is only use if tint is enabled
  52207. */
  52208. tintColor: Color3;
  52209. /**
  52210. * Defines the distance at which the tint color should be found in the
  52211. * clear coat media.
  52212. * This is only use if tint is enabled
  52213. */
  52214. tintColorAtDistance: number;
  52215. /**
  52216. * Defines the clear coat layer thickness.
  52217. * This is only use if tint is enabled
  52218. */
  52219. tintThickness: number;
  52220. private _tintTexture;
  52221. /**
  52222. * Stores the clear tint values in a texture.
  52223. * rgb is tint
  52224. * a is a thickness factor
  52225. */
  52226. tintTexture: Nullable<BaseTexture>;
  52227. /** @hidden */
  52228. private _internalMarkAllSubMeshesAsTexturesDirty;
  52229. /** @hidden */
  52230. _markAllSubMeshesAsTexturesDirty(): void;
  52231. /**
  52232. * Instantiate a new istance of clear coat configuration.
  52233. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52234. */
  52235. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52236. /**
  52237. * Gets wehter the submesh is ready to be used or not.
  52238. * @param defines the list of "defines" to update.
  52239. * @param scene defines the scene the material belongs to.
  52240. * @param engine defines the engine the material belongs to.
  52241. * @param disableBumpMap defines wether the material disables bump or not.
  52242. * @returns - boolean indicating that the submesh is ready or not.
  52243. */
  52244. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  52245. /**
  52246. * Checks to see if a texture is used in the material.
  52247. * @param defines the list of "defines" to update.
  52248. * @param scene defines the scene to the material belongs to.
  52249. */
  52250. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  52251. /**
  52252. * Binds the material data.
  52253. * @param uniformBuffer defines the Uniform buffer to fill in.
  52254. * @param scene defines the scene the material belongs to.
  52255. * @param engine defines the engine the material belongs to.
  52256. * @param disableBumpMap defines wether the material disables bump or not.
  52257. * @param isFrozen defines wether the material is frozen or not.
  52258. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52259. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52260. */
  52261. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  52262. /**
  52263. * Checks to see if a texture is used in the material.
  52264. * @param texture - Base texture to use.
  52265. * @returns - Boolean specifying if a texture is used in the material.
  52266. */
  52267. hasTexture(texture: BaseTexture): boolean;
  52268. /**
  52269. * Returns an array of the actively used textures.
  52270. * @param activeTextures Array of BaseTextures
  52271. */
  52272. getActiveTextures(activeTextures: BaseTexture[]): void;
  52273. /**
  52274. * Returns the animatable textures.
  52275. * @param animatables Array of animatable textures.
  52276. */
  52277. getAnimatables(animatables: IAnimatable[]): void;
  52278. /**
  52279. * Disposes the resources of the material.
  52280. * @param forceDisposeTextures - Forces the disposal of all textures.
  52281. */
  52282. dispose(forceDisposeTextures?: boolean): void;
  52283. /**
  52284. * Get the current class name of the texture useful for serialization or dynamic coding.
  52285. * @returns "PBRClearCoatConfiguration"
  52286. */
  52287. getClassName(): string;
  52288. /**
  52289. * Add fallbacks to the effect fallbacks list.
  52290. * @param defines defines the Base texture to use.
  52291. * @param fallbacks defines the current fallback list.
  52292. * @param currentRank defines the current fallback rank.
  52293. * @returns the new fallback rank.
  52294. */
  52295. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52296. /**
  52297. * Add the required uniforms to the current list.
  52298. * @param uniforms defines the current uniform list.
  52299. */
  52300. static AddUniforms(uniforms: string[]): void;
  52301. /**
  52302. * Add the required samplers to the current list.
  52303. * @param samplers defines the current sampler list.
  52304. */
  52305. static AddSamplers(samplers: string[]): void;
  52306. /**
  52307. * Add the required uniforms to the current buffer.
  52308. * @param uniformBuffer defines the current uniform buffer.
  52309. */
  52310. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52311. /**
  52312. * Makes a duplicate of the current configuration into another one.
  52313. * @param clearCoatConfiguration define the config where to copy the info
  52314. */
  52315. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  52316. /**
  52317. * Serializes this clear coat configuration.
  52318. * @returns - An object with the serialized config.
  52319. */
  52320. serialize(): any;
  52321. /**
  52322. * Parses a anisotropy Configuration from a serialized object.
  52323. * @param source - Serialized object.
  52324. * @param scene Defines the scene we are parsing for
  52325. * @param rootUrl Defines the rootUrl to load from
  52326. */
  52327. parse(source: any, scene: Scene, rootUrl: string): void;
  52328. }
  52329. }
  52330. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  52331. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52333. import { Vector2 } from "babylonjs/Maths/math.vector";
  52334. import { Scene } from "babylonjs/scene";
  52335. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52336. import { Nullable } from "babylonjs/types";
  52337. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52338. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52339. /**
  52340. * @hidden
  52341. */
  52342. export interface IMaterialAnisotropicDefines {
  52343. ANISOTROPIC: boolean;
  52344. ANISOTROPIC_TEXTURE: boolean;
  52345. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52346. MAINUV1: boolean;
  52347. _areTexturesDirty: boolean;
  52348. _needUVs: boolean;
  52349. }
  52350. /**
  52351. * Define the code related to the anisotropic parameters of the pbr material.
  52352. */
  52353. export class PBRAnisotropicConfiguration {
  52354. private _isEnabled;
  52355. /**
  52356. * Defines if the anisotropy is enabled in the material.
  52357. */
  52358. isEnabled: boolean;
  52359. /**
  52360. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  52361. */
  52362. intensity: number;
  52363. /**
  52364. * Defines if the effect is along the tangents, bitangents or in between.
  52365. * By default, the effect is "strectching" the highlights along the tangents.
  52366. */
  52367. direction: Vector2;
  52368. private _texture;
  52369. /**
  52370. * Stores the anisotropy values in a texture.
  52371. * rg is direction (like normal from -1 to 1)
  52372. * b is a intensity
  52373. */
  52374. texture: Nullable<BaseTexture>;
  52375. /** @hidden */
  52376. private _internalMarkAllSubMeshesAsTexturesDirty;
  52377. /** @hidden */
  52378. _markAllSubMeshesAsTexturesDirty(): void;
  52379. /**
  52380. * Instantiate a new istance of anisotropy configuration.
  52381. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52382. */
  52383. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52384. /**
  52385. * Specifies that the submesh is ready to be used.
  52386. * @param defines the list of "defines" to update.
  52387. * @param scene defines the scene the material belongs to.
  52388. * @returns - boolean indicating that the submesh is ready or not.
  52389. */
  52390. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  52391. /**
  52392. * Checks to see if a texture is used in the material.
  52393. * @param defines the list of "defines" to update.
  52394. * @param mesh the mesh we are preparing the defines for.
  52395. * @param scene defines the scene the material belongs to.
  52396. */
  52397. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  52398. /**
  52399. * Binds the material data.
  52400. * @param uniformBuffer defines the Uniform buffer to fill in.
  52401. * @param scene defines the scene the material belongs to.
  52402. * @param isFrozen defines wether the material is frozen or not.
  52403. */
  52404. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52405. /**
  52406. * Checks to see if a texture is used in the material.
  52407. * @param texture - Base texture to use.
  52408. * @returns - Boolean specifying if a texture is used in the material.
  52409. */
  52410. hasTexture(texture: BaseTexture): boolean;
  52411. /**
  52412. * Returns an array of the actively used textures.
  52413. * @param activeTextures Array of BaseTextures
  52414. */
  52415. getActiveTextures(activeTextures: BaseTexture[]): void;
  52416. /**
  52417. * Returns the animatable textures.
  52418. * @param animatables Array of animatable textures.
  52419. */
  52420. getAnimatables(animatables: IAnimatable[]): void;
  52421. /**
  52422. * Disposes the resources of the material.
  52423. * @param forceDisposeTextures - Forces the disposal of all textures.
  52424. */
  52425. dispose(forceDisposeTextures?: boolean): void;
  52426. /**
  52427. * Get the current class name of the texture useful for serialization or dynamic coding.
  52428. * @returns "PBRAnisotropicConfiguration"
  52429. */
  52430. getClassName(): string;
  52431. /**
  52432. * Add fallbacks to the effect fallbacks list.
  52433. * @param defines defines the Base texture to use.
  52434. * @param fallbacks defines the current fallback list.
  52435. * @param currentRank defines the current fallback rank.
  52436. * @returns the new fallback rank.
  52437. */
  52438. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52439. /**
  52440. * Add the required uniforms to the current list.
  52441. * @param uniforms defines the current uniform list.
  52442. */
  52443. static AddUniforms(uniforms: string[]): void;
  52444. /**
  52445. * Add the required uniforms to the current buffer.
  52446. * @param uniformBuffer defines the current uniform buffer.
  52447. */
  52448. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52449. /**
  52450. * Add the required samplers to the current list.
  52451. * @param samplers defines the current sampler list.
  52452. */
  52453. static AddSamplers(samplers: string[]): void;
  52454. /**
  52455. * Makes a duplicate of the current configuration into another one.
  52456. * @param anisotropicConfiguration define the config where to copy the info
  52457. */
  52458. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  52459. /**
  52460. * Serializes this anisotropy configuration.
  52461. * @returns - An object with the serialized config.
  52462. */
  52463. serialize(): any;
  52464. /**
  52465. * Parses a anisotropy Configuration from a serialized object.
  52466. * @param source - Serialized object.
  52467. * @param scene Defines the scene we are parsing for
  52468. * @param rootUrl Defines the rootUrl to load from
  52469. */
  52470. parse(source: any, scene: Scene, rootUrl: string): void;
  52471. }
  52472. }
  52473. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  52474. import { Scene } from "babylonjs/scene";
  52475. /**
  52476. * @hidden
  52477. */
  52478. export interface IMaterialBRDFDefines {
  52479. BRDF_V_HEIGHT_CORRELATED: boolean;
  52480. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52481. SPHERICAL_HARMONICS: boolean;
  52482. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52483. /** @hidden */
  52484. _areMiscDirty: boolean;
  52485. }
  52486. /**
  52487. * Define the code related to the BRDF parameters of the pbr material.
  52488. */
  52489. export class PBRBRDFConfiguration {
  52490. /**
  52491. * Default value used for the energy conservation.
  52492. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52493. */
  52494. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  52495. /**
  52496. * Default value used for the Smith Visibility Height Correlated mode.
  52497. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52498. */
  52499. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  52500. /**
  52501. * Default value used for the IBL diffuse part.
  52502. * This can help switching back to the polynomials mode globally which is a tiny bit
  52503. * less GPU intensive at the drawback of a lower quality.
  52504. */
  52505. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  52506. /**
  52507. * Default value used for activating energy conservation for the specular workflow.
  52508. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52509. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52510. */
  52511. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  52512. private _useEnergyConservation;
  52513. /**
  52514. * Defines if the material uses energy conservation.
  52515. */
  52516. useEnergyConservation: boolean;
  52517. private _useSmithVisibilityHeightCorrelated;
  52518. /**
  52519. * LEGACY Mode set to false
  52520. * Defines if the material uses height smith correlated visibility term.
  52521. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  52522. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  52523. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  52524. * Not relying on height correlated will also disable energy conservation.
  52525. */
  52526. useSmithVisibilityHeightCorrelated: boolean;
  52527. private _useSphericalHarmonics;
  52528. /**
  52529. * LEGACY Mode set to false
  52530. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  52531. * diffuse part of the IBL.
  52532. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  52533. * to the ground truth.
  52534. */
  52535. useSphericalHarmonics: boolean;
  52536. private _useSpecularGlossinessInputEnergyConservation;
  52537. /**
  52538. * Defines if the material uses energy conservation, when the specular workflow is active.
  52539. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52540. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52541. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  52542. */
  52543. useSpecularGlossinessInputEnergyConservation: boolean;
  52544. /** @hidden */
  52545. private _internalMarkAllSubMeshesAsMiscDirty;
  52546. /** @hidden */
  52547. _markAllSubMeshesAsMiscDirty(): void;
  52548. /**
  52549. * Instantiate a new istance of clear coat configuration.
  52550. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  52551. */
  52552. constructor(markAllSubMeshesAsMiscDirty: () => void);
  52553. /**
  52554. * Checks to see if a texture is used in the material.
  52555. * @param defines the list of "defines" to update.
  52556. */
  52557. prepareDefines(defines: IMaterialBRDFDefines): void;
  52558. /**
  52559. * Get the current class name of the texture useful for serialization or dynamic coding.
  52560. * @returns "PBRClearCoatConfiguration"
  52561. */
  52562. getClassName(): string;
  52563. /**
  52564. * Makes a duplicate of the current configuration into another one.
  52565. * @param brdfConfiguration define the config where to copy the info
  52566. */
  52567. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  52568. /**
  52569. * Serializes this BRDF configuration.
  52570. * @returns - An object with the serialized config.
  52571. */
  52572. serialize(): any;
  52573. /**
  52574. * Parses a anisotropy Configuration from a serialized object.
  52575. * @param source - Serialized object.
  52576. * @param scene Defines the scene we are parsing for
  52577. * @param rootUrl Defines the rootUrl to load from
  52578. */
  52579. parse(source: any, scene: Scene, rootUrl: string): void;
  52580. }
  52581. }
  52582. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  52583. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52584. import { Color3 } from "babylonjs/Maths/math.color";
  52585. import { Scene } from "babylonjs/scene";
  52586. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52587. import { Nullable } from "babylonjs/types";
  52588. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52589. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52590. /**
  52591. * @hidden
  52592. */
  52593. export interface IMaterialSheenDefines {
  52594. SHEEN: boolean;
  52595. SHEEN_TEXTURE: boolean;
  52596. SHEEN_TEXTUREDIRECTUV: number;
  52597. SHEEN_LINKWITHALBEDO: boolean;
  52598. SHEEN_ROUGHNESS: boolean;
  52599. SHEEN_ALBEDOSCALING: boolean;
  52600. /** @hidden */
  52601. _areTexturesDirty: boolean;
  52602. }
  52603. /**
  52604. * Define the code related to the Sheen parameters of the pbr material.
  52605. */
  52606. export class PBRSheenConfiguration {
  52607. private _isEnabled;
  52608. /**
  52609. * Defines if the material uses sheen.
  52610. */
  52611. isEnabled: boolean;
  52612. private _linkSheenWithAlbedo;
  52613. /**
  52614. * Defines if the sheen is linked to the sheen color.
  52615. */
  52616. linkSheenWithAlbedo: boolean;
  52617. /**
  52618. * Defines the sheen intensity.
  52619. */
  52620. intensity: number;
  52621. /**
  52622. * Defines the sheen color.
  52623. */
  52624. color: Color3;
  52625. private _texture;
  52626. /**
  52627. * Stores the sheen tint values in a texture.
  52628. * rgb is tint
  52629. * a is a intensity
  52630. */
  52631. texture: Nullable<BaseTexture>;
  52632. private _roughness;
  52633. /**
  52634. * Defines the sheen roughness.
  52635. * It is not taken into account if linkSheenWithAlbedo is true.
  52636. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  52637. */
  52638. roughness: Nullable<number>;
  52639. private _albedoScaling;
  52640. /**
  52641. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  52642. * It allows the strength of the sheen effect to not depend on the base color of the material,
  52643. * making it easier to setup and tweak the effect
  52644. */
  52645. albedoScaling: boolean;
  52646. /** @hidden */
  52647. private _internalMarkAllSubMeshesAsTexturesDirty;
  52648. /** @hidden */
  52649. _markAllSubMeshesAsTexturesDirty(): void;
  52650. /**
  52651. * Instantiate a new istance of clear coat configuration.
  52652. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52653. */
  52654. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52655. /**
  52656. * Specifies that the submesh is ready to be used.
  52657. * @param defines the list of "defines" to update.
  52658. * @param scene defines the scene the material belongs to.
  52659. * @returns - boolean indicating that the submesh is ready or not.
  52660. */
  52661. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  52662. /**
  52663. * Checks to see if a texture is used in the material.
  52664. * @param defines the list of "defines" to update.
  52665. * @param scene defines the scene the material belongs to.
  52666. */
  52667. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  52668. /**
  52669. * Binds the material data.
  52670. * @param uniformBuffer defines the Uniform buffer to fill in.
  52671. * @param scene defines the scene the material belongs to.
  52672. * @param isFrozen defines wether the material is frozen or not.
  52673. */
  52674. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52675. /**
  52676. * Checks to see if a texture is used in the material.
  52677. * @param texture - Base texture to use.
  52678. * @returns - Boolean specifying if a texture is used in the material.
  52679. */
  52680. hasTexture(texture: BaseTexture): boolean;
  52681. /**
  52682. * Returns an array of the actively used textures.
  52683. * @param activeTextures Array of BaseTextures
  52684. */
  52685. getActiveTextures(activeTextures: BaseTexture[]): void;
  52686. /**
  52687. * Returns the animatable textures.
  52688. * @param animatables Array of animatable textures.
  52689. */
  52690. getAnimatables(animatables: IAnimatable[]): void;
  52691. /**
  52692. * Disposes the resources of the material.
  52693. * @param forceDisposeTextures - Forces the disposal of all textures.
  52694. */
  52695. dispose(forceDisposeTextures?: boolean): void;
  52696. /**
  52697. * Get the current class name of the texture useful for serialization or dynamic coding.
  52698. * @returns "PBRSheenConfiguration"
  52699. */
  52700. getClassName(): string;
  52701. /**
  52702. * Add fallbacks to the effect fallbacks list.
  52703. * @param defines defines the Base texture to use.
  52704. * @param fallbacks defines the current fallback list.
  52705. * @param currentRank defines the current fallback rank.
  52706. * @returns the new fallback rank.
  52707. */
  52708. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52709. /**
  52710. * Add the required uniforms to the current list.
  52711. * @param uniforms defines the current uniform list.
  52712. */
  52713. static AddUniforms(uniforms: string[]): void;
  52714. /**
  52715. * Add the required uniforms to the current buffer.
  52716. * @param uniformBuffer defines the current uniform buffer.
  52717. */
  52718. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52719. /**
  52720. * Add the required samplers to the current list.
  52721. * @param samplers defines the current sampler list.
  52722. */
  52723. static AddSamplers(samplers: string[]): void;
  52724. /**
  52725. * Makes a duplicate of the current configuration into another one.
  52726. * @param sheenConfiguration define the config where to copy the info
  52727. */
  52728. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  52729. /**
  52730. * Serializes this BRDF configuration.
  52731. * @returns - An object with the serialized config.
  52732. */
  52733. serialize(): any;
  52734. /**
  52735. * Parses a anisotropy Configuration from a serialized object.
  52736. * @param source - Serialized object.
  52737. * @param scene Defines the scene we are parsing for
  52738. * @param rootUrl Defines the rootUrl to load from
  52739. */
  52740. parse(source: any, scene: Scene, rootUrl: string): void;
  52741. }
  52742. }
  52743. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  52744. import { Nullable } from "babylonjs/types";
  52745. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52746. import { Color3 } from "babylonjs/Maths/math.color";
  52747. import { SmartArray } from "babylonjs/Misc/smartArray";
  52748. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52749. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52750. import { Effect } from "babylonjs/Materials/effect";
  52751. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52752. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52753. import { Engine } from "babylonjs/Engines/engine";
  52754. import { Scene } from "babylonjs/scene";
  52755. /**
  52756. * @hidden
  52757. */
  52758. export interface IMaterialSubSurfaceDefines {
  52759. SUBSURFACE: boolean;
  52760. SS_REFRACTION: boolean;
  52761. SS_TRANSLUCENCY: boolean;
  52762. SS_SCATERRING: boolean;
  52763. SS_THICKNESSANDMASK_TEXTURE: boolean;
  52764. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  52765. SS_REFRACTIONMAP_3D: boolean;
  52766. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  52767. SS_LODINREFRACTIONALPHA: boolean;
  52768. SS_GAMMAREFRACTION: boolean;
  52769. SS_RGBDREFRACTION: boolean;
  52770. SS_LINEARSPECULARREFRACTION: boolean;
  52771. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  52772. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  52773. /** @hidden */
  52774. _areTexturesDirty: boolean;
  52775. }
  52776. /**
  52777. * Define the code related to the sub surface parameters of the pbr material.
  52778. */
  52779. export class PBRSubSurfaceConfiguration {
  52780. private _isRefractionEnabled;
  52781. /**
  52782. * Defines if the refraction is enabled in the material.
  52783. */
  52784. isRefractionEnabled: boolean;
  52785. private _isTranslucencyEnabled;
  52786. /**
  52787. * Defines if the translucency is enabled in the material.
  52788. */
  52789. isTranslucencyEnabled: boolean;
  52790. private _isScatteringEnabled;
  52791. /**
  52792. * Defines the refraction intensity of the material.
  52793. * The refraction when enabled replaces the Diffuse part of the material.
  52794. * The intensity helps transitionning between diffuse and refraction.
  52795. */
  52796. refractionIntensity: number;
  52797. /**
  52798. * Defines the translucency intensity of the material.
  52799. * When translucency has been enabled, this defines how much of the "translucency"
  52800. * is addded to the diffuse part of the material.
  52801. */
  52802. translucencyIntensity: number;
  52803. /**
  52804. * Defines the scattering intensity of the material.
  52805. * When scattering has been enabled, this defines how much of the "scattered light"
  52806. * is addded to the diffuse part of the material.
  52807. */
  52808. scatteringIntensity: number;
  52809. private _thicknessTexture;
  52810. /**
  52811. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  52812. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  52813. * 0 would mean minimumThickness
  52814. * 1 would mean maximumThickness
  52815. * The other channels might be use as a mask to vary the different effects intensity.
  52816. */
  52817. thicknessTexture: Nullable<BaseTexture>;
  52818. private _refractionTexture;
  52819. /**
  52820. * Defines the texture to use for refraction.
  52821. */
  52822. refractionTexture: Nullable<BaseTexture>;
  52823. private _indexOfRefraction;
  52824. /**
  52825. * Defines the index of refraction used in the material.
  52826. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  52827. */
  52828. indexOfRefraction: number;
  52829. private _invertRefractionY;
  52830. /**
  52831. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52832. */
  52833. invertRefractionY: boolean;
  52834. private _linkRefractionWithTransparency;
  52835. /**
  52836. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52837. * Materials half opaque for instance using refraction could benefit from this control.
  52838. */
  52839. linkRefractionWithTransparency: boolean;
  52840. /**
  52841. * Defines the minimum thickness stored in the thickness map.
  52842. * If no thickness map is defined, this value will be used to simulate thickness.
  52843. */
  52844. minimumThickness: number;
  52845. /**
  52846. * Defines the maximum thickness stored in the thickness map.
  52847. */
  52848. maximumThickness: number;
  52849. /**
  52850. * Defines the volume tint of the material.
  52851. * This is used for both translucency and scattering.
  52852. */
  52853. tintColor: Color3;
  52854. /**
  52855. * Defines the distance at which the tint color should be found in the media.
  52856. * This is used for refraction only.
  52857. */
  52858. tintColorAtDistance: number;
  52859. /**
  52860. * Defines how far each channel transmit through the media.
  52861. * It is defined as a color to simplify it selection.
  52862. */
  52863. diffusionDistance: Color3;
  52864. private _useMaskFromThicknessTexture;
  52865. /**
  52866. * Stores the intensity of the different subsurface effects in the thickness texture.
  52867. * * the green channel is the translucency intensity.
  52868. * * the blue channel is the scattering intensity.
  52869. * * the alpha channel is the refraction intensity.
  52870. */
  52871. useMaskFromThicknessTexture: boolean;
  52872. /** @hidden */
  52873. private _internalMarkAllSubMeshesAsTexturesDirty;
  52874. /** @hidden */
  52875. _markAllSubMeshesAsTexturesDirty(): void;
  52876. /**
  52877. * Instantiate a new istance of sub surface configuration.
  52878. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52879. */
  52880. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52881. /**
  52882. * Gets wehter the submesh is ready to be used or not.
  52883. * @param defines the list of "defines" to update.
  52884. * @param scene defines the scene the material belongs to.
  52885. * @returns - boolean indicating that the submesh is ready or not.
  52886. */
  52887. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  52888. /**
  52889. * Checks to see if a texture is used in the material.
  52890. * @param defines the list of "defines" to update.
  52891. * @param scene defines the scene to the material belongs to.
  52892. */
  52893. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  52894. /**
  52895. * Binds the material data.
  52896. * @param uniformBuffer defines the Uniform buffer to fill in.
  52897. * @param scene defines the scene the material belongs to.
  52898. * @param engine defines the engine the material belongs to.
  52899. * @param isFrozen defines wether the material is frozen or not.
  52900. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  52901. */
  52902. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  52903. /**
  52904. * Unbinds the material from the mesh.
  52905. * @param activeEffect defines the effect that should be unbound from.
  52906. * @returns true if unbound, otherwise false
  52907. */
  52908. unbind(activeEffect: Effect): boolean;
  52909. /**
  52910. * Returns the texture used for refraction or null if none is used.
  52911. * @param scene defines the scene the material belongs to.
  52912. * @returns - Refraction texture if present. If no refraction texture and refraction
  52913. * is linked with transparency, returns environment texture. Otherwise, returns null.
  52914. */
  52915. private _getRefractionTexture;
  52916. /**
  52917. * Returns true if alpha blending should be disabled.
  52918. */
  52919. get disableAlphaBlending(): boolean;
  52920. /**
  52921. * Fills the list of render target textures.
  52922. * @param renderTargets the list of render targets to update
  52923. */
  52924. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  52925. /**
  52926. * Checks to see if a texture is used in the material.
  52927. * @param texture - Base texture to use.
  52928. * @returns - Boolean specifying if a texture is used in the material.
  52929. */
  52930. hasTexture(texture: BaseTexture): boolean;
  52931. /**
  52932. * Gets a boolean indicating that current material needs to register RTT
  52933. * @returns true if this uses a render target otherwise false.
  52934. */
  52935. hasRenderTargetTextures(): boolean;
  52936. /**
  52937. * Returns an array of the actively used textures.
  52938. * @param activeTextures Array of BaseTextures
  52939. */
  52940. getActiveTextures(activeTextures: BaseTexture[]): void;
  52941. /**
  52942. * Returns the animatable textures.
  52943. * @param animatables Array of animatable textures.
  52944. */
  52945. getAnimatables(animatables: IAnimatable[]): void;
  52946. /**
  52947. * Disposes the resources of the material.
  52948. * @param forceDisposeTextures - Forces the disposal of all textures.
  52949. */
  52950. dispose(forceDisposeTextures?: boolean): void;
  52951. /**
  52952. * Get the current class name of the texture useful for serialization or dynamic coding.
  52953. * @returns "PBRSubSurfaceConfiguration"
  52954. */
  52955. getClassName(): string;
  52956. /**
  52957. * Add fallbacks to the effect fallbacks list.
  52958. * @param defines defines the Base texture to use.
  52959. * @param fallbacks defines the current fallback list.
  52960. * @param currentRank defines the current fallback rank.
  52961. * @returns the new fallback rank.
  52962. */
  52963. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52964. /**
  52965. * Add the required uniforms to the current list.
  52966. * @param uniforms defines the current uniform list.
  52967. */
  52968. static AddUniforms(uniforms: string[]): void;
  52969. /**
  52970. * Add the required samplers to the current list.
  52971. * @param samplers defines the current sampler list.
  52972. */
  52973. static AddSamplers(samplers: string[]): void;
  52974. /**
  52975. * Add the required uniforms to the current buffer.
  52976. * @param uniformBuffer defines the current uniform buffer.
  52977. */
  52978. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52979. /**
  52980. * Makes a duplicate of the current configuration into another one.
  52981. * @param configuration define the config where to copy the info
  52982. */
  52983. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  52984. /**
  52985. * Serializes this Sub Surface configuration.
  52986. * @returns - An object with the serialized config.
  52987. */
  52988. serialize(): any;
  52989. /**
  52990. * Parses a anisotropy Configuration from a serialized object.
  52991. * @param source - Serialized object.
  52992. * @param scene Defines the scene we are parsing for
  52993. * @param rootUrl Defines the rootUrl to load from
  52994. */
  52995. parse(source: any, scene: Scene, rootUrl: string): void;
  52996. }
  52997. }
  52998. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  52999. /** @hidden */
  53000. export var pbrFragmentDeclaration: {
  53001. name: string;
  53002. shader: string;
  53003. };
  53004. }
  53005. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  53006. /** @hidden */
  53007. export var pbrUboDeclaration: {
  53008. name: string;
  53009. shader: string;
  53010. };
  53011. }
  53012. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  53013. /** @hidden */
  53014. export var pbrFragmentExtraDeclaration: {
  53015. name: string;
  53016. shader: string;
  53017. };
  53018. }
  53019. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  53020. /** @hidden */
  53021. export var pbrFragmentSamplersDeclaration: {
  53022. name: string;
  53023. shader: string;
  53024. };
  53025. }
  53026. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  53027. /** @hidden */
  53028. export var pbrHelperFunctions: {
  53029. name: string;
  53030. shader: string;
  53031. };
  53032. }
  53033. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  53034. /** @hidden */
  53035. export var harmonicsFunctions: {
  53036. name: string;
  53037. shader: string;
  53038. };
  53039. }
  53040. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  53041. /** @hidden */
  53042. export var pbrDirectLightingSetupFunctions: {
  53043. name: string;
  53044. shader: string;
  53045. };
  53046. }
  53047. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  53048. /** @hidden */
  53049. export var pbrDirectLightingFalloffFunctions: {
  53050. name: string;
  53051. shader: string;
  53052. };
  53053. }
  53054. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  53055. /** @hidden */
  53056. export var pbrBRDFFunctions: {
  53057. name: string;
  53058. shader: string;
  53059. };
  53060. }
  53061. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  53062. /** @hidden */
  53063. export var pbrDirectLightingFunctions: {
  53064. name: string;
  53065. shader: string;
  53066. };
  53067. }
  53068. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  53069. /** @hidden */
  53070. export var pbrIBLFunctions: {
  53071. name: string;
  53072. shader: string;
  53073. };
  53074. }
  53075. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  53076. /** @hidden */
  53077. export var pbrDebug: {
  53078. name: string;
  53079. shader: string;
  53080. };
  53081. }
  53082. declare module "babylonjs/Shaders/pbr.fragment" {
  53083. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  53084. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  53085. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  53086. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  53087. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  53088. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  53089. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  53090. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  53091. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53092. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  53093. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53094. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  53095. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  53096. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  53097. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53098. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  53099. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  53100. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  53101. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  53102. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  53103. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  53104. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  53105. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  53106. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  53107. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  53108. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  53109. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  53110. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  53111. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  53112. /** @hidden */
  53113. export var pbrPixelShader: {
  53114. name: string;
  53115. shader: string;
  53116. };
  53117. }
  53118. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  53119. /** @hidden */
  53120. export var pbrVertexDeclaration: {
  53121. name: string;
  53122. shader: string;
  53123. };
  53124. }
  53125. declare module "babylonjs/Shaders/pbr.vertex" {
  53126. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  53127. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  53128. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53129. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53130. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53131. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53132. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  53133. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  53134. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  53135. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  53136. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  53137. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  53138. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  53139. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53140. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  53141. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53142. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53143. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  53144. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53145. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  53146. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  53147. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  53148. /** @hidden */
  53149. export var pbrVertexShader: {
  53150. name: string;
  53151. shader: string;
  53152. };
  53153. }
  53154. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  53155. import { Nullable } from "babylonjs/types";
  53156. import { Scene } from "babylonjs/scene";
  53157. import { Matrix } from "babylonjs/Maths/math.vector";
  53158. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53160. import { Mesh } from "babylonjs/Meshes/mesh";
  53161. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  53162. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  53163. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  53164. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  53165. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  53166. import { Color3 } from "babylonjs/Maths/math.color";
  53167. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53168. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  53169. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53170. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53171. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53172. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53173. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53174. import "babylonjs/Shaders/pbr.fragment";
  53175. import "babylonjs/Shaders/pbr.vertex";
  53176. /**
  53177. * Manages the defines for the PBR Material.
  53178. * @hidden
  53179. */
  53180. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  53181. PBR: boolean;
  53182. MAINUV1: boolean;
  53183. MAINUV2: boolean;
  53184. UV1: boolean;
  53185. UV2: boolean;
  53186. ALBEDO: boolean;
  53187. GAMMAALBEDO: boolean;
  53188. ALBEDODIRECTUV: number;
  53189. VERTEXCOLOR: boolean;
  53190. AMBIENT: boolean;
  53191. AMBIENTDIRECTUV: number;
  53192. AMBIENTINGRAYSCALE: boolean;
  53193. OPACITY: boolean;
  53194. VERTEXALPHA: boolean;
  53195. OPACITYDIRECTUV: number;
  53196. OPACITYRGB: boolean;
  53197. ALPHATEST: boolean;
  53198. DEPTHPREPASS: boolean;
  53199. ALPHABLEND: boolean;
  53200. ALPHAFROMALBEDO: boolean;
  53201. ALPHATESTVALUE: string;
  53202. SPECULAROVERALPHA: boolean;
  53203. RADIANCEOVERALPHA: boolean;
  53204. ALPHAFRESNEL: boolean;
  53205. LINEARALPHAFRESNEL: boolean;
  53206. PREMULTIPLYALPHA: boolean;
  53207. EMISSIVE: boolean;
  53208. EMISSIVEDIRECTUV: number;
  53209. REFLECTIVITY: boolean;
  53210. REFLECTIVITYDIRECTUV: number;
  53211. SPECULARTERM: boolean;
  53212. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  53213. MICROSURFACEAUTOMATIC: boolean;
  53214. LODBASEDMICROSFURACE: boolean;
  53215. MICROSURFACEMAP: boolean;
  53216. MICROSURFACEMAPDIRECTUV: number;
  53217. METALLICWORKFLOW: boolean;
  53218. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  53219. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  53220. METALLNESSSTOREINMETALMAPBLUE: boolean;
  53221. AOSTOREINMETALMAPRED: boolean;
  53222. METALLICF0FACTORFROMMETALLICMAP: boolean;
  53223. ENVIRONMENTBRDF: boolean;
  53224. ENVIRONMENTBRDF_RGBD: boolean;
  53225. NORMAL: boolean;
  53226. TANGENT: boolean;
  53227. BUMP: boolean;
  53228. BUMPDIRECTUV: number;
  53229. OBJECTSPACE_NORMALMAP: boolean;
  53230. PARALLAX: boolean;
  53231. PARALLAXOCCLUSION: boolean;
  53232. NORMALXYSCALE: boolean;
  53233. LIGHTMAP: boolean;
  53234. LIGHTMAPDIRECTUV: number;
  53235. USELIGHTMAPASSHADOWMAP: boolean;
  53236. GAMMALIGHTMAP: boolean;
  53237. RGBDLIGHTMAP: boolean;
  53238. REFLECTION: boolean;
  53239. REFLECTIONMAP_3D: boolean;
  53240. REFLECTIONMAP_SPHERICAL: boolean;
  53241. REFLECTIONMAP_PLANAR: boolean;
  53242. REFLECTIONMAP_CUBIC: boolean;
  53243. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  53244. REFLECTIONMAP_PROJECTION: boolean;
  53245. REFLECTIONMAP_SKYBOX: boolean;
  53246. REFLECTIONMAP_EXPLICIT: boolean;
  53247. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  53248. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  53249. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  53250. INVERTCUBICMAP: boolean;
  53251. USESPHERICALFROMREFLECTIONMAP: boolean;
  53252. USEIRRADIANCEMAP: boolean;
  53253. SPHERICAL_HARMONICS: boolean;
  53254. USESPHERICALINVERTEX: boolean;
  53255. REFLECTIONMAP_OPPOSITEZ: boolean;
  53256. LODINREFLECTIONALPHA: boolean;
  53257. GAMMAREFLECTION: boolean;
  53258. RGBDREFLECTION: boolean;
  53259. LINEARSPECULARREFLECTION: boolean;
  53260. RADIANCEOCCLUSION: boolean;
  53261. HORIZONOCCLUSION: boolean;
  53262. INSTANCES: boolean;
  53263. NUM_BONE_INFLUENCERS: number;
  53264. BonesPerMesh: number;
  53265. BONETEXTURE: boolean;
  53266. NONUNIFORMSCALING: boolean;
  53267. MORPHTARGETS: boolean;
  53268. MORPHTARGETS_NORMAL: boolean;
  53269. MORPHTARGETS_TANGENT: boolean;
  53270. MORPHTARGETS_UV: boolean;
  53271. NUM_MORPH_INFLUENCERS: number;
  53272. IMAGEPROCESSING: boolean;
  53273. VIGNETTE: boolean;
  53274. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53275. VIGNETTEBLENDMODEOPAQUE: boolean;
  53276. TONEMAPPING: boolean;
  53277. TONEMAPPING_ACES: boolean;
  53278. CONTRAST: boolean;
  53279. COLORCURVES: boolean;
  53280. COLORGRADING: boolean;
  53281. COLORGRADING3D: boolean;
  53282. SAMPLER3DGREENDEPTH: boolean;
  53283. SAMPLER3DBGRMAP: boolean;
  53284. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53285. EXPOSURE: boolean;
  53286. MULTIVIEW: boolean;
  53287. USEPHYSICALLIGHTFALLOFF: boolean;
  53288. USEGLTFLIGHTFALLOFF: boolean;
  53289. TWOSIDEDLIGHTING: boolean;
  53290. SHADOWFLOAT: boolean;
  53291. CLIPPLANE: boolean;
  53292. CLIPPLANE2: boolean;
  53293. CLIPPLANE3: boolean;
  53294. CLIPPLANE4: boolean;
  53295. CLIPPLANE5: boolean;
  53296. CLIPPLANE6: boolean;
  53297. POINTSIZE: boolean;
  53298. FOG: boolean;
  53299. LOGARITHMICDEPTH: boolean;
  53300. FORCENORMALFORWARD: boolean;
  53301. SPECULARAA: boolean;
  53302. CLEARCOAT: boolean;
  53303. CLEARCOAT_DEFAULTIOR: boolean;
  53304. CLEARCOAT_TEXTURE: boolean;
  53305. CLEARCOAT_TEXTUREDIRECTUV: number;
  53306. CLEARCOAT_BUMP: boolean;
  53307. CLEARCOAT_BUMPDIRECTUV: number;
  53308. CLEARCOAT_TINT: boolean;
  53309. CLEARCOAT_TINT_TEXTURE: boolean;
  53310. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53311. ANISOTROPIC: boolean;
  53312. ANISOTROPIC_TEXTURE: boolean;
  53313. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53314. BRDF_V_HEIGHT_CORRELATED: boolean;
  53315. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53316. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53317. SHEEN: boolean;
  53318. SHEEN_TEXTURE: boolean;
  53319. SHEEN_TEXTUREDIRECTUV: number;
  53320. SHEEN_LINKWITHALBEDO: boolean;
  53321. SHEEN_ROUGHNESS: boolean;
  53322. SHEEN_ALBEDOSCALING: boolean;
  53323. SUBSURFACE: boolean;
  53324. SS_REFRACTION: boolean;
  53325. SS_TRANSLUCENCY: boolean;
  53326. SS_SCATERRING: boolean;
  53327. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53328. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53329. SS_REFRACTIONMAP_3D: boolean;
  53330. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53331. SS_LODINREFRACTIONALPHA: boolean;
  53332. SS_GAMMAREFRACTION: boolean;
  53333. SS_RGBDREFRACTION: boolean;
  53334. SS_LINEARSPECULARREFRACTION: boolean;
  53335. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53336. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53337. UNLIT: boolean;
  53338. DEBUGMODE: number;
  53339. /**
  53340. * Initializes the PBR Material defines.
  53341. */
  53342. constructor();
  53343. /**
  53344. * Resets the PBR Material defines.
  53345. */
  53346. reset(): void;
  53347. }
  53348. /**
  53349. * The Physically based material base class of BJS.
  53350. *
  53351. * This offers the main features of a standard PBR material.
  53352. * For more information, please refer to the documentation :
  53353. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53354. */
  53355. export abstract class PBRBaseMaterial extends PushMaterial {
  53356. /**
  53357. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53358. */
  53359. static readonly PBRMATERIAL_OPAQUE: number;
  53360. /**
  53361. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53362. */
  53363. static readonly PBRMATERIAL_ALPHATEST: number;
  53364. /**
  53365. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53366. */
  53367. static readonly PBRMATERIAL_ALPHABLEND: number;
  53368. /**
  53369. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53370. * They are also discarded below the alpha cutoff threshold to improve performances.
  53371. */
  53372. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53373. /**
  53374. * Defines the default value of how much AO map is occluding the analytical lights
  53375. * (point spot...).
  53376. */
  53377. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53378. /**
  53379. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  53380. */
  53381. static readonly LIGHTFALLOFF_PHYSICAL: number;
  53382. /**
  53383. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  53384. * to enhance interoperability with other engines.
  53385. */
  53386. static readonly LIGHTFALLOFF_GLTF: number;
  53387. /**
  53388. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  53389. * to enhance interoperability with other materials.
  53390. */
  53391. static readonly LIGHTFALLOFF_STANDARD: number;
  53392. /**
  53393. * Intensity of the direct lights e.g. the four lights available in your scene.
  53394. * This impacts both the direct diffuse and specular highlights.
  53395. */
  53396. protected _directIntensity: number;
  53397. /**
  53398. * Intensity of the emissive part of the material.
  53399. * This helps controlling the emissive effect without modifying the emissive color.
  53400. */
  53401. protected _emissiveIntensity: number;
  53402. /**
  53403. * Intensity of the environment e.g. how much the environment will light the object
  53404. * either through harmonics for rough material or through the refelction for shiny ones.
  53405. */
  53406. protected _environmentIntensity: number;
  53407. /**
  53408. * This is a special control allowing the reduction of the specular highlights coming from the
  53409. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53410. */
  53411. protected _specularIntensity: number;
  53412. /**
  53413. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  53414. */
  53415. private _lightingInfos;
  53416. /**
  53417. * Debug Control allowing disabling the bump map on this material.
  53418. */
  53419. protected _disableBumpMap: boolean;
  53420. /**
  53421. * AKA Diffuse Texture in standard nomenclature.
  53422. */
  53423. protected _albedoTexture: Nullable<BaseTexture>;
  53424. /**
  53425. * AKA Occlusion Texture in other nomenclature.
  53426. */
  53427. protected _ambientTexture: Nullable<BaseTexture>;
  53428. /**
  53429. * AKA Occlusion Texture Intensity in other nomenclature.
  53430. */
  53431. protected _ambientTextureStrength: number;
  53432. /**
  53433. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53434. * 1 means it completely occludes it
  53435. * 0 mean it has no impact
  53436. */
  53437. protected _ambientTextureImpactOnAnalyticalLights: number;
  53438. /**
  53439. * Stores the alpha values in a texture.
  53440. */
  53441. protected _opacityTexture: Nullable<BaseTexture>;
  53442. /**
  53443. * Stores the reflection values in a texture.
  53444. */
  53445. protected _reflectionTexture: Nullable<BaseTexture>;
  53446. /**
  53447. * Stores the emissive values in a texture.
  53448. */
  53449. protected _emissiveTexture: Nullable<BaseTexture>;
  53450. /**
  53451. * AKA Specular texture in other nomenclature.
  53452. */
  53453. protected _reflectivityTexture: Nullable<BaseTexture>;
  53454. /**
  53455. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53456. */
  53457. protected _metallicTexture: Nullable<BaseTexture>;
  53458. /**
  53459. * Specifies the metallic scalar of the metallic/roughness workflow.
  53460. * Can also be used to scale the metalness values of the metallic texture.
  53461. */
  53462. protected _metallic: Nullable<number>;
  53463. /**
  53464. * Specifies the roughness scalar of the metallic/roughness workflow.
  53465. * Can also be used to scale the roughness values of the metallic texture.
  53466. */
  53467. protected _roughness: Nullable<number>;
  53468. /**
  53469. * Specifies the an F0 factor to help configuring the material F0.
  53470. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53471. * to 0.5 the previously hard coded value stays the same.
  53472. * Can also be used to scale the F0 values of the metallic texture.
  53473. */
  53474. protected _metallicF0Factor: number;
  53475. /**
  53476. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53477. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53478. * your expectation as it multiplies with the texture data.
  53479. */
  53480. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  53481. /**
  53482. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53483. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53484. */
  53485. protected _microSurfaceTexture: Nullable<BaseTexture>;
  53486. /**
  53487. * Stores surface normal data used to displace a mesh in a texture.
  53488. */
  53489. protected _bumpTexture: Nullable<BaseTexture>;
  53490. /**
  53491. * Stores the pre-calculated light information of a mesh in a texture.
  53492. */
  53493. protected _lightmapTexture: Nullable<BaseTexture>;
  53494. /**
  53495. * The color of a material in ambient lighting.
  53496. */
  53497. protected _ambientColor: Color3;
  53498. /**
  53499. * AKA Diffuse Color in other nomenclature.
  53500. */
  53501. protected _albedoColor: Color3;
  53502. /**
  53503. * AKA Specular Color in other nomenclature.
  53504. */
  53505. protected _reflectivityColor: Color3;
  53506. /**
  53507. * The color applied when light is reflected from a material.
  53508. */
  53509. protected _reflectionColor: Color3;
  53510. /**
  53511. * The color applied when light is emitted from a material.
  53512. */
  53513. protected _emissiveColor: Color3;
  53514. /**
  53515. * AKA Glossiness in other nomenclature.
  53516. */
  53517. protected _microSurface: number;
  53518. /**
  53519. * Specifies that the material will use the light map as a show map.
  53520. */
  53521. protected _useLightmapAsShadowmap: boolean;
  53522. /**
  53523. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53524. * makes the reflect vector face the model (under horizon).
  53525. */
  53526. protected _useHorizonOcclusion: boolean;
  53527. /**
  53528. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53529. * too much the area relying on ambient texture to define their ambient occlusion.
  53530. */
  53531. protected _useRadianceOcclusion: boolean;
  53532. /**
  53533. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53534. */
  53535. protected _useAlphaFromAlbedoTexture: boolean;
  53536. /**
  53537. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  53538. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53539. */
  53540. protected _useSpecularOverAlpha: boolean;
  53541. /**
  53542. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53543. */
  53544. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53545. /**
  53546. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53547. */
  53548. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  53549. /**
  53550. * Specifies if the metallic texture contains the roughness information in its green channel.
  53551. */
  53552. protected _useRoughnessFromMetallicTextureGreen: boolean;
  53553. /**
  53554. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53555. */
  53556. protected _useMetallnessFromMetallicTextureBlue: boolean;
  53557. /**
  53558. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53559. */
  53560. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  53561. /**
  53562. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53563. */
  53564. protected _useAmbientInGrayScale: boolean;
  53565. /**
  53566. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53567. * The material will try to infer what glossiness each pixel should be.
  53568. */
  53569. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  53570. /**
  53571. * Defines the falloff type used in this material.
  53572. * It by default is Physical.
  53573. */
  53574. protected _lightFalloff: number;
  53575. /**
  53576. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53577. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53578. */
  53579. protected _useRadianceOverAlpha: boolean;
  53580. /**
  53581. * Allows using an object space normal map (instead of tangent space).
  53582. */
  53583. protected _useObjectSpaceNormalMap: boolean;
  53584. /**
  53585. * Allows using the bump map in parallax mode.
  53586. */
  53587. protected _useParallax: boolean;
  53588. /**
  53589. * Allows using the bump map in parallax occlusion mode.
  53590. */
  53591. protected _useParallaxOcclusion: boolean;
  53592. /**
  53593. * Controls the scale bias of the parallax mode.
  53594. */
  53595. protected _parallaxScaleBias: number;
  53596. /**
  53597. * If sets to true, disables all the lights affecting the material.
  53598. */
  53599. protected _disableLighting: boolean;
  53600. /**
  53601. * Number of Simultaneous lights allowed on the material.
  53602. */
  53603. protected _maxSimultaneousLights: number;
  53604. /**
  53605. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53606. */
  53607. protected _invertNormalMapX: boolean;
  53608. /**
  53609. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53610. */
  53611. protected _invertNormalMapY: boolean;
  53612. /**
  53613. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53614. */
  53615. protected _twoSidedLighting: boolean;
  53616. /**
  53617. * Defines the alpha limits in alpha test mode.
  53618. */
  53619. protected _alphaCutOff: number;
  53620. /**
  53621. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53622. */
  53623. protected _forceAlphaTest: boolean;
  53624. /**
  53625. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53626. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53627. */
  53628. protected _useAlphaFresnel: boolean;
  53629. /**
  53630. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53631. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53632. */
  53633. protected _useLinearAlphaFresnel: boolean;
  53634. /**
  53635. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  53636. * from cos thetav and roughness:
  53637. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  53638. */
  53639. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  53640. /**
  53641. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53642. */
  53643. protected _forceIrradianceInFragment: boolean;
  53644. /**
  53645. * Force normal to face away from face.
  53646. */
  53647. protected _forceNormalForward: boolean;
  53648. /**
  53649. * Enables specular anti aliasing in the PBR shader.
  53650. * It will both interacts on the Geometry for analytical and IBL lighting.
  53651. * It also prefilter the roughness map based on the bump values.
  53652. */
  53653. protected _enableSpecularAntiAliasing: boolean;
  53654. /**
  53655. * Default configuration related to image processing available in the PBR Material.
  53656. */
  53657. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53658. /**
  53659. * Keep track of the image processing observer to allow dispose and replace.
  53660. */
  53661. private _imageProcessingObserver;
  53662. /**
  53663. * Attaches a new image processing configuration to the PBR Material.
  53664. * @param configuration
  53665. */
  53666. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53667. /**
  53668. * Stores the available render targets.
  53669. */
  53670. private _renderTargets;
  53671. /**
  53672. * Sets the global ambient color for the material used in lighting calculations.
  53673. */
  53674. private _globalAmbientColor;
  53675. /**
  53676. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  53677. */
  53678. private _useLogarithmicDepth;
  53679. /**
  53680. * If set to true, no lighting calculations will be applied.
  53681. */
  53682. private _unlit;
  53683. private _debugMode;
  53684. /**
  53685. * @hidden
  53686. * This is reserved for the inspector.
  53687. * Defines the material debug mode.
  53688. * It helps seeing only some components of the material while troubleshooting.
  53689. */
  53690. debugMode: number;
  53691. /**
  53692. * @hidden
  53693. * This is reserved for the inspector.
  53694. * Specify from where on screen the debug mode should start.
  53695. * The value goes from -1 (full screen) to 1 (not visible)
  53696. * It helps with side by side comparison against the final render
  53697. * This defaults to -1
  53698. */
  53699. private debugLimit;
  53700. /**
  53701. * @hidden
  53702. * This is reserved for the inspector.
  53703. * As the default viewing range might not be enough (if the ambient is really small for instance)
  53704. * You can use the factor to better multiply the final value.
  53705. */
  53706. private debugFactor;
  53707. /**
  53708. * Defines the clear coat layer parameters for the material.
  53709. */
  53710. readonly clearCoat: PBRClearCoatConfiguration;
  53711. /**
  53712. * Defines the anisotropic parameters for the material.
  53713. */
  53714. readonly anisotropy: PBRAnisotropicConfiguration;
  53715. /**
  53716. * Defines the BRDF parameters for the material.
  53717. */
  53718. readonly brdf: PBRBRDFConfiguration;
  53719. /**
  53720. * Defines the Sheen parameters for the material.
  53721. */
  53722. readonly sheen: PBRSheenConfiguration;
  53723. /**
  53724. * Defines the SubSurface parameters for the material.
  53725. */
  53726. readonly subSurface: PBRSubSurfaceConfiguration;
  53727. /**
  53728. * Custom callback helping to override the default shader used in the material.
  53729. */
  53730. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  53731. protected _rebuildInParallel: boolean;
  53732. /**
  53733. * Instantiates a new PBRMaterial instance.
  53734. *
  53735. * @param name The material name
  53736. * @param scene The scene the material will be use in.
  53737. */
  53738. constructor(name: string, scene: Scene);
  53739. /**
  53740. * Gets a boolean indicating that current material needs to register RTT
  53741. */
  53742. get hasRenderTargetTextures(): boolean;
  53743. /**
  53744. * Gets the name of the material class.
  53745. */
  53746. getClassName(): string;
  53747. /**
  53748. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53749. */
  53750. get useLogarithmicDepth(): boolean;
  53751. /**
  53752. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53753. */
  53754. set useLogarithmicDepth(value: boolean);
  53755. /**
  53756. * Returns true if alpha blending should be disabled.
  53757. */
  53758. protected get _disableAlphaBlending(): boolean;
  53759. /**
  53760. * Specifies whether or not this material should be rendered in alpha blend mode.
  53761. */
  53762. needAlphaBlending(): boolean;
  53763. /**
  53764. * Specifies whether or not this material should be rendered in alpha test mode.
  53765. */
  53766. needAlphaTesting(): boolean;
  53767. /**
  53768. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  53769. */
  53770. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  53771. /**
  53772. * Gets the texture used for the alpha test.
  53773. */
  53774. getAlphaTestTexture(): Nullable<BaseTexture>;
  53775. /**
  53776. * Specifies that the submesh is ready to be used.
  53777. * @param mesh - BJS mesh.
  53778. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  53779. * @param useInstances - Specifies that instances should be used.
  53780. * @returns - boolean indicating that the submesh is ready or not.
  53781. */
  53782. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53783. /**
  53784. * Specifies if the material uses metallic roughness workflow.
  53785. * @returns boolean specifiying if the material uses metallic roughness workflow.
  53786. */
  53787. isMetallicWorkflow(): boolean;
  53788. private _prepareEffect;
  53789. private _prepareDefines;
  53790. /**
  53791. * Force shader compilation
  53792. */
  53793. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  53794. /**
  53795. * Initializes the uniform buffer layout for the shader.
  53796. */
  53797. buildUniformLayout(): void;
  53798. /**
  53799. * Unbinds the material from the mesh
  53800. */
  53801. unbind(): void;
  53802. /**
  53803. * Binds the submesh data.
  53804. * @param world - The world matrix.
  53805. * @param mesh - The BJS mesh.
  53806. * @param subMesh - A submesh of the BJS mesh.
  53807. */
  53808. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53809. /**
  53810. * Returns the animatable textures.
  53811. * @returns - Array of animatable textures.
  53812. */
  53813. getAnimatables(): IAnimatable[];
  53814. /**
  53815. * Returns the texture used for reflections.
  53816. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  53817. */
  53818. private _getReflectionTexture;
  53819. /**
  53820. * Returns an array of the actively used textures.
  53821. * @returns - Array of BaseTextures
  53822. */
  53823. getActiveTextures(): BaseTexture[];
  53824. /**
  53825. * Checks to see if a texture is used in the material.
  53826. * @param texture - Base texture to use.
  53827. * @returns - Boolean specifying if a texture is used in the material.
  53828. */
  53829. hasTexture(texture: BaseTexture): boolean;
  53830. /**
  53831. * Disposes the resources of the material.
  53832. * @param forceDisposeEffect - Forces the disposal of effects.
  53833. * @param forceDisposeTextures - Forces the disposal of all textures.
  53834. */
  53835. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53836. }
  53837. }
  53838. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  53839. import { Nullable } from "babylonjs/types";
  53840. import { Scene } from "babylonjs/scene";
  53841. import { Color3 } from "babylonjs/Maths/math.color";
  53842. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  53843. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  53844. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53845. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53846. /**
  53847. * The Physically based material of BJS.
  53848. *
  53849. * This offers the main features of a standard PBR material.
  53850. * For more information, please refer to the documentation :
  53851. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53852. */
  53853. export class PBRMaterial extends PBRBaseMaterial {
  53854. /**
  53855. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53856. */
  53857. static readonly PBRMATERIAL_OPAQUE: number;
  53858. /**
  53859. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53860. */
  53861. static readonly PBRMATERIAL_ALPHATEST: number;
  53862. /**
  53863. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53864. */
  53865. static readonly PBRMATERIAL_ALPHABLEND: number;
  53866. /**
  53867. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53868. * They are also discarded below the alpha cutoff threshold to improve performances.
  53869. */
  53870. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53871. /**
  53872. * Defines the default value of how much AO map is occluding the analytical lights
  53873. * (point spot...).
  53874. */
  53875. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53876. /**
  53877. * Intensity of the direct lights e.g. the four lights available in your scene.
  53878. * This impacts both the direct diffuse and specular highlights.
  53879. */
  53880. directIntensity: number;
  53881. /**
  53882. * Intensity of the emissive part of the material.
  53883. * This helps controlling the emissive effect without modifying the emissive color.
  53884. */
  53885. emissiveIntensity: number;
  53886. /**
  53887. * Intensity of the environment e.g. how much the environment will light the object
  53888. * either through harmonics for rough material or through the refelction for shiny ones.
  53889. */
  53890. environmentIntensity: number;
  53891. /**
  53892. * This is a special control allowing the reduction of the specular highlights coming from the
  53893. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53894. */
  53895. specularIntensity: number;
  53896. /**
  53897. * Debug Control allowing disabling the bump map on this material.
  53898. */
  53899. disableBumpMap: boolean;
  53900. /**
  53901. * AKA Diffuse Texture in standard nomenclature.
  53902. */
  53903. albedoTexture: BaseTexture;
  53904. /**
  53905. * AKA Occlusion Texture in other nomenclature.
  53906. */
  53907. ambientTexture: BaseTexture;
  53908. /**
  53909. * AKA Occlusion Texture Intensity in other nomenclature.
  53910. */
  53911. ambientTextureStrength: number;
  53912. /**
  53913. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53914. * 1 means it completely occludes it
  53915. * 0 mean it has no impact
  53916. */
  53917. ambientTextureImpactOnAnalyticalLights: number;
  53918. /**
  53919. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  53920. */
  53921. opacityTexture: BaseTexture;
  53922. /**
  53923. * Stores the reflection values in a texture.
  53924. */
  53925. reflectionTexture: Nullable<BaseTexture>;
  53926. /**
  53927. * Stores the emissive values in a texture.
  53928. */
  53929. emissiveTexture: BaseTexture;
  53930. /**
  53931. * AKA Specular texture in other nomenclature.
  53932. */
  53933. reflectivityTexture: BaseTexture;
  53934. /**
  53935. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53936. */
  53937. metallicTexture: BaseTexture;
  53938. /**
  53939. * Specifies the metallic scalar of the metallic/roughness workflow.
  53940. * Can also be used to scale the metalness values of the metallic texture.
  53941. */
  53942. metallic: Nullable<number>;
  53943. /**
  53944. * Specifies the roughness scalar of the metallic/roughness workflow.
  53945. * Can also be used to scale the roughness values of the metallic texture.
  53946. */
  53947. roughness: Nullable<number>;
  53948. /**
  53949. * Specifies the an F0 factor to help configuring the material F0.
  53950. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53951. * to 0.5 the previously hard coded value stays the same.
  53952. * Can also be used to scale the F0 values of the metallic texture.
  53953. */
  53954. metallicF0Factor: number;
  53955. /**
  53956. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53957. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53958. * your expectation as it multiplies with the texture data.
  53959. */
  53960. useMetallicF0FactorFromMetallicTexture: boolean;
  53961. /**
  53962. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53963. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53964. */
  53965. microSurfaceTexture: BaseTexture;
  53966. /**
  53967. * Stores surface normal data used to displace a mesh in a texture.
  53968. */
  53969. bumpTexture: BaseTexture;
  53970. /**
  53971. * Stores the pre-calculated light information of a mesh in a texture.
  53972. */
  53973. lightmapTexture: BaseTexture;
  53974. /**
  53975. * Stores the refracted light information in a texture.
  53976. */
  53977. get refractionTexture(): Nullable<BaseTexture>;
  53978. set refractionTexture(value: Nullable<BaseTexture>);
  53979. /**
  53980. * The color of a material in ambient lighting.
  53981. */
  53982. ambientColor: Color3;
  53983. /**
  53984. * AKA Diffuse Color in other nomenclature.
  53985. */
  53986. albedoColor: Color3;
  53987. /**
  53988. * AKA Specular Color in other nomenclature.
  53989. */
  53990. reflectivityColor: Color3;
  53991. /**
  53992. * The color reflected from the material.
  53993. */
  53994. reflectionColor: Color3;
  53995. /**
  53996. * The color emitted from the material.
  53997. */
  53998. emissiveColor: Color3;
  53999. /**
  54000. * AKA Glossiness in other nomenclature.
  54001. */
  54002. microSurface: number;
  54003. /**
  54004. * source material index of refraction (IOR)' / 'destination material IOR.
  54005. */
  54006. get indexOfRefraction(): number;
  54007. set indexOfRefraction(value: number);
  54008. /**
  54009. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54010. */
  54011. get invertRefractionY(): boolean;
  54012. set invertRefractionY(value: boolean);
  54013. /**
  54014. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54015. * Materials half opaque for instance using refraction could benefit from this control.
  54016. */
  54017. get linkRefractionWithTransparency(): boolean;
  54018. set linkRefractionWithTransparency(value: boolean);
  54019. /**
  54020. * If true, the light map contains occlusion information instead of lighting info.
  54021. */
  54022. useLightmapAsShadowmap: boolean;
  54023. /**
  54024. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54025. */
  54026. useAlphaFromAlbedoTexture: boolean;
  54027. /**
  54028. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54029. */
  54030. forceAlphaTest: boolean;
  54031. /**
  54032. * Defines the alpha limits in alpha test mode.
  54033. */
  54034. alphaCutOff: number;
  54035. /**
  54036. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  54037. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54038. */
  54039. useSpecularOverAlpha: boolean;
  54040. /**
  54041. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54042. */
  54043. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  54044. /**
  54045. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54046. */
  54047. useRoughnessFromMetallicTextureAlpha: boolean;
  54048. /**
  54049. * Specifies if the metallic texture contains the roughness information in its green channel.
  54050. */
  54051. useRoughnessFromMetallicTextureGreen: boolean;
  54052. /**
  54053. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54054. */
  54055. useMetallnessFromMetallicTextureBlue: boolean;
  54056. /**
  54057. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54058. */
  54059. useAmbientOcclusionFromMetallicTextureRed: boolean;
  54060. /**
  54061. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54062. */
  54063. useAmbientInGrayScale: boolean;
  54064. /**
  54065. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54066. * The material will try to infer what glossiness each pixel should be.
  54067. */
  54068. useAutoMicroSurfaceFromReflectivityMap: boolean;
  54069. /**
  54070. * BJS is using an harcoded light falloff based on a manually sets up range.
  54071. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54072. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54073. */
  54074. get usePhysicalLightFalloff(): boolean;
  54075. /**
  54076. * BJS is using an harcoded light falloff based on a manually sets up range.
  54077. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54078. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54079. */
  54080. set usePhysicalLightFalloff(value: boolean);
  54081. /**
  54082. * In order to support the falloff compatibility with gltf, a special mode has been added
  54083. * to reproduce the gltf light falloff.
  54084. */
  54085. get useGLTFLightFalloff(): boolean;
  54086. /**
  54087. * In order to support the falloff compatibility with gltf, a special mode has been added
  54088. * to reproduce the gltf light falloff.
  54089. */
  54090. set useGLTFLightFalloff(value: boolean);
  54091. /**
  54092. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54093. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54094. */
  54095. useRadianceOverAlpha: boolean;
  54096. /**
  54097. * Allows using an object space normal map (instead of tangent space).
  54098. */
  54099. useObjectSpaceNormalMap: boolean;
  54100. /**
  54101. * Allows using the bump map in parallax mode.
  54102. */
  54103. useParallax: boolean;
  54104. /**
  54105. * Allows using the bump map in parallax occlusion mode.
  54106. */
  54107. useParallaxOcclusion: boolean;
  54108. /**
  54109. * Controls the scale bias of the parallax mode.
  54110. */
  54111. parallaxScaleBias: number;
  54112. /**
  54113. * If sets to true, disables all the lights affecting the material.
  54114. */
  54115. disableLighting: boolean;
  54116. /**
  54117. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54118. */
  54119. forceIrradianceInFragment: boolean;
  54120. /**
  54121. * Number of Simultaneous lights allowed on the material.
  54122. */
  54123. maxSimultaneousLights: number;
  54124. /**
  54125. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54126. */
  54127. invertNormalMapX: boolean;
  54128. /**
  54129. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54130. */
  54131. invertNormalMapY: boolean;
  54132. /**
  54133. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54134. */
  54135. twoSidedLighting: boolean;
  54136. /**
  54137. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54138. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54139. */
  54140. useAlphaFresnel: boolean;
  54141. /**
  54142. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54143. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54144. */
  54145. useLinearAlphaFresnel: boolean;
  54146. /**
  54147. * Let user defines the brdf lookup texture used for IBL.
  54148. * A default 8bit version is embedded but you could point at :
  54149. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  54150. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  54151. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  54152. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  54153. */
  54154. environmentBRDFTexture: Nullable<BaseTexture>;
  54155. /**
  54156. * Force normal to face away from face.
  54157. */
  54158. forceNormalForward: boolean;
  54159. /**
  54160. * Enables specular anti aliasing in the PBR shader.
  54161. * It will both interacts on the Geometry for analytical and IBL lighting.
  54162. * It also prefilter the roughness map based on the bump values.
  54163. */
  54164. enableSpecularAntiAliasing: boolean;
  54165. /**
  54166. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54167. * makes the reflect vector face the model (under horizon).
  54168. */
  54169. useHorizonOcclusion: boolean;
  54170. /**
  54171. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54172. * too much the area relying on ambient texture to define their ambient occlusion.
  54173. */
  54174. useRadianceOcclusion: boolean;
  54175. /**
  54176. * If set to true, no lighting calculations will be applied.
  54177. */
  54178. unlit: boolean;
  54179. /**
  54180. * Gets the image processing configuration used either in this material.
  54181. */
  54182. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  54183. /**
  54184. * Sets the Default image processing configuration used either in the this material.
  54185. *
  54186. * If sets to null, the scene one is in use.
  54187. */
  54188. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  54189. /**
  54190. * Gets wether the color curves effect is enabled.
  54191. */
  54192. get cameraColorCurvesEnabled(): boolean;
  54193. /**
  54194. * Sets wether the color curves effect is enabled.
  54195. */
  54196. set cameraColorCurvesEnabled(value: boolean);
  54197. /**
  54198. * Gets wether the color grading effect is enabled.
  54199. */
  54200. get cameraColorGradingEnabled(): boolean;
  54201. /**
  54202. * Gets wether the color grading effect is enabled.
  54203. */
  54204. set cameraColorGradingEnabled(value: boolean);
  54205. /**
  54206. * Gets wether tonemapping is enabled or not.
  54207. */
  54208. get cameraToneMappingEnabled(): boolean;
  54209. /**
  54210. * Sets wether tonemapping is enabled or not
  54211. */
  54212. set cameraToneMappingEnabled(value: boolean);
  54213. /**
  54214. * The camera exposure used on this material.
  54215. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54216. * This corresponds to a photographic exposure.
  54217. */
  54218. get cameraExposure(): number;
  54219. /**
  54220. * The camera exposure used on this material.
  54221. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54222. * This corresponds to a photographic exposure.
  54223. */
  54224. set cameraExposure(value: number);
  54225. /**
  54226. * Gets The camera contrast used on this material.
  54227. */
  54228. get cameraContrast(): number;
  54229. /**
  54230. * Sets The camera contrast used on this material.
  54231. */
  54232. set cameraContrast(value: number);
  54233. /**
  54234. * Gets the Color Grading 2D Lookup Texture.
  54235. */
  54236. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54237. /**
  54238. * Sets the Color Grading 2D Lookup Texture.
  54239. */
  54240. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54241. /**
  54242. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54243. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54244. * 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;
  54245. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54246. */
  54247. get cameraColorCurves(): Nullable<ColorCurves>;
  54248. /**
  54249. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54250. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54251. * 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;
  54252. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54253. */
  54254. set cameraColorCurves(value: Nullable<ColorCurves>);
  54255. /**
  54256. * Instantiates a new PBRMaterial instance.
  54257. *
  54258. * @param name The material name
  54259. * @param scene The scene the material will be use in.
  54260. */
  54261. constructor(name: string, scene: Scene);
  54262. /**
  54263. * Returns the name of this material class.
  54264. */
  54265. getClassName(): string;
  54266. /**
  54267. * Makes a duplicate of the current material.
  54268. * @param name - name to use for the new material.
  54269. */
  54270. clone(name: string): PBRMaterial;
  54271. /**
  54272. * Serializes this PBR Material.
  54273. * @returns - An object with the serialized material.
  54274. */
  54275. serialize(): any;
  54276. /**
  54277. * Parses a PBR Material from a serialized object.
  54278. * @param source - Serialized object.
  54279. * @param scene - BJS scene instance.
  54280. * @param rootUrl - url for the scene object
  54281. * @returns - PBRMaterial
  54282. */
  54283. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  54284. }
  54285. }
  54286. declare module "babylonjs/Misc/dds" {
  54287. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54288. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54289. import { Nullable } from "babylonjs/types";
  54290. import { Scene } from "babylonjs/scene";
  54291. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  54292. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54293. /**
  54294. * Direct draw surface info
  54295. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  54296. */
  54297. export interface DDSInfo {
  54298. /**
  54299. * Width of the texture
  54300. */
  54301. width: number;
  54302. /**
  54303. * Width of the texture
  54304. */
  54305. height: number;
  54306. /**
  54307. * Number of Mipmaps for the texture
  54308. * @see https://en.wikipedia.org/wiki/Mipmap
  54309. */
  54310. mipmapCount: number;
  54311. /**
  54312. * If the textures format is a known fourCC format
  54313. * @see https://www.fourcc.org/
  54314. */
  54315. isFourCC: boolean;
  54316. /**
  54317. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  54318. */
  54319. isRGB: boolean;
  54320. /**
  54321. * If the texture is a lumincance format
  54322. */
  54323. isLuminance: boolean;
  54324. /**
  54325. * If this is a cube texture
  54326. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  54327. */
  54328. isCube: boolean;
  54329. /**
  54330. * If the texture is a compressed format eg. FOURCC_DXT1
  54331. */
  54332. isCompressed: boolean;
  54333. /**
  54334. * The dxgiFormat of the texture
  54335. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  54336. */
  54337. dxgiFormat: number;
  54338. /**
  54339. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  54340. */
  54341. textureType: number;
  54342. /**
  54343. * Sphericle polynomial created for the dds texture
  54344. */
  54345. sphericalPolynomial?: SphericalPolynomial;
  54346. }
  54347. /**
  54348. * Class used to provide DDS decompression tools
  54349. */
  54350. export class DDSTools {
  54351. /**
  54352. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  54353. */
  54354. static StoreLODInAlphaChannel: boolean;
  54355. /**
  54356. * Gets DDS information from an array buffer
  54357. * @param data defines the array buffer view to read data from
  54358. * @returns the DDS information
  54359. */
  54360. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  54361. private static _FloatView;
  54362. private static _Int32View;
  54363. private static _ToHalfFloat;
  54364. private static _FromHalfFloat;
  54365. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  54366. private static _GetHalfFloatRGBAArrayBuffer;
  54367. private static _GetFloatRGBAArrayBuffer;
  54368. private static _GetFloatAsUIntRGBAArrayBuffer;
  54369. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  54370. private static _GetRGBAArrayBuffer;
  54371. private static _ExtractLongWordOrder;
  54372. private static _GetRGBArrayBuffer;
  54373. private static _GetLuminanceArrayBuffer;
  54374. /**
  54375. * Uploads DDS Levels to a Babylon Texture
  54376. * @hidden
  54377. */
  54378. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  54379. }
  54380. module "babylonjs/Engines/thinEngine" {
  54381. interface ThinEngine {
  54382. /**
  54383. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  54384. * @param rootUrl defines the url where the file to load is located
  54385. * @param scene defines the current scene
  54386. * @param lodScale defines scale to apply to the mip map selection
  54387. * @param lodOffset defines offset to apply to the mip map selection
  54388. * @param onLoad defines an optional callback raised when the texture is loaded
  54389. * @param onError defines an optional callback raised if there is an issue to load the texture
  54390. * @param format defines the format of the data
  54391. * @param forcedExtension defines the extension to use to pick the right loader
  54392. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  54393. * @returns the cube texture as an InternalTexture
  54394. */
  54395. 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;
  54396. }
  54397. }
  54398. }
  54399. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  54400. import { Nullable } from "babylonjs/types";
  54401. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54402. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54403. /**
  54404. * Implementation of the DDS Texture Loader.
  54405. * @hidden
  54406. */
  54407. export class _DDSTextureLoader implements IInternalTextureLoader {
  54408. /**
  54409. * Defines wether the loader supports cascade loading the different faces.
  54410. */
  54411. readonly supportCascades: boolean;
  54412. /**
  54413. * This returns if the loader support the current file information.
  54414. * @param extension defines the file extension of the file being loaded
  54415. * @returns true if the loader can load the specified file
  54416. */
  54417. canLoad(extension: string): boolean;
  54418. /**
  54419. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54420. * @param data contains the texture data
  54421. * @param texture defines the BabylonJS internal texture
  54422. * @param createPolynomials will be true if polynomials have been requested
  54423. * @param onLoad defines the callback to trigger once the texture is ready
  54424. * @param onError defines the callback to trigger in case of error
  54425. */
  54426. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54427. /**
  54428. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54429. * @param data contains the texture data
  54430. * @param texture defines the BabylonJS internal texture
  54431. * @param callback defines the method to call once ready to upload
  54432. */
  54433. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54434. }
  54435. }
  54436. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  54437. import { Nullable } from "babylonjs/types";
  54438. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54439. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54440. /**
  54441. * Implementation of the ENV Texture Loader.
  54442. * @hidden
  54443. */
  54444. export class _ENVTextureLoader implements IInternalTextureLoader {
  54445. /**
  54446. * Defines wether the loader supports cascade loading the different faces.
  54447. */
  54448. readonly supportCascades: boolean;
  54449. /**
  54450. * This returns if the loader support the current file information.
  54451. * @param extension defines the file extension of the file being loaded
  54452. * @returns true if the loader can load the specified file
  54453. */
  54454. canLoad(extension: string): boolean;
  54455. /**
  54456. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54457. * @param data contains the texture data
  54458. * @param texture defines the BabylonJS internal texture
  54459. * @param createPolynomials will be true if polynomials have been requested
  54460. * @param onLoad defines the callback to trigger once the texture is ready
  54461. * @param onError defines the callback to trigger in case of error
  54462. */
  54463. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54464. /**
  54465. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54466. * @param data contains the texture data
  54467. * @param texture defines the BabylonJS internal texture
  54468. * @param callback defines the method to call once ready to upload
  54469. */
  54470. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54471. }
  54472. }
  54473. declare module "babylonjs/Misc/khronosTextureContainer" {
  54474. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54475. /**
  54476. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54477. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54478. */
  54479. export class KhronosTextureContainer {
  54480. /** contents of the KTX container file */
  54481. data: ArrayBufferView;
  54482. private static HEADER_LEN;
  54483. private static COMPRESSED_2D;
  54484. private static COMPRESSED_3D;
  54485. private static TEX_2D;
  54486. private static TEX_3D;
  54487. /**
  54488. * Gets the openGL type
  54489. */
  54490. glType: number;
  54491. /**
  54492. * Gets the openGL type size
  54493. */
  54494. glTypeSize: number;
  54495. /**
  54496. * Gets the openGL format
  54497. */
  54498. glFormat: number;
  54499. /**
  54500. * Gets the openGL internal format
  54501. */
  54502. glInternalFormat: number;
  54503. /**
  54504. * Gets the base internal format
  54505. */
  54506. glBaseInternalFormat: number;
  54507. /**
  54508. * Gets image width in pixel
  54509. */
  54510. pixelWidth: number;
  54511. /**
  54512. * Gets image height in pixel
  54513. */
  54514. pixelHeight: number;
  54515. /**
  54516. * Gets image depth in pixels
  54517. */
  54518. pixelDepth: number;
  54519. /**
  54520. * Gets the number of array elements
  54521. */
  54522. numberOfArrayElements: number;
  54523. /**
  54524. * Gets the number of faces
  54525. */
  54526. numberOfFaces: number;
  54527. /**
  54528. * Gets the number of mipmap levels
  54529. */
  54530. numberOfMipmapLevels: number;
  54531. /**
  54532. * Gets the bytes of key value data
  54533. */
  54534. bytesOfKeyValueData: number;
  54535. /**
  54536. * Gets the load type
  54537. */
  54538. loadType: number;
  54539. /**
  54540. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  54541. */
  54542. isInvalid: boolean;
  54543. /**
  54544. * Creates a new KhronosTextureContainer
  54545. * @param data contents of the KTX container file
  54546. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  54547. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  54548. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  54549. */
  54550. constructor(
  54551. /** contents of the KTX container file */
  54552. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  54553. /**
  54554. * Uploads KTX content to a Babylon Texture.
  54555. * It is assumed that the texture has already been created & is currently bound
  54556. * @hidden
  54557. */
  54558. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  54559. private _upload2DCompressedLevels;
  54560. /**
  54561. * Checks if the given data starts with a KTX file identifier.
  54562. * @param data the data to check
  54563. * @returns true if the data is a KTX file or false otherwise
  54564. */
  54565. static IsValid(data: ArrayBufferView): boolean;
  54566. }
  54567. }
  54568. declare module "babylonjs/Misc/khronosTextureContainer2" {
  54569. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54570. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54571. /**
  54572. * Class for loading KTX2 files
  54573. * !!! Experimental Extension Subject to Changes !!!
  54574. * @hidden
  54575. */
  54576. export class KhronosTextureContainer2 {
  54577. private static _ModulePromise;
  54578. private static _TranscodeFormat;
  54579. constructor(engine: ThinEngine);
  54580. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  54581. private _determineTranscodeFormat;
  54582. /**
  54583. * Checks if the given data starts with a KTX2 file identifier.
  54584. * @param data the data to check
  54585. * @returns true if the data is a KTX2 file or false otherwise
  54586. */
  54587. static IsValid(data: ArrayBufferView): boolean;
  54588. }
  54589. }
  54590. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  54591. import { Nullable } from "babylonjs/types";
  54592. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54593. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54594. /**
  54595. * Implementation of the KTX Texture Loader.
  54596. * @hidden
  54597. */
  54598. export class _KTXTextureLoader implements IInternalTextureLoader {
  54599. /**
  54600. * Defines wether the loader supports cascade loading the different faces.
  54601. */
  54602. readonly supportCascades: boolean;
  54603. /**
  54604. * This returns if the loader support the current file information.
  54605. * @param extension defines the file extension of the file being loaded
  54606. * @returns true if the loader can load the specified file
  54607. */
  54608. canLoad(extension: string): boolean;
  54609. /**
  54610. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54611. * @param data contains the texture data
  54612. * @param texture defines the BabylonJS internal texture
  54613. * @param createPolynomials will be true if polynomials have been requested
  54614. * @param onLoad defines the callback to trigger once the texture is ready
  54615. * @param onError defines the callback to trigger in case of error
  54616. */
  54617. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54618. /**
  54619. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54620. * @param data contains the texture data
  54621. * @param texture defines the BabylonJS internal texture
  54622. * @param callback defines the method to call once ready to upload
  54623. */
  54624. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  54625. }
  54626. }
  54627. declare module "babylonjs/Helpers/sceneHelpers" {
  54628. import { Nullable } from "babylonjs/types";
  54629. import { Mesh } from "babylonjs/Meshes/mesh";
  54630. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54631. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  54632. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  54633. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54634. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54635. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54636. import "babylonjs/Meshes/Builders/boxBuilder";
  54637. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  54638. /** @hidden */
  54639. export var _forceSceneHelpersToBundle: boolean;
  54640. module "babylonjs/scene" {
  54641. interface Scene {
  54642. /**
  54643. * Creates a default light for the scene.
  54644. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  54645. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  54646. */
  54647. createDefaultLight(replace?: boolean): void;
  54648. /**
  54649. * Creates a default camera for the scene.
  54650. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  54651. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54652. * @param replace has default false, when true replaces the active camera in the scene
  54653. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  54654. */
  54655. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54656. /**
  54657. * Creates a default camera and a default light.
  54658. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  54659. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54660. * @param replace has the default false, when true replaces the active camera/light in the scene
  54661. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  54662. */
  54663. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54664. /**
  54665. * Creates a new sky box
  54666. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  54667. * @param environmentTexture defines the texture to use as environment texture
  54668. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  54669. * @param scale defines the overall scale of the skybox
  54670. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  54671. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  54672. * @returns a new mesh holding the sky box
  54673. */
  54674. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  54675. /**
  54676. * Creates a new environment
  54677. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  54678. * @param options defines the options you can use to configure the environment
  54679. * @returns the new EnvironmentHelper
  54680. */
  54681. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  54682. /**
  54683. * Creates a new VREXperienceHelper
  54684. * @see http://doc.babylonjs.com/how_to/webvr_helper
  54685. * @param webVROptions defines the options used to create the new VREXperienceHelper
  54686. * @returns a new VREXperienceHelper
  54687. */
  54688. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  54689. /**
  54690. * Creates a new WebXRDefaultExperience
  54691. * @see http://doc.babylonjs.com/how_to/webxr
  54692. * @param options experience options
  54693. * @returns a promise for a new WebXRDefaultExperience
  54694. */
  54695. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  54696. }
  54697. }
  54698. }
  54699. declare module "babylonjs/Helpers/videoDome" {
  54700. import { Scene } from "babylonjs/scene";
  54701. import { TransformNode } from "babylonjs/Meshes/transformNode";
  54702. import { Mesh } from "babylonjs/Meshes/mesh";
  54703. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  54704. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  54705. import "babylonjs/Meshes/Builders/sphereBuilder";
  54706. /**
  54707. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  54708. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  54709. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  54710. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54711. */
  54712. export class VideoDome extends TransformNode {
  54713. /**
  54714. * Define the video source as a Monoscopic panoramic 360 video.
  54715. */
  54716. static readonly MODE_MONOSCOPIC: number;
  54717. /**
  54718. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54719. */
  54720. static readonly MODE_TOPBOTTOM: number;
  54721. /**
  54722. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54723. */
  54724. static readonly MODE_SIDEBYSIDE: number;
  54725. private _halfDome;
  54726. private _useDirectMapping;
  54727. /**
  54728. * The video texture being displayed on the sphere
  54729. */
  54730. protected _videoTexture: VideoTexture;
  54731. /**
  54732. * Gets the video texture being displayed on the sphere
  54733. */
  54734. get videoTexture(): VideoTexture;
  54735. /**
  54736. * The skybox material
  54737. */
  54738. protected _material: BackgroundMaterial;
  54739. /**
  54740. * The surface used for the skybox
  54741. */
  54742. protected _mesh: Mesh;
  54743. /**
  54744. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  54745. */
  54746. private _halfDomeMask;
  54747. /**
  54748. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54749. * Also see the options.resolution property.
  54750. */
  54751. get fovMultiplier(): number;
  54752. set fovMultiplier(value: number);
  54753. private _videoMode;
  54754. /**
  54755. * Gets or set the current video mode for the video. It can be:
  54756. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  54757. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54758. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54759. */
  54760. get videoMode(): number;
  54761. set videoMode(value: number);
  54762. /**
  54763. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  54764. *
  54765. */
  54766. get halfDome(): boolean;
  54767. /**
  54768. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  54769. */
  54770. set halfDome(enabled: boolean);
  54771. /**
  54772. * Oberserver used in Stereoscopic VR Mode.
  54773. */
  54774. private _onBeforeCameraRenderObserver;
  54775. /**
  54776. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  54777. * @param name Element's name, child elements will append suffixes for their own names.
  54778. * @param urlsOrVideo defines the url(s) or the video element to use
  54779. * @param options An object containing optional or exposed sub element properties
  54780. */
  54781. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  54782. resolution?: number;
  54783. clickToPlay?: boolean;
  54784. autoPlay?: boolean;
  54785. loop?: boolean;
  54786. size?: number;
  54787. poster?: string;
  54788. faceForward?: boolean;
  54789. useDirectMapping?: boolean;
  54790. halfDomeMode?: boolean;
  54791. }, scene: Scene);
  54792. private _changeVideoMode;
  54793. /**
  54794. * Releases resources associated with this node.
  54795. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54796. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54797. */
  54798. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  54799. }
  54800. }
  54801. declare module "babylonjs/Helpers/index" {
  54802. export * from "babylonjs/Helpers/environmentHelper";
  54803. export * from "babylonjs/Helpers/photoDome";
  54804. export * from "babylonjs/Helpers/sceneHelpers";
  54805. export * from "babylonjs/Helpers/videoDome";
  54806. }
  54807. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  54808. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54809. import { IDisposable } from "babylonjs/scene";
  54810. import { Engine } from "babylonjs/Engines/engine";
  54811. /**
  54812. * This class can be used to get instrumentation data from a Babylon engine
  54813. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54814. */
  54815. export class EngineInstrumentation implements IDisposable {
  54816. /**
  54817. * Define the instrumented engine.
  54818. */
  54819. engine: Engine;
  54820. private _captureGPUFrameTime;
  54821. private _gpuFrameTimeToken;
  54822. private _gpuFrameTime;
  54823. private _captureShaderCompilationTime;
  54824. private _shaderCompilationTime;
  54825. private _onBeginFrameObserver;
  54826. private _onEndFrameObserver;
  54827. private _onBeforeShaderCompilationObserver;
  54828. private _onAfterShaderCompilationObserver;
  54829. /**
  54830. * Gets the perf counter used for GPU frame time
  54831. */
  54832. get gpuFrameTimeCounter(): PerfCounter;
  54833. /**
  54834. * Gets the GPU frame time capture status
  54835. */
  54836. get captureGPUFrameTime(): boolean;
  54837. /**
  54838. * Enable or disable the GPU frame time capture
  54839. */
  54840. set captureGPUFrameTime(value: boolean);
  54841. /**
  54842. * Gets the perf counter used for shader compilation time
  54843. */
  54844. get shaderCompilationTimeCounter(): PerfCounter;
  54845. /**
  54846. * Gets the shader compilation time capture status
  54847. */
  54848. get captureShaderCompilationTime(): boolean;
  54849. /**
  54850. * Enable or disable the shader compilation time capture
  54851. */
  54852. set captureShaderCompilationTime(value: boolean);
  54853. /**
  54854. * Instantiates a new engine instrumentation.
  54855. * This class can be used to get instrumentation data from a Babylon engine
  54856. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54857. * @param engine Defines the engine to instrument
  54858. */
  54859. constructor(
  54860. /**
  54861. * Define the instrumented engine.
  54862. */
  54863. engine: Engine);
  54864. /**
  54865. * Dispose and release associated resources.
  54866. */
  54867. dispose(): void;
  54868. }
  54869. }
  54870. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  54871. import { Scene, IDisposable } from "babylonjs/scene";
  54872. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54873. /**
  54874. * This class can be used to get instrumentation data from a Babylon engine
  54875. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54876. */
  54877. export class SceneInstrumentation implements IDisposable {
  54878. /**
  54879. * Defines the scene to instrument
  54880. */
  54881. scene: Scene;
  54882. private _captureActiveMeshesEvaluationTime;
  54883. private _activeMeshesEvaluationTime;
  54884. private _captureRenderTargetsRenderTime;
  54885. private _renderTargetsRenderTime;
  54886. private _captureFrameTime;
  54887. private _frameTime;
  54888. private _captureRenderTime;
  54889. private _renderTime;
  54890. private _captureInterFrameTime;
  54891. private _interFrameTime;
  54892. private _captureParticlesRenderTime;
  54893. private _particlesRenderTime;
  54894. private _captureSpritesRenderTime;
  54895. private _spritesRenderTime;
  54896. private _capturePhysicsTime;
  54897. private _physicsTime;
  54898. private _captureAnimationsTime;
  54899. private _animationsTime;
  54900. private _captureCameraRenderTime;
  54901. private _cameraRenderTime;
  54902. private _onBeforeActiveMeshesEvaluationObserver;
  54903. private _onAfterActiveMeshesEvaluationObserver;
  54904. private _onBeforeRenderTargetsRenderObserver;
  54905. private _onAfterRenderTargetsRenderObserver;
  54906. private _onAfterRenderObserver;
  54907. private _onBeforeDrawPhaseObserver;
  54908. private _onAfterDrawPhaseObserver;
  54909. private _onBeforeAnimationsObserver;
  54910. private _onBeforeParticlesRenderingObserver;
  54911. private _onAfterParticlesRenderingObserver;
  54912. private _onBeforeSpritesRenderingObserver;
  54913. private _onAfterSpritesRenderingObserver;
  54914. private _onBeforePhysicsObserver;
  54915. private _onAfterPhysicsObserver;
  54916. private _onAfterAnimationsObserver;
  54917. private _onBeforeCameraRenderObserver;
  54918. private _onAfterCameraRenderObserver;
  54919. /**
  54920. * Gets the perf counter used for active meshes evaluation time
  54921. */
  54922. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  54923. /**
  54924. * Gets the active meshes evaluation time capture status
  54925. */
  54926. get captureActiveMeshesEvaluationTime(): boolean;
  54927. /**
  54928. * Enable or disable the active meshes evaluation time capture
  54929. */
  54930. set captureActiveMeshesEvaluationTime(value: boolean);
  54931. /**
  54932. * Gets the perf counter used for render targets render time
  54933. */
  54934. get renderTargetsRenderTimeCounter(): PerfCounter;
  54935. /**
  54936. * Gets the render targets render time capture status
  54937. */
  54938. get captureRenderTargetsRenderTime(): boolean;
  54939. /**
  54940. * Enable or disable the render targets render time capture
  54941. */
  54942. set captureRenderTargetsRenderTime(value: boolean);
  54943. /**
  54944. * Gets the perf counter used for particles render time
  54945. */
  54946. get particlesRenderTimeCounter(): PerfCounter;
  54947. /**
  54948. * Gets the particles render time capture status
  54949. */
  54950. get captureParticlesRenderTime(): boolean;
  54951. /**
  54952. * Enable or disable the particles render time capture
  54953. */
  54954. set captureParticlesRenderTime(value: boolean);
  54955. /**
  54956. * Gets the perf counter used for sprites render time
  54957. */
  54958. get spritesRenderTimeCounter(): PerfCounter;
  54959. /**
  54960. * Gets the sprites render time capture status
  54961. */
  54962. get captureSpritesRenderTime(): boolean;
  54963. /**
  54964. * Enable or disable the sprites render time capture
  54965. */
  54966. set captureSpritesRenderTime(value: boolean);
  54967. /**
  54968. * Gets the perf counter used for physics time
  54969. */
  54970. get physicsTimeCounter(): PerfCounter;
  54971. /**
  54972. * Gets the physics time capture status
  54973. */
  54974. get capturePhysicsTime(): boolean;
  54975. /**
  54976. * Enable or disable the physics time capture
  54977. */
  54978. set capturePhysicsTime(value: boolean);
  54979. /**
  54980. * Gets the perf counter used for animations time
  54981. */
  54982. get animationsTimeCounter(): PerfCounter;
  54983. /**
  54984. * Gets the animations time capture status
  54985. */
  54986. get captureAnimationsTime(): boolean;
  54987. /**
  54988. * Enable or disable the animations time capture
  54989. */
  54990. set captureAnimationsTime(value: boolean);
  54991. /**
  54992. * Gets the perf counter used for frame time capture
  54993. */
  54994. get frameTimeCounter(): PerfCounter;
  54995. /**
  54996. * Gets the frame time capture status
  54997. */
  54998. get captureFrameTime(): boolean;
  54999. /**
  55000. * Enable or disable the frame time capture
  55001. */
  55002. set captureFrameTime(value: boolean);
  55003. /**
  55004. * Gets the perf counter used for inter-frames time capture
  55005. */
  55006. get interFrameTimeCounter(): PerfCounter;
  55007. /**
  55008. * Gets the inter-frames time capture status
  55009. */
  55010. get captureInterFrameTime(): boolean;
  55011. /**
  55012. * Enable or disable the inter-frames time capture
  55013. */
  55014. set captureInterFrameTime(value: boolean);
  55015. /**
  55016. * Gets the perf counter used for render time capture
  55017. */
  55018. get renderTimeCounter(): PerfCounter;
  55019. /**
  55020. * Gets the render time capture status
  55021. */
  55022. get captureRenderTime(): boolean;
  55023. /**
  55024. * Enable or disable the render time capture
  55025. */
  55026. set captureRenderTime(value: boolean);
  55027. /**
  55028. * Gets the perf counter used for camera render time capture
  55029. */
  55030. get cameraRenderTimeCounter(): PerfCounter;
  55031. /**
  55032. * Gets the camera render time capture status
  55033. */
  55034. get captureCameraRenderTime(): boolean;
  55035. /**
  55036. * Enable or disable the camera render time capture
  55037. */
  55038. set captureCameraRenderTime(value: boolean);
  55039. /**
  55040. * Gets the perf counter used for draw calls
  55041. */
  55042. get drawCallsCounter(): PerfCounter;
  55043. /**
  55044. * Instantiates a new scene instrumentation.
  55045. * This class can be used to get instrumentation data from a Babylon engine
  55046. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  55047. * @param scene Defines the scene to instrument
  55048. */
  55049. constructor(
  55050. /**
  55051. * Defines the scene to instrument
  55052. */
  55053. scene: Scene);
  55054. /**
  55055. * Dispose and release associated resources.
  55056. */
  55057. dispose(): void;
  55058. }
  55059. }
  55060. declare module "babylonjs/Instrumentation/index" {
  55061. export * from "babylonjs/Instrumentation/engineInstrumentation";
  55062. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  55063. export * from "babylonjs/Instrumentation/timeToken";
  55064. }
  55065. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  55066. /** @hidden */
  55067. export var glowMapGenerationPixelShader: {
  55068. name: string;
  55069. shader: string;
  55070. };
  55071. }
  55072. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  55073. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55074. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  55075. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  55076. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55077. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  55078. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55079. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55080. /** @hidden */
  55081. export var glowMapGenerationVertexShader: {
  55082. name: string;
  55083. shader: string;
  55084. };
  55085. }
  55086. declare module "babylonjs/Layers/effectLayer" {
  55087. import { Observable } from "babylonjs/Misc/observable";
  55088. import { Nullable } from "babylonjs/types";
  55089. import { Camera } from "babylonjs/Cameras/camera";
  55090. import { Scene } from "babylonjs/scene";
  55091. import { ISize } from "babylonjs/Maths/math.size";
  55092. import { Color4 } from "babylonjs/Maths/math.color";
  55093. import { Engine } from "babylonjs/Engines/engine";
  55094. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55095. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55096. import { Mesh } from "babylonjs/Meshes/mesh";
  55097. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55098. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55099. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55100. import { Effect } from "babylonjs/Materials/effect";
  55101. import { Material } from "babylonjs/Materials/material";
  55102. import "babylonjs/Shaders/glowMapGeneration.fragment";
  55103. import "babylonjs/Shaders/glowMapGeneration.vertex";
  55104. /**
  55105. * Effect layer options. This helps customizing the behaviour
  55106. * of the effect layer.
  55107. */
  55108. export interface IEffectLayerOptions {
  55109. /**
  55110. * Multiplication factor apply to the canvas size to compute the render target size
  55111. * used to generated the objects (the smaller the faster).
  55112. */
  55113. mainTextureRatio: number;
  55114. /**
  55115. * Enforces a fixed size texture to ensure effect stability across devices.
  55116. */
  55117. mainTextureFixedSize?: number;
  55118. /**
  55119. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  55120. */
  55121. alphaBlendingMode: number;
  55122. /**
  55123. * The camera attached to the layer.
  55124. */
  55125. camera: Nullable<Camera>;
  55126. /**
  55127. * The rendering group to draw the layer in.
  55128. */
  55129. renderingGroupId: number;
  55130. }
  55131. /**
  55132. * The effect layer Helps adding post process effect blended with the main pass.
  55133. *
  55134. * This can be for instance use to generate glow or higlight effects on the scene.
  55135. *
  55136. * The effect layer class can not be used directly and is intented to inherited from to be
  55137. * customized per effects.
  55138. */
  55139. export abstract class EffectLayer {
  55140. private _vertexBuffers;
  55141. private _indexBuffer;
  55142. private _cachedDefines;
  55143. private _effectLayerMapGenerationEffect;
  55144. private _effectLayerOptions;
  55145. private _mergeEffect;
  55146. protected _scene: Scene;
  55147. protected _engine: Engine;
  55148. protected _maxSize: number;
  55149. protected _mainTextureDesiredSize: ISize;
  55150. protected _mainTexture: RenderTargetTexture;
  55151. protected _shouldRender: boolean;
  55152. protected _postProcesses: PostProcess[];
  55153. protected _textures: BaseTexture[];
  55154. protected _emissiveTextureAndColor: {
  55155. texture: Nullable<BaseTexture>;
  55156. color: Color4;
  55157. };
  55158. /**
  55159. * The name of the layer
  55160. */
  55161. name: string;
  55162. /**
  55163. * The clear color of the texture used to generate the glow map.
  55164. */
  55165. neutralColor: Color4;
  55166. /**
  55167. * Specifies whether the highlight layer is enabled or not.
  55168. */
  55169. isEnabled: boolean;
  55170. /**
  55171. * Gets the camera attached to the layer.
  55172. */
  55173. get camera(): Nullable<Camera>;
  55174. /**
  55175. * Gets the rendering group id the layer should render in.
  55176. */
  55177. get renderingGroupId(): number;
  55178. set renderingGroupId(renderingGroupId: number);
  55179. /**
  55180. * An event triggered when the effect layer has been disposed.
  55181. */
  55182. onDisposeObservable: Observable<EffectLayer>;
  55183. /**
  55184. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  55185. */
  55186. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  55187. /**
  55188. * An event triggered when the generated texture is being merged in the scene.
  55189. */
  55190. onBeforeComposeObservable: Observable<EffectLayer>;
  55191. /**
  55192. * An event triggered when the mesh is rendered into the effect render target.
  55193. */
  55194. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  55195. /**
  55196. * An event triggered after the mesh has been rendered into the effect render target.
  55197. */
  55198. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  55199. /**
  55200. * An event triggered when the generated texture has been merged in the scene.
  55201. */
  55202. onAfterComposeObservable: Observable<EffectLayer>;
  55203. /**
  55204. * An event triggered when the efffect layer changes its size.
  55205. */
  55206. onSizeChangedObservable: Observable<EffectLayer>;
  55207. /** @hidden */
  55208. static _SceneComponentInitialization: (scene: Scene) => void;
  55209. /**
  55210. * Instantiates a new effect Layer and references it in the scene.
  55211. * @param name The name of the layer
  55212. * @param scene The scene to use the layer in
  55213. */
  55214. constructor(
  55215. /** The Friendly of the effect in the scene */
  55216. name: string, scene: Scene);
  55217. /**
  55218. * Get the effect name of the layer.
  55219. * @return The effect name
  55220. */
  55221. abstract getEffectName(): string;
  55222. /**
  55223. * Checks for the readiness of the element composing the layer.
  55224. * @param subMesh the mesh to check for
  55225. * @param useInstances specify whether or not to use instances to render the mesh
  55226. * @return true if ready otherwise, false
  55227. */
  55228. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55229. /**
  55230. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55231. * @returns true if the effect requires stencil during the main canvas render pass.
  55232. */
  55233. abstract needStencil(): boolean;
  55234. /**
  55235. * Create the merge effect. This is the shader use to blit the information back
  55236. * to the main canvas at the end of the scene rendering.
  55237. * @returns The effect containing the shader used to merge the effect on the main canvas
  55238. */
  55239. protected abstract _createMergeEffect(): Effect;
  55240. /**
  55241. * Creates the render target textures and post processes used in the effect layer.
  55242. */
  55243. protected abstract _createTextureAndPostProcesses(): void;
  55244. /**
  55245. * Implementation specific of rendering the generating effect on the main canvas.
  55246. * @param effect The effect used to render through
  55247. */
  55248. protected abstract _internalRender(effect: Effect): void;
  55249. /**
  55250. * Sets the required values for both the emissive texture and and the main color.
  55251. */
  55252. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55253. /**
  55254. * Free any resources and references associated to a mesh.
  55255. * Internal use
  55256. * @param mesh The mesh to free.
  55257. */
  55258. abstract _disposeMesh(mesh: Mesh): void;
  55259. /**
  55260. * Serializes this layer (Glow or Highlight for example)
  55261. * @returns a serialized layer object
  55262. */
  55263. abstract serialize?(): any;
  55264. /**
  55265. * Initializes the effect layer with the required options.
  55266. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  55267. */
  55268. protected _init(options: Partial<IEffectLayerOptions>): void;
  55269. /**
  55270. * Generates the index buffer of the full screen quad blending to the main canvas.
  55271. */
  55272. private _generateIndexBuffer;
  55273. /**
  55274. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  55275. */
  55276. private _generateVertexBuffer;
  55277. /**
  55278. * Sets the main texture desired size which is the closest power of two
  55279. * of the engine canvas size.
  55280. */
  55281. private _setMainTextureSize;
  55282. /**
  55283. * Creates the main texture for the effect layer.
  55284. */
  55285. protected _createMainTexture(): void;
  55286. /**
  55287. * Adds specific effects defines.
  55288. * @param defines The defines to add specifics to.
  55289. */
  55290. protected _addCustomEffectDefines(defines: string[]): void;
  55291. /**
  55292. * Checks for the readiness of the element composing the layer.
  55293. * @param subMesh the mesh to check for
  55294. * @param useInstances specify whether or not to use instances to render the mesh
  55295. * @param emissiveTexture the associated emissive texture used to generate the glow
  55296. * @return true if ready otherwise, false
  55297. */
  55298. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  55299. /**
  55300. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  55301. */
  55302. render(): void;
  55303. /**
  55304. * Determine if a given mesh will be used in the current effect.
  55305. * @param mesh mesh to test
  55306. * @returns true if the mesh will be used
  55307. */
  55308. hasMesh(mesh: AbstractMesh): boolean;
  55309. /**
  55310. * Returns true if the layer contains information to display, otherwise false.
  55311. * @returns true if the glow layer should be rendered
  55312. */
  55313. shouldRender(): boolean;
  55314. /**
  55315. * Returns true if the mesh should render, otherwise false.
  55316. * @param mesh The mesh to render
  55317. * @returns true if it should render otherwise false
  55318. */
  55319. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  55320. /**
  55321. * Returns true if the mesh can be rendered, otherwise false.
  55322. * @param mesh The mesh to render
  55323. * @param material The material used on the mesh
  55324. * @returns true if it can be rendered otherwise false
  55325. */
  55326. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55327. /**
  55328. * Returns true if the mesh should render, otherwise false.
  55329. * @param mesh The mesh to render
  55330. * @returns true if it should render otherwise false
  55331. */
  55332. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  55333. /**
  55334. * Renders the submesh passed in parameter to the generation map.
  55335. */
  55336. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  55337. /**
  55338. * Defines whether the current material of the mesh should be use to render the effect.
  55339. * @param mesh defines the current mesh to render
  55340. */
  55341. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55342. /**
  55343. * Rebuild the required buffers.
  55344. * @hidden Internal use only.
  55345. */
  55346. _rebuild(): void;
  55347. /**
  55348. * Dispose only the render target textures and post process.
  55349. */
  55350. private _disposeTextureAndPostProcesses;
  55351. /**
  55352. * Dispose the highlight layer and free resources.
  55353. */
  55354. dispose(): void;
  55355. /**
  55356. * Gets the class name of the effect layer
  55357. * @returns the string with the class name of the effect layer
  55358. */
  55359. getClassName(): string;
  55360. /**
  55361. * Creates an effect layer from parsed effect layer data
  55362. * @param parsedEffectLayer defines effect layer data
  55363. * @param scene defines the current scene
  55364. * @param rootUrl defines the root URL containing the effect layer information
  55365. * @returns a parsed effect Layer
  55366. */
  55367. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  55368. }
  55369. }
  55370. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  55371. import { Scene } from "babylonjs/scene";
  55372. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55373. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55374. import { AbstractScene } from "babylonjs/abstractScene";
  55375. module "babylonjs/abstractScene" {
  55376. interface AbstractScene {
  55377. /**
  55378. * The list of effect layers (highlights/glow) added to the scene
  55379. * @see http://doc.babylonjs.com/how_to/highlight_layer
  55380. * @see http://doc.babylonjs.com/how_to/glow_layer
  55381. */
  55382. effectLayers: Array<EffectLayer>;
  55383. /**
  55384. * Removes the given effect layer from this scene.
  55385. * @param toRemove defines the effect layer to remove
  55386. * @returns the index of the removed effect layer
  55387. */
  55388. removeEffectLayer(toRemove: EffectLayer): number;
  55389. /**
  55390. * Adds the given effect layer to this scene
  55391. * @param newEffectLayer defines the effect layer to add
  55392. */
  55393. addEffectLayer(newEffectLayer: EffectLayer): void;
  55394. }
  55395. }
  55396. /**
  55397. * Defines the layer scene component responsible to manage any effect layers
  55398. * in a given scene.
  55399. */
  55400. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  55401. /**
  55402. * The component name helpfull to identify the component in the list of scene components.
  55403. */
  55404. readonly name: string;
  55405. /**
  55406. * The scene the component belongs to.
  55407. */
  55408. scene: Scene;
  55409. private _engine;
  55410. private _renderEffects;
  55411. private _needStencil;
  55412. private _previousStencilState;
  55413. /**
  55414. * Creates a new instance of the component for the given scene
  55415. * @param scene Defines the scene to register the component in
  55416. */
  55417. constructor(scene: Scene);
  55418. /**
  55419. * Registers the component in a given scene
  55420. */
  55421. register(): void;
  55422. /**
  55423. * Rebuilds the elements related to this component in case of
  55424. * context lost for instance.
  55425. */
  55426. rebuild(): void;
  55427. /**
  55428. * Serializes the component data to the specified json object
  55429. * @param serializationObject The object to serialize to
  55430. */
  55431. serialize(serializationObject: any): void;
  55432. /**
  55433. * Adds all the elements from the container to the scene
  55434. * @param container the container holding the elements
  55435. */
  55436. addFromContainer(container: AbstractScene): void;
  55437. /**
  55438. * Removes all the elements in the container from the scene
  55439. * @param container contains the elements to remove
  55440. * @param dispose if the removed element should be disposed (default: false)
  55441. */
  55442. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55443. /**
  55444. * Disposes the component and the associated ressources.
  55445. */
  55446. dispose(): void;
  55447. private _isReadyForMesh;
  55448. private _renderMainTexture;
  55449. private _setStencil;
  55450. private _setStencilBack;
  55451. private _draw;
  55452. private _drawCamera;
  55453. private _drawRenderingGroup;
  55454. }
  55455. }
  55456. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  55457. /** @hidden */
  55458. export var glowMapMergePixelShader: {
  55459. name: string;
  55460. shader: string;
  55461. };
  55462. }
  55463. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  55464. /** @hidden */
  55465. export var glowMapMergeVertexShader: {
  55466. name: string;
  55467. shader: string;
  55468. };
  55469. }
  55470. declare module "babylonjs/Layers/glowLayer" {
  55471. import { Nullable } from "babylonjs/types";
  55472. import { Camera } from "babylonjs/Cameras/camera";
  55473. import { Scene } from "babylonjs/scene";
  55474. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55475. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55476. import { Mesh } from "babylonjs/Meshes/mesh";
  55477. import { Texture } from "babylonjs/Materials/Textures/texture";
  55478. import { Effect } from "babylonjs/Materials/effect";
  55479. import { Material } from "babylonjs/Materials/material";
  55480. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55481. import { Color4 } from "babylonjs/Maths/math.color";
  55482. import "babylonjs/Shaders/glowMapMerge.fragment";
  55483. import "babylonjs/Shaders/glowMapMerge.vertex";
  55484. import "babylonjs/Layers/effectLayerSceneComponent";
  55485. module "babylonjs/abstractScene" {
  55486. interface AbstractScene {
  55487. /**
  55488. * Return a the first highlight layer of the scene with a given name.
  55489. * @param name The name of the highlight layer to look for.
  55490. * @return The highlight layer if found otherwise null.
  55491. */
  55492. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  55493. }
  55494. }
  55495. /**
  55496. * Glow layer options. This helps customizing the behaviour
  55497. * of the glow layer.
  55498. */
  55499. export interface IGlowLayerOptions {
  55500. /**
  55501. * Multiplication factor apply to the canvas size to compute the render target size
  55502. * used to generated the glowing objects (the smaller the faster).
  55503. */
  55504. mainTextureRatio: number;
  55505. /**
  55506. * Enforces a fixed size texture to ensure resize independant blur.
  55507. */
  55508. mainTextureFixedSize?: number;
  55509. /**
  55510. * How big is the kernel of the blur texture.
  55511. */
  55512. blurKernelSize: number;
  55513. /**
  55514. * The camera attached to the layer.
  55515. */
  55516. camera: Nullable<Camera>;
  55517. /**
  55518. * Enable MSAA by chosing the number of samples.
  55519. */
  55520. mainTextureSamples?: number;
  55521. /**
  55522. * The rendering group to draw the layer in.
  55523. */
  55524. renderingGroupId: number;
  55525. }
  55526. /**
  55527. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  55528. *
  55529. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  55530. *
  55531. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  55532. */
  55533. export class GlowLayer extends EffectLayer {
  55534. /**
  55535. * Effect Name of the layer.
  55536. */
  55537. static readonly EffectName: string;
  55538. /**
  55539. * The default blur kernel size used for the glow.
  55540. */
  55541. static DefaultBlurKernelSize: number;
  55542. /**
  55543. * The default texture size ratio used for the glow.
  55544. */
  55545. static DefaultTextureRatio: number;
  55546. /**
  55547. * Sets the kernel size of the blur.
  55548. */
  55549. set blurKernelSize(value: number);
  55550. /**
  55551. * Gets the kernel size of the blur.
  55552. */
  55553. get blurKernelSize(): number;
  55554. /**
  55555. * Sets the glow intensity.
  55556. */
  55557. set intensity(value: number);
  55558. /**
  55559. * Gets the glow intensity.
  55560. */
  55561. get intensity(): number;
  55562. private _options;
  55563. private _intensity;
  55564. private _horizontalBlurPostprocess1;
  55565. private _verticalBlurPostprocess1;
  55566. private _horizontalBlurPostprocess2;
  55567. private _verticalBlurPostprocess2;
  55568. private _blurTexture1;
  55569. private _blurTexture2;
  55570. private _postProcesses1;
  55571. private _postProcesses2;
  55572. private _includedOnlyMeshes;
  55573. private _excludedMeshes;
  55574. private _meshesUsingTheirOwnMaterials;
  55575. /**
  55576. * Callback used to let the user override the color selection on a per mesh basis
  55577. */
  55578. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  55579. /**
  55580. * Callback used to let the user override the texture selection on a per mesh basis
  55581. */
  55582. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  55583. /**
  55584. * Instantiates a new glow Layer and references it to the scene.
  55585. * @param name The name of the layer
  55586. * @param scene The scene to use the layer in
  55587. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  55588. */
  55589. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  55590. /**
  55591. * Get the effect name of the layer.
  55592. * @return The effect name
  55593. */
  55594. getEffectName(): string;
  55595. /**
  55596. * Create the merge effect. This is the shader use to blit the information back
  55597. * to the main canvas at the end of the scene rendering.
  55598. */
  55599. protected _createMergeEffect(): Effect;
  55600. /**
  55601. * Creates the render target textures and post processes used in the glow layer.
  55602. */
  55603. protected _createTextureAndPostProcesses(): void;
  55604. /**
  55605. * Checks for the readiness of the element composing the layer.
  55606. * @param subMesh the mesh to check for
  55607. * @param useInstances specify wether or not to use instances to render the mesh
  55608. * @param emissiveTexture the associated emissive texture used to generate the glow
  55609. * @return true if ready otherwise, false
  55610. */
  55611. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55612. /**
  55613. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55614. */
  55615. needStencil(): boolean;
  55616. /**
  55617. * Returns true if the mesh can be rendered, otherwise false.
  55618. * @param mesh The mesh to render
  55619. * @param material The material used on the mesh
  55620. * @returns true if it can be rendered otherwise false
  55621. */
  55622. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55623. /**
  55624. * Implementation specific of rendering the generating effect on the main canvas.
  55625. * @param effect The effect used to render through
  55626. */
  55627. protected _internalRender(effect: Effect): void;
  55628. /**
  55629. * Sets the required values for both the emissive texture and and the main color.
  55630. */
  55631. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55632. /**
  55633. * Returns true if the mesh should render, otherwise false.
  55634. * @param mesh The mesh to render
  55635. * @returns true if it should render otherwise false
  55636. */
  55637. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55638. /**
  55639. * Adds specific effects defines.
  55640. * @param defines The defines to add specifics to.
  55641. */
  55642. protected _addCustomEffectDefines(defines: string[]): void;
  55643. /**
  55644. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  55645. * @param mesh The mesh to exclude from the glow layer
  55646. */
  55647. addExcludedMesh(mesh: Mesh): void;
  55648. /**
  55649. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  55650. * @param mesh The mesh to remove
  55651. */
  55652. removeExcludedMesh(mesh: Mesh): void;
  55653. /**
  55654. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  55655. * @param mesh The mesh to include in the glow layer
  55656. */
  55657. addIncludedOnlyMesh(mesh: Mesh): void;
  55658. /**
  55659. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  55660. * @param mesh The mesh to remove
  55661. */
  55662. removeIncludedOnlyMesh(mesh: Mesh): void;
  55663. /**
  55664. * Determine if a given mesh will be used in the glow layer
  55665. * @param mesh The mesh to test
  55666. * @returns true if the mesh will be highlighted by the current glow layer
  55667. */
  55668. hasMesh(mesh: AbstractMesh): boolean;
  55669. /**
  55670. * Defines whether the current material of the mesh should be use to render the effect.
  55671. * @param mesh defines the current mesh to render
  55672. */
  55673. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55674. /**
  55675. * Add a mesh to be rendered through its own material and not with emissive only.
  55676. * @param mesh The mesh for which we need to use its material
  55677. */
  55678. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  55679. /**
  55680. * Remove a mesh from being rendered through its own material and not with emissive only.
  55681. * @param mesh The mesh for which we need to not use its material
  55682. */
  55683. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  55684. /**
  55685. * Free any resources and references associated to a mesh.
  55686. * Internal use
  55687. * @param mesh The mesh to free.
  55688. * @hidden
  55689. */
  55690. _disposeMesh(mesh: Mesh): void;
  55691. /**
  55692. * Gets the class name of the effect layer
  55693. * @returns the string with the class name of the effect layer
  55694. */
  55695. getClassName(): string;
  55696. /**
  55697. * Serializes this glow layer
  55698. * @returns a serialized glow layer object
  55699. */
  55700. serialize(): any;
  55701. /**
  55702. * Creates a Glow Layer from parsed glow layer data
  55703. * @param parsedGlowLayer defines glow layer data
  55704. * @param scene defines the current scene
  55705. * @param rootUrl defines the root URL containing the glow layer information
  55706. * @returns a parsed Glow Layer
  55707. */
  55708. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  55709. }
  55710. }
  55711. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  55712. /** @hidden */
  55713. export var glowBlurPostProcessPixelShader: {
  55714. name: string;
  55715. shader: string;
  55716. };
  55717. }
  55718. declare module "babylonjs/Layers/highlightLayer" {
  55719. import { Observable } from "babylonjs/Misc/observable";
  55720. import { Nullable } from "babylonjs/types";
  55721. import { Camera } from "babylonjs/Cameras/camera";
  55722. import { Scene } from "babylonjs/scene";
  55723. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55724. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55725. import { Mesh } from "babylonjs/Meshes/mesh";
  55726. import { Effect } from "babylonjs/Materials/effect";
  55727. import { Material } from "babylonjs/Materials/material";
  55728. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55729. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  55730. import "babylonjs/Shaders/glowMapMerge.fragment";
  55731. import "babylonjs/Shaders/glowMapMerge.vertex";
  55732. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  55733. module "babylonjs/abstractScene" {
  55734. interface AbstractScene {
  55735. /**
  55736. * Return a the first highlight layer of the scene with a given name.
  55737. * @param name The name of the highlight layer to look for.
  55738. * @return The highlight layer if found otherwise null.
  55739. */
  55740. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  55741. }
  55742. }
  55743. /**
  55744. * Highlight layer options. This helps customizing the behaviour
  55745. * of the highlight layer.
  55746. */
  55747. export interface IHighlightLayerOptions {
  55748. /**
  55749. * Multiplication factor apply to the canvas size to compute the render target size
  55750. * used to generated the glowing objects (the smaller the faster).
  55751. */
  55752. mainTextureRatio: number;
  55753. /**
  55754. * Enforces a fixed size texture to ensure resize independant blur.
  55755. */
  55756. mainTextureFixedSize?: number;
  55757. /**
  55758. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  55759. * of the picture to blur (the smaller the faster).
  55760. */
  55761. blurTextureSizeRatio: number;
  55762. /**
  55763. * How big in texel of the blur texture is the vertical blur.
  55764. */
  55765. blurVerticalSize: number;
  55766. /**
  55767. * How big in texel of the blur texture is the horizontal blur.
  55768. */
  55769. blurHorizontalSize: number;
  55770. /**
  55771. * Alpha blending mode used to apply the blur. Default is combine.
  55772. */
  55773. alphaBlendingMode: number;
  55774. /**
  55775. * The camera attached to the layer.
  55776. */
  55777. camera: Nullable<Camera>;
  55778. /**
  55779. * Should we display highlight as a solid stroke?
  55780. */
  55781. isStroke?: boolean;
  55782. /**
  55783. * The rendering group to draw the layer in.
  55784. */
  55785. renderingGroupId: number;
  55786. }
  55787. /**
  55788. * The highlight layer Helps adding a glow effect around a mesh.
  55789. *
  55790. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  55791. * glowy meshes to your scene.
  55792. *
  55793. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  55794. */
  55795. export class HighlightLayer extends EffectLayer {
  55796. name: string;
  55797. /**
  55798. * Effect Name of the highlight layer.
  55799. */
  55800. static readonly EffectName: string;
  55801. /**
  55802. * The neutral color used during the preparation of the glow effect.
  55803. * This is black by default as the blend operation is a blend operation.
  55804. */
  55805. static NeutralColor: Color4;
  55806. /**
  55807. * Stencil value used for glowing meshes.
  55808. */
  55809. static GlowingMeshStencilReference: number;
  55810. /**
  55811. * Stencil value used for the other meshes in the scene.
  55812. */
  55813. static NormalMeshStencilReference: number;
  55814. /**
  55815. * Specifies whether or not the inner glow is ACTIVE in the layer.
  55816. */
  55817. innerGlow: boolean;
  55818. /**
  55819. * Specifies whether or not the outer glow is ACTIVE in the layer.
  55820. */
  55821. outerGlow: boolean;
  55822. /**
  55823. * Specifies the horizontal size of the blur.
  55824. */
  55825. set blurHorizontalSize(value: number);
  55826. /**
  55827. * Specifies the vertical size of the blur.
  55828. */
  55829. set blurVerticalSize(value: number);
  55830. /**
  55831. * Gets the horizontal size of the blur.
  55832. */
  55833. get blurHorizontalSize(): number;
  55834. /**
  55835. * Gets the vertical size of the blur.
  55836. */
  55837. get blurVerticalSize(): number;
  55838. /**
  55839. * An event triggered when the highlight layer is being blurred.
  55840. */
  55841. onBeforeBlurObservable: Observable<HighlightLayer>;
  55842. /**
  55843. * An event triggered when the highlight layer has been blurred.
  55844. */
  55845. onAfterBlurObservable: Observable<HighlightLayer>;
  55846. private _instanceGlowingMeshStencilReference;
  55847. private _options;
  55848. private _downSamplePostprocess;
  55849. private _horizontalBlurPostprocess;
  55850. private _verticalBlurPostprocess;
  55851. private _blurTexture;
  55852. private _meshes;
  55853. private _excludedMeshes;
  55854. /**
  55855. * Instantiates a new highlight Layer and references it to the scene..
  55856. * @param name The name of the layer
  55857. * @param scene The scene to use the layer in
  55858. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  55859. */
  55860. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  55861. /**
  55862. * Get the effect name of the layer.
  55863. * @return The effect name
  55864. */
  55865. getEffectName(): string;
  55866. /**
  55867. * Create the merge effect. This is the shader use to blit the information back
  55868. * to the main canvas at the end of the scene rendering.
  55869. */
  55870. protected _createMergeEffect(): Effect;
  55871. /**
  55872. * Creates the render target textures and post processes used in the highlight layer.
  55873. */
  55874. protected _createTextureAndPostProcesses(): void;
  55875. /**
  55876. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  55877. */
  55878. needStencil(): boolean;
  55879. /**
  55880. * Checks for the readiness of the element composing the layer.
  55881. * @param subMesh the mesh to check for
  55882. * @param useInstances specify wether or not to use instances to render the mesh
  55883. * @param emissiveTexture the associated emissive texture used to generate the glow
  55884. * @return true if ready otherwise, false
  55885. */
  55886. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55887. /**
  55888. * Implementation specific of rendering the generating effect on the main canvas.
  55889. * @param effect The effect used to render through
  55890. */
  55891. protected _internalRender(effect: Effect): void;
  55892. /**
  55893. * Returns true if the layer contains information to display, otherwise false.
  55894. */
  55895. shouldRender(): boolean;
  55896. /**
  55897. * Returns true if the mesh should render, otherwise false.
  55898. * @param mesh The mesh to render
  55899. * @returns true if it should render otherwise false
  55900. */
  55901. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55902. /**
  55903. * Sets the required values for both the emissive texture and and the main color.
  55904. */
  55905. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55906. /**
  55907. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  55908. * @param mesh The mesh to exclude from the highlight layer
  55909. */
  55910. addExcludedMesh(mesh: Mesh): void;
  55911. /**
  55912. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  55913. * @param mesh The mesh to highlight
  55914. */
  55915. removeExcludedMesh(mesh: Mesh): void;
  55916. /**
  55917. * Determine if a given mesh will be highlighted by the current HighlightLayer
  55918. * @param mesh mesh to test
  55919. * @returns true if the mesh will be highlighted by the current HighlightLayer
  55920. */
  55921. hasMesh(mesh: AbstractMesh): boolean;
  55922. /**
  55923. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  55924. * @param mesh The mesh to highlight
  55925. * @param color The color of the highlight
  55926. * @param glowEmissiveOnly Extract the glow from the emissive texture
  55927. */
  55928. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  55929. /**
  55930. * Remove a mesh from the highlight layer in order to make it stop glowing.
  55931. * @param mesh The mesh to highlight
  55932. */
  55933. removeMesh(mesh: Mesh): void;
  55934. /**
  55935. * Remove all the meshes currently referenced in the highlight layer
  55936. */
  55937. removeAllMeshes(): void;
  55938. /**
  55939. * Force the stencil to the normal expected value for none glowing parts
  55940. */
  55941. private _defaultStencilReference;
  55942. /**
  55943. * Free any resources and references associated to a mesh.
  55944. * Internal use
  55945. * @param mesh The mesh to free.
  55946. * @hidden
  55947. */
  55948. _disposeMesh(mesh: Mesh): void;
  55949. /**
  55950. * Dispose the highlight layer and free resources.
  55951. */
  55952. dispose(): void;
  55953. /**
  55954. * Gets the class name of the effect layer
  55955. * @returns the string with the class name of the effect layer
  55956. */
  55957. getClassName(): string;
  55958. /**
  55959. * Serializes this Highlight layer
  55960. * @returns a serialized Highlight layer object
  55961. */
  55962. serialize(): any;
  55963. /**
  55964. * Creates a Highlight layer from parsed Highlight layer data
  55965. * @param parsedHightlightLayer defines the Highlight layer data
  55966. * @param scene defines the current scene
  55967. * @param rootUrl defines the root URL containing the Highlight layer information
  55968. * @returns a parsed Highlight layer
  55969. */
  55970. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  55971. }
  55972. }
  55973. declare module "babylonjs/Layers/layerSceneComponent" {
  55974. import { Scene } from "babylonjs/scene";
  55975. import { ISceneComponent } from "babylonjs/sceneComponent";
  55976. import { Layer } from "babylonjs/Layers/layer";
  55977. import { AbstractScene } from "babylonjs/abstractScene";
  55978. module "babylonjs/abstractScene" {
  55979. interface AbstractScene {
  55980. /**
  55981. * The list of layers (background and foreground) of the scene
  55982. */
  55983. layers: Array<Layer>;
  55984. }
  55985. }
  55986. /**
  55987. * Defines the layer scene component responsible to manage any layers
  55988. * in a given scene.
  55989. */
  55990. export class LayerSceneComponent implements ISceneComponent {
  55991. /**
  55992. * The component name helpfull to identify the component in the list of scene components.
  55993. */
  55994. readonly name: string;
  55995. /**
  55996. * The scene the component belongs to.
  55997. */
  55998. scene: Scene;
  55999. private _engine;
  56000. /**
  56001. * Creates a new instance of the component for the given scene
  56002. * @param scene Defines the scene to register the component in
  56003. */
  56004. constructor(scene: Scene);
  56005. /**
  56006. * Registers the component in a given scene
  56007. */
  56008. register(): void;
  56009. /**
  56010. * Rebuilds the elements related to this component in case of
  56011. * context lost for instance.
  56012. */
  56013. rebuild(): void;
  56014. /**
  56015. * Disposes the component and the associated ressources.
  56016. */
  56017. dispose(): void;
  56018. private _draw;
  56019. private _drawCameraPredicate;
  56020. private _drawCameraBackground;
  56021. private _drawCameraForeground;
  56022. private _drawRenderTargetPredicate;
  56023. private _drawRenderTargetBackground;
  56024. private _drawRenderTargetForeground;
  56025. /**
  56026. * Adds all the elements from the container to the scene
  56027. * @param container the container holding the elements
  56028. */
  56029. addFromContainer(container: AbstractScene): void;
  56030. /**
  56031. * Removes all the elements in the container from the scene
  56032. * @param container contains the elements to remove
  56033. * @param dispose if the removed element should be disposed (default: false)
  56034. */
  56035. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56036. }
  56037. }
  56038. declare module "babylonjs/Shaders/layer.fragment" {
  56039. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56040. /** @hidden */
  56041. export var layerPixelShader: {
  56042. name: string;
  56043. shader: string;
  56044. };
  56045. }
  56046. declare module "babylonjs/Shaders/layer.vertex" {
  56047. /** @hidden */
  56048. export var layerVertexShader: {
  56049. name: string;
  56050. shader: string;
  56051. };
  56052. }
  56053. declare module "babylonjs/Layers/layer" {
  56054. import { Observable } from "babylonjs/Misc/observable";
  56055. import { Nullable } from "babylonjs/types";
  56056. import { Scene } from "babylonjs/scene";
  56057. import { Vector2 } from "babylonjs/Maths/math.vector";
  56058. import { Color4 } from "babylonjs/Maths/math.color";
  56059. import { Texture } from "babylonjs/Materials/Textures/texture";
  56060. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56061. import "babylonjs/Shaders/layer.fragment";
  56062. import "babylonjs/Shaders/layer.vertex";
  56063. /**
  56064. * This represents a full screen 2d layer.
  56065. * This can be useful to display a picture in the background of your scene for instance.
  56066. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56067. */
  56068. export class Layer {
  56069. /**
  56070. * Define the name of the layer.
  56071. */
  56072. name: string;
  56073. /**
  56074. * Define the texture the layer should display.
  56075. */
  56076. texture: Nullable<Texture>;
  56077. /**
  56078. * Is the layer in background or foreground.
  56079. */
  56080. isBackground: boolean;
  56081. /**
  56082. * Define the color of the layer (instead of texture).
  56083. */
  56084. color: Color4;
  56085. /**
  56086. * Define the scale of the layer in order to zoom in out of the texture.
  56087. */
  56088. scale: Vector2;
  56089. /**
  56090. * Define an offset for the layer in order to shift the texture.
  56091. */
  56092. offset: Vector2;
  56093. /**
  56094. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  56095. */
  56096. alphaBlendingMode: number;
  56097. /**
  56098. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  56099. * Alpha test will not mix with the background color in case of transparency.
  56100. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  56101. */
  56102. alphaTest: boolean;
  56103. /**
  56104. * Define a mask to restrict the layer to only some of the scene cameras.
  56105. */
  56106. layerMask: number;
  56107. /**
  56108. * Define the list of render target the layer is visible into.
  56109. */
  56110. renderTargetTextures: RenderTargetTexture[];
  56111. /**
  56112. * Define if the layer is only used in renderTarget or if it also
  56113. * renders in the main frame buffer of the canvas.
  56114. */
  56115. renderOnlyInRenderTargetTextures: boolean;
  56116. private _scene;
  56117. private _vertexBuffers;
  56118. private _indexBuffer;
  56119. private _effect;
  56120. private _previousDefines;
  56121. /**
  56122. * An event triggered when the layer is disposed.
  56123. */
  56124. onDisposeObservable: Observable<Layer>;
  56125. private _onDisposeObserver;
  56126. /**
  56127. * Back compatibility with callback before the onDisposeObservable existed.
  56128. * The set callback will be triggered when the layer has been disposed.
  56129. */
  56130. set onDispose(callback: () => void);
  56131. /**
  56132. * An event triggered before rendering the scene
  56133. */
  56134. onBeforeRenderObservable: Observable<Layer>;
  56135. private _onBeforeRenderObserver;
  56136. /**
  56137. * Back compatibility with callback before the onBeforeRenderObservable existed.
  56138. * The set callback will be triggered just before rendering the layer.
  56139. */
  56140. set onBeforeRender(callback: () => void);
  56141. /**
  56142. * An event triggered after rendering the scene
  56143. */
  56144. onAfterRenderObservable: Observable<Layer>;
  56145. private _onAfterRenderObserver;
  56146. /**
  56147. * Back compatibility with callback before the onAfterRenderObservable existed.
  56148. * The set callback will be triggered just after rendering the layer.
  56149. */
  56150. set onAfterRender(callback: () => void);
  56151. /**
  56152. * Instantiates a new layer.
  56153. * This represents a full screen 2d layer.
  56154. * This can be useful to display a picture in the background of your scene for instance.
  56155. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56156. * @param name Define the name of the layer in the scene
  56157. * @param imgUrl Define the url of the texture to display in the layer
  56158. * @param scene Define the scene the layer belongs to
  56159. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  56160. * @param color Defines a color for the layer
  56161. */
  56162. constructor(
  56163. /**
  56164. * Define the name of the layer.
  56165. */
  56166. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  56167. private _createIndexBuffer;
  56168. /** @hidden */
  56169. _rebuild(): void;
  56170. /**
  56171. * Renders the layer in the scene.
  56172. */
  56173. render(): void;
  56174. /**
  56175. * Disposes and releases the associated ressources.
  56176. */
  56177. dispose(): void;
  56178. }
  56179. }
  56180. declare module "babylonjs/Layers/index" {
  56181. export * from "babylonjs/Layers/effectLayer";
  56182. export * from "babylonjs/Layers/effectLayerSceneComponent";
  56183. export * from "babylonjs/Layers/glowLayer";
  56184. export * from "babylonjs/Layers/highlightLayer";
  56185. export * from "babylonjs/Layers/layer";
  56186. export * from "babylonjs/Layers/layerSceneComponent";
  56187. }
  56188. declare module "babylonjs/Shaders/lensFlare.fragment" {
  56189. /** @hidden */
  56190. export var lensFlarePixelShader: {
  56191. name: string;
  56192. shader: string;
  56193. };
  56194. }
  56195. declare module "babylonjs/Shaders/lensFlare.vertex" {
  56196. /** @hidden */
  56197. export var lensFlareVertexShader: {
  56198. name: string;
  56199. shader: string;
  56200. };
  56201. }
  56202. declare module "babylonjs/LensFlares/lensFlareSystem" {
  56203. import { Scene } from "babylonjs/scene";
  56204. import { Vector3 } from "babylonjs/Maths/math.vector";
  56205. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56206. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  56207. import "babylonjs/Shaders/lensFlare.fragment";
  56208. import "babylonjs/Shaders/lensFlare.vertex";
  56209. import { Viewport } from "babylonjs/Maths/math.viewport";
  56210. /**
  56211. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56212. * It is usually composed of several `lensFlare`.
  56213. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56214. */
  56215. export class LensFlareSystem {
  56216. /**
  56217. * Define the name of the lens flare system
  56218. */
  56219. name: string;
  56220. /**
  56221. * List of lens flares used in this system.
  56222. */
  56223. lensFlares: LensFlare[];
  56224. /**
  56225. * Define a limit from the border the lens flare can be visible.
  56226. */
  56227. borderLimit: number;
  56228. /**
  56229. * Define a viewport border we do not want to see the lens flare in.
  56230. */
  56231. viewportBorder: number;
  56232. /**
  56233. * Define a predicate which could limit the list of meshes able to occlude the effect.
  56234. */
  56235. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56236. /**
  56237. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  56238. */
  56239. layerMask: number;
  56240. /**
  56241. * Define the id of the lens flare system in the scene.
  56242. * (equal to name by default)
  56243. */
  56244. id: string;
  56245. private _scene;
  56246. private _emitter;
  56247. private _vertexBuffers;
  56248. private _indexBuffer;
  56249. private _effect;
  56250. private _positionX;
  56251. private _positionY;
  56252. private _isEnabled;
  56253. /** @hidden */
  56254. static _SceneComponentInitialization: (scene: Scene) => void;
  56255. /**
  56256. * Instantiates a lens flare system.
  56257. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56258. * It is usually composed of several `lensFlare`.
  56259. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56260. * @param name Define the name of the lens flare system in the scene
  56261. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  56262. * @param scene Define the scene the lens flare system belongs to
  56263. */
  56264. constructor(
  56265. /**
  56266. * Define the name of the lens flare system
  56267. */
  56268. name: string, emitter: any, scene: Scene);
  56269. /**
  56270. * Define if the lens flare system is enabled.
  56271. */
  56272. get isEnabled(): boolean;
  56273. set isEnabled(value: boolean);
  56274. /**
  56275. * Get the scene the effects belongs to.
  56276. * @returns the scene holding the lens flare system
  56277. */
  56278. getScene(): Scene;
  56279. /**
  56280. * Get the emitter of the lens flare system.
  56281. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56282. * @returns the emitter of the lens flare system
  56283. */
  56284. getEmitter(): any;
  56285. /**
  56286. * Set the emitter of the lens flare system.
  56287. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56288. * @param newEmitter Define the new emitter of the system
  56289. */
  56290. setEmitter(newEmitter: any): void;
  56291. /**
  56292. * Get the lens flare system emitter position.
  56293. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  56294. * @returns the position
  56295. */
  56296. getEmitterPosition(): Vector3;
  56297. /**
  56298. * @hidden
  56299. */
  56300. computeEffectivePosition(globalViewport: Viewport): boolean;
  56301. /** @hidden */
  56302. _isVisible(): boolean;
  56303. /**
  56304. * @hidden
  56305. */
  56306. render(): boolean;
  56307. /**
  56308. * Dispose and release the lens flare with its associated resources.
  56309. */
  56310. dispose(): void;
  56311. /**
  56312. * Parse a lens flare system from a JSON repressentation
  56313. * @param parsedLensFlareSystem Define the JSON to parse
  56314. * @param scene Define the scene the parsed system should be instantiated in
  56315. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  56316. * @returns the parsed system
  56317. */
  56318. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  56319. /**
  56320. * Serialize the current Lens Flare System into a JSON representation.
  56321. * @returns the serialized JSON
  56322. */
  56323. serialize(): any;
  56324. }
  56325. }
  56326. declare module "babylonjs/LensFlares/lensFlare" {
  56327. import { Nullable } from "babylonjs/types";
  56328. import { Color3 } from "babylonjs/Maths/math.color";
  56329. import { Texture } from "babylonjs/Materials/Textures/texture";
  56330. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56331. /**
  56332. * This represents one of the lens effect in a `lensFlareSystem`.
  56333. * It controls one of the indiviual texture used in the effect.
  56334. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56335. */
  56336. export class LensFlare {
  56337. /**
  56338. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56339. */
  56340. size: number;
  56341. /**
  56342. * 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.
  56343. */
  56344. position: number;
  56345. /**
  56346. * Define the lens color.
  56347. */
  56348. color: Color3;
  56349. /**
  56350. * Define the lens texture.
  56351. */
  56352. texture: Nullable<Texture>;
  56353. /**
  56354. * Define the alpha mode to render this particular lens.
  56355. */
  56356. alphaMode: number;
  56357. private _system;
  56358. /**
  56359. * Creates a new Lens Flare.
  56360. * This represents one of the lens effect in a `lensFlareSystem`.
  56361. * It controls one of the indiviual texture used in the effect.
  56362. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56363. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  56364. * @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.
  56365. * @param color Define the lens color
  56366. * @param imgUrl Define the lens texture url
  56367. * @param system Define the `lensFlareSystem` this flare is part of
  56368. * @returns The newly created Lens Flare
  56369. */
  56370. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  56371. /**
  56372. * Instantiates a new Lens Flare.
  56373. * This represents one of the lens effect in a `lensFlareSystem`.
  56374. * It controls one of the indiviual texture used in the effect.
  56375. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56376. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  56377. * @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.
  56378. * @param color Define the lens color
  56379. * @param imgUrl Define the lens texture url
  56380. * @param system Define the `lensFlareSystem` this flare is part of
  56381. */
  56382. constructor(
  56383. /**
  56384. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56385. */
  56386. size: number,
  56387. /**
  56388. * 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.
  56389. */
  56390. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  56391. /**
  56392. * Dispose and release the lens flare with its associated resources.
  56393. */
  56394. dispose(): void;
  56395. }
  56396. }
  56397. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  56398. import { Nullable } from "babylonjs/types";
  56399. import { Scene } from "babylonjs/scene";
  56400. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56401. import { AbstractScene } from "babylonjs/abstractScene";
  56402. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56403. module "babylonjs/abstractScene" {
  56404. interface AbstractScene {
  56405. /**
  56406. * The list of lens flare system added to the scene
  56407. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56408. */
  56409. lensFlareSystems: Array<LensFlareSystem>;
  56410. /**
  56411. * Removes the given lens flare system from this scene.
  56412. * @param toRemove The lens flare system to remove
  56413. * @returns The index of the removed lens flare system
  56414. */
  56415. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  56416. /**
  56417. * Adds the given lens flare system to this scene
  56418. * @param newLensFlareSystem The lens flare system to add
  56419. */
  56420. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  56421. /**
  56422. * Gets a lens flare system using its name
  56423. * @param name defines the name to look for
  56424. * @returns the lens flare system or null if not found
  56425. */
  56426. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  56427. /**
  56428. * Gets a lens flare system using its id
  56429. * @param id defines the id to look for
  56430. * @returns the lens flare system or null if not found
  56431. */
  56432. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  56433. }
  56434. }
  56435. /**
  56436. * Defines the lens flare scene component responsible to manage any lens flares
  56437. * in a given scene.
  56438. */
  56439. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  56440. /**
  56441. * The component name helpfull to identify the component in the list of scene components.
  56442. */
  56443. readonly name: string;
  56444. /**
  56445. * The scene the component belongs to.
  56446. */
  56447. scene: Scene;
  56448. /**
  56449. * Creates a new instance of the component for the given scene
  56450. * @param scene Defines the scene to register the component in
  56451. */
  56452. constructor(scene: Scene);
  56453. /**
  56454. * Registers the component in a given scene
  56455. */
  56456. register(): void;
  56457. /**
  56458. * Rebuilds the elements related to this component in case of
  56459. * context lost for instance.
  56460. */
  56461. rebuild(): void;
  56462. /**
  56463. * Adds all the elements from the container to the scene
  56464. * @param container the container holding the elements
  56465. */
  56466. addFromContainer(container: AbstractScene): void;
  56467. /**
  56468. * Removes all the elements in the container from the scene
  56469. * @param container contains the elements to remove
  56470. * @param dispose if the removed element should be disposed (default: false)
  56471. */
  56472. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56473. /**
  56474. * Serializes the component data to the specified json object
  56475. * @param serializationObject The object to serialize to
  56476. */
  56477. serialize(serializationObject: any): void;
  56478. /**
  56479. * Disposes the component and the associated ressources.
  56480. */
  56481. dispose(): void;
  56482. private _draw;
  56483. }
  56484. }
  56485. declare module "babylonjs/LensFlares/index" {
  56486. export * from "babylonjs/LensFlares/lensFlare";
  56487. export * from "babylonjs/LensFlares/lensFlareSystem";
  56488. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  56489. }
  56490. declare module "babylonjs/Shaders/depth.fragment" {
  56491. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  56492. /** @hidden */
  56493. export var depthPixelShader: {
  56494. name: string;
  56495. shader: string;
  56496. };
  56497. }
  56498. declare module "babylonjs/Shaders/depth.vertex" {
  56499. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56500. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56501. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56502. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56503. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  56504. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56505. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56506. /** @hidden */
  56507. export var depthVertexShader: {
  56508. name: string;
  56509. shader: string;
  56510. };
  56511. }
  56512. declare module "babylonjs/Rendering/depthRenderer" {
  56513. import { Nullable } from "babylonjs/types";
  56514. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56515. import { Scene } from "babylonjs/scene";
  56516. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56517. import { Camera } from "babylonjs/Cameras/camera";
  56518. import "babylonjs/Shaders/depth.fragment";
  56519. import "babylonjs/Shaders/depth.vertex";
  56520. /**
  56521. * This represents a depth renderer in Babylon.
  56522. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56523. */
  56524. export class DepthRenderer {
  56525. private _scene;
  56526. private _depthMap;
  56527. private _effect;
  56528. private readonly _storeNonLinearDepth;
  56529. private readonly _clearColor;
  56530. /** Get if the depth renderer is using packed depth or not */
  56531. readonly isPacked: boolean;
  56532. private _cachedDefines;
  56533. private _camera;
  56534. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  56535. enabled: boolean;
  56536. /**
  56537. * Specifiess that the depth renderer will only be used within
  56538. * the camera it is created for.
  56539. * This can help forcing its rendering during the camera processing.
  56540. */
  56541. useOnlyInActiveCamera: boolean;
  56542. /** @hidden */
  56543. static _SceneComponentInitialization: (scene: Scene) => void;
  56544. /**
  56545. * Instantiates a depth renderer
  56546. * @param scene The scene the renderer belongs to
  56547. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56548. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56549. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  56550. */
  56551. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  56552. /**
  56553. * Creates the depth rendering effect and checks if the effect is ready.
  56554. * @param subMesh The submesh to be used to render the depth map of
  56555. * @param useInstances If multiple world instances should be used
  56556. * @returns if the depth renderer is ready to render the depth map
  56557. */
  56558. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56559. /**
  56560. * Gets the texture which the depth map will be written to.
  56561. * @returns The depth map texture
  56562. */
  56563. getDepthMap(): RenderTargetTexture;
  56564. /**
  56565. * Disposes of the depth renderer.
  56566. */
  56567. dispose(): void;
  56568. }
  56569. }
  56570. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  56571. /** @hidden */
  56572. export var minmaxReduxPixelShader: {
  56573. name: string;
  56574. shader: string;
  56575. };
  56576. }
  56577. declare module "babylonjs/Misc/minMaxReducer" {
  56578. import { Nullable } from "babylonjs/types";
  56579. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56580. import { Camera } from "babylonjs/Cameras/camera";
  56581. import { Observer } from "babylonjs/Misc/observable";
  56582. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56583. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  56584. import { Observable } from "babylonjs/Misc/observable";
  56585. import "babylonjs/Shaders/minmaxRedux.fragment";
  56586. /**
  56587. * This class computes a min/max reduction from a texture: it means it computes the minimum
  56588. * and maximum values from all values of the texture.
  56589. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  56590. * The source values are read from the red channel of the texture.
  56591. */
  56592. export class MinMaxReducer {
  56593. /**
  56594. * Observable triggered when the computation has been performed
  56595. */
  56596. onAfterReductionPerformed: Observable<{
  56597. min: number;
  56598. max: number;
  56599. }>;
  56600. protected _camera: Camera;
  56601. protected _sourceTexture: Nullable<RenderTargetTexture>;
  56602. protected _reductionSteps: Nullable<Array<PostProcess>>;
  56603. protected _postProcessManager: PostProcessManager;
  56604. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  56605. protected _forceFullscreenViewport: boolean;
  56606. /**
  56607. * Creates a min/max reducer
  56608. * @param camera The camera to use for the post processes
  56609. */
  56610. constructor(camera: Camera);
  56611. /**
  56612. * Gets the texture used to read the values from.
  56613. */
  56614. get sourceTexture(): Nullable<RenderTargetTexture>;
  56615. /**
  56616. * Sets the source texture to read the values from.
  56617. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  56618. * because in such textures '1' value must not be taken into account to compute the maximum
  56619. * as this value is used to clear the texture.
  56620. * Note that the computation is not activated by calling this function, you must call activate() for that!
  56621. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  56622. * @param depthRedux Indicates if the texture is a depth texture or not
  56623. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  56624. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56625. */
  56626. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56627. /**
  56628. * Defines the refresh rate of the computation.
  56629. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56630. */
  56631. get refreshRate(): number;
  56632. set refreshRate(value: number);
  56633. protected _activated: boolean;
  56634. /**
  56635. * Gets the activation status of the reducer
  56636. */
  56637. get activated(): boolean;
  56638. /**
  56639. * Activates the reduction computation.
  56640. * When activated, the observers registered in onAfterReductionPerformed are
  56641. * called after the compuation is performed
  56642. */
  56643. activate(): void;
  56644. /**
  56645. * Deactivates the reduction computation.
  56646. */
  56647. deactivate(): void;
  56648. /**
  56649. * Disposes the min/max reducer
  56650. * @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.
  56651. */
  56652. dispose(disposeAll?: boolean): void;
  56653. }
  56654. }
  56655. declare module "babylonjs/Misc/depthReducer" {
  56656. import { Nullable } from "babylonjs/types";
  56657. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56658. import { Camera } from "babylonjs/Cameras/camera";
  56659. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56660. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  56661. /**
  56662. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  56663. */
  56664. export class DepthReducer extends MinMaxReducer {
  56665. private _depthRenderer;
  56666. private _depthRendererId;
  56667. /**
  56668. * Gets the depth renderer used for the computation.
  56669. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  56670. */
  56671. get depthRenderer(): Nullable<DepthRenderer>;
  56672. /**
  56673. * Creates a depth reducer
  56674. * @param camera The camera used to render the depth texture
  56675. */
  56676. constructor(camera: Camera);
  56677. /**
  56678. * Sets the depth renderer to use to generate the depth map
  56679. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  56680. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  56681. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56682. */
  56683. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  56684. /** @hidden */
  56685. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56686. /**
  56687. * Activates the reduction computation.
  56688. * When activated, the observers registered in onAfterReductionPerformed are
  56689. * called after the compuation is performed
  56690. */
  56691. activate(): void;
  56692. /**
  56693. * Deactivates the reduction computation.
  56694. */
  56695. deactivate(): void;
  56696. /**
  56697. * Disposes the depth reducer
  56698. * @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.
  56699. */
  56700. dispose(disposeAll?: boolean): void;
  56701. }
  56702. }
  56703. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  56704. import { Nullable } from "babylonjs/types";
  56705. import { Scene } from "babylonjs/scene";
  56706. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56707. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56708. import { Effect } from "babylonjs/Materials/effect";
  56709. import "babylonjs/Shaders/shadowMap.fragment";
  56710. import "babylonjs/Shaders/shadowMap.vertex";
  56711. import "babylonjs/Shaders/depthBoxBlur.fragment";
  56712. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  56713. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56714. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  56715. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56716. /**
  56717. * A CSM implementation allowing casting shadows on large scenes.
  56718. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56719. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  56720. */
  56721. export class CascadedShadowGenerator extends ShadowGenerator {
  56722. private static readonly frustumCornersNDCSpace;
  56723. /**
  56724. * Name of the CSM class
  56725. */
  56726. static CLASSNAME: string;
  56727. /**
  56728. * Defines the default number of cascades used by the CSM.
  56729. */
  56730. static readonly DEFAULT_CASCADES_COUNT: number;
  56731. /**
  56732. * Defines the minimum number of cascades used by the CSM.
  56733. */
  56734. static readonly MIN_CASCADES_COUNT: number;
  56735. /**
  56736. * Defines the maximum number of cascades used by the CSM.
  56737. */
  56738. static readonly MAX_CASCADES_COUNT: number;
  56739. protected _validateFilter(filter: number): number;
  56740. /**
  56741. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  56742. */
  56743. penumbraDarkness: number;
  56744. private _numCascades;
  56745. /**
  56746. * Gets or set the number of cascades used by the CSM.
  56747. */
  56748. get numCascades(): number;
  56749. set numCascades(value: number);
  56750. /**
  56751. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  56752. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  56753. */
  56754. stabilizeCascades: boolean;
  56755. private _freezeShadowCastersBoundingInfo;
  56756. private _freezeShadowCastersBoundingInfoObservable;
  56757. /**
  56758. * Enables or disables the shadow casters bounding info computation.
  56759. * If your shadow casters don't move, you can disable this feature.
  56760. * If it is enabled, the bounding box computation is done every frame.
  56761. */
  56762. get freezeShadowCastersBoundingInfo(): boolean;
  56763. set freezeShadowCastersBoundingInfo(freeze: boolean);
  56764. private _scbiMin;
  56765. private _scbiMax;
  56766. protected _computeShadowCastersBoundingInfo(): void;
  56767. protected _shadowCastersBoundingInfo: BoundingInfo;
  56768. /**
  56769. * Gets or sets the shadow casters bounding info.
  56770. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  56771. * so that the system won't overwrite the bounds you provide
  56772. */
  56773. get shadowCastersBoundingInfo(): BoundingInfo;
  56774. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  56775. protected _breaksAreDirty: boolean;
  56776. protected _minDistance: number;
  56777. protected _maxDistance: number;
  56778. /**
  56779. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  56780. *
  56781. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  56782. * If you don't know these values, simply leave them to their defaults and don't call this function.
  56783. * @param min minimal distance for the breaks (default to 0.)
  56784. * @param max maximal distance for the breaks (default to 1.)
  56785. */
  56786. setMinMaxDistance(min: number, max: number): void;
  56787. /** Gets the minimal distance used in the cascade break computation */
  56788. get minDistance(): number;
  56789. /** Gets the maximal distance used in the cascade break computation */
  56790. get maxDistance(): number;
  56791. /**
  56792. * Gets the class name of that object
  56793. * @returns "CascadedShadowGenerator"
  56794. */
  56795. getClassName(): string;
  56796. private _cascadeMinExtents;
  56797. private _cascadeMaxExtents;
  56798. /**
  56799. * Gets a cascade minimum extents
  56800. * @param cascadeIndex index of the cascade
  56801. * @returns the minimum cascade extents
  56802. */
  56803. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  56804. /**
  56805. * Gets a cascade maximum extents
  56806. * @param cascadeIndex index of the cascade
  56807. * @returns the maximum cascade extents
  56808. */
  56809. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  56810. private _cascades;
  56811. private _currentLayer;
  56812. private _viewSpaceFrustumsZ;
  56813. private _viewMatrices;
  56814. private _projectionMatrices;
  56815. private _transformMatrices;
  56816. private _transformMatricesAsArray;
  56817. private _frustumLengths;
  56818. private _lightSizeUVCorrection;
  56819. private _depthCorrection;
  56820. private _frustumCornersWorldSpace;
  56821. private _frustumCenter;
  56822. private _shadowCameraPos;
  56823. private _shadowMaxZ;
  56824. /**
  56825. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  56826. * It defaults to camera.maxZ
  56827. */
  56828. get shadowMaxZ(): number;
  56829. /**
  56830. * Sets the shadow max z distance.
  56831. */
  56832. set shadowMaxZ(value: number);
  56833. protected _debug: boolean;
  56834. /**
  56835. * Gets or sets the debug flag.
  56836. * When enabled, the cascades are materialized by different colors on the screen.
  56837. */
  56838. get debug(): boolean;
  56839. set debug(dbg: boolean);
  56840. private _depthClamp;
  56841. /**
  56842. * Gets or sets the depth clamping value.
  56843. *
  56844. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  56845. * to account for the shadow casters far away.
  56846. *
  56847. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  56848. */
  56849. get depthClamp(): boolean;
  56850. set depthClamp(value: boolean);
  56851. private _cascadeBlendPercentage;
  56852. /**
  56853. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  56854. * It defaults to 0.1 (10% blending).
  56855. */
  56856. get cascadeBlendPercentage(): number;
  56857. set cascadeBlendPercentage(value: number);
  56858. private _lambda;
  56859. /**
  56860. * Gets or set the lambda parameter.
  56861. * This parameter is used to split the camera frustum and create the cascades.
  56862. * 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.
  56863. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  56864. */
  56865. get lambda(): number;
  56866. set lambda(value: number);
  56867. /**
  56868. * Gets the view matrix corresponding to a given cascade
  56869. * @param cascadeNum cascade to retrieve the view matrix from
  56870. * @returns the cascade view matrix
  56871. */
  56872. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  56873. /**
  56874. * Gets the projection matrix corresponding to a given cascade
  56875. * @param cascadeNum cascade to retrieve the projection matrix from
  56876. * @returns the cascade projection matrix
  56877. */
  56878. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  56879. /**
  56880. * Gets the transformation matrix corresponding to a given cascade
  56881. * @param cascadeNum cascade to retrieve the transformation matrix from
  56882. * @returns the cascade transformation matrix
  56883. */
  56884. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  56885. private _depthRenderer;
  56886. /**
  56887. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  56888. *
  56889. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  56890. *
  56891. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  56892. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  56893. * @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
  56894. */
  56895. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  56896. private _depthReducer;
  56897. private _autoCalcDepthBounds;
  56898. /**
  56899. * Gets or sets the autoCalcDepthBounds property.
  56900. *
  56901. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  56902. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  56903. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  56904. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  56905. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  56906. */
  56907. get autoCalcDepthBounds(): boolean;
  56908. set autoCalcDepthBounds(value: boolean);
  56909. /**
  56910. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  56911. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56912. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  56913. * for setting the refresh rate on the renderer yourself!
  56914. */
  56915. get autoCalcDepthBoundsRefreshRate(): number;
  56916. set autoCalcDepthBoundsRefreshRate(value: number);
  56917. /**
  56918. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  56919. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  56920. * you change the camera near/far planes!
  56921. */
  56922. splitFrustum(): void;
  56923. private _splitFrustum;
  56924. private _computeMatrices;
  56925. private _computeFrustumInWorldSpace;
  56926. private _computeCascadeFrustum;
  56927. /** @hidden */
  56928. static _SceneComponentInitialization: (scene: Scene) => void;
  56929. /**
  56930. * Creates a Cascaded Shadow Generator object.
  56931. * A ShadowGenerator is the required tool to use the shadows.
  56932. * Each directional light casting shadows needs to use its own ShadowGenerator.
  56933. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56934. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  56935. * @param light The directional light object generating the shadows.
  56936. * @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.
  56937. */
  56938. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  56939. protected _initializeGenerator(): void;
  56940. protected _createTargetRenderTexture(): void;
  56941. protected _initializeShadowMap(): void;
  56942. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  56943. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  56944. /**
  56945. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  56946. * @param defines Defines of the material we want to update
  56947. * @param lightIndex Index of the light in the enabled light list of the material
  56948. */
  56949. prepareDefines(defines: any, lightIndex: number): void;
  56950. /**
  56951. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  56952. * defined in the generator but impacting the effect).
  56953. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  56954. * @param effect The effect we are binfing the information for
  56955. */
  56956. bindShadowLight(lightIndex: string, effect: Effect): void;
  56957. /**
  56958. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  56959. * (eq to view projection * shadow projection matrices)
  56960. * @returns The transform matrix used to create the shadow map
  56961. */
  56962. getTransformMatrix(): Matrix;
  56963. /**
  56964. * Disposes the ShadowGenerator.
  56965. * Returns nothing.
  56966. */
  56967. dispose(): void;
  56968. /**
  56969. * Serializes the shadow generator setup to a json object.
  56970. * @returns The serialized JSON object
  56971. */
  56972. serialize(): any;
  56973. /**
  56974. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  56975. * @param parsedShadowGenerator The JSON object to parse
  56976. * @param scene The scene to create the shadow map for
  56977. * @returns The parsed shadow generator
  56978. */
  56979. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  56980. }
  56981. }
  56982. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  56983. import { Scene } from "babylonjs/scene";
  56984. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56985. import { AbstractScene } from "babylonjs/abstractScene";
  56986. /**
  56987. * Defines the shadow generator component responsible to manage any shadow generators
  56988. * in a given scene.
  56989. */
  56990. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  56991. /**
  56992. * The component name helpfull to identify the component in the list of scene components.
  56993. */
  56994. readonly name: string;
  56995. /**
  56996. * The scene the component belongs to.
  56997. */
  56998. scene: Scene;
  56999. /**
  57000. * Creates a new instance of the component for the given scene
  57001. * @param scene Defines the scene to register the component in
  57002. */
  57003. constructor(scene: Scene);
  57004. /**
  57005. * Registers the component in a given scene
  57006. */
  57007. register(): void;
  57008. /**
  57009. * Rebuilds the elements related to this component in case of
  57010. * context lost for instance.
  57011. */
  57012. rebuild(): void;
  57013. /**
  57014. * Serializes the component data to the specified json object
  57015. * @param serializationObject The object to serialize to
  57016. */
  57017. serialize(serializationObject: any): void;
  57018. /**
  57019. * Adds all the elements from the container to the scene
  57020. * @param container the container holding the elements
  57021. */
  57022. addFromContainer(container: AbstractScene): void;
  57023. /**
  57024. * Removes all the elements in the container from the scene
  57025. * @param container contains the elements to remove
  57026. * @param dispose if the removed element should be disposed (default: false)
  57027. */
  57028. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57029. /**
  57030. * Rebuilds the elements related to this component in case of
  57031. * context lost for instance.
  57032. */
  57033. dispose(): void;
  57034. private _gatherRenderTargets;
  57035. }
  57036. }
  57037. declare module "babylonjs/Lights/Shadows/index" {
  57038. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  57039. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  57040. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  57041. }
  57042. declare module "babylonjs/Lights/pointLight" {
  57043. import { Scene } from "babylonjs/scene";
  57044. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57045. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57046. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  57047. import { Effect } from "babylonjs/Materials/effect";
  57048. /**
  57049. * A point light is a light defined by an unique point in world space.
  57050. * The light is emitted in every direction from this point.
  57051. * A good example of a point light is a standard light bulb.
  57052. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57053. */
  57054. export class PointLight extends ShadowLight {
  57055. private _shadowAngle;
  57056. /**
  57057. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57058. * This specifies what angle the shadow will use to be created.
  57059. *
  57060. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57061. */
  57062. get shadowAngle(): number;
  57063. /**
  57064. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57065. * This specifies what angle the shadow will use to be created.
  57066. *
  57067. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57068. */
  57069. set shadowAngle(value: number);
  57070. /**
  57071. * Gets the direction if it has been set.
  57072. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57073. */
  57074. get direction(): Vector3;
  57075. /**
  57076. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57077. */
  57078. set direction(value: Vector3);
  57079. /**
  57080. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  57081. * A PointLight emits the light in every direction.
  57082. * It can cast shadows.
  57083. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  57084. * ```javascript
  57085. * var pointLight = new PointLight("pl", camera.position, scene);
  57086. * ```
  57087. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57088. * @param name The light friendly name
  57089. * @param position The position of the point light in the scene
  57090. * @param scene The scene the lights belongs to
  57091. */
  57092. constructor(name: string, position: Vector3, scene: Scene);
  57093. /**
  57094. * Returns the string "PointLight"
  57095. * @returns the class name
  57096. */
  57097. getClassName(): string;
  57098. /**
  57099. * Returns the integer 0.
  57100. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57101. */
  57102. getTypeID(): number;
  57103. /**
  57104. * Specifies wether or not the shadowmap should be a cube texture.
  57105. * @returns true if the shadowmap needs to be a cube texture.
  57106. */
  57107. needCube(): boolean;
  57108. /**
  57109. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  57110. * @param faceIndex The index of the face we are computed the direction to generate shadow
  57111. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  57112. */
  57113. getShadowDirection(faceIndex?: number): Vector3;
  57114. /**
  57115. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  57116. * - fov = PI / 2
  57117. * - aspect ratio : 1.0
  57118. * - z-near and far equal to the active camera minZ and maxZ.
  57119. * Returns the PointLight.
  57120. */
  57121. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57122. protected _buildUniformLayout(): void;
  57123. /**
  57124. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  57125. * @param effect The effect to update
  57126. * @param lightIndex The index of the light in the effect to update
  57127. * @returns The point light
  57128. */
  57129. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  57130. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  57131. /**
  57132. * Prepares the list of defines specific to the light type.
  57133. * @param defines the list of defines
  57134. * @param lightIndex defines the index of the light for the effect
  57135. */
  57136. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57137. }
  57138. }
  57139. declare module "babylonjs/Lights/index" {
  57140. export * from "babylonjs/Lights/light";
  57141. export * from "babylonjs/Lights/shadowLight";
  57142. export * from "babylonjs/Lights/Shadows/index";
  57143. export * from "babylonjs/Lights/directionalLight";
  57144. export * from "babylonjs/Lights/hemisphericLight";
  57145. export * from "babylonjs/Lights/pointLight";
  57146. export * from "babylonjs/Lights/spotLight";
  57147. }
  57148. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  57149. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  57150. /**
  57151. * Header information of HDR texture files.
  57152. */
  57153. export interface HDRInfo {
  57154. /**
  57155. * The height of the texture in pixels.
  57156. */
  57157. height: number;
  57158. /**
  57159. * The width of the texture in pixels.
  57160. */
  57161. width: number;
  57162. /**
  57163. * The index of the beginning of the data in the binary file.
  57164. */
  57165. dataPosition: number;
  57166. }
  57167. /**
  57168. * This groups tools to convert HDR texture to native colors array.
  57169. */
  57170. export class HDRTools {
  57171. private static Ldexp;
  57172. private static Rgbe2float;
  57173. private static readStringLine;
  57174. /**
  57175. * Reads header information from an RGBE texture stored in a native array.
  57176. * More information on this format are available here:
  57177. * https://en.wikipedia.org/wiki/RGBE_image_format
  57178. *
  57179. * @param uint8array The binary file stored in native array.
  57180. * @return The header information.
  57181. */
  57182. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  57183. /**
  57184. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  57185. * This RGBE texture needs to store the information as a panorama.
  57186. *
  57187. * More information on this format are available here:
  57188. * https://en.wikipedia.org/wiki/RGBE_image_format
  57189. *
  57190. * @param buffer The binary file stored in an array buffer.
  57191. * @param size The expected size of the extracted cubemap.
  57192. * @return The Cube Map information.
  57193. */
  57194. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  57195. /**
  57196. * Returns the pixels data extracted from an RGBE texture.
  57197. * This pixels will be stored left to right up to down in the R G B order in one array.
  57198. *
  57199. * More information on this format are available here:
  57200. * https://en.wikipedia.org/wiki/RGBE_image_format
  57201. *
  57202. * @param uint8array The binary file stored in an array buffer.
  57203. * @param hdrInfo The header information of the file.
  57204. * @return The pixels data in RGB right to left up to down order.
  57205. */
  57206. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  57207. private static RGBE_ReadPixels_RLE;
  57208. }
  57209. }
  57210. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  57211. import { Nullable } from "babylonjs/types";
  57212. import { Scene } from "babylonjs/scene";
  57213. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57214. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57215. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57216. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57217. /**
  57218. * This represents a texture coming from an HDR input.
  57219. *
  57220. * The only supported format is currently panorama picture stored in RGBE format.
  57221. * Example of such files can be found on HDRLib: http://hdrlib.com/
  57222. */
  57223. export class HDRCubeTexture extends BaseTexture {
  57224. private static _facesMapping;
  57225. private _generateHarmonics;
  57226. private _noMipmap;
  57227. private _textureMatrix;
  57228. private _size;
  57229. private _onLoad;
  57230. private _onError;
  57231. /**
  57232. * The texture URL.
  57233. */
  57234. url: string;
  57235. /**
  57236. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  57237. */
  57238. coordinatesMode: number;
  57239. protected _isBlocking: boolean;
  57240. /**
  57241. * Sets wether or not the texture is blocking during loading.
  57242. */
  57243. set isBlocking(value: boolean);
  57244. /**
  57245. * Gets wether or not the texture is blocking during loading.
  57246. */
  57247. get isBlocking(): boolean;
  57248. protected _rotationY: number;
  57249. /**
  57250. * Sets texture matrix rotation angle around Y axis in radians.
  57251. */
  57252. set rotationY(value: number);
  57253. /**
  57254. * Gets texture matrix rotation angle around Y axis radians.
  57255. */
  57256. get rotationY(): number;
  57257. /**
  57258. * Gets or sets the center of the bounding box associated with the cube texture
  57259. * It must define where the camera used to render the texture was set
  57260. */
  57261. boundingBoxPosition: Vector3;
  57262. private _boundingBoxSize;
  57263. /**
  57264. * Gets or sets the size of the bounding box associated with the cube texture
  57265. * When defined, the cubemap will switch to local mode
  57266. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57267. * @example https://www.babylonjs-playground.com/#RNASML
  57268. */
  57269. set boundingBoxSize(value: Vector3);
  57270. get boundingBoxSize(): Vector3;
  57271. /**
  57272. * Instantiates an HDRTexture from the following parameters.
  57273. *
  57274. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  57275. * @param scene The scene the texture will be used in
  57276. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  57277. * @param noMipmap Forces to not generate the mipmap if true
  57278. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  57279. * @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)
  57280. * @param reserved Reserved flag for internal use.
  57281. */
  57282. 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>);
  57283. /**
  57284. * Get the current class name of the texture useful for serialization or dynamic coding.
  57285. * @returns "HDRCubeTexture"
  57286. */
  57287. getClassName(): string;
  57288. /**
  57289. * Occurs when the file is raw .hdr file.
  57290. */
  57291. private loadTexture;
  57292. clone(): HDRCubeTexture;
  57293. delayLoad(): void;
  57294. /**
  57295. * Get the texture reflection matrix used to rotate/transform the reflection.
  57296. * @returns the reflection matrix
  57297. */
  57298. getReflectionTextureMatrix(): Matrix;
  57299. /**
  57300. * Set the texture reflection matrix used to rotate/transform the reflection.
  57301. * @param value Define the reflection matrix to set
  57302. */
  57303. setReflectionTextureMatrix(value: Matrix): void;
  57304. /**
  57305. * Parses a JSON representation of an HDR Texture in order to create the texture
  57306. * @param parsedTexture Define the JSON representation
  57307. * @param scene Define the scene the texture should be created in
  57308. * @param rootUrl Define the root url in case we need to load relative dependencies
  57309. * @returns the newly created texture after parsing
  57310. */
  57311. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  57312. serialize(): any;
  57313. }
  57314. }
  57315. declare module "babylonjs/Physics/physicsEngine" {
  57316. import { Nullable } from "babylonjs/types";
  57317. import { Vector3 } from "babylonjs/Maths/math.vector";
  57318. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57319. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  57320. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  57321. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57322. /**
  57323. * Class used to control physics engine
  57324. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57325. */
  57326. export class PhysicsEngine implements IPhysicsEngine {
  57327. private _physicsPlugin;
  57328. /**
  57329. * Global value used to control the smallest number supported by the simulation
  57330. */
  57331. static Epsilon: number;
  57332. private _impostors;
  57333. private _joints;
  57334. private _subTimeStep;
  57335. /**
  57336. * Gets the gravity vector used by the simulation
  57337. */
  57338. gravity: Vector3;
  57339. /**
  57340. * Factory used to create the default physics plugin.
  57341. * @returns The default physics plugin
  57342. */
  57343. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  57344. /**
  57345. * Creates a new Physics Engine
  57346. * @param gravity defines the gravity vector used by the simulation
  57347. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  57348. */
  57349. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  57350. /**
  57351. * Sets the gravity vector used by the simulation
  57352. * @param gravity defines the gravity vector to use
  57353. */
  57354. setGravity(gravity: Vector3): void;
  57355. /**
  57356. * Set the time step of the physics engine.
  57357. * Default is 1/60.
  57358. * To slow it down, enter 1/600 for example.
  57359. * To speed it up, 1/30
  57360. * @param newTimeStep defines the new timestep to apply to this world.
  57361. */
  57362. setTimeStep(newTimeStep?: number): void;
  57363. /**
  57364. * Get the time step of the physics engine.
  57365. * @returns the current time step
  57366. */
  57367. getTimeStep(): number;
  57368. /**
  57369. * Set the sub time step of the physics engine.
  57370. * Default is 0 meaning there is no sub steps
  57371. * To increase physics resolution precision, set a small value (like 1 ms)
  57372. * @param subTimeStep defines the new sub timestep used for physics resolution.
  57373. */
  57374. setSubTimeStep(subTimeStep?: number): void;
  57375. /**
  57376. * Get the sub time step of the physics engine.
  57377. * @returns the current sub time step
  57378. */
  57379. getSubTimeStep(): number;
  57380. /**
  57381. * Release all resources
  57382. */
  57383. dispose(): void;
  57384. /**
  57385. * Gets the name of the current physics plugin
  57386. * @returns the name of the plugin
  57387. */
  57388. getPhysicsPluginName(): string;
  57389. /**
  57390. * Adding a new impostor for the impostor tracking.
  57391. * This will be done by the impostor itself.
  57392. * @param impostor the impostor to add
  57393. */
  57394. addImpostor(impostor: PhysicsImpostor): void;
  57395. /**
  57396. * Remove an impostor from the engine.
  57397. * This impostor and its mesh will not longer be updated by the physics engine.
  57398. * @param impostor the impostor to remove
  57399. */
  57400. removeImpostor(impostor: PhysicsImpostor): void;
  57401. /**
  57402. * Add a joint to the physics engine
  57403. * @param mainImpostor defines the main impostor to which the joint is added.
  57404. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  57405. * @param joint defines the joint that will connect both impostors.
  57406. */
  57407. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57408. /**
  57409. * Removes a joint from the simulation
  57410. * @param mainImpostor defines the impostor used with the joint
  57411. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  57412. * @param joint defines the joint to remove
  57413. */
  57414. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57415. /**
  57416. * Called by the scene. No need to call it.
  57417. * @param delta defines the timespam between frames
  57418. */
  57419. _step(delta: number): void;
  57420. /**
  57421. * Gets the current plugin used to run the simulation
  57422. * @returns current plugin
  57423. */
  57424. getPhysicsPlugin(): IPhysicsEnginePlugin;
  57425. /**
  57426. * Gets the list of physic impostors
  57427. * @returns an array of PhysicsImpostor
  57428. */
  57429. getImpostors(): Array<PhysicsImpostor>;
  57430. /**
  57431. * Gets the impostor for a physics enabled object
  57432. * @param object defines the object impersonated by the impostor
  57433. * @returns the PhysicsImpostor or null if not found
  57434. */
  57435. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  57436. /**
  57437. * Gets the impostor for a physics body object
  57438. * @param body defines physics body used by the impostor
  57439. * @returns the PhysicsImpostor or null if not found
  57440. */
  57441. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  57442. /**
  57443. * Does a raycast in the physics world
  57444. * @param from when should the ray start?
  57445. * @param to when should the ray end?
  57446. * @returns PhysicsRaycastResult
  57447. */
  57448. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57449. }
  57450. }
  57451. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  57452. import { Nullable } from "babylonjs/types";
  57453. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57454. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57455. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57456. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57457. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57458. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57459. /** @hidden */
  57460. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  57461. private _useDeltaForWorldStep;
  57462. world: any;
  57463. name: string;
  57464. private _physicsMaterials;
  57465. private _fixedTimeStep;
  57466. private _cannonRaycastResult;
  57467. private _raycastResult;
  57468. private _physicsBodysToRemoveAfterStep;
  57469. BJSCANNON: any;
  57470. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  57471. setGravity(gravity: Vector3): void;
  57472. setTimeStep(timeStep: number): void;
  57473. getTimeStep(): number;
  57474. executeStep(delta: number): void;
  57475. private _removeMarkedPhysicsBodiesFromWorld;
  57476. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57477. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57478. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57479. private _processChildMeshes;
  57480. removePhysicsBody(impostor: PhysicsImpostor): void;
  57481. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57482. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57483. private _addMaterial;
  57484. private _checkWithEpsilon;
  57485. private _createShape;
  57486. private _createHeightmap;
  57487. private _minus90X;
  57488. private _plus90X;
  57489. private _tmpPosition;
  57490. private _tmpDeltaPosition;
  57491. private _tmpUnityRotation;
  57492. private _updatePhysicsBodyTransformation;
  57493. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57494. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57495. isSupported(): boolean;
  57496. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57497. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57498. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57499. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57500. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57501. getBodyMass(impostor: PhysicsImpostor): number;
  57502. getBodyFriction(impostor: PhysicsImpostor): number;
  57503. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57504. getBodyRestitution(impostor: PhysicsImpostor): number;
  57505. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57506. sleepBody(impostor: PhysicsImpostor): void;
  57507. wakeUpBody(impostor: PhysicsImpostor): void;
  57508. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  57509. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57510. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57511. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57512. getRadius(impostor: PhysicsImpostor): number;
  57513. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57514. dispose(): void;
  57515. private _extendNamespace;
  57516. /**
  57517. * Does a raycast in the physics world
  57518. * @param from when should the ray start?
  57519. * @param to when should the ray end?
  57520. * @returns PhysicsRaycastResult
  57521. */
  57522. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57523. }
  57524. }
  57525. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  57526. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57527. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57528. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57530. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57531. import { Nullable } from "babylonjs/types";
  57532. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57533. /** @hidden */
  57534. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  57535. world: any;
  57536. name: string;
  57537. BJSOIMO: any;
  57538. private _raycastResult;
  57539. constructor(iterations?: number, oimoInjection?: any);
  57540. setGravity(gravity: Vector3): void;
  57541. setTimeStep(timeStep: number): void;
  57542. getTimeStep(): number;
  57543. private _tmpImpostorsArray;
  57544. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57545. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57546. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57547. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57548. private _tmpPositionVector;
  57549. removePhysicsBody(impostor: PhysicsImpostor): void;
  57550. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57551. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57552. isSupported(): boolean;
  57553. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57554. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57555. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57556. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57557. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57558. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57559. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57560. getBodyMass(impostor: PhysicsImpostor): number;
  57561. getBodyFriction(impostor: PhysicsImpostor): number;
  57562. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57563. getBodyRestitution(impostor: PhysicsImpostor): number;
  57564. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57565. sleepBody(impostor: PhysicsImpostor): void;
  57566. wakeUpBody(impostor: PhysicsImpostor): void;
  57567. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57568. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  57569. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  57570. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57571. getRadius(impostor: PhysicsImpostor): number;
  57572. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57573. dispose(): void;
  57574. /**
  57575. * Does a raycast in the physics world
  57576. * @param from when should the ray start?
  57577. * @param to when should the ray end?
  57578. * @returns PhysicsRaycastResult
  57579. */
  57580. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57581. }
  57582. }
  57583. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  57584. import { Nullable } from "babylonjs/types";
  57585. import { Scene } from "babylonjs/scene";
  57586. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  57587. import { Color4 } from "babylonjs/Maths/math.color";
  57588. import { Mesh } from "babylonjs/Meshes/mesh";
  57589. /**
  57590. * Class containing static functions to help procedurally build meshes
  57591. */
  57592. export class RibbonBuilder {
  57593. /**
  57594. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57595. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57596. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57597. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57598. * * 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
  57599. * * 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
  57600. * * 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
  57601. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57602. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57603. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57604. * * 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
  57605. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57606. * * 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
  57607. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57609. * @param name defines the name of the mesh
  57610. * @param options defines the options used to create the mesh
  57611. * @param scene defines the hosting scene
  57612. * @returns the ribbon mesh
  57613. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57614. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57615. */
  57616. static CreateRibbon(name: string, options: {
  57617. pathArray: Vector3[][];
  57618. closeArray?: boolean;
  57619. closePath?: boolean;
  57620. offset?: number;
  57621. updatable?: boolean;
  57622. sideOrientation?: number;
  57623. frontUVs?: Vector4;
  57624. backUVs?: Vector4;
  57625. instance?: Mesh;
  57626. invertUV?: boolean;
  57627. uvs?: Vector2[];
  57628. colors?: Color4[];
  57629. }, scene?: Nullable<Scene>): Mesh;
  57630. }
  57631. }
  57632. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  57633. import { Nullable } from "babylonjs/types";
  57634. import { Scene } from "babylonjs/scene";
  57635. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57636. import { Mesh } from "babylonjs/Meshes/mesh";
  57637. /**
  57638. * Class containing static functions to help procedurally build meshes
  57639. */
  57640. export class ShapeBuilder {
  57641. /**
  57642. * 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.
  57643. * * 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.
  57644. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57645. * * 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.
  57646. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57647. * * 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
  57648. * * 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
  57649. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57650. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57651. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57652. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57653. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57654. * @param name defines the name of the mesh
  57655. * @param options defines the options used to create the mesh
  57656. * @param scene defines the hosting scene
  57657. * @returns the extruded shape mesh
  57658. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57659. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57660. */
  57661. static ExtrudeShape(name: string, options: {
  57662. shape: Vector3[];
  57663. path: Vector3[];
  57664. scale?: number;
  57665. rotation?: number;
  57666. cap?: number;
  57667. updatable?: boolean;
  57668. sideOrientation?: number;
  57669. frontUVs?: Vector4;
  57670. backUVs?: Vector4;
  57671. instance?: Mesh;
  57672. invertUV?: boolean;
  57673. }, scene?: Nullable<Scene>): Mesh;
  57674. /**
  57675. * Creates an custom extruded shape mesh.
  57676. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57677. * * 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.
  57678. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57679. * * 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
  57680. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57681. * * 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
  57682. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57683. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57684. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57685. * * 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
  57686. * * 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
  57687. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57688. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57689. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57690. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57692. * @param name defines the name of the mesh
  57693. * @param options defines the options used to create the mesh
  57694. * @param scene defines the hosting scene
  57695. * @returns the custom extruded shape mesh
  57696. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57697. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57698. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57699. */
  57700. static ExtrudeShapeCustom(name: string, options: {
  57701. shape: Vector3[];
  57702. path: Vector3[];
  57703. scaleFunction?: any;
  57704. rotationFunction?: any;
  57705. ribbonCloseArray?: boolean;
  57706. ribbonClosePath?: boolean;
  57707. cap?: number;
  57708. updatable?: boolean;
  57709. sideOrientation?: number;
  57710. frontUVs?: Vector4;
  57711. backUVs?: Vector4;
  57712. instance?: Mesh;
  57713. invertUV?: boolean;
  57714. }, scene?: Nullable<Scene>): Mesh;
  57715. private static _ExtrudeShapeGeneric;
  57716. }
  57717. }
  57718. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  57719. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  57720. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57721. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57722. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57723. import { Nullable } from "babylonjs/types";
  57724. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57725. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57726. /**
  57727. * AmmoJS Physics plugin
  57728. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  57729. * @see https://github.com/kripken/ammo.js/
  57730. */
  57731. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  57732. private _useDeltaForWorldStep;
  57733. /**
  57734. * Reference to the Ammo library
  57735. */
  57736. bjsAMMO: any;
  57737. /**
  57738. * Created ammoJS world which physics bodies are added to
  57739. */
  57740. world: any;
  57741. /**
  57742. * Name of the plugin
  57743. */
  57744. name: string;
  57745. private _timeStep;
  57746. private _fixedTimeStep;
  57747. private _maxSteps;
  57748. private _tmpQuaternion;
  57749. private _tmpAmmoTransform;
  57750. private _tmpAmmoQuaternion;
  57751. private _tmpAmmoConcreteContactResultCallback;
  57752. private _collisionConfiguration;
  57753. private _dispatcher;
  57754. private _overlappingPairCache;
  57755. private _solver;
  57756. private _softBodySolver;
  57757. private _tmpAmmoVectorA;
  57758. private _tmpAmmoVectorB;
  57759. private _tmpAmmoVectorC;
  57760. private _tmpAmmoVectorD;
  57761. private _tmpContactCallbackResult;
  57762. private _tmpAmmoVectorRCA;
  57763. private _tmpAmmoVectorRCB;
  57764. private _raycastResult;
  57765. private static readonly DISABLE_COLLISION_FLAG;
  57766. private static readonly KINEMATIC_FLAG;
  57767. private static readonly DISABLE_DEACTIVATION_FLAG;
  57768. /**
  57769. * Initializes the ammoJS plugin
  57770. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  57771. * @param ammoInjection can be used to inject your own ammo reference
  57772. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  57773. */
  57774. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  57775. /**
  57776. * Sets the gravity of the physics world (m/(s^2))
  57777. * @param gravity Gravity to set
  57778. */
  57779. setGravity(gravity: Vector3): void;
  57780. /**
  57781. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  57782. * @param timeStep timestep to use in seconds
  57783. */
  57784. setTimeStep(timeStep: number): void;
  57785. /**
  57786. * 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)
  57787. * @param fixedTimeStep fixedTimeStep to use in seconds
  57788. */
  57789. setFixedTimeStep(fixedTimeStep: number): void;
  57790. /**
  57791. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  57792. * @param maxSteps the maximum number of steps by the physics engine per frame
  57793. */
  57794. setMaxSteps(maxSteps: number): void;
  57795. /**
  57796. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  57797. * @returns the current timestep in seconds
  57798. */
  57799. getTimeStep(): number;
  57800. /**
  57801. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  57802. */
  57803. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  57804. private _isImpostorInContact;
  57805. private _isImpostorPairInContact;
  57806. private _stepSimulation;
  57807. /**
  57808. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  57809. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  57810. * After the step the babylon meshes are set to the position of the physics imposters
  57811. * @param delta amount of time to step forward
  57812. * @param impostors array of imposters to update before/after the step
  57813. */
  57814. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57815. /**
  57816. * Update babylon mesh to match physics world object
  57817. * @param impostor imposter to match
  57818. */
  57819. private _afterSoftStep;
  57820. /**
  57821. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57822. * @param impostor imposter to match
  57823. */
  57824. private _ropeStep;
  57825. /**
  57826. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57827. * @param impostor imposter to match
  57828. */
  57829. private _softbodyOrClothStep;
  57830. private _tmpVector;
  57831. private _tmpMatrix;
  57832. /**
  57833. * Applies an impulse on the imposter
  57834. * @param impostor imposter to apply impulse to
  57835. * @param force amount of force to be applied to the imposter
  57836. * @param contactPoint the location to apply the impulse on the imposter
  57837. */
  57838. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57839. /**
  57840. * Applies a force on the imposter
  57841. * @param impostor imposter to apply force
  57842. * @param force amount of force to be applied to the imposter
  57843. * @param contactPoint the location to apply the force on the imposter
  57844. */
  57845. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57846. /**
  57847. * Creates a physics body using the plugin
  57848. * @param impostor the imposter to create the physics body on
  57849. */
  57850. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57851. /**
  57852. * Removes the physics body from the imposter and disposes of the body's memory
  57853. * @param impostor imposter to remove the physics body from
  57854. */
  57855. removePhysicsBody(impostor: PhysicsImpostor): void;
  57856. /**
  57857. * Generates a joint
  57858. * @param impostorJoint the imposter joint to create the joint with
  57859. */
  57860. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57861. /**
  57862. * Removes a joint
  57863. * @param impostorJoint the imposter joint to remove the joint from
  57864. */
  57865. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57866. private _addMeshVerts;
  57867. /**
  57868. * Initialise the soft body vertices to match its object's (mesh) vertices
  57869. * Softbody vertices (nodes) are in world space and to match this
  57870. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  57871. * @param impostor to create the softbody for
  57872. */
  57873. private _softVertexData;
  57874. /**
  57875. * Create an impostor's soft body
  57876. * @param impostor to create the softbody for
  57877. */
  57878. private _createSoftbody;
  57879. /**
  57880. * Create cloth for an impostor
  57881. * @param impostor to create the softbody for
  57882. */
  57883. private _createCloth;
  57884. /**
  57885. * Create rope for an impostor
  57886. * @param impostor to create the softbody for
  57887. */
  57888. private _createRope;
  57889. /**
  57890. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  57891. * @param impostor to create the custom physics shape for
  57892. */
  57893. private _createCustom;
  57894. private _addHullVerts;
  57895. private _createShape;
  57896. /**
  57897. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  57898. * @param impostor imposter containing the physics body and babylon object
  57899. */
  57900. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57901. /**
  57902. * Sets the babylon object's position/rotation from the physics body's position/rotation
  57903. * @param impostor imposter containing the physics body and babylon object
  57904. * @param newPosition new position
  57905. * @param newRotation new rotation
  57906. */
  57907. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57908. /**
  57909. * If this plugin is supported
  57910. * @returns true if its supported
  57911. */
  57912. isSupported(): boolean;
  57913. /**
  57914. * Sets the linear velocity of the physics body
  57915. * @param impostor imposter to set the velocity on
  57916. * @param velocity velocity to set
  57917. */
  57918. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57919. /**
  57920. * Sets the angular velocity of the physics body
  57921. * @param impostor imposter to set the velocity on
  57922. * @param velocity velocity to set
  57923. */
  57924. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57925. /**
  57926. * gets the linear velocity
  57927. * @param impostor imposter to get linear velocity from
  57928. * @returns linear velocity
  57929. */
  57930. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57931. /**
  57932. * gets the angular velocity
  57933. * @param impostor imposter to get angular velocity from
  57934. * @returns angular velocity
  57935. */
  57936. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57937. /**
  57938. * Sets the mass of physics body
  57939. * @param impostor imposter to set the mass on
  57940. * @param mass mass to set
  57941. */
  57942. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57943. /**
  57944. * Gets the mass of the physics body
  57945. * @param impostor imposter to get the mass from
  57946. * @returns mass
  57947. */
  57948. getBodyMass(impostor: PhysicsImpostor): number;
  57949. /**
  57950. * Gets friction of the impostor
  57951. * @param impostor impostor to get friction from
  57952. * @returns friction value
  57953. */
  57954. getBodyFriction(impostor: PhysicsImpostor): number;
  57955. /**
  57956. * Sets friction of the impostor
  57957. * @param impostor impostor to set friction on
  57958. * @param friction friction value
  57959. */
  57960. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57961. /**
  57962. * Gets restitution of the impostor
  57963. * @param impostor impostor to get restitution from
  57964. * @returns restitution value
  57965. */
  57966. getBodyRestitution(impostor: PhysicsImpostor): number;
  57967. /**
  57968. * Sets resitution of the impostor
  57969. * @param impostor impostor to set resitution on
  57970. * @param restitution resitution value
  57971. */
  57972. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57973. /**
  57974. * Gets pressure inside the impostor
  57975. * @param impostor impostor to get pressure from
  57976. * @returns pressure value
  57977. */
  57978. getBodyPressure(impostor: PhysicsImpostor): number;
  57979. /**
  57980. * Sets pressure inside a soft body impostor
  57981. * Cloth and rope must remain 0 pressure
  57982. * @param impostor impostor to set pressure on
  57983. * @param pressure pressure value
  57984. */
  57985. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  57986. /**
  57987. * Gets stiffness of the impostor
  57988. * @param impostor impostor to get stiffness from
  57989. * @returns pressure value
  57990. */
  57991. getBodyStiffness(impostor: PhysicsImpostor): number;
  57992. /**
  57993. * Sets stiffness of the impostor
  57994. * @param impostor impostor to set stiffness on
  57995. * @param stiffness stiffness value from 0 to 1
  57996. */
  57997. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  57998. /**
  57999. * Gets velocityIterations of the impostor
  58000. * @param impostor impostor to get velocity iterations from
  58001. * @returns velocityIterations value
  58002. */
  58003. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  58004. /**
  58005. * Sets velocityIterations of the impostor
  58006. * @param impostor impostor to set velocity iterations on
  58007. * @param velocityIterations velocityIterations value
  58008. */
  58009. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  58010. /**
  58011. * Gets positionIterations of the impostor
  58012. * @param impostor impostor to get position iterations from
  58013. * @returns positionIterations value
  58014. */
  58015. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  58016. /**
  58017. * Sets positionIterations of the impostor
  58018. * @param impostor impostor to set position on
  58019. * @param positionIterations positionIterations value
  58020. */
  58021. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  58022. /**
  58023. * Append an anchor to a cloth object
  58024. * @param impostor is the cloth impostor to add anchor to
  58025. * @param otherImpostor is the rigid impostor to anchor to
  58026. * @param width ratio across width from 0 to 1
  58027. * @param height ratio up height from 0 to 1
  58028. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  58029. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  58030. */
  58031. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58032. /**
  58033. * Append an hook to a rope object
  58034. * @param impostor is the rope impostor to add hook to
  58035. * @param otherImpostor is the rigid impostor to hook to
  58036. * @param length ratio along the rope from 0 to 1
  58037. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  58038. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  58039. */
  58040. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58041. /**
  58042. * Sleeps the physics body and stops it from being active
  58043. * @param impostor impostor to sleep
  58044. */
  58045. sleepBody(impostor: PhysicsImpostor): void;
  58046. /**
  58047. * Activates the physics body
  58048. * @param impostor impostor to activate
  58049. */
  58050. wakeUpBody(impostor: PhysicsImpostor): void;
  58051. /**
  58052. * Updates the distance parameters of the joint
  58053. * @param joint joint to update
  58054. * @param maxDistance maximum distance of the joint
  58055. * @param minDistance minimum distance of the joint
  58056. */
  58057. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58058. /**
  58059. * Sets a motor on the joint
  58060. * @param joint joint to set motor on
  58061. * @param speed speed of the motor
  58062. * @param maxForce maximum force of the motor
  58063. * @param motorIndex index of the motor
  58064. */
  58065. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  58066. /**
  58067. * Sets the motors limit
  58068. * @param joint joint to set limit on
  58069. * @param upperLimit upper limit
  58070. * @param lowerLimit lower limit
  58071. */
  58072. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  58073. /**
  58074. * Syncs the position and rotation of a mesh with the impostor
  58075. * @param mesh mesh to sync
  58076. * @param impostor impostor to update the mesh with
  58077. */
  58078. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58079. /**
  58080. * Gets the radius of the impostor
  58081. * @param impostor impostor to get radius from
  58082. * @returns the radius
  58083. */
  58084. getRadius(impostor: PhysicsImpostor): number;
  58085. /**
  58086. * Gets the box size of the impostor
  58087. * @param impostor impostor to get box size from
  58088. * @param result the resulting box size
  58089. */
  58090. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58091. /**
  58092. * Disposes of the impostor
  58093. */
  58094. dispose(): void;
  58095. /**
  58096. * Does a raycast in the physics world
  58097. * @param from when should the ray start?
  58098. * @param to when should the ray end?
  58099. * @returns PhysicsRaycastResult
  58100. */
  58101. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58102. }
  58103. }
  58104. declare module "babylonjs/Probes/reflectionProbe" {
  58105. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58106. import { Vector3 } from "babylonjs/Maths/math.vector";
  58107. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58108. import { Nullable } from "babylonjs/types";
  58109. import { Scene } from "babylonjs/scene";
  58110. module "babylonjs/abstractScene" {
  58111. interface AbstractScene {
  58112. /**
  58113. * The list of reflection probes added to the scene
  58114. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58115. */
  58116. reflectionProbes: Array<ReflectionProbe>;
  58117. /**
  58118. * Removes the given reflection probe from this scene.
  58119. * @param toRemove The reflection probe to remove
  58120. * @returns The index of the removed reflection probe
  58121. */
  58122. removeReflectionProbe(toRemove: ReflectionProbe): number;
  58123. /**
  58124. * Adds the given reflection probe to this scene.
  58125. * @param newReflectionProbe The reflection probe to add
  58126. */
  58127. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  58128. }
  58129. }
  58130. /**
  58131. * Class used to generate realtime reflection / refraction cube textures
  58132. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58133. */
  58134. export class ReflectionProbe {
  58135. /** defines the name of the probe */
  58136. name: string;
  58137. private _scene;
  58138. private _renderTargetTexture;
  58139. private _projectionMatrix;
  58140. private _viewMatrix;
  58141. private _target;
  58142. private _add;
  58143. private _attachedMesh;
  58144. private _invertYAxis;
  58145. /** Gets or sets probe position (center of the cube map) */
  58146. position: Vector3;
  58147. /**
  58148. * Creates a new reflection probe
  58149. * @param name defines the name of the probe
  58150. * @param size defines the texture resolution (for each face)
  58151. * @param scene defines the hosting scene
  58152. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  58153. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  58154. */
  58155. constructor(
  58156. /** defines the name of the probe */
  58157. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  58158. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  58159. get samples(): number;
  58160. set samples(value: number);
  58161. /** Gets or sets the refresh rate to use (on every frame by default) */
  58162. get refreshRate(): number;
  58163. set refreshRate(value: number);
  58164. /**
  58165. * Gets the hosting scene
  58166. * @returns a Scene
  58167. */
  58168. getScene(): Scene;
  58169. /** Gets the internal CubeTexture used to render to */
  58170. get cubeTexture(): RenderTargetTexture;
  58171. /** Gets the list of meshes to render */
  58172. get renderList(): Nullable<AbstractMesh[]>;
  58173. /**
  58174. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  58175. * @param mesh defines the mesh to attach to
  58176. */
  58177. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  58178. /**
  58179. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  58180. * @param renderingGroupId The rendering group id corresponding to its index
  58181. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  58182. */
  58183. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  58184. /**
  58185. * Clean all associated resources
  58186. */
  58187. dispose(): void;
  58188. /**
  58189. * Converts the reflection probe information to a readable string for debug purpose.
  58190. * @param fullDetails Supports for multiple levels of logging within scene loading
  58191. * @returns the human readable reflection probe info
  58192. */
  58193. toString(fullDetails?: boolean): string;
  58194. /**
  58195. * Get the class name of the relfection probe.
  58196. * @returns "ReflectionProbe"
  58197. */
  58198. getClassName(): string;
  58199. /**
  58200. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  58201. * @returns The JSON representation of the texture
  58202. */
  58203. serialize(): any;
  58204. /**
  58205. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  58206. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  58207. * @param scene Define the scene the parsed reflection probe should be instantiated in
  58208. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  58209. * @returns The parsed reflection probe if successful
  58210. */
  58211. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  58212. }
  58213. }
  58214. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  58215. /** @hidden */
  58216. export var _BabylonLoaderRegistered: boolean;
  58217. /**
  58218. * Helps setting up some configuration for the babylon file loader.
  58219. */
  58220. export class BabylonFileLoaderConfiguration {
  58221. /**
  58222. * The loader does not allow injecting custom physix engine into the plugins.
  58223. * Unfortunately in ES6, we need to manually inject them into the plugin.
  58224. * So you could set this variable to your engine import to make it work.
  58225. */
  58226. static LoaderInjectedPhysicsEngine: any;
  58227. }
  58228. }
  58229. declare module "babylonjs/Loading/Plugins/index" {
  58230. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  58231. }
  58232. declare module "babylonjs/Loading/index" {
  58233. export * from "babylonjs/Loading/loadingScreen";
  58234. export * from "babylonjs/Loading/Plugins/index";
  58235. export * from "babylonjs/Loading/sceneLoader";
  58236. export * from "babylonjs/Loading/sceneLoaderFlags";
  58237. }
  58238. declare module "babylonjs/Materials/Background/index" {
  58239. export * from "babylonjs/Materials/Background/backgroundMaterial";
  58240. }
  58241. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  58242. import { Scene } from "babylonjs/scene";
  58243. import { Color3 } from "babylonjs/Maths/math.color";
  58244. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58245. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58246. /**
  58247. * The Physically based simple base material of BJS.
  58248. *
  58249. * This enables better naming and convention enforcements on top of the pbrMaterial.
  58250. * It is used as the base class for both the specGloss and metalRough conventions.
  58251. */
  58252. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  58253. /**
  58254. * Number of Simultaneous lights allowed on the material.
  58255. */
  58256. maxSimultaneousLights: number;
  58257. /**
  58258. * If sets to true, disables all the lights affecting the material.
  58259. */
  58260. disableLighting: boolean;
  58261. /**
  58262. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  58263. */
  58264. environmentTexture: BaseTexture;
  58265. /**
  58266. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58267. */
  58268. invertNormalMapX: boolean;
  58269. /**
  58270. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58271. */
  58272. invertNormalMapY: boolean;
  58273. /**
  58274. * Normal map used in the model.
  58275. */
  58276. normalTexture: BaseTexture;
  58277. /**
  58278. * Emissivie color used to self-illuminate the model.
  58279. */
  58280. emissiveColor: Color3;
  58281. /**
  58282. * Emissivie texture used to self-illuminate the model.
  58283. */
  58284. emissiveTexture: BaseTexture;
  58285. /**
  58286. * Occlusion Channel Strenght.
  58287. */
  58288. occlusionStrength: number;
  58289. /**
  58290. * Occlusion Texture of the material (adding extra occlusion effects).
  58291. */
  58292. occlusionTexture: BaseTexture;
  58293. /**
  58294. * Defines the alpha limits in alpha test mode.
  58295. */
  58296. alphaCutOff: number;
  58297. /**
  58298. * Gets the current double sided mode.
  58299. */
  58300. get doubleSided(): boolean;
  58301. /**
  58302. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58303. */
  58304. set doubleSided(value: boolean);
  58305. /**
  58306. * Stores the pre-calculated light information of a mesh in a texture.
  58307. */
  58308. lightmapTexture: BaseTexture;
  58309. /**
  58310. * If true, the light map contains occlusion information instead of lighting info.
  58311. */
  58312. useLightmapAsShadowmap: boolean;
  58313. /**
  58314. * Instantiates a new PBRMaterial instance.
  58315. *
  58316. * @param name The material name
  58317. * @param scene The scene the material will be use in.
  58318. */
  58319. constructor(name: string, scene: Scene);
  58320. getClassName(): string;
  58321. }
  58322. }
  58323. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  58324. import { Scene } from "babylonjs/scene";
  58325. import { Color3 } from "babylonjs/Maths/math.color";
  58326. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58327. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58328. /**
  58329. * The PBR material of BJS following the metal roughness convention.
  58330. *
  58331. * This fits to the PBR convention in the GLTF definition:
  58332. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  58333. */
  58334. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  58335. /**
  58336. * The base color has two different interpretations depending on the value of metalness.
  58337. * When the material is a metal, the base color is the specific measured reflectance value
  58338. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  58339. * of the material.
  58340. */
  58341. baseColor: Color3;
  58342. /**
  58343. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  58344. * well as opacity information in the alpha channel.
  58345. */
  58346. baseTexture: BaseTexture;
  58347. /**
  58348. * Specifies the metallic scalar value of the material.
  58349. * Can also be used to scale the metalness values of the metallic texture.
  58350. */
  58351. metallic: number;
  58352. /**
  58353. * Specifies the roughness scalar value of the material.
  58354. * Can also be used to scale the roughness values of the metallic texture.
  58355. */
  58356. roughness: number;
  58357. /**
  58358. * Texture containing both the metallic value in the B channel and the
  58359. * roughness value in the G channel to keep better precision.
  58360. */
  58361. metallicRoughnessTexture: BaseTexture;
  58362. /**
  58363. * Instantiates a new PBRMetalRoughnessMaterial instance.
  58364. *
  58365. * @param name The material name
  58366. * @param scene The scene the material will be use in.
  58367. */
  58368. constructor(name: string, scene: Scene);
  58369. /**
  58370. * Return the currrent class name of the material.
  58371. */
  58372. getClassName(): string;
  58373. /**
  58374. * Makes a duplicate of the current material.
  58375. * @param name - name to use for the new material.
  58376. */
  58377. clone(name: string): PBRMetallicRoughnessMaterial;
  58378. /**
  58379. * Serialize the material to a parsable JSON object.
  58380. */
  58381. serialize(): any;
  58382. /**
  58383. * Parses a JSON object correponding to the serialize function.
  58384. */
  58385. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  58386. }
  58387. }
  58388. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  58389. import { Scene } from "babylonjs/scene";
  58390. import { Color3 } from "babylonjs/Maths/math.color";
  58391. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58392. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58393. /**
  58394. * The PBR material of BJS following the specular glossiness convention.
  58395. *
  58396. * This fits to the PBR convention in the GLTF definition:
  58397. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  58398. */
  58399. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  58400. /**
  58401. * Specifies the diffuse color of the material.
  58402. */
  58403. diffuseColor: Color3;
  58404. /**
  58405. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  58406. * channel.
  58407. */
  58408. diffuseTexture: BaseTexture;
  58409. /**
  58410. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  58411. */
  58412. specularColor: Color3;
  58413. /**
  58414. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  58415. */
  58416. glossiness: number;
  58417. /**
  58418. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  58419. */
  58420. specularGlossinessTexture: BaseTexture;
  58421. /**
  58422. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  58423. *
  58424. * @param name The material name
  58425. * @param scene The scene the material will be use in.
  58426. */
  58427. constructor(name: string, scene: Scene);
  58428. /**
  58429. * Return the currrent class name of the material.
  58430. */
  58431. getClassName(): string;
  58432. /**
  58433. * Makes a duplicate of the current material.
  58434. * @param name - name to use for the new material.
  58435. */
  58436. clone(name: string): PBRSpecularGlossinessMaterial;
  58437. /**
  58438. * Serialize the material to a parsable JSON object.
  58439. */
  58440. serialize(): any;
  58441. /**
  58442. * Parses a JSON object correponding to the serialize function.
  58443. */
  58444. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  58445. }
  58446. }
  58447. declare module "babylonjs/Materials/PBR/index" {
  58448. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58449. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58450. export * from "babylonjs/Materials/PBR/pbrMaterial";
  58451. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  58452. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  58453. }
  58454. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  58455. import { Nullable } from "babylonjs/types";
  58456. import { Scene } from "babylonjs/scene";
  58457. import { Matrix } from "babylonjs/Maths/math.vector";
  58458. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58459. /**
  58460. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  58461. * It can help converting any input color in a desired output one. This can then be used to create effects
  58462. * from sepia, black and white to sixties or futuristic rendering...
  58463. *
  58464. * The only supported format is currently 3dl.
  58465. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  58466. */
  58467. export class ColorGradingTexture extends BaseTexture {
  58468. /**
  58469. * The current texture matrix. (will always be identity in color grading texture)
  58470. */
  58471. private _textureMatrix;
  58472. /**
  58473. * The texture URL.
  58474. */
  58475. url: string;
  58476. /**
  58477. * Empty line regex stored for GC.
  58478. */
  58479. private static _noneEmptyLineRegex;
  58480. private _engine;
  58481. /**
  58482. * Instantiates a ColorGradingTexture from the following parameters.
  58483. *
  58484. * @param url The location of the color gradind data (currently only supporting 3dl)
  58485. * @param scene The scene the texture will be used in
  58486. */
  58487. constructor(url: string, scene: Scene);
  58488. /**
  58489. * Returns the texture matrix used in most of the material.
  58490. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  58491. */
  58492. getTextureMatrix(): Matrix;
  58493. /**
  58494. * Occurs when the file being loaded is a .3dl LUT file.
  58495. */
  58496. private load3dlTexture;
  58497. /**
  58498. * Starts the loading process of the texture.
  58499. */
  58500. private loadTexture;
  58501. /**
  58502. * Clones the color gradind texture.
  58503. */
  58504. clone(): ColorGradingTexture;
  58505. /**
  58506. * Called during delayed load for textures.
  58507. */
  58508. delayLoad(): void;
  58509. /**
  58510. * Parses a color grading texture serialized by Babylon.
  58511. * @param parsedTexture The texture information being parsedTexture
  58512. * @param scene The scene to load the texture in
  58513. * @param rootUrl The root url of the data assets to load
  58514. * @return A color gradind texture
  58515. */
  58516. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  58517. /**
  58518. * Serializes the LUT texture to json format.
  58519. */
  58520. serialize(): any;
  58521. }
  58522. }
  58523. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  58524. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58525. import { Scene } from "babylonjs/scene";
  58526. import { Nullable } from "babylonjs/types";
  58527. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58528. /**
  58529. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  58530. */
  58531. export class EquiRectangularCubeTexture extends BaseTexture {
  58532. /** The six faces of the cube. */
  58533. private static _FacesMapping;
  58534. private _noMipmap;
  58535. private _onLoad;
  58536. private _onError;
  58537. /** The size of the cubemap. */
  58538. private _size;
  58539. /** The buffer of the image. */
  58540. private _buffer;
  58541. /** The width of the input image. */
  58542. private _width;
  58543. /** The height of the input image. */
  58544. private _height;
  58545. /** The URL to the image. */
  58546. url: string;
  58547. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  58548. coordinatesMode: number;
  58549. /**
  58550. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  58551. * @param url The location of the image
  58552. * @param scene The scene the texture will be used in
  58553. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58554. * @param noMipmap Forces to not generate the mipmap if true
  58555. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58556. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58557. * @param onLoad — defines a callback called when texture is loaded
  58558. * @param onError — defines a callback called if there is an error
  58559. */
  58560. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  58561. /**
  58562. * Load the image data, by putting the image on a canvas and extracting its buffer.
  58563. */
  58564. private loadImage;
  58565. /**
  58566. * Convert the image buffer into a cubemap and create a CubeTexture.
  58567. */
  58568. private loadTexture;
  58569. /**
  58570. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  58571. * @param buffer The ArrayBuffer that should be converted.
  58572. * @returns The buffer as Float32Array.
  58573. */
  58574. private getFloat32ArrayFromArrayBuffer;
  58575. /**
  58576. * Get the current class name of the texture useful for serialization or dynamic coding.
  58577. * @returns "EquiRectangularCubeTexture"
  58578. */
  58579. getClassName(): string;
  58580. /**
  58581. * Create a clone of the current EquiRectangularCubeTexture and return it.
  58582. * @returns A clone of the current EquiRectangularCubeTexture.
  58583. */
  58584. clone(): EquiRectangularCubeTexture;
  58585. }
  58586. }
  58587. declare module "babylonjs/Misc/tga" {
  58588. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58589. /**
  58590. * Based on jsTGALoader - Javascript loader for TGA file
  58591. * By Vincent Thibault
  58592. * @see http://blog.robrowser.com/javascript-tga-loader.html
  58593. */
  58594. export class TGATools {
  58595. private static _TYPE_INDEXED;
  58596. private static _TYPE_RGB;
  58597. private static _TYPE_GREY;
  58598. private static _TYPE_RLE_INDEXED;
  58599. private static _TYPE_RLE_RGB;
  58600. private static _TYPE_RLE_GREY;
  58601. private static _ORIGIN_MASK;
  58602. private static _ORIGIN_SHIFT;
  58603. private static _ORIGIN_BL;
  58604. private static _ORIGIN_BR;
  58605. private static _ORIGIN_UL;
  58606. private static _ORIGIN_UR;
  58607. /**
  58608. * Gets the header of a TGA file
  58609. * @param data defines the TGA data
  58610. * @returns the header
  58611. */
  58612. static GetTGAHeader(data: Uint8Array): any;
  58613. /**
  58614. * Uploads TGA content to a Babylon Texture
  58615. * @hidden
  58616. */
  58617. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  58618. /** @hidden */
  58619. 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;
  58620. /** @hidden */
  58621. 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;
  58622. /** @hidden */
  58623. 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;
  58624. /** @hidden */
  58625. 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;
  58626. /** @hidden */
  58627. 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;
  58628. /** @hidden */
  58629. 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;
  58630. }
  58631. }
  58632. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  58633. import { Nullable } from "babylonjs/types";
  58634. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58635. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58636. /**
  58637. * Implementation of the TGA Texture Loader.
  58638. * @hidden
  58639. */
  58640. export class _TGATextureLoader implements IInternalTextureLoader {
  58641. /**
  58642. * Defines wether the loader supports cascade loading the different faces.
  58643. */
  58644. readonly supportCascades: boolean;
  58645. /**
  58646. * This returns if the loader support the current file information.
  58647. * @param extension defines the file extension of the file being loaded
  58648. * @returns true if the loader can load the specified file
  58649. */
  58650. canLoad(extension: string): boolean;
  58651. /**
  58652. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58653. * @param data contains the texture data
  58654. * @param texture defines the BabylonJS internal texture
  58655. * @param createPolynomials will be true if polynomials have been requested
  58656. * @param onLoad defines the callback to trigger once the texture is ready
  58657. * @param onError defines the callback to trigger in case of error
  58658. */
  58659. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58660. /**
  58661. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58662. * @param data contains the texture data
  58663. * @param texture defines the BabylonJS internal texture
  58664. * @param callback defines the method to call once ready to upload
  58665. */
  58666. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58667. }
  58668. }
  58669. declare module "babylonjs/Misc/basis" {
  58670. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58671. /**
  58672. * Info about the .basis files
  58673. */
  58674. class BasisFileInfo {
  58675. /**
  58676. * If the file has alpha
  58677. */
  58678. hasAlpha: boolean;
  58679. /**
  58680. * Info about each image of the basis file
  58681. */
  58682. images: Array<{
  58683. levels: Array<{
  58684. width: number;
  58685. height: number;
  58686. transcodedPixels: ArrayBufferView;
  58687. }>;
  58688. }>;
  58689. }
  58690. /**
  58691. * Result of transcoding a basis file
  58692. */
  58693. class TranscodeResult {
  58694. /**
  58695. * Info about the .basis file
  58696. */
  58697. fileInfo: BasisFileInfo;
  58698. /**
  58699. * Format to use when loading the file
  58700. */
  58701. format: number;
  58702. }
  58703. /**
  58704. * Configuration options for the Basis transcoder
  58705. */
  58706. export class BasisTranscodeConfiguration {
  58707. /**
  58708. * Supported compression formats used to determine the supported output format of the transcoder
  58709. */
  58710. supportedCompressionFormats?: {
  58711. /**
  58712. * etc1 compression format
  58713. */
  58714. etc1?: boolean;
  58715. /**
  58716. * s3tc compression format
  58717. */
  58718. s3tc?: boolean;
  58719. /**
  58720. * pvrtc compression format
  58721. */
  58722. pvrtc?: boolean;
  58723. /**
  58724. * etc2 compression format
  58725. */
  58726. etc2?: boolean;
  58727. };
  58728. /**
  58729. * If mipmap levels should be loaded for transcoded images (Default: true)
  58730. */
  58731. loadMipmapLevels?: boolean;
  58732. /**
  58733. * Index of a single image to load (Default: all images)
  58734. */
  58735. loadSingleImage?: number;
  58736. }
  58737. /**
  58738. * Used to load .Basis files
  58739. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  58740. */
  58741. export class BasisTools {
  58742. private static _IgnoreSupportedFormats;
  58743. /**
  58744. * URL to use when loading the basis transcoder
  58745. */
  58746. static JSModuleURL: string;
  58747. /**
  58748. * URL to use when loading the wasm module for the transcoder
  58749. */
  58750. static WasmModuleURL: string;
  58751. /**
  58752. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  58753. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  58754. * @returns internal format corresponding to the Basis format
  58755. */
  58756. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  58757. private static _WorkerPromise;
  58758. private static _Worker;
  58759. private static _actionId;
  58760. private static _CreateWorkerAsync;
  58761. /**
  58762. * Transcodes a loaded image file to compressed pixel data
  58763. * @param data image data to transcode
  58764. * @param config configuration options for the transcoding
  58765. * @returns a promise resulting in the transcoded image
  58766. */
  58767. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  58768. /**
  58769. * Loads a texture from the transcode result
  58770. * @param texture texture load to
  58771. * @param transcodeResult the result of transcoding the basis file to load from
  58772. */
  58773. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  58774. }
  58775. }
  58776. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  58777. import { Nullable } from "babylonjs/types";
  58778. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58779. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58780. /**
  58781. * Loader for .basis file format
  58782. */
  58783. export class _BasisTextureLoader implements IInternalTextureLoader {
  58784. /**
  58785. * Defines whether the loader supports cascade loading the different faces.
  58786. */
  58787. readonly supportCascades: boolean;
  58788. /**
  58789. * This returns if the loader support the current file information.
  58790. * @param extension defines the file extension of the file being loaded
  58791. * @returns true if the loader can load the specified file
  58792. */
  58793. canLoad(extension: string): boolean;
  58794. /**
  58795. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58796. * @param data contains the texture data
  58797. * @param texture defines the BabylonJS internal texture
  58798. * @param createPolynomials will be true if polynomials have been requested
  58799. * @param onLoad defines the callback to trigger once the texture is ready
  58800. * @param onError defines the callback to trigger in case of error
  58801. */
  58802. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58803. /**
  58804. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58805. * @param data contains the texture data
  58806. * @param texture defines the BabylonJS internal texture
  58807. * @param callback defines the method to call once ready to upload
  58808. */
  58809. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58810. }
  58811. }
  58812. declare module "babylonjs/Materials/Textures/Loaders/index" {
  58813. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  58814. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  58815. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  58816. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  58817. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  58818. }
  58819. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  58820. import { Scene } from "babylonjs/scene";
  58821. import { Texture } from "babylonjs/Materials/Textures/texture";
  58822. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58823. /**
  58824. * 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.
  58825. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58826. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58827. */
  58828. export class CustomProceduralTexture extends ProceduralTexture {
  58829. private _animate;
  58830. private _time;
  58831. private _config;
  58832. private _texturePath;
  58833. /**
  58834. * Instantiates a new Custom Procedural Texture.
  58835. * 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.
  58836. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58837. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58838. * @param name Define the name of the texture
  58839. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  58840. * @param size Define the size of the texture to create
  58841. * @param scene Define the scene the texture belongs to
  58842. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  58843. * @param generateMipMaps Define if the texture should creates mip maps or not
  58844. */
  58845. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58846. private _loadJson;
  58847. /**
  58848. * Is the texture ready to be used ? (rendered at least once)
  58849. * @returns true if ready, otherwise, false.
  58850. */
  58851. isReady(): boolean;
  58852. /**
  58853. * Render the texture to its associated render target.
  58854. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  58855. */
  58856. render(useCameraPostProcess?: boolean): void;
  58857. /**
  58858. * Update the list of dependant textures samplers in the shader.
  58859. */
  58860. updateTextures(): void;
  58861. /**
  58862. * Update the uniform values of the procedural texture in the shader.
  58863. */
  58864. updateShaderUniforms(): void;
  58865. /**
  58866. * Define if the texture animates or not.
  58867. */
  58868. get animate(): boolean;
  58869. set animate(value: boolean);
  58870. }
  58871. }
  58872. declare module "babylonjs/Shaders/noise.fragment" {
  58873. /** @hidden */
  58874. export var noisePixelShader: {
  58875. name: string;
  58876. shader: string;
  58877. };
  58878. }
  58879. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  58880. import { Nullable } from "babylonjs/types";
  58881. import { Scene } from "babylonjs/scene";
  58882. import { Texture } from "babylonjs/Materials/Textures/texture";
  58883. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58884. import "babylonjs/Shaders/noise.fragment";
  58885. /**
  58886. * Class used to generate noise procedural textures
  58887. */
  58888. export class NoiseProceduralTexture extends ProceduralTexture {
  58889. private _time;
  58890. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  58891. brightness: number;
  58892. /** Defines the number of octaves to process */
  58893. octaves: number;
  58894. /** Defines the level of persistence (0.8 by default) */
  58895. persistence: number;
  58896. /** Gets or sets animation speed factor (default is 1) */
  58897. animationSpeedFactor: number;
  58898. /**
  58899. * Creates a new NoiseProceduralTexture
  58900. * @param name defines the name fo the texture
  58901. * @param size defines the size of the texture (default is 256)
  58902. * @param scene defines the hosting scene
  58903. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  58904. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  58905. */
  58906. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58907. private _updateShaderUniforms;
  58908. protected _getDefines(): string;
  58909. /** Generate the current state of the procedural texture */
  58910. render(useCameraPostProcess?: boolean): void;
  58911. /**
  58912. * Serializes this noise procedural texture
  58913. * @returns a serialized noise procedural texture object
  58914. */
  58915. serialize(): any;
  58916. /**
  58917. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  58918. * @param parsedTexture defines parsed texture data
  58919. * @param scene defines the current scene
  58920. * @param rootUrl defines the root URL containing noise procedural texture information
  58921. * @returns a parsed NoiseProceduralTexture
  58922. */
  58923. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  58924. }
  58925. }
  58926. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  58927. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  58928. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  58929. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58930. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  58931. }
  58932. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  58933. import { Nullable } from "babylonjs/types";
  58934. import { Scene } from "babylonjs/scene";
  58935. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58936. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58937. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  58938. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58939. /**
  58940. * Raw cube texture where the raw buffers are passed in
  58941. */
  58942. export class RawCubeTexture extends CubeTexture {
  58943. /**
  58944. * Creates a cube texture where the raw buffers are passed in.
  58945. * @param scene defines the scene the texture is attached to
  58946. * @param data defines the array of data to use to create each face
  58947. * @param size defines the size of the textures
  58948. * @param format defines the format of the data
  58949. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  58950. * @param generateMipMaps defines if the engine should generate the mip levels
  58951. * @param invertY defines if data must be stored with Y axis inverted
  58952. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  58953. * @param compression defines the compression used (null by default)
  58954. */
  58955. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  58956. /**
  58957. * Updates the raw cube texture.
  58958. * @param data defines the data to store
  58959. * @param format defines the data format
  58960. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  58961. * @param invertY defines if data must be stored with Y axis inverted
  58962. * @param compression defines the compression used (null by default)
  58963. * @param level defines which level of the texture to update
  58964. */
  58965. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  58966. /**
  58967. * Updates a raw cube texture with RGBD encoded data.
  58968. * @param data defines the array of data [mipmap][face] to use to create each face
  58969. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  58970. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  58971. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  58972. * @returns a promsie that resolves when the operation is complete
  58973. */
  58974. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  58975. /**
  58976. * Clones the raw cube texture.
  58977. * @return a new cube texture
  58978. */
  58979. clone(): CubeTexture;
  58980. /** @hidden */
  58981. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  58982. }
  58983. }
  58984. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  58985. import { Scene } from "babylonjs/scene";
  58986. import { Texture } from "babylonjs/Materials/Textures/texture";
  58987. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58988. /**
  58989. * Class used to store 3D textures containing user data
  58990. */
  58991. export class RawTexture3D extends Texture {
  58992. /** Gets or sets the texture format to use */
  58993. format: number;
  58994. private _engine;
  58995. /**
  58996. * Create a new RawTexture3D
  58997. * @param data defines the data of the texture
  58998. * @param width defines the width of the texture
  58999. * @param height defines the height of the texture
  59000. * @param depth defines the depth of the texture
  59001. * @param format defines the texture format to use
  59002. * @param scene defines the hosting scene
  59003. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59004. * @param invertY defines if texture must be stored with Y axis inverted
  59005. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59006. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59007. */
  59008. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  59009. /** Gets or sets the texture format to use */
  59010. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  59011. /**
  59012. * Update the texture with new data
  59013. * @param data defines the data to store in the texture
  59014. */
  59015. update(data: ArrayBufferView): void;
  59016. }
  59017. }
  59018. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  59019. import { Scene } from "babylonjs/scene";
  59020. import { Texture } from "babylonjs/Materials/Textures/texture";
  59021. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59022. /**
  59023. * Class used to store 2D array textures containing user data
  59024. */
  59025. export class RawTexture2DArray extends Texture {
  59026. /** Gets or sets the texture format to use */
  59027. format: number;
  59028. private _engine;
  59029. /**
  59030. * Create a new RawTexture2DArray
  59031. * @param data defines the data of the texture
  59032. * @param width defines the width of the texture
  59033. * @param height defines the height of the texture
  59034. * @param depth defines the number of layers of the texture
  59035. * @param format defines the texture format to use
  59036. * @param scene defines the hosting scene
  59037. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59038. * @param invertY defines if texture must be stored with Y axis inverted
  59039. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59040. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59041. */
  59042. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  59043. /** Gets or sets the texture format to use */
  59044. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  59045. /**
  59046. * Update the texture with new data
  59047. * @param data defines the data to store in the texture
  59048. */
  59049. update(data: ArrayBufferView): void;
  59050. }
  59051. }
  59052. declare module "babylonjs/Materials/Textures/refractionTexture" {
  59053. import { Scene } from "babylonjs/scene";
  59054. import { Plane } from "babylonjs/Maths/math.plane";
  59055. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59056. /**
  59057. * Creates a refraction texture used by refraction channel of the standard material.
  59058. * It is like a mirror but to see through a material.
  59059. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59060. */
  59061. export class RefractionTexture extends RenderTargetTexture {
  59062. /**
  59063. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  59064. * 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.
  59065. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59066. */
  59067. refractionPlane: Plane;
  59068. /**
  59069. * Define how deep under the surface we should see.
  59070. */
  59071. depth: number;
  59072. /**
  59073. * Creates a refraction texture used by refraction channel of the standard material.
  59074. * It is like a mirror but to see through a material.
  59075. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59076. * @param name Define the texture name
  59077. * @param size Define the size of the underlying texture
  59078. * @param scene Define the scene the refraction belongs to
  59079. * @param generateMipMaps Define if we need to generate mips level for the refraction
  59080. */
  59081. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  59082. /**
  59083. * Clone the refraction texture.
  59084. * @returns the cloned texture
  59085. */
  59086. clone(): RefractionTexture;
  59087. /**
  59088. * Serialize the texture to a JSON representation you could use in Parse later on
  59089. * @returns the serialized JSON representation
  59090. */
  59091. serialize(): any;
  59092. }
  59093. }
  59094. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  59095. import { Nullable } from "babylonjs/types";
  59096. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59097. import { Matrix } from "babylonjs/Maths/math.vector";
  59098. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  59099. import "babylonjs/Engines/Extensions/engine.videoTexture";
  59100. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59101. import { Scene } from "babylonjs/scene";
  59102. /**
  59103. * Defines the options related to the creation of an HtmlElementTexture
  59104. */
  59105. export interface IHtmlElementTextureOptions {
  59106. /**
  59107. * Defines wether mip maps should be created or not.
  59108. */
  59109. generateMipMaps?: boolean;
  59110. /**
  59111. * Defines the sampling mode of the texture.
  59112. */
  59113. samplingMode?: number;
  59114. /**
  59115. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  59116. */
  59117. engine: Nullable<ThinEngine>;
  59118. /**
  59119. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  59120. */
  59121. scene: Nullable<Scene>;
  59122. }
  59123. /**
  59124. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  59125. * To be as efficient as possible depending on your constraints nothing aside the first upload
  59126. * is automatically managed.
  59127. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  59128. * in your application.
  59129. *
  59130. * As the update is not automatic, you need to call them manually.
  59131. */
  59132. export class HtmlElementTexture extends BaseTexture {
  59133. /**
  59134. * The texture URL.
  59135. */
  59136. element: HTMLVideoElement | HTMLCanvasElement;
  59137. private static readonly DefaultOptions;
  59138. private _textureMatrix;
  59139. private _engine;
  59140. private _isVideo;
  59141. private _generateMipMaps;
  59142. private _samplingMode;
  59143. /**
  59144. * Instantiates a HtmlElementTexture from the following parameters.
  59145. *
  59146. * @param name Defines the name of the texture
  59147. * @param element Defines the video or canvas the texture is filled with
  59148. * @param options Defines the other none mandatory texture creation options
  59149. */
  59150. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  59151. private _createInternalTexture;
  59152. /**
  59153. * Returns the texture matrix used in most of the material.
  59154. */
  59155. getTextureMatrix(): Matrix;
  59156. /**
  59157. * Updates the content of the texture.
  59158. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  59159. */
  59160. update(invertY?: Nullable<boolean>): void;
  59161. }
  59162. }
  59163. declare module "babylonjs/Materials/Textures/Packer/frame" {
  59164. import { Vector2 } from "babylonjs/Maths/math.vector";
  59165. /**
  59166. * Defines the basic options interface of a TexturePacker Frame
  59167. */
  59168. export interface ITexturePackerFrame {
  59169. /**
  59170. * The frame ID
  59171. */
  59172. id: number;
  59173. /**
  59174. * The frames Scale
  59175. */
  59176. scale: Vector2;
  59177. /**
  59178. * The Frames offset
  59179. */
  59180. offset: Vector2;
  59181. }
  59182. /**
  59183. * This is a support class for frame Data on texture packer sets.
  59184. */
  59185. export class TexturePackerFrame implements ITexturePackerFrame {
  59186. /**
  59187. * The frame ID
  59188. */
  59189. id: number;
  59190. /**
  59191. * The frames Scale
  59192. */
  59193. scale: Vector2;
  59194. /**
  59195. * The Frames offset
  59196. */
  59197. offset: Vector2;
  59198. /**
  59199. * Initializes a texture package frame.
  59200. * @param id The numerical frame identifier
  59201. * @param scale Scalar Vector2 for UV frame
  59202. * @param offset Vector2 for the frame position in UV units.
  59203. * @returns TexturePackerFrame
  59204. */
  59205. constructor(id: number, scale: Vector2, offset: Vector2);
  59206. }
  59207. }
  59208. declare module "babylonjs/Materials/Textures/Packer/packer" {
  59209. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59210. import { Scene } from "babylonjs/scene";
  59211. import { Nullable } from "babylonjs/types";
  59212. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  59213. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  59214. /**
  59215. * Defines the basic options interface of a TexturePacker
  59216. */
  59217. export interface ITexturePackerOptions {
  59218. /**
  59219. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  59220. */
  59221. map?: string[];
  59222. /**
  59223. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59224. */
  59225. uvsIn?: string;
  59226. /**
  59227. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59228. */
  59229. uvsOut?: string;
  59230. /**
  59231. * number representing the layout style. Defaults to LAYOUT_STRIP
  59232. */
  59233. layout?: number;
  59234. /**
  59235. * number of columns if using custom column count layout(2). This defaults to 4.
  59236. */
  59237. colnum?: number;
  59238. /**
  59239. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  59240. */
  59241. updateInputMeshes?: boolean;
  59242. /**
  59243. * boolean flag to dispose all the source textures. Defaults to true.
  59244. */
  59245. disposeSources?: boolean;
  59246. /**
  59247. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  59248. */
  59249. fillBlanks?: boolean;
  59250. /**
  59251. * string value representing the context fill style color. Defaults to 'black'.
  59252. */
  59253. customFillColor?: string;
  59254. /**
  59255. * Width and Height Value of each Frame in the TexturePacker Sets
  59256. */
  59257. frameSize?: number;
  59258. /**
  59259. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  59260. */
  59261. paddingRatio?: number;
  59262. /**
  59263. * Number that declares the fill method for the padding gutter.
  59264. */
  59265. paddingMode?: number;
  59266. /**
  59267. * If in SUBUV_COLOR padding mode what color to use.
  59268. */
  59269. paddingColor?: Color3 | Color4;
  59270. }
  59271. /**
  59272. * Defines the basic interface of a TexturePacker JSON File
  59273. */
  59274. export interface ITexturePackerJSON {
  59275. /**
  59276. * The frame ID
  59277. */
  59278. name: string;
  59279. /**
  59280. * The base64 channel data
  59281. */
  59282. sets: any;
  59283. /**
  59284. * The options of the Packer
  59285. */
  59286. options: ITexturePackerOptions;
  59287. /**
  59288. * The frame data of the Packer
  59289. */
  59290. frames: Array<number>;
  59291. }
  59292. /**
  59293. * This is a support class that generates a series of packed texture sets.
  59294. * @see https://doc.babylonjs.com/babylon101/materials
  59295. */
  59296. export class TexturePacker {
  59297. /** Packer Layout Constant 0 */
  59298. static readonly LAYOUT_STRIP: number;
  59299. /** Packer Layout Constant 1 */
  59300. static readonly LAYOUT_POWER2: number;
  59301. /** Packer Layout Constant 2 */
  59302. static readonly LAYOUT_COLNUM: number;
  59303. /** Packer Layout Constant 0 */
  59304. static readonly SUBUV_WRAP: number;
  59305. /** Packer Layout Constant 1 */
  59306. static readonly SUBUV_EXTEND: number;
  59307. /** Packer Layout Constant 2 */
  59308. static readonly SUBUV_COLOR: number;
  59309. /** The Name of the Texture Package */
  59310. name: string;
  59311. /** The scene scope of the TexturePacker */
  59312. scene: Scene;
  59313. /** The Meshes to target */
  59314. meshes: AbstractMesh[];
  59315. /** Arguments passed with the Constructor */
  59316. options: ITexturePackerOptions;
  59317. /** The promise that is started upon initialization */
  59318. promise: Nullable<Promise<TexturePacker | string>>;
  59319. /** The Container object for the channel sets that are generated */
  59320. sets: object;
  59321. /** The Container array for the frames that are generated */
  59322. frames: TexturePackerFrame[];
  59323. /** The expected number of textures the system is parsing. */
  59324. private _expecting;
  59325. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  59326. private _paddingValue;
  59327. /**
  59328. * Initializes a texture package series from an array of meshes or a single mesh.
  59329. * @param name The name of the package
  59330. * @param meshes The target meshes to compose the package from
  59331. * @param options The arguments that texture packer should follow while building.
  59332. * @param scene The scene which the textures are scoped to.
  59333. * @returns TexturePacker
  59334. */
  59335. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  59336. /**
  59337. * Starts the package process
  59338. * @param resolve The promises resolution function
  59339. * @returns TexturePacker
  59340. */
  59341. private _createFrames;
  59342. /**
  59343. * Calculates the Size of the Channel Sets
  59344. * @returns Vector2
  59345. */
  59346. private _calculateSize;
  59347. /**
  59348. * Calculates the UV data for the frames.
  59349. * @param baseSize the base frameSize
  59350. * @param padding the base frame padding
  59351. * @param dtSize size of the Dynamic Texture for that channel
  59352. * @param dtUnits is 1/dtSize
  59353. * @param update flag to update the input meshes
  59354. */
  59355. private _calculateMeshUVFrames;
  59356. /**
  59357. * Calculates the frames Offset.
  59358. * @param index of the frame
  59359. * @returns Vector2
  59360. */
  59361. private _getFrameOffset;
  59362. /**
  59363. * Updates a Mesh to the frame data
  59364. * @param mesh that is the target
  59365. * @param frameID or the frame index
  59366. */
  59367. private _updateMeshUV;
  59368. /**
  59369. * Updates a Meshes materials to use the texture packer channels
  59370. * @param m is the mesh to target
  59371. * @param force all channels on the packer to be set.
  59372. */
  59373. private _updateTextureReferences;
  59374. /**
  59375. * Public method to set a Mesh to a frame
  59376. * @param m that is the target
  59377. * @param frameID or the frame index
  59378. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  59379. */
  59380. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  59381. /**
  59382. * Starts the async promise to compile the texture packer.
  59383. * @returns Promise<void>
  59384. */
  59385. processAsync(): Promise<void>;
  59386. /**
  59387. * Disposes all textures associated with this packer
  59388. */
  59389. dispose(): void;
  59390. /**
  59391. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  59392. * @param imageType is the image type to use.
  59393. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  59394. */
  59395. download(imageType?: string, quality?: number): void;
  59396. /**
  59397. * Public method to load a texturePacker JSON file.
  59398. * @param data of the JSON file in string format.
  59399. */
  59400. updateFromJSON(data: string): void;
  59401. }
  59402. }
  59403. declare module "babylonjs/Materials/Textures/Packer/index" {
  59404. export * from "babylonjs/Materials/Textures/Packer/packer";
  59405. export * from "babylonjs/Materials/Textures/Packer/frame";
  59406. }
  59407. declare module "babylonjs/Materials/Textures/index" {
  59408. export * from "babylonjs/Materials/Textures/baseTexture";
  59409. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  59410. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  59411. export * from "babylonjs/Materials/Textures/cubeTexture";
  59412. export * from "babylonjs/Materials/Textures/dynamicTexture";
  59413. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  59414. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  59415. export * from "babylonjs/Materials/Textures/internalTexture";
  59416. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  59417. export * from "babylonjs/Materials/Textures/Loaders/index";
  59418. export * from "babylonjs/Materials/Textures/mirrorTexture";
  59419. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  59420. export * from "babylonjs/Materials/Textures/Procedurals/index";
  59421. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  59422. export * from "babylonjs/Materials/Textures/rawTexture";
  59423. export * from "babylonjs/Materials/Textures/rawTexture3D";
  59424. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  59425. export * from "babylonjs/Materials/Textures/refractionTexture";
  59426. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  59427. export * from "babylonjs/Materials/Textures/texture";
  59428. export * from "babylonjs/Materials/Textures/videoTexture";
  59429. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  59430. export * from "babylonjs/Materials/Textures/Packer/index";
  59431. }
  59432. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  59433. /**
  59434. * Enum used to define the target of a block
  59435. */
  59436. export enum NodeMaterialBlockTargets {
  59437. /** Vertex shader */
  59438. Vertex = 1,
  59439. /** Fragment shader */
  59440. Fragment = 2,
  59441. /** Neutral */
  59442. Neutral = 4,
  59443. /** Vertex and Fragment */
  59444. VertexAndFragment = 3
  59445. }
  59446. }
  59447. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  59448. /**
  59449. * Defines the kind of connection point for node based material
  59450. */
  59451. export enum NodeMaterialBlockConnectionPointTypes {
  59452. /** Float */
  59453. Float = 1,
  59454. /** Int */
  59455. Int = 2,
  59456. /** Vector2 */
  59457. Vector2 = 4,
  59458. /** Vector3 */
  59459. Vector3 = 8,
  59460. /** Vector4 */
  59461. Vector4 = 16,
  59462. /** Color3 */
  59463. Color3 = 32,
  59464. /** Color4 */
  59465. Color4 = 64,
  59466. /** Matrix */
  59467. Matrix = 128,
  59468. /** Detect type based on connection */
  59469. AutoDetect = 1024,
  59470. /** Output type that will be defined by input type */
  59471. BasedOnInput = 2048
  59472. }
  59473. }
  59474. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  59475. /**
  59476. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  59477. */
  59478. export enum NodeMaterialBlockConnectionPointMode {
  59479. /** Value is an uniform */
  59480. Uniform = 0,
  59481. /** Value is a mesh attribute */
  59482. Attribute = 1,
  59483. /** Value is a varying between vertex and fragment shaders */
  59484. Varying = 2,
  59485. /** Mode is undefined */
  59486. Undefined = 3
  59487. }
  59488. }
  59489. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  59490. /**
  59491. * Enum used to define system values e.g. values automatically provided by the system
  59492. */
  59493. export enum NodeMaterialSystemValues {
  59494. /** World */
  59495. World = 1,
  59496. /** View */
  59497. View = 2,
  59498. /** Projection */
  59499. Projection = 3,
  59500. /** ViewProjection */
  59501. ViewProjection = 4,
  59502. /** WorldView */
  59503. WorldView = 5,
  59504. /** WorldViewProjection */
  59505. WorldViewProjection = 6,
  59506. /** CameraPosition */
  59507. CameraPosition = 7,
  59508. /** Fog Color */
  59509. FogColor = 8,
  59510. /** Delta time */
  59511. DeltaTime = 9
  59512. }
  59513. }
  59514. declare module "babylonjs/Materials/Node/Enums/index" {
  59515. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59516. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59517. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  59518. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  59519. }
  59520. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  59521. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59522. /**
  59523. * Root class for all node material optimizers
  59524. */
  59525. export class NodeMaterialOptimizer {
  59526. /**
  59527. * Function used to optimize a NodeMaterial graph
  59528. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  59529. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  59530. */
  59531. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  59532. }
  59533. }
  59534. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  59535. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59536. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59537. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59538. import { Scene } from "babylonjs/scene";
  59539. /**
  59540. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  59541. */
  59542. export class TransformBlock extends NodeMaterialBlock {
  59543. /**
  59544. * Defines the value to use to complement W value to transform it to a Vector4
  59545. */
  59546. complementW: number;
  59547. /**
  59548. * Defines the value to use to complement z value to transform it to a Vector4
  59549. */
  59550. complementZ: number;
  59551. /**
  59552. * Creates a new TransformBlock
  59553. * @param name defines the block name
  59554. */
  59555. constructor(name: string);
  59556. /**
  59557. * Gets the current class name
  59558. * @returns the class name
  59559. */
  59560. getClassName(): string;
  59561. /**
  59562. * Gets the vector input
  59563. */
  59564. get vector(): NodeMaterialConnectionPoint;
  59565. /**
  59566. * Gets the output component
  59567. */
  59568. get output(): NodeMaterialConnectionPoint;
  59569. /**
  59570. * Gets the xyz output component
  59571. */
  59572. get xyz(): NodeMaterialConnectionPoint;
  59573. /**
  59574. * Gets the matrix transform input
  59575. */
  59576. get transform(): NodeMaterialConnectionPoint;
  59577. protected _buildBlock(state: NodeMaterialBuildState): this;
  59578. serialize(): any;
  59579. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59580. protected _dumpPropertiesCode(): string;
  59581. }
  59582. }
  59583. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  59584. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59585. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59586. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59587. /**
  59588. * Block used to output the vertex position
  59589. */
  59590. export class VertexOutputBlock extends NodeMaterialBlock {
  59591. /**
  59592. * Creates a new VertexOutputBlock
  59593. * @param name defines the block name
  59594. */
  59595. constructor(name: string);
  59596. /**
  59597. * Gets the current class name
  59598. * @returns the class name
  59599. */
  59600. getClassName(): string;
  59601. /**
  59602. * Gets the vector input component
  59603. */
  59604. get vector(): NodeMaterialConnectionPoint;
  59605. protected _buildBlock(state: NodeMaterialBuildState): this;
  59606. }
  59607. }
  59608. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  59609. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59610. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59611. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59612. /**
  59613. * Block used to output the final color
  59614. */
  59615. export class FragmentOutputBlock extends NodeMaterialBlock {
  59616. /**
  59617. * Create a new FragmentOutputBlock
  59618. * @param name defines the block name
  59619. */
  59620. constructor(name: string);
  59621. /**
  59622. * Gets the current class name
  59623. * @returns the class name
  59624. */
  59625. getClassName(): string;
  59626. /**
  59627. * Gets the rgba input component
  59628. */
  59629. get rgba(): NodeMaterialConnectionPoint;
  59630. /**
  59631. * Gets the rgb input component
  59632. */
  59633. get rgb(): NodeMaterialConnectionPoint;
  59634. /**
  59635. * Gets the a input component
  59636. */
  59637. get a(): NodeMaterialConnectionPoint;
  59638. protected _buildBlock(state: NodeMaterialBuildState): this;
  59639. }
  59640. }
  59641. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  59642. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59643. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59644. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59645. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59646. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59647. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59648. import { Effect } from "babylonjs/Materials/effect";
  59649. import { Mesh } from "babylonjs/Meshes/mesh";
  59650. import { Nullable } from "babylonjs/types";
  59651. import { Scene } from "babylonjs/scene";
  59652. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  59653. /**
  59654. * Block used to read a reflection texture from a sampler
  59655. */
  59656. export class ReflectionTextureBlock extends NodeMaterialBlock {
  59657. private _define3DName;
  59658. private _defineCubicName;
  59659. private _defineExplicitName;
  59660. private _defineProjectionName;
  59661. private _defineLocalCubicName;
  59662. private _defineSphericalName;
  59663. private _definePlanarName;
  59664. private _defineEquirectangularName;
  59665. private _defineMirroredEquirectangularFixedName;
  59666. private _defineEquirectangularFixedName;
  59667. private _defineSkyboxName;
  59668. private _cubeSamplerName;
  59669. private _2DSamplerName;
  59670. private _positionUVWName;
  59671. private _directionWName;
  59672. private _reflectionCoordsName;
  59673. private _reflection2DCoordsName;
  59674. private _reflectionColorName;
  59675. private _reflectionMatrixName;
  59676. /**
  59677. * Gets or sets the texture associated with the node
  59678. */
  59679. texture: Nullable<BaseTexture>;
  59680. /**
  59681. * Create a new TextureBlock
  59682. * @param name defines the block name
  59683. */
  59684. constructor(name: string);
  59685. /**
  59686. * Gets the current class name
  59687. * @returns the class name
  59688. */
  59689. getClassName(): string;
  59690. /**
  59691. * Gets the world position input component
  59692. */
  59693. get position(): NodeMaterialConnectionPoint;
  59694. /**
  59695. * Gets the world position input component
  59696. */
  59697. get worldPosition(): NodeMaterialConnectionPoint;
  59698. /**
  59699. * Gets the world normal input component
  59700. */
  59701. get worldNormal(): NodeMaterialConnectionPoint;
  59702. /**
  59703. * Gets the world input component
  59704. */
  59705. get world(): NodeMaterialConnectionPoint;
  59706. /**
  59707. * Gets the camera (or eye) position component
  59708. */
  59709. get cameraPosition(): NodeMaterialConnectionPoint;
  59710. /**
  59711. * Gets the view input component
  59712. */
  59713. get view(): NodeMaterialConnectionPoint;
  59714. /**
  59715. * Gets the rgb output component
  59716. */
  59717. get rgb(): NodeMaterialConnectionPoint;
  59718. /**
  59719. * Gets the r output component
  59720. */
  59721. get r(): NodeMaterialConnectionPoint;
  59722. /**
  59723. * Gets the g output component
  59724. */
  59725. get g(): NodeMaterialConnectionPoint;
  59726. /**
  59727. * Gets the b output component
  59728. */
  59729. get b(): NodeMaterialConnectionPoint;
  59730. autoConfigure(material: NodeMaterial): void;
  59731. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59732. isReady(): boolean;
  59733. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59734. private _injectVertexCode;
  59735. private _writeOutput;
  59736. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59737. protected _dumpPropertiesCode(): string;
  59738. serialize(): any;
  59739. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59740. }
  59741. }
  59742. declare module "babylonjs/Materials/Node/nodeMaterial" {
  59743. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59744. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59745. import { Scene } from "babylonjs/scene";
  59746. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59747. import { Matrix } from "babylonjs/Maths/math.vector";
  59748. import { Mesh } from "babylonjs/Meshes/mesh";
  59749. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59750. import { Observable } from "babylonjs/Misc/observable";
  59751. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59752. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  59753. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59754. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  59755. import { Nullable } from "babylonjs/types";
  59756. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59757. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59758. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59759. /**
  59760. * Interface used to configure the node material editor
  59761. */
  59762. export interface INodeMaterialEditorOptions {
  59763. /** Define the URl to load node editor script */
  59764. editorURL?: string;
  59765. }
  59766. /** @hidden */
  59767. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  59768. NORMAL: boolean;
  59769. TANGENT: boolean;
  59770. UV1: boolean;
  59771. /** BONES */
  59772. NUM_BONE_INFLUENCERS: number;
  59773. BonesPerMesh: number;
  59774. BONETEXTURE: boolean;
  59775. /** MORPH TARGETS */
  59776. MORPHTARGETS: boolean;
  59777. MORPHTARGETS_NORMAL: boolean;
  59778. MORPHTARGETS_TANGENT: boolean;
  59779. MORPHTARGETS_UV: boolean;
  59780. NUM_MORPH_INFLUENCERS: number;
  59781. /** IMAGE PROCESSING */
  59782. IMAGEPROCESSING: boolean;
  59783. VIGNETTE: boolean;
  59784. VIGNETTEBLENDMODEMULTIPLY: boolean;
  59785. VIGNETTEBLENDMODEOPAQUE: boolean;
  59786. TONEMAPPING: boolean;
  59787. TONEMAPPING_ACES: boolean;
  59788. CONTRAST: boolean;
  59789. EXPOSURE: boolean;
  59790. COLORCURVES: boolean;
  59791. COLORGRADING: boolean;
  59792. COLORGRADING3D: boolean;
  59793. SAMPLER3DGREENDEPTH: boolean;
  59794. SAMPLER3DBGRMAP: boolean;
  59795. IMAGEPROCESSINGPOSTPROCESS: boolean;
  59796. /** MISC. */
  59797. BUMPDIRECTUV: number;
  59798. constructor();
  59799. setValue(name: string, value: boolean): void;
  59800. }
  59801. /**
  59802. * Class used to configure NodeMaterial
  59803. */
  59804. export interface INodeMaterialOptions {
  59805. /**
  59806. * Defines if blocks should emit comments
  59807. */
  59808. emitComments: boolean;
  59809. }
  59810. /**
  59811. * Class used to create a node based material built by assembling shader blocks
  59812. */
  59813. export class NodeMaterial extends PushMaterial {
  59814. private static _BuildIdGenerator;
  59815. private _options;
  59816. private _vertexCompilationState;
  59817. private _fragmentCompilationState;
  59818. private _sharedData;
  59819. private _buildId;
  59820. private _buildWasSuccessful;
  59821. private _cachedWorldViewMatrix;
  59822. private _cachedWorldViewProjectionMatrix;
  59823. private _optimizers;
  59824. private _animationFrame;
  59825. /** Define the Url to load node editor script */
  59826. static EditorURL: string;
  59827. /** Define the Url to load snippets */
  59828. static SnippetUrl: string;
  59829. private BJSNODEMATERIALEDITOR;
  59830. /** Get the inspector from bundle or global */
  59831. private _getGlobalNodeMaterialEditor;
  59832. /**
  59833. * Gets or sets data used by visual editor
  59834. * @see https://nme.babylonjs.com
  59835. */
  59836. editorData: any;
  59837. /**
  59838. * 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)
  59839. */
  59840. ignoreAlpha: boolean;
  59841. /**
  59842. * Defines the maximum number of lights that can be used in the material
  59843. */
  59844. maxSimultaneousLights: number;
  59845. /**
  59846. * Observable raised when the material is built
  59847. */
  59848. onBuildObservable: Observable<NodeMaterial>;
  59849. /**
  59850. * Gets or sets the root nodes of the material vertex shader
  59851. */
  59852. _vertexOutputNodes: NodeMaterialBlock[];
  59853. /**
  59854. * Gets or sets the root nodes of the material fragment (pixel) shader
  59855. */
  59856. _fragmentOutputNodes: NodeMaterialBlock[];
  59857. /** Gets or sets options to control the node material overall behavior */
  59858. get options(): INodeMaterialOptions;
  59859. set options(options: INodeMaterialOptions);
  59860. /**
  59861. * Default configuration related to image processing available in the standard Material.
  59862. */
  59863. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59864. /**
  59865. * Gets the image processing configuration used either in this material.
  59866. */
  59867. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  59868. /**
  59869. * Sets the Default image processing configuration used either in the this material.
  59870. *
  59871. * If sets to null, the scene one is in use.
  59872. */
  59873. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  59874. /**
  59875. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  59876. */
  59877. attachedBlocks: NodeMaterialBlock[];
  59878. /**
  59879. * Create a new node based material
  59880. * @param name defines the material name
  59881. * @param scene defines the hosting scene
  59882. * @param options defines creation option
  59883. */
  59884. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  59885. /**
  59886. * Gets the current class name of the material e.g. "NodeMaterial"
  59887. * @returns the class name
  59888. */
  59889. getClassName(): string;
  59890. /**
  59891. * Keep track of the image processing observer to allow dispose and replace.
  59892. */
  59893. private _imageProcessingObserver;
  59894. /**
  59895. * Attaches a new image processing configuration to the Standard Material.
  59896. * @param configuration
  59897. */
  59898. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59899. /**
  59900. * Get a block by its name
  59901. * @param name defines the name of the block to retrieve
  59902. * @returns the required block or null if not found
  59903. */
  59904. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  59905. /**
  59906. * Get a block by its name
  59907. * @param predicate defines the predicate used to find the good candidate
  59908. * @returns the required block or null if not found
  59909. */
  59910. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  59911. /**
  59912. * Get an input block by its name
  59913. * @param predicate defines the predicate used to find the good candidate
  59914. * @returns the required input block or null if not found
  59915. */
  59916. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  59917. /**
  59918. * Gets the list of input blocks attached to this material
  59919. * @returns an array of InputBlocks
  59920. */
  59921. getInputBlocks(): InputBlock[];
  59922. /**
  59923. * Adds a new optimizer to the list of optimizers
  59924. * @param optimizer defines the optimizers to add
  59925. * @returns the current material
  59926. */
  59927. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59928. /**
  59929. * Remove an optimizer from the list of optimizers
  59930. * @param optimizer defines the optimizers to remove
  59931. * @returns the current material
  59932. */
  59933. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59934. /**
  59935. * Add a new block to the list of output nodes
  59936. * @param node defines the node to add
  59937. * @returns the current material
  59938. */
  59939. addOutputNode(node: NodeMaterialBlock): this;
  59940. /**
  59941. * Remove a block from the list of root nodes
  59942. * @param node defines the node to remove
  59943. * @returns the current material
  59944. */
  59945. removeOutputNode(node: NodeMaterialBlock): this;
  59946. private _addVertexOutputNode;
  59947. private _removeVertexOutputNode;
  59948. private _addFragmentOutputNode;
  59949. private _removeFragmentOutputNode;
  59950. /**
  59951. * Specifies if the material will require alpha blending
  59952. * @returns a boolean specifying if alpha blending is needed
  59953. */
  59954. needAlphaBlending(): boolean;
  59955. /**
  59956. * Specifies if this material should be rendered in alpha test mode
  59957. * @returns a boolean specifying if an alpha test is needed.
  59958. */
  59959. needAlphaTesting(): boolean;
  59960. private _initializeBlock;
  59961. private _resetDualBlocks;
  59962. /**
  59963. * Remove a block from the current node material
  59964. * @param block defines the block to remove
  59965. */
  59966. removeBlock(block: NodeMaterialBlock): void;
  59967. /**
  59968. * Build the material and generates the inner effect
  59969. * @param verbose defines if the build should log activity
  59970. */
  59971. build(verbose?: boolean): void;
  59972. /**
  59973. * Runs an otpimization phase to try to improve the shader code
  59974. */
  59975. optimize(): void;
  59976. private _prepareDefinesForAttributes;
  59977. /**
  59978. * Get if the submesh is ready to be used and all its information available.
  59979. * Child classes can use it to update shaders
  59980. * @param mesh defines the mesh to check
  59981. * @param subMesh defines which submesh to check
  59982. * @param useInstances specifies that instances should be used
  59983. * @returns a boolean indicating that the submesh is ready or not
  59984. */
  59985. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59986. /**
  59987. * Get a string representing the shaders built by the current node graph
  59988. */
  59989. get compiledShaders(): string;
  59990. /**
  59991. * Binds the world matrix to the material
  59992. * @param world defines the world transformation matrix
  59993. */
  59994. bindOnlyWorldMatrix(world: Matrix): void;
  59995. /**
  59996. * Binds the submesh to this material by preparing the effect and shader to draw
  59997. * @param world defines the world transformation matrix
  59998. * @param mesh defines the mesh containing the submesh
  59999. * @param subMesh defines the submesh to bind the material to
  60000. */
  60001. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  60002. /**
  60003. * Gets the active textures from the material
  60004. * @returns an array of textures
  60005. */
  60006. getActiveTextures(): BaseTexture[];
  60007. /**
  60008. * Gets the list of texture blocks
  60009. * @returns an array of texture blocks
  60010. */
  60011. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  60012. /**
  60013. * Specifies if the material uses a texture
  60014. * @param texture defines the texture to check against the material
  60015. * @returns a boolean specifying if the material uses the texture
  60016. */
  60017. hasTexture(texture: BaseTexture): boolean;
  60018. /**
  60019. * Disposes the material
  60020. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  60021. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  60022. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  60023. */
  60024. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  60025. /** Creates the node editor window. */
  60026. private _createNodeEditor;
  60027. /**
  60028. * Launch the node material editor
  60029. * @param config Define the configuration of the editor
  60030. * @return a promise fulfilled when the node editor is visible
  60031. */
  60032. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  60033. /**
  60034. * Clear the current material
  60035. */
  60036. clear(): void;
  60037. /**
  60038. * Clear the current material and set it to a default state
  60039. */
  60040. setToDefault(): void;
  60041. /**
  60042. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  60043. * @param url defines the url to load from
  60044. * @returns a promise that will fullfil when the material is fully loaded
  60045. */
  60046. loadAsync(url: string): Promise<void>;
  60047. private _gatherBlocks;
  60048. /**
  60049. * Generate a string containing the code declaration required to create an equivalent of this material
  60050. * @returns a string
  60051. */
  60052. generateCode(): string;
  60053. /**
  60054. * Serializes this material in a JSON representation
  60055. * @returns the serialized material object
  60056. */
  60057. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  60058. private _restoreConnections;
  60059. /**
  60060. * Clear the current graph and load a new one from a serialization object
  60061. * @param source defines the JSON representation of the material
  60062. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60063. */
  60064. loadFromSerialization(source: any, rootUrl?: string): void;
  60065. /**
  60066. * Creates a node material from parsed material data
  60067. * @param source defines the JSON representation of the material
  60068. * @param scene defines the hosting scene
  60069. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60070. * @returns a new node material
  60071. */
  60072. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  60073. /**
  60074. * Creates a node material from a snippet saved in a remote file
  60075. * @param name defines the name of the material to create
  60076. * @param url defines the url to load from
  60077. * @param scene defines the hosting scene
  60078. * @returns a promise that will resolve to the new node material
  60079. */
  60080. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  60081. /**
  60082. * Creates a node material from a snippet saved by the node material editor
  60083. * @param snippetId defines the snippet to load
  60084. * @param scene defines the hosting scene
  60085. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60086. * @returns a promise that will resolve to the new node material
  60087. */
  60088. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  60089. /**
  60090. * Creates a new node material set to default basic configuration
  60091. * @param name defines the name of the material
  60092. * @param scene defines the hosting scene
  60093. * @returns a new NodeMaterial
  60094. */
  60095. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  60096. }
  60097. }
  60098. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  60099. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60100. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60101. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60102. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60103. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60104. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60105. import { Effect } from "babylonjs/Materials/effect";
  60106. import { Mesh } from "babylonjs/Meshes/mesh";
  60107. import { Nullable } from "babylonjs/types";
  60108. import { Texture } from "babylonjs/Materials/Textures/texture";
  60109. import { Scene } from "babylonjs/scene";
  60110. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60111. /**
  60112. * Block used to read a texture from a sampler
  60113. */
  60114. export class TextureBlock extends NodeMaterialBlock {
  60115. private _defineName;
  60116. private _linearDefineName;
  60117. private _tempTextureRead;
  60118. private _samplerName;
  60119. private _transformedUVName;
  60120. private _textureTransformName;
  60121. private _textureInfoName;
  60122. private _mainUVName;
  60123. private _mainUVDefineName;
  60124. /**
  60125. * Gets or sets the texture associated with the node
  60126. */
  60127. texture: Nullable<Texture>;
  60128. /**
  60129. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  60130. */
  60131. convertToGammaSpace: boolean;
  60132. /**
  60133. * Create a new TextureBlock
  60134. * @param name defines the block name
  60135. */
  60136. constructor(name: string);
  60137. /**
  60138. * Gets the current class name
  60139. * @returns the class name
  60140. */
  60141. getClassName(): string;
  60142. /**
  60143. * Gets the uv input component
  60144. */
  60145. get uv(): NodeMaterialConnectionPoint;
  60146. /**
  60147. * Gets the rgba output component
  60148. */
  60149. get rgba(): NodeMaterialConnectionPoint;
  60150. /**
  60151. * Gets the rgb output component
  60152. */
  60153. get rgb(): NodeMaterialConnectionPoint;
  60154. /**
  60155. * Gets the r output component
  60156. */
  60157. get r(): NodeMaterialConnectionPoint;
  60158. /**
  60159. * Gets the g output component
  60160. */
  60161. get g(): NodeMaterialConnectionPoint;
  60162. /**
  60163. * Gets the b output component
  60164. */
  60165. get b(): NodeMaterialConnectionPoint;
  60166. /**
  60167. * Gets the a output component
  60168. */
  60169. get a(): NodeMaterialConnectionPoint;
  60170. get target(): NodeMaterialBlockTargets;
  60171. autoConfigure(material: NodeMaterial): void;
  60172. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60173. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60174. isReady(): boolean;
  60175. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60176. private get _isMixed();
  60177. private _injectVertexCode;
  60178. private _writeTextureRead;
  60179. private _writeOutput;
  60180. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60181. protected _dumpPropertiesCode(): string;
  60182. serialize(): any;
  60183. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60184. }
  60185. }
  60186. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  60187. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60188. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60189. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60190. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60191. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  60192. import { Scene } from "babylonjs/scene";
  60193. /**
  60194. * Class used to store shared data between 2 NodeMaterialBuildState
  60195. */
  60196. export class NodeMaterialBuildStateSharedData {
  60197. /**
  60198. * Gets the list of emitted varyings
  60199. */
  60200. temps: string[];
  60201. /**
  60202. * Gets the list of emitted varyings
  60203. */
  60204. varyings: string[];
  60205. /**
  60206. * Gets the varying declaration string
  60207. */
  60208. varyingDeclaration: string;
  60209. /**
  60210. * Input blocks
  60211. */
  60212. inputBlocks: InputBlock[];
  60213. /**
  60214. * Input blocks
  60215. */
  60216. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  60217. /**
  60218. * Bindable blocks (Blocks that need to set data to the effect)
  60219. */
  60220. bindableBlocks: NodeMaterialBlock[];
  60221. /**
  60222. * List of blocks that can provide a compilation fallback
  60223. */
  60224. blocksWithFallbacks: NodeMaterialBlock[];
  60225. /**
  60226. * List of blocks that can provide a define update
  60227. */
  60228. blocksWithDefines: NodeMaterialBlock[];
  60229. /**
  60230. * List of blocks that can provide a repeatable content
  60231. */
  60232. repeatableContentBlocks: NodeMaterialBlock[];
  60233. /**
  60234. * List of blocks that can provide a dynamic list of uniforms
  60235. */
  60236. dynamicUniformBlocks: NodeMaterialBlock[];
  60237. /**
  60238. * List of blocks that can block the isReady function for the material
  60239. */
  60240. blockingBlocks: NodeMaterialBlock[];
  60241. /**
  60242. * Gets the list of animated inputs
  60243. */
  60244. animatedInputs: InputBlock[];
  60245. /**
  60246. * Build Id used to avoid multiple recompilations
  60247. */
  60248. buildId: number;
  60249. /** List of emitted variables */
  60250. variableNames: {
  60251. [key: string]: number;
  60252. };
  60253. /** List of emitted defines */
  60254. defineNames: {
  60255. [key: string]: number;
  60256. };
  60257. /** Should emit comments? */
  60258. emitComments: boolean;
  60259. /** Emit build activity */
  60260. verbose: boolean;
  60261. /** Gets or sets the hosting scene */
  60262. scene: Scene;
  60263. /**
  60264. * Gets the compilation hints emitted at compilation time
  60265. */
  60266. hints: {
  60267. needWorldViewMatrix: boolean;
  60268. needWorldViewProjectionMatrix: boolean;
  60269. needAlphaBlending: boolean;
  60270. needAlphaTesting: boolean;
  60271. };
  60272. /**
  60273. * List of compilation checks
  60274. */
  60275. checks: {
  60276. emitVertex: boolean;
  60277. emitFragment: boolean;
  60278. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  60279. };
  60280. /** Creates a new shared data */
  60281. constructor();
  60282. /**
  60283. * Emits console errors and exceptions if there is a failing check
  60284. */
  60285. emitErrors(): void;
  60286. }
  60287. }
  60288. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  60289. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60290. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60291. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  60292. /**
  60293. * Class used to store node based material build state
  60294. */
  60295. export class NodeMaterialBuildState {
  60296. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  60297. supportUniformBuffers: boolean;
  60298. /**
  60299. * Gets the list of emitted attributes
  60300. */
  60301. attributes: string[];
  60302. /**
  60303. * Gets the list of emitted uniforms
  60304. */
  60305. uniforms: string[];
  60306. /**
  60307. * Gets the list of emitted constants
  60308. */
  60309. constants: string[];
  60310. /**
  60311. * Gets the list of emitted samplers
  60312. */
  60313. samplers: string[];
  60314. /**
  60315. * Gets the list of emitted functions
  60316. */
  60317. functions: {
  60318. [key: string]: string;
  60319. };
  60320. /**
  60321. * Gets the list of emitted extensions
  60322. */
  60323. extensions: {
  60324. [key: string]: string;
  60325. };
  60326. /**
  60327. * Gets the target of the compilation state
  60328. */
  60329. target: NodeMaterialBlockTargets;
  60330. /**
  60331. * Gets the list of emitted counters
  60332. */
  60333. counters: {
  60334. [key: string]: number;
  60335. };
  60336. /**
  60337. * Shared data between multiple NodeMaterialBuildState instances
  60338. */
  60339. sharedData: NodeMaterialBuildStateSharedData;
  60340. /** @hidden */
  60341. _vertexState: NodeMaterialBuildState;
  60342. /** @hidden */
  60343. _attributeDeclaration: string;
  60344. /** @hidden */
  60345. _uniformDeclaration: string;
  60346. /** @hidden */
  60347. _constantDeclaration: string;
  60348. /** @hidden */
  60349. _samplerDeclaration: string;
  60350. /** @hidden */
  60351. _varyingTransfer: string;
  60352. private _repeatableContentAnchorIndex;
  60353. /** @hidden */
  60354. _builtCompilationString: string;
  60355. /**
  60356. * Gets the emitted compilation strings
  60357. */
  60358. compilationString: string;
  60359. /**
  60360. * Finalize the compilation strings
  60361. * @param state defines the current compilation state
  60362. */
  60363. finalize(state: NodeMaterialBuildState): void;
  60364. /** @hidden */
  60365. get _repeatableContentAnchor(): string;
  60366. /** @hidden */
  60367. _getFreeVariableName(prefix: string): string;
  60368. /** @hidden */
  60369. _getFreeDefineName(prefix: string): string;
  60370. /** @hidden */
  60371. _excludeVariableName(name: string): void;
  60372. /** @hidden */
  60373. _emit2DSampler(name: string): void;
  60374. /** @hidden */
  60375. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  60376. /** @hidden */
  60377. _emitExtension(name: string, extension: string): void;
  60378. /** @hidden */
  60379. _emitFunction(name: string, code: string, comments: string): void;
  60380. /** @hidden */
  60381. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  60382. replaceStrings?: {
  60383. search: RegExp;
  60384. replace: string;
  60385. }[];
  60386. repeatKey?: string;
  60387. }): string;
  60388. /** @hidden */
  60389. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  60390. repeatKey?: string;
  60391. removeAttributes?: boolean;
  60392. removeUniforms?: boolean;
  60393. removeVaryings?: boolean;
  60394. removeIfDef?: boolean;
  60395. replaceStrings?: {
  60396. search: RegExp;
  60397. replace: string;
  60398. }[];
  60399. }, storeKey?: string): void;
  60400. /** @hidden */
  60401. _registerTempVariable(name: string): boolean;
  60402. /** @hidden */
  60403. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  60404. /** @hidden */
  60405. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  60406. /** @hidden */
  60407. _emitFloat(value: number): string;
  60408. }
  60409. }
  60410. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  60411. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60412. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60413. import { Nullable } from "babylonjs/types";
  60414. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60415. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60416. import { Effect } from "babylonjs/Materials/effect";
  60417. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60418. import { Mesh } from "babylonjs/Meshes/mesh";
  60419. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60420. import { Scene } from "babylonjs/scene";
  60421. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60422. /**
  60423. * Defines a block that can be used inside a node based material
  60424. */
  60425. export class NodeMaterialBlock {
  60426. private _buildId;
  60427. private _buildTarget;
  60428. private _target;
  60429. private _isFinalMerger;
  60430. private _isInput;
  60431. protected _isUnique: boolean;
  60432. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  60433. inputsAreExclusive: boolean;
  60434. /** @hidden */
  60435. _codeVariableName: string;
  60436. /** @hidden */
  60437. _inputs: NodeMaterialConnectionPoint[];
  60438. /** @hidden */
  60439. _outputs: NodeMaterialConnectionPoint[];
  60440. /** @hidden */
  60441. _preparationId: number;
  60442. /**
  60443. * Gets or sets the name of the block
  60444. */
  60445. name: string;
  60446. /**
  60447. * Gets or sets the unique id of the node
  60448. */
  60449. uniqueId: number;
  60450. /**
  60451. * Gets or sets the comments associated with this block
  60452. */
  60453. comments: string;
  60454. /**
  60455. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  60456. */
  60457. get isUnique(): boolean;
  60458. /**
  60459. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  60460. */
  60461. get isFinalMerger(): boolean;
  60462. /**
  60463. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  60464. */
  60465. get isInput(): boolean;
  60466. /**
  60467. * Gets or sets the build Id
  60468. */
  60469. get buildId(): number;
  60470. set buildId(value: number);
  60471. /**
  60472. * Gets or sets the target of the block
  60473. */
  60474. get target(): NodeMaterialBlockTargets;
  60475. set target(value: NodeMaterialBlockTargets);
  60476. /**
  60477. * Gets the list of input points
  60478. */
  60479. get inputs(): NodeMaterialConnectionPoint[];
  60480. /** Gets the list of output points */
  60481. get outputs(): NodeMaterialConnectionPoint[];
  60482. /**
  60483. * Find an input by its name
  60484. * @param name defines the name of the input to look for
  60485. * @returns the input or null if not found
  60486. */
  60487. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60488. /**
  60489. * Find an output by its name
  60490. * @param name defines the name of the outputto look for
  60491. * @returns the output or null if not found
  60492. */
  60493. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60494. /**
  60495. * Creates a new NodeMaterialBlock
  60496. * @param name defines the block name
  60497. * @param target defines the target of that block (Vertex by default)
  60498. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  60499. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  60500. */
  60501. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  60502. /**
  60503. * Initialize the block and prepare the context for build
  60504. * @param state defines the state that will be used for the build
  60505. */
  60506. initialize(state: NodeMaterialBuildState): void;
  60507. /**
  60508. * Bind data to effect. Will only be called for blocks with isBindable === true
  60509. * @param effect defines the effect to bind data to
  60510. * @param nodeMaterial defines the hosting NodeMaterial
  60511. * @param mesh defines the mesh that will be rendered
  60512. */
  60513. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60514. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  60515. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  60516. protected _writeFloat(value: number): string;
  60517. /**
  60518. * Gets the current class name e.g. "NodeMaterialBlock"
  60519. * @returns the class name
  60520. */
  60521. getClassName(): string;
  60522. /**
  60523. * Register a new input. Must be called inside a block constructor
  60524. * @param name defines the connection point name
  60525. * @param type defines the connection point type
  60526. * @param isOptional defines a boolean indicating that this input can be omitted
  60527. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60528. * @returns the current block
  60529. */
  60530. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  60531. /**
  60532. * Register a new output. Must be called inside a block constructor
  60533. * @param name defines the connection point name
  60534. * @param type defines the connection point type
  60535. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60536. * @returns the current block
  60537. */
  60538. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  60539. /**
  60540. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  60541. * @param forOutput defines an optional connection point to check compatibility with
  60542. * @returns the first available input or null
  60543. */
  60544. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  60545. /**
  60546. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  60547. * @param forBlock defines an optional block to check compatibility with
  60548. * @returns the first available input or null
  60549. */
  60550. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  60551. /**
  60552. * Gets the sibling of the given output
  60553. * @param current defines the current output
  60554. * @returns the next output in the list or null
  60555. */
  60556. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  60557. /**
  60558. * Connect current block with another block
  60559. * @param other defines the block to connect with
  60560. * @param options define the various options to help pick the right connections
  60561. * @returns the current block
  60562. */
  60563. connectTo(other: NodeMaterialBlock, options?: {
  60564. input?: string;
  60565. output?: string;
  60566. outputSwizzle?: string;
  60567. }): this | undefined;
  60568. protected _buildBlock(state: NodeMaterialBuildState): void;
  60569. /**
  60570. * Add uniforms, samplers and uniform buffers at compilation time
  60571. * @param state defines the state to update
  60572. * @param nodeMaterial defines the node material requesting the update
  60573. * @param defines defines the material defines to update
  60574. * @param uniformBuffers defines the list of uniform buffer names
  60575. */
  60576. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  60577. /**
  60578. * Add potential fallbacks if shader compilation fails
  60579. * @param mesh defines the mesh to be rendered
  60580. * @param fallbacks defines the current prioritized list of fallbacks
  60581. */
  60582. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60583. /**
  60584. * Initialize defines for shader compilation
  60585. * @param mesh defines the mesh to be rendered
  60586. * @param nodeMaterial defines the node material requesting the update
  60587. * @param defines defines the material defines to update
  60588. * @param useInstances specifies that instances should be used
  60589. */
  60590. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60591. /**
  60592. * Update defines for shader compilation
  60593. * @param mesh defines the mesh to be rendered
  60594. * @param nodeMaterial defines the node material requesting the update
  60595. * @param defines defines the material defines to update
  60596. * @param useInstances specifies that instances should be used
  60597. */
  60598. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60599. /**
  60600. * Lets the block try to connect some inputs automatically
  60601. * @param material defines the hosting NodeMaterial
  60602. */
  60603. autoConfigure(material: NodeMaterial): void;
  60604. /**
  60605. * Function called when a block is declared as repeatable content generator
  60606. * @param vertexShaderState defines the current compilation state for the vertex shader
  60607. * @param fragmentShaderState defines the current compilation state for the fragment shader
  60608. * @param mesh defines the mesh to be rendered
  60609. * @param defines defines the material defines to update
  60610. */
  60611. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60612. /**
  60613. * Checks if the block is ready
  60614. * @param mesh defines the mesh to be rendered
  60615. * @param nodeMaterial defines the node material requesting the update
  60616. * @param defines defines the material defines to update
  60617. * @param useInstances specifies that instances should be used
  60618. * @returns true if the block is ready
  60619. */
  60620. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  60621. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  60622. private _processBuild;
  60623. /**
  60624. * Compile the current node and generate the shader code
  60625. * @param state defines the current compilation state (uniforms, samplers, current string)
  60626. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  60627. * @returns true if already built
  60628. */
  60629. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  60630. protected _inputRename(name: string): string;
  60631. protected _outputRename(name: string): string;
  60632. protected _dumpPropertiesCode(): string;
  60633. /** @hidden */
  60634. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  60635. /** @hidden */
  60636. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  60637. /**
  60638. * Clone the current block to a new identical block
  60639. * @param scene defines the hosting scene
  60640. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60641. * @returns a copy of the current block
  60642. */
  60643. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  60644. /**
  60645. * Serializes this block in a JSON representation
  60646. * @returns the serialized block object
  60647. */
  60648. serialize(): any;
  60649. /** @hidden */
  60650. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60651. /**
  60652. * Release resources
  60653. */
  60654. dispose(): void;
  60655. }
  60656. }
  60657. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  60658. /**
  60659. * Enum defining the type of animations supported by InputBlock
  60660. */
  60661. export enum AnimatedInputBlockTypes {
  60662. /** No animation */
  60663. None = 0,
  60664. /** Time based animation. Will only work for floats */
  60665. Time = 1
  60666. }
  60667. }
  60668. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  60669. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60670. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60671. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  60672. import { Nullable } from "babylonjs/types";
  60673. import { Effect } from "babylonjs/Materials/effect";
  60674. import { Matrix } from "babylonjs/Maths/math.vector";
  60675. import { Scene } from "babylonjs/scene";
  60676. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60677. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60678. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60679. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  60680. import { Observable } from "babylonjs/Misc/observable";
  60681. /**
  60682. * Block used to expose an input value
  60683. */
  60684. export class InputBlock extends NodeMaterialBlock {
  60685. private _mode;
  60686. private _associatedVariableName;
  60687. private _storedValue;
  60688. private _valueCallback;
  60689. private _type;
  60690. private _animationType;
  60691. /** Gets or set a value used to limit the range of float values */
  60692. min: number;
  60693. /** Gets or set a value used to limit the range of float values */
  60694. max: number;
  60695. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  60696. isBoolean: boolean;
  60697. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  60698. matrixMode: number;
  60699. /** @hidden */
  60700. _systemValue: Nullable<NodeMaterialSystemValues>;
  60701. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  60702. visibleInInspector: boolean;
  60703. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  60704. isConstant: boolean;
  60705. /** Gets or sets the group to use to display this block in the Inspector */
  60706. groupInInspector: string;
  60707. /** Gets an observable raised when the value is changed */
  60708. onValueChangedObservable: Observable<InputBlock>;
  60709. /**
  60710. * Gets or sets the connection point type (default is float)
  60711. */
  60712. get type(): NodeMaterialBlockConnectionPointTypes;
  60713. /**
  60714. * Creates a new InputBlock
  60715. * @param name defines the block name
  60716. * @param target defines the target of that block (Vertex by default)
  60717. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  60718. */
  60719. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  60720. /**
  60721. * Gets the output component
  60722. */
  60723. get output(): NodeMaterialConnectionPoint;
  60724. /**
  60725. * Set the source of this connection point to a vertex attribute
  60726. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  60727. * @returns the current connection point
  60728. */
  60729. setAsAttribute(attributeName?: string): InputBlock;
  60730. /**
  60731. * Set the source of this connection point to a system value
  60732. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  60733. * @returns the current connection point
  60734. */
  60735. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  60736. /**
  60737. * Gets or sets the value of that point.
  60738. * Please note that this value will be ignored if valueCallback is defined
  60739. */
  60740. get value(): any;
  60741. set value(value: any);
  60742. /**
  60743. * Gets or sets a callback used to get the value of that point.
  60744. * Please note that setting this value will force the connection point to ignore the value property
  60745. */
  60746. get valueCallback(): () => any;
  60747. set valueCallback(value: () => any);
  60748. /**
  60749. * Gets or sets the associated variable name in the shader
  60750. */
  60751. get associatedVariableName(): string;
  60752. set associatedVariableName(value: string);
  60753. /** Gets or sets the type of animation applied to the input */
  60754. get animationType(): AnimatedInputBlockTypes;
  60755. set animationType(value: AnimatedInputBlockTypes);
  60756. /**
  60757. * Gets a boolean indicating that this connection point not defined yet
  60758. */
  60759. get isUndefined(): boolean;
  60760. /**
  60761. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  60762. * In this case the connection point name must be the name of the uniform to use.
  60763. * Can only be set on inputs
  60764. */
  60765. get isUniform(): boolean;
  60766. set isUniform(value: boolean);
  60767. /**
  60768. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  60769. * In this case the connection point name must be the name of the attribute to use
  60770. * Can only be set on inputs
  60771. */
  60772. get isAttribute(): boolean;
  60773. set isAttribute(value: boolean);
  60774. /**
  60775. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  60776. * Can only be set on exit points
  60777. */
  60778. get isVarying(): boolean;
  60779. set isVarying(value: boolean);
  60780. /**
  60781. * Gets a boolean indicating that the current connection point is a system value
  60782. */
  60783. get isSystemValue(): boolean;
  60784. /**
  60785. * Gets or sets the current well known value or null if not defined as a system value
  60786. */
  60787. get systemValue(): Nullable<NodeMaterialSystemValues>;
  60788. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  60789. /**
  60790. * Gets the current class name
  60791. * @returns the class name
  60792. */
  60793. getClassName(): string;
  60794. /**
  60795. * Animate the input if animationType !== None
  60796. * @param scene defines the rendering scene
  60797. */
  60798. animate(scene: Scene): void;
  60799. private _emitDefine;
  60800. initialize(state: NodeMaterialBuildState): void;
  60801. /**
  60802. * Set the input block to its default value (based on its type)
  60803. */
  60804. setDefaultValue(): void;
  60805. private _emitConstant;
  60806. private _emit;
  60807. /** @hidden */
  60808. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  60809. /** @hidden */
  60810. _transmit(effect: Effect, scene: Scene): void;
  60811. protected _buildBlock(state: NodeMaterialBuildState): void;
  60812. protected _dumpPropertiesCode(): string;
  60813. dispose(): void;
  60814. serialize(): any;
  60815. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60816. }
  60817. }
  60818. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  60819. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60820. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60821. import { Nullable } from "babylonjs/types";
  60822. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60823. import { Observable } from "babylonjs/Misc/observable";
  60824. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60825. /**
  60826. * Enum used to define the compatibility state between two connection points
  60827. */
  60828. export enum NodeMaterialConnectionPointCompatibilityStates {
  60829. /** Points are compatibles */
  60830. Compatible = 0,
  60831. /** Points are incompatible because of their types */
  60832. TypeIncompatible = 1,
  60833. /** Points are incompatible because of their targets (vertex vs fragment) */
  60834. TargetIncompatible = 2
  60835. }
  60836. /**
  60837. * Defines the direction of a connection point
  60838. */
  60839. export enum NodeMaterialConnectionPointDirection {
  60840. /** Input */
  60841. Input = 0,
  60842. /** Output */
  60843. Output = 1
  60844. }
  60845. /**
  60846. * Defines a connection point for a block
  60847. */
  60848. export class NodeMaterialConnectionPoint {
  60849. /** @hidden */
  60850. _ownerBlock: NodeMaterialBlock;
  60851. /** @hidden */
  60852. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  60853. private _endpoints;
  60854. private _associatedVariableName;
  60855. private _direction;
  60856. /** @hidden */
  60857. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60858. /** @hidden */
  60859. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60860. private _type;
  60861. /** @hidden */
  60862. _enforceAssociatedVariableName: boolean;
  60863. /** Gets the direction of the point */
  60864. get direction(): NodeMaterialConnectionPointDirection;
  60865. /**
  60866. * Gets or sets the additional types supported by this connection point
  60867. */
  60868. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60869. /**
  60870. * Gets or sets the additional types excluded by this connection point
  60871. */
  60872. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60873. /**
  60874. * Observable triggered when this point is connected
  60875. */
  60876. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  60877. /**
  60878. * Gets or sets the associated variable name in the shader
  60879. */
  60880. get associatedVariableName(): string;
  60881. set associatedVariableName(value: string);
  60882. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  60883. get innerType(): NodeMaterialBlockConnectionPointTypes;
  60884. /**
  60885. * Gets or sets the connection point type (default is float)
  60886. */
  60887. get type(): NodeMaterialBlockConnectionPointTypes;
  60888. set type(value: NodeMaterialBlockConnectionPointTypes);
  60889. /**
  60890. * Gets or sets the connection point name
  60891. */
  60892. name: string;
  60893. /**
  60894. * Gets or sets a boolean indicating that this connection point can be omitted
  60895. */
  60896. isOptional: boolean;
  60897. /**
  60898. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  60899. */
  60900. define: string;
  60901. /** @hidden */
  60902. _prioritizeVertex: boolean;
  60903. private _target;
  60904. /** Gets or sets the target of that connection point */
  60905. get target(): NodeMaterialBlockTargets;
  60906. set target(value: NodeMaterialBlockTargets);
  60907. /**
  60908. * Gets a boolean indicating that the current point is connected
  60909. */
  60910. get isConnected(): boolean;
  60911. /**
  60912. * Gets a boolean indicating that the current point is connected to an input block
  60913. */
  60914. get isConnectedToInputBlock(): boolean;
  60915. /**
  60916. * Gets a the connected input block (if any)
  60917. */
  60918. get connectInputBlock(): Nullable<InputBlock>;
  60919. /** Get the other side of the connection (if any) */
  60920. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  60921. /** Get the block that owns this connection point */
  60922. get ownerBlock(): NodeMaterialBlock;
  60923. /** Get the block connected on the other side of this connection (if any) */
  60924. get sourceBlock(): Nullable<NodeMaterialBlock>;
  60925. /** Get the block connected on the endpoints of this connection (if any) */
  60926. get connectedBlocks(): Array<NodeMaterialBlock>;
  60927. /** Gets the list of connected endpoints */
  60928. get endpoints(): NodeMaterialConnectionPoint[];
  60929. /** Gets a boolean indicating if that output point is connected to at least one input */
  60930. get hasEndpoints(): boolean;
  60931. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  60932. get isConnectedInVertexShader(): boolean;
  60933. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  60934. get isConnectedInFragmentShader(): boolean;
  60935. /**
  60936. * Creates a new connection point
  60937. * @param name defines the connection point name
  60938. * @param ownerBlock defines the block hosting this connection point
  60939. * @param direction defines the direction of the connection point
  60940. */
  60941. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  60942. /**
  60943. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  60944. * @returns the class name
  60945. */
  60946. getClassName(): string;
  60947. /**
  60948. * Gets a boolean indicating if the current point can be connected to another point
  60949. * @param connectionPoint defines the other connection point
  60950. * @returns a boolean
  60951. */
  60952. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  60953. /**
  60954. * Gets a number indicating if the current point can be connected to another point
  60955. * @param connectionPoint defines the other connection point
  60956. * @returns a number defining the compatibility state
  60957. */
  60958. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  60959. /**
  60960. * Connect this point to another connection point
  60961. * @param connectionPoint defines the other connection point
  60962. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  60963. * @returns the current connection point
  60964. */
  60965. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  60966. /**
  60967. * Disconnect this point from one of his endpoint
  60968. * @param endpoint defines the other connection point
  60969. * @returns the current connection point
  60970. */
  60971. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  60972. /**
  60973. * Serializes this point in a JSON representation
  60974. * @returns the serialized point object
  60975. */
  60976. serialize(): any;
  60977. /**
  60978. * Release resources
  60979. */
  60980. dispose(): void;
  60981. }
  60982. }
  60983. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  60984. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60985. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60987. import { Mesh } from "babylonjs/Meshes/mesh";
  60988. import { Effect } from "babylonjs/Materials/effect";
  60989. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60990. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60991. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60992. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60993. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60994. /**
  60995. * Block used to add support for vertex skinning (bones)
  60996. */
  60997. export class BonesBlock extends NodeMaterialBlock {
  60998. /**
  60999. * Creates a new BonesBlock
  61000. * @param name defines the block name
  61001. */
  61002. constructor(name: string);
  61003. /**
  61004. * Initialize the block and prepare the context for build
  61005. * @param state defines the state that will be used for the build
  61006. */
  61007. initialize(state: NodeMaterialBuildState): void;
  61008. /**
  61009. * Gets the current class name
  61010. * @returns the class name
  61011. */
  61012. getClassName(): string;
  61013. /**
  61014. * Gets the matrix indices input component
  61015. */
  61016. get matricesIndices(): NodeMaterialConnectionPoint;
  61017. /**
  61018. * Gets the matrix weights input component
  61019. */
  61020. get matricesWeights(): NodeMaterialConnectionPoint;
  61021. /**
  61022. * Gets the extra matrix indices input component
  61023. */
  61024. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  61025. /**
  61026. * Gets the extra matrix weights input component
  61027. */
  61028. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  61029. /**
  61030. * Gets the world input component
  61031. */
  61032. get world(): NodeMaterialConnectionPoint;
  61033. /**
  61034. * Gets the output component
  61035. */
  61036. get output(): NodeMaterialConnectionPoint;
  61037. autoConfigure(material: NodeMaterial): void;
  61038. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61039. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61040. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61041. protected _buildBlock(state: NodeMaterialBuildState): this;
  61042. }
  61043. }
  61044. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  61045. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61046. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61047. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61048. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61049. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61050. /**
  61051. * Block used to add support for instances
  61052. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  61053. */
  61054. export class InstancesBlock extends NodeMaterialBlock {
  61055. /**
  61056. * Creates a new InstancesBlock
  61057. * @param name defines the block name
  61058. */
  61059. constructor(name: string);
  61060. /**
  61061. * Gets the current class name
  61062. * @returns the class name
  61063. */
  61064. getClassName(): string;
  61065. /**
  61066. * Gets the first world row input component
  61067. */
  61068. get world0(): NodeMaterialConnectionPoint;
  61069. /**
  61070. * Gets the second world row input component
  61071. */
  61072. get world1(): NodeMaterialConnectionPoint;
  61073. /**
  61074. * Gets the third world row input component
  61075. */
  61076. get world2(): NodeMaterialConnectionPoint;
  61077. /**
  61078. * Gets the forth world row input component
  61079. */
  61080. get world3(): NodeMaterialConnectionPoint;
  61081. /**
  61082. * Gets the world input component
  61083. */
  61084. get world(): NodeMaterialConnectionPoint;
  61085. /**
  61086. * Gets the output component
  61087. */
  61088. get output(): NodeMaterialConnectionPoint;
  61089. /**
  61090. * Gets the isntanceID component
  61091. */
  61092. get instanceID(): NodeMaterialConnectionPoint;
  61093. autoConfigure(material: NodeMaterial): void;
  61094. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61095. protected _buildBlock(state: NodeMaterialBuildState): this;
  61096. }
  61097. }
  61098. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  61099. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61100. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61101. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61103. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61104. import { Effect } from "babylonjs/Materials/effect";
  61105. import { Mesh } from "babylonjs/Meshes/mesh";
  61106. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61107. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61108. /**
  61109. * Block used to add morph targets support to vertex shader
  61110. */
  61111. export class MorphTargetsBlock extends NodeMaterialBlock {
  61112. private _repeatableContentAnchor;
  61113. /**
  61114. * Create a new MorphTargetsBlock
  61115. * @param name defines the block name
  61116. */
  61117. constructor(name: string);
  61118. /**
  61119. * Gets the current class name
  61120. * @returns the class name
  61121. */
  61122. getClassName(): string;
  61123. /**
  61124. * Gets the position input component
  61125. */
  61126. get position(): NodeMaterialConnectionPoint;
  61127. /**
  61128. * Gets the normal input component
  61129. */
  61130. get normal(): NodeMaterialConnectionPoint;
  61131. /**
  61132. * Gets the tangent input component
  61133. */
  61134. get tangent(): NodeMaterialConnectionPoint;
  61135. /**
  61136. * Gets the tangent input component
  61137. */
  61138. get uv(): NodeMaterialConnectionPoint;
  61139. /**
  61140. * Gets the position output component
  61141. */
  61142. get positionOutput(): NodeMaterialConnectionPoint;
  61143. /**
  61144. * Gets the normal output component
  61145. */
  61146. get normalOutput(): NodeMaterialConnectionPoint;
  61147. /**
  61148. * Gets the tangent output component
  61149. */
  61150. get tangentOutput(): NodeMaterialConnectionPoint;
  61151. /**
  61152. * Gets the tangent output component
  61153. */
  61154. get uvOutput(): NodeMaterialConnectionPoint;
  61155. initialize(state: NodeMaterialBuildState): void;
  61156. autoConfigure(material: NodeMaterial): void;
  61157. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61158. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61159. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61160. protected _buildBlock(state: NodeMaterialBuildState): this;
  61161. }
  61162. }
  61163. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  61164. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61165. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61166. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61167. import { Nullable } from "babylonjs/types";
  61168. import { Scene } from "babylonjs/scene";
  61169. import { Effect } from "babylonjs/Materials/effect";
  61170. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61171. import { Mesh } from "babylonjs/Meshes/mesh";
  61172. import { Light } from "babylonjs/Lights/light";
  61173. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61174. /**
  61175. * Block used to get data information from a light
  61176. */
  61177. export class LightInformationBlock extends NodeMaterialBlock {
  61178. private _lightDataUniformName;
  61179. private _lightColorUniformName;
  61180. private _lightTypeDefineName;
  61181. /**
  61182. * Gets or sets the light associated with this block
  61183. */
  61184. light: Nullable<Light>;
  61185. /**
  61186. * Creates a new LightInformationBlock
  61187. * @param name defines the block name
  61188. */
  61189. constructor(name: string);
  61190. /**
  61191. * Gets the current class name
  61192. * @returns the class name
  61193. */
  61194. getClassName(): string;
  61195. /**
  61196. * Gets the world position input component
  61197. */
  61198. get worldPosition(): NodeMaterialConnectionPoint;
  61199. /**
  61200. * Gets the direction output component
  61201. */
  61202. get direction(): NodeMaterialConnectionPoint;
  61203. /**
  61204. * Gets the direction output component
  61205. */
  61206. get color(): NodeMaterialConnectionPoint;
  61207. /**
  61208. * Gets the direction output component
  61209. */
  61210. get intensity(): NodeMaterialConnectionPoint;
  61211. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61212. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61213. protected _buildBlock(state: NodeMaterialBuildState): this;
  61214. serialize(): any;
  61215. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61216. }
  61217. }
  61218. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  61219. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  61220. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  61221. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  61222. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  61223. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  61224. }
  61225. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  61226. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61227. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61228. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61229. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61230. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61231. import { Effect } from "babylonjs/Materials/effect";
  61232. import { Mesh } from "babylonjs/Meshes/mesh";
  61233. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61234. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61235. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61236. /**
  61237. * Block used to add image processing support to fragment shader
  61238. */
  61239. export class ImageProcessingBlock extends NodeMaterialBlock {
  61240. /**
  61241. * Create a new ImageProcessingBlock
  61242. * @param name defines the block name
  61243. */
  61244. constructor(name: string);
  61245. /**
  61246. * Gets the current class name
  61247. * @returns the class name
  61248. */
  61249. getClassName(): string;
  61250. /**
  61251. * Gets the color input component
  61252. */
  61253. get color(): NodeMaterialConnectionPoint;
  61254. /**
  61255. * Gets the output component
  61256. */
  61257. get output(): NodeMaterialConnectionPoint;
  61258. /**
  61259. * Initialize the block and prepare the context for build
  61260. * @param state defines the state that will be used for the build
  61261. */
  61262. initialize(state: NodeMaterialBuildState): void;
  61263. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61264. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61265. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61266. protected _buildBlock(state: NodeMaterialBuildState): this;
  61267. }
  61268. }
  61269. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  61270. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61271. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61272. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61273. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61274. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61275. import { Effect } from "babylonjs/Materials/effect";
  61276. import { Mesh } from "babylonjs/Meshes/mesh";
  61277. import { Scene } from "babylonjs/scene";
  61278. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  61279. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  61280. /**
  61281. * Block used to pertub normals based on a normal map
  61282. */
  61283. export class PerturbNormalBlock extends NodeMaterialBlock {
  61284. private _tangentSpaceParameterName;
  61285. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61286. invertX: boolean;
  61287. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61288. invertY: boolean;
  61289. /**
  61290. * Create a new PerturbNormalBlock
  61291. * @param name defines the block name
  61292. */
  61293. constructor(name: string);
  61294. /**
  61295. * Gets the current class name
  61296. * @returns the class name
  61297. */
  61298. getClassName(): string;
  61299. /**
  61300. * Gets the world position input component
  61301. */
  61302. get worldPosition(): NodeMaterialConnectionPoint;
  61303. /**
  61304. * Gets the world normal input component
  61305. */
  61306. get worldNormal(): NodeMaterialConnectionPoint;
  61307. /**
  61308. * Gets the world tangent input component
  61309. */
  61310. get worldTangent(): NodeMaterialConnectionPoint;
  61311. /**
  61312. * Gets the uv input component
  61313. */
  61314. get uv(): NodeMaterialConnectionPoint;
  61315. /**
  61316. * Gets the normal map color input component
  61317. */
  61318. get normalMapColor(): NodeMaterialConnectionPoint;
  61319. /**
  61320. * Gets the strength input component
  61321. */
  61322. get strength(): NodeMaterialConnectionPoint;
  61323. /**
  61324. * Gets the output component
  61325. */
  61326. get output(): NodeMaterialConnectionPoint;
  61327. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61328. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61329. autoConfigure(material: NodeMaterial): void;
  61330. protected _buildBlock(state: NodeMaterialBuildState): this;
  61331. protected _dumpPropertiesCode(): string;
  61332. serialize(): any;
  61333. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61334. }
  61335. }
  61336. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  61337. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61338. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61339. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61340. /**
  61341. * Block used to discard a pixel if a value is smaller than a cutoff
  61342. */
  61343. export class DiscardBlock extends NodeMaterialBlock {
  61344. /**
  61345. * Create a new DiscardBlock
  61346. * @param name defines the block name
  61347. */
  61348. constructor(name: string);
  61349. /**
  61350. * Gets the current class name
  61351. * @returns the class name
  61352. */
  61353. getClassName(): string;
  61354. /**
  61355. * Gets the color input component
  61356. */
  61357. get value(): NodeMaterialConnectionPoint;
  61358. /**
  61359. * Gets the cutoff input component
  61360. */
  61361. get cutoff(): NodeMaterialConnectionPoint;
  61362. protected _buildBlock(state: NodeMaterialBuildState): this;
  61363. }
  61364. }
  61365. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  61366. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61367. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61368. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61369. /**
  61370. * Block used to test if the fragment shader is front facing
  61371. */
  61372. export class FrontFacingBlock extends NodeMaterialBlock {
  61373. /**
  61374. * Creates a new FrontFacingBlock
  61375. * @param name defines the block name
  61376. */
  61377. constructor(name: string);
  61378. /**
  61379. * Gets the current class name
  61380. * @returns the class name
  61381. */
  61382. getClassName(): string;
  61383. /**
  61384. * Gets the output component
  61385. */
  61386. get output(): NodeMaterialConnectionPoint;
  61387. protected _buildBlock(state: NodeMaterialBuildState): this;
  61388. }
  61389. }
  61390. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  61391. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61392. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61393. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61394. /**
  61395. * Block used to get the derivative value on x and y of a given input
  61396. */
  61397. export class DerivativeBlock extends NodeMaterialBlock {
  61398. /**
  61399. * Create a new DerivativeBlock
  61400. * @param name defines the block name
  61401. */
  61402. constructor(name: string);
  61403. /**
  61404. * Gets the current class name
  61405. * @returns the class name
  61406. */
  61407. getClassName(): string;
  61408. /**
  61409. * Gets the input component
  61410. */
  61411. get input(): NodeMaterialConnectionPoint;
  61412. /**
  61413. * Gets the derivative output on x
  61414. */
  61415. get dx(): NodeMaterialConnectionPoint;
  61416. /**
  61417. * Gets the derivative output on y
  61418. */
  61419. get dy(): NodeMaterialConnectionPoint;
  61420. protected _buildBlock(state: NodeMaterialBuildState): this;
  61421. }
  61422. }
  61423. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  61424. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  61425. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  61426. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  61427. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  61428. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  61429. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  61430. }
  61431. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  61432. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61433. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61434. import { Mesh } from "babylonjs/Meshes/mesh";
  61435. import { Effect } from "babylonjs/Materials/effect";
  61436. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61437. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61438. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61439. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  61440. /**
  61441. * Block used to add support for scene fog
  61442. */
  61443. export class FogBlock extends NodeMaterialBlock {
  61444. private _fogDistanceName;
  61445. private _fogParameters;
  61446. /**
  61447. * Create a new FogBlock
  61448. * @param name defines the block name
  61449. */
  61450. constructor(name: string);
  61451. /**
  61452. * Gets the current class name
  61453. * @returns the class name
  61454. */
  61455. getClassName(): string;
  61456. /**
  61457. * Gets the world position input component
  61458. */
  61459. get worldPosition(): NodeMaterialConnectionPoint;
  61460. /**
  61461. * Gets the view input component
  61462. */
  61463. get view(): NodeMaterialConnectionPoint;
  61464. /**
  61465. * Gets the color input component
  61466. */
  61467. get input(): NodeMaterialConnectionPoint;
  61468. /**
  61469. * Gets the fog color input component
  61470. */
  61471. get fogColor(): NodeMaterialConnectionPoint;
  61472. /**
  61473. * Gets the output component
  61474. */
  61475. get output(): NodeMaterialConnectionPoint;
  61476. autoConfigure(material: NodeMaterial): void;
  61477. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61478. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61479. protected _buildBlock(state: NodeMaterialBuildState): this;
  61480. }
  61481. }
  61482. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  61483. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61484. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61485. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61486. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61487. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61488. import { Effect } from "babylonjs/Materials/effect";
  61489. import { Mesh } from "babylonjs/Meshes/mesh";
  61490. import { Light } from "babylonjs/Lights/light";
  61491. import { Nullable } from "babylonjs/types";
  61492. import { Scene } from "babylonjs/scene";
  61493. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  61494. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  61495. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  61496. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61497. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  61498. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  61499. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  61500. /**
  61501. * Block used to add light in the fragment shader
  61502. */
  61503. export class LightBlock extends NodeMaterialBlock {
  61504. private _lightId;
  61505. /**
  61506. * Gets or sets the light associated with this block
  61507. */
  61508. light: Nullable<Light>;
  61509. /**
  61510. * Create a new LightBlock
  61511. * @param name defines the block name
  61512. */
  61513. constructor(name: string);
  61514. /**
  61515. * Gets the current class name
  61516. * @returns the class name
  61517. */
  61518. getClassName(): string;
  61519. /**
  61520. * Gets the world position input component
  61521. */
  61522. get worldPosition(): NodeMaterialConnectionPoint;
  61523. /**
  61524. * Gets the world normal input component
  61525. */
  61526. get worldNormal(): NodeMaterialConnectionPoint;
  61527. /**
  61528. * Gets the camera (or eye) position component
  61529. */
  61530. get cameraPosition(): NodeMaterialConnectionPoint;
  61531. /**
  61532. * Gets the glossiness component
  61533. */
  61534. get glossiness(): NodeMaterialConnectionPoint;
  61535. /**
  61536. * Gets the glossinness power component
  61537. */
  61538. get glossPower(): NodeMaterialConnectionPoint;
  61539. /**
  61540. * Gets the diffuse color component
  61541. */
  61542. get diffuseColor(): NodeMaterialConnectionPoint;
  61543. /**
  61544. * Gets the specular color component
  61545. */
  61546. get specularColor(): NodeMaterialConnectionPoint;
  61547. /**
  61548. * Gets the diffuse output component
  61549. */
  61550. get diffuseOutput(): NodeMaterialConnectionPoint;
  61551. /**
  61552. * Gets the specular output component
  61553. */
  61554. get specularOutput(): NodeMaterialConnectionPoint;
  61555. /**
  61556. * Gets the shadow output component
  61557. */
  61558. get shadow(): NodeMaterialConnectionPoint;
  61559. autoConfigure(material: NodeMaterial): void;
  61560. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61561. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61562. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61563. private _injectVertexCode;
  61564. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61565. serialize(): any;
  61566. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61567. }
  61568. }
  61569. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  61570. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  61571. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  61572. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  61573. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  61574. }
  61575. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  61576. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61577. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  61578. }
  61579. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  61580. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61581. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61582. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61583. /**
  61584. * Block used to multiply 2 values
  61585. */
  61586. export class MultiplyBlock extends NodeMaterialBlock {
  61587. /**
  61588. * Creates a new MultiplyBlock
  61589. * @param name defines the block name
  61590. */
  61591. constructor(name: string);
  61592. /**
  61593. * Gets the current class name
  61594. * @returns the class name
  61595. */
  61596. getClassName(): string;
  61597. /**
  61598. * Gets the left operand input component
  61599. */
  61600. get left(): NodeMaterialConnectionPoint;
  61601. /**
  61602. * Gets the right operand input component
  61603. */
  61604. get right(): NodeMaterialConnectionPoint;
  61605. /**
  61606. * Gets the output component
  61607. */
  61608. get output(): NodeMaterialConnectionPoint;
  61609. protected _buildBlock(state: NodeMaterialBuildState): this;
  61610. }
  61611. }
  61612. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  61613. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61614. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61615. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61616. /**
  61617. * Block used to add 2 vectors
  61618. */
  61619. export class AddBlock extends NodeMaterialBlock {
  61620. /**
  61621. * Creates a new AddBlock
  61622. * @param name defines the block name
  61623. */
  61624. constructor(name: string);
  61625. /**
  61626. * Gets the current class name
  61627. * @returns the class name
  61628. */
  61629. getClassName(): string;
  61630. /**
  61631. * Gets the left operand input component
  61632. */
  61633. get left(): NodeMaterialConnectionPoint;
  61634. /**
  61635. * Gets the right operand input component
  61636. */
  61637. get right(): NodeMaterialConnectionPoint;
  61638. /**
  61639. * Gets the output component
  61640. */
  61641. get output(): NodeMaterialConnectionPoint;
  61642. protected _buildBlock(state: NodeMaterialBuildState): this;
  61643. }
  61644. }
  61645. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  61646. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61647. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61648. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61649. /**
  61650. * Block used to scale a vector by a float
  61651. */
  61652. export class ScaleBlock extends NodeMaterialBlock {
  61653. /**
  61654. * Creates a new ScaleBlock
  61655. * @param name defines the block name
  61656. */
  61657. constructor(name: string);
  61658. /**
  61659. * Gets the current class name
  61660. * @returns the class name
  61661. */
  61662. getClassName(): string;
  61663. /**
  61664. * Gets the input component
  61665. */
  61666. get input(): NodeMaterialConnectionPoint;
  61667. /**
  61668. * Gets the factor input component
  61669. */
  61670. get factor(): NodeMaterialConnectionPoint;
  61671. /**
  61672. * Gets the output component
  61673. */
  61674. get output(): NodeMaterialConnectionPoint;
  61675. protected _buildBlock(state: NodeMaterialBuildState): this;
  61676. }
  61677. }
  61678. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  61679. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61680. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61681. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61682. import { Scene } from "babylonjs/scene";
  61683. /**
  61684. * Block used to clamp a float
  61685. */
  61686. export class ClampBlock extends NodeMaterialBlock {
  61687. /** Gets or sets the minimum range */
  61688. minimum: number;
  61689. /** Gets or sets the maximum range */
  61690. maximum: number;
  61691. /**
  61692. * Creates a new ClampBlock
  61693. * @param name defines the block name
  61694. */
  61695. constructor(name: string);
  61696. /**
  61697. * Gets the current class name
  61698. * @returns the class name
  61699. */
  61700. getClassName(): string;
  61701. /**
  61702. * Gets the value input component
  61703. */
  61704. get value(): NodeMaterialConnectionPoint;
  61705. /**
  61706. * Gets the output component
  61707. */
  61708. get output(): NodeMaterialConnectionPoint;
  61709. protected _buildBlock(state: NodeMaterialBuildState): this;
  61710. protected _dumpPropertiesCode(): string;
  61711. serialize(): any;
  61712. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61713. }
  61714. }
  61715. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  61716. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61717. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61718. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61719. /**
  61720. * Block used to apply a cross product between 2 vectors
  61721. */
  61722. export class CrossBlock extends NodeMaterialBlock {
  61723. /**
  61724. * Creates a new CrossBlock
  61725. * @param name defines the block name
  61726. */
  61727. constructor(name: string);
  61728. /**
  61729. * Gets the current class name
  61730. * @returns the class name
  61731. */
  61732. getClassName(): string;
  61733. /**
  61734. * Gets the left operand input component
  61735. */
  61736. get left(): NodeMaterialConnectionPoint;
  61737. /**
  61738. * Gets the right operand input component
  61739. */
  61740. get right(): NodeMaterialConnectionPoint;
  61741. /**
  61742. * Gets the output component
  61743. */
  61744. get output(): NodeMaterialConnectionPoint;
  61745. protected _buildBlock(state: NodeMaterialBuildState): this;
  61746. }
  61747. }
  61748. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  61749. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61750. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61751. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61752. /**
  61753. * Block used to apply a dot product between 2 vectors
  61754. */
  61755. export class DotBlock extends NodeMaterialBlock {
  61756. /**
  61757. * Creates a new DotBlock
  61758. * @param name defines the block name
  61759. */
  61760. constructor(name: string);
  61761. /**
  61762. * Gets the current class name
  61763. * @returns the class name
  61764. */
  61765. getClassName(): string;
  61766. /**
  61767. * Gets the left operand input component
  61768. */
  61769. get left(): NodeMaterialConnectionPoint;
  61770. /**
  61771. * Gets the right operand input component
  61772. */
  61773. get right(): NodeMaterialConnectionPoint;
  61774. /**
  61775. * Gets the output component
  61776. */
  61777. get output(): NodeMaterialConnectionPoint;
  61778. protected _buildBlock(state: NodeMaterialBuildState): this;
  61779. }
  61780. }
  61781. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  61782. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61783. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61784. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61785. import { Vector2 } from "babylonjs/Maths/math.vector";
  61786. import { Scene } from "babylonjs/scene";
  61787. /**
  61788. * Block used to remap a float from a range to a new one
  61789. */
  61790. export class RemapBlock extends NodeMaterialBlock {
  61791. /**
  61792. * Gets or sets the source range
  61793. */
  61794. sourceRange: Vector2;
  61795. /**
  61796. * Gets or sets the target range
  61797. */
  61798. targetRange: Vector2;
  61799. /**
  61800. * Creates a new RemapBlock
  61801. * @param name defines the block name
  61802. */
  61803. constructor(name: string);
  61804. /**
  61805. * Gets the current class name
  61806. * @returns the class name
  61807. */
  61808. getClassName(): string;
  61809. /**
  61810. * Gets the input component
  61811. */
  61812. get input(): NodeMaterialConnectionPoint;
  61813. /**
  61814. * Gets the source min input component
  61815. */
  61816. get sourceMin(): NodeMaterialConnectionPoint;
  61817. /**
  61818. * Gets the source max input component
  61819. */
  61820. get sourceMax(): NodeMaterialConnectionPoint;
  61821. /**
  61822. * Gets the target min input component
  61823. */
  61824. get targetMin(): NodeMaterialConnectionPoint;
  61825. /**
  61826. * Gets the target max input component
  61827. */
  61828. get targetMax(): NodeMaterialConnectionPoint;
  61829. /**
  61830. * Gets the output component
  61831. */
  61832. get output(): NodeMaterialConnectionPoint;
  61833. protected _buildBlock(state: NodeMaterialBuildState): this;
  61834. protected _dumpPropertiesCode(): string;
  61835. serialize(): any;
  61836. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61837. }
  61838. }
  61839. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  61840. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61841. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61842. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61843. /**
  61844. * Block used to normalize a vector
  61845. */
  61846. export class NormalizeBlock extends NodeMaterialBlock {
  61847. /**
  61848. * Creates a new NormalizeBlock
  61849. * @param name defines the block name
  61850. */
  61851. constructor(name: string);
  61852. /**
  61853. * Gets the current class name
  61854. * @returns the class name
  61855. */
  61856. getClassName(): string;
  61857. /**
  61858. * Gets the input component
  61859. */
  61860. get input(): NodeMaterialConnectionPoint;
  61861. /**
  61862. * Gets the output component
  61863. */
  61864. get output(): NodeMaterialConnectionPoint;
  61865. protected _buildBlock(state: NodeMaterialBuildState): this;
  61866. }
  61867. }
  61868. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  61869. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61870. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61871. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61872. import { Scene } from "babylonjs/scene";
  61873. /**
  61874. * Operations supported by the Trigonometry block
  61875. */
  61876. export enum TrigonometryBlockOperations {
  61877. /** Cos */
  61878. Cos = 0,
  61879. /** Sin */
  61880. Sin = 1,
  61881. /** Abs */
  61882. Abs = 2,
  61883. /** Exp */
  61884. Exp = 3,
  61885. /** Exp2 */
  61886. Exp2 = 4,
  61887. /** Round */
  61888. Round = 5,
  61889. /** Floor */
  61890. Floor = 6,
  61891. /** Ceiling */
  61892. Ceiling = 7,
  61893. /** Square root */
  61894. Sqrt = 8,
  61895. /** Log */
  61896. Log = 9,
  61897. /** Tangent */
  61898. Tan = 10,
  61899. /** Arc tangent */
  61900. ArcTan = 11,
  61901. /** Arc cosinus */
  61902. ArcCos = 12,
  61903. /** Arc sinus */
  61904. ArcSin = 13,
  61905. /** Fraction */
  61906. Fract = 14,
  61907. /** Sign */
  61908. Sign = 15,
  61909. /** To radians (from degrees) */
  61910. Radians = 16,
  61911. /** To degrees (from radians) */
  61912. Degrees = 17
  61913. }
  61914. /**
  61915. * Block used to apply trigonometry operation to floats
  61916. */
  61917. export class TrigonometryBlock extends NodeMaterialBlock {
  61918. /**
  61919. * Gets or sets the operation applied by the block
  61920. */
  61921. operation: TrigonometryBlockOperations;
  61922. /**
  61923. * Creates a new TrigonometryBlock
  61924. * @param name defines the block name
  61925. */
  61926. constructor(name: string);
  61927. /**
  61928. * Gets the current class name
  61929. * @returns the class name
  61930. */
  61931. getClassName(): string;
  61932. /**
  61933. * Gets the input component
  61934. */
  61935. get input(): NodeMaterialConnectionPoint;
  61936. /**
  61937. * Gets the output component
  61938. */
  61939. get output(): NodeMaterialConnectionPoint;
  61940. protected _buildBlock(state: NodeMaterialBuildState): this;
  61941. serialize(): any;
  61942. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61943. protected _dumpPropertiesCode(): string;
  61944. }
  61945. }
  61946. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  61947. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61948. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61949. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61950. /**
  61951. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61952. */
  61953. export class ColorMergerBlock extends NodeMaterialBlock {
  61954. /**
  61955. * Create a new ColorMergerBlock
  61956. * @param name defines the block name
  61957. */
  61958. constructor(name: string);
  61959. /**
  61960. * Gets the current class name
  61961. * @returns the class name
  61962. */
  61963. getClassName(): string;
  61964. /**
  61965. * Gets the rgb component (input)
  61966. */
  61967. get rgbIn(): NodeMaterialConnectionPoint;
  61968. /**
  61969. * Gets the r component (input)
  61970. */
  61971. get r(): NodeMaterialConnectionPoint;
  61972. /**
  61973. * Gets the g component (input)
  61974. */
  61975. get g(): NodeMaterialConnectionPoint;
  61976. /**
  61977. * Gets the b component (input)
  61978. */
  61979. get b(): NodeMaterialConnectionPoint;
  61980. /**
  61981. * Gets the a component (input)
  61982. */
  61983. get a(): NodeMaterialConnectionPoint;
  61984. /**
  61985. * Gets the rgba component (output)
  61986. */
  61987. get rgba(): NodeMaterialConnectionPoint;
  61988. /**
  61989. * Gets the rgb component (output)
  61990. */
  61991. get rgbOut(): NodeMaterialConnectionPoint;
  61992. /**
  61993. * Gets the rgb component (output)
  61994. * @deprecated Please use rgbOut instead.
  61995. */
  61996. get rgb(): NodeMaterialConnectionPoint;
  61997. protected _buildBlock(state: NodeMaterialBuildState): this;
  61998. }
  61999. }
  62000. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  62001. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62002. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62003. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62004. /**
  62005. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  62006. */
  62007. export class VectorMergerBlock extends NodeMaterialBlock {
  62008. /**
  62009. * Create a new VectorMergerBlock
  62010. * @param name defines the block name
  62011. */
  62012. constructor(name: string);
  62013. /**
  62014. * Gets the current class name
  62015. * @returns the class name
  62016. */
  62017. getClassName(): string;
  62018. /**
  62019. * Gets the xyz component (input)
  62020. */
  62021. get xyzIn(): NodeMaterialConnectionPoint;
  62022. /**
  62023. * Gets the xy component (input)
  62024. */
  62025. get xyIn(): NodeMaterialConnectionPoint;
  62026. /**
  62027. * Gets the x component (input)
  62028. */
  62029. get x(): NodeMaterialConnectionPoint;
  62030. /**
  62031. * Gets the y component (input)
  62032. */
  62033. get y(): NodeMaterialConnectionPoint;
  62034. /**
  62035. * Gets the z component (input)
  62036. */
  62037. get z(): NodeMaterialConnectionPoint;
  62038. /**
  62039. * Gets the w component (input)
  62040. */
  62041. get w(): NodeMaterialConnectionPoint;
  62042. /**
  62043. * Gets the xyzw component (output)
  62044. */
  62045. get xyzw(): NodeMaterialConnectionPoint;
  62046. /**
  62047. * Gets the xyz component (output)
  62048. */
  62049. get xyzOut(): NodeMaterialConnectionPoint;
  62050. /**
  62051. * Gets the xy component (output)
  62052. */
  62053. get xyOut(): NodeMaterialConnectionPoint;
  62054. /**
  62055. * Gets the xy component (output)
  62056. * @deprecated Please use xyOut instead.
  62057. */
  62058. get xy(): NodeMaterialConnectionPoint;
  62059. /**
  62060. * Gets the xyz component (output)
  62061. * @deprecated Please use xyzOut instead.
  62062. */
  62063. get xyz(): NodeMaterialConnectionPoint;
  62064. protected _buildBlock(state: NodeMaterialBuildState): this;
  62065. }
  62066. }
  62067. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  62068. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62069. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62070. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62071. /**
  62072. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  62073. */
  62074. export class ColorSplitterBlock extends NodeMaterialBlock {
  62075. /**
  62076. * Create a new ColorSplitterBlock
  62077. * @param name defines the block name
  62078. */
  62079. constructor(name: string);
  62080. /**
  62081. * Gets the current class name
  62082. * @returns the class name
  62083. */
  62084. getClassName(): string;
  62085. /**
  62086. * Gets the rgba component (input)
  62087. */
  62088. get rgba(): NodeMaterialConnectionPoint;
  62089. /**
  62090. * Gets the rgb component (input)
  62091. */
  62092. get rgbIn(): NodeMaterialConnectionPoint;
  62093. /**
  62094. * Gets the rgb component (output)
  62095. */
  62096. get rgbOut(): NodeMaterialConnectionPoint;
  62097. /**
  62098. * Gets the r component (output)
  62099. */
  62100. get r(): NodeMaterialConnectionPoint;
  62101. /**
  62102. * Gets the g component (output)
  62103. */
  62104. get g(): NodeMaterialConnectionPoint;
  62105. /**
  62106. * Gets the b component (output)
  62107. */
  62108. get b(): NodeMaterialConnectionPoint;
  62109. /**
  62110. * Gets the a component (output)
  62111. */
  62112. get a(): NodeMaterialConnectionPoint;
  62113. protected _inputRename(name: string): string;
  62114. protected _outputRename(name: string): string;
  62115. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62116. }
  62117. }
  62118. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  62119. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62120. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62121. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62122. /**
  62123. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  62124. */
  62125. export class VectorSplitterBlock extends NodeMaterialBlock {
  62126. /**
  62127. * Create a new VectorSplitterBlock
  62128. * @param name defines the block name
  62129. */
  62130. constructor(name: string);
  62131. /**
  62132. * Gets the current class name
  62133. * @returns the class name
  62134. */
  62135. getClassName(): string;
  62136. /**
  62137. * Gets the xyzw component (input)
  62138. */
  62139. get xyzw(): NodeMaterialConnectionPoint;
  62140. /**
  62141. * Gets the xyz component (input)
  62142. */
  62143. get xyzIn(): NodeMaterialConnectionPoint;
  62144. /**
  62145. * Gets the xy component (input)
  62146. */
  62147. get xyIn(): NodeMaterialConnectionPoint;
  62148. /**
  62149. * Gets the xyz component (output)
  62150. */
  62151. get xyzOut(): NodeMaterialConnectionPoint;
  62152. /**
  62153. * Gets the xy component (output)
  62154. */
  62155. get xyOut(): NodeMaterialConnectionPoint;
  62156. /**
  62157. * Gets the x component (output)
  62158. */
  62159. get x(): NodeMaterialConnectionPoint;
  62160. /**
  62161. * Gets the y component (output)
  62162. */
  62163. get y(): NodeMaterialConnectionPoint;
  62164. /**
  62165. * Gets the z component (output)
  62166. */
  62167. get z(): NodeMaterialConnectionPoint;
  62168. /**
  62169. * Gets the w component (output)
  62170. */
  62171. get w(): NodeMaterialConnectionPoint;
  62172. protected _inputRename(name: string): string;
  62173. protected _outputRename(name: string): string;
  62174. protected _buildBlock(state: NodeMaterialBuildState): this;
  62175. }
  62176. }
  62177. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  62178. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62179. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62180. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62181. /**
  62182. * Block used to lerp between 2 values
  62183. */
  62184. export class LerpBlock extends NodeMaterialBlock {
  62185. /**
  62186. * Creates a new LerpBlock
  62187. * @param name defines the block name
  62188. */
  62189. constructor(name: string);
  62190. /**
  62191. * Gets the current class name
  62192. * @returns the class name
  62193. */
  62194. getClassName(): string;
  62195. /**
  62196. * Gets the left operand input component
  62197. */
  62198. get left(): NodeMaterialConnectionPoint;
  62199. /**
  62200. * Gets the right operand input component
  62201. */
  62202. get right(): NodeMaterialConnectionPoint;
  62203. /**
  62204. * Gets the gradient operand input component
  62205. */
  62206. get gradient(): NodeMaterialConnectionPoint;
  62207. /**
  62208. * Gets the output component
  62209. */
  62210. get output(): NodeMaterialConnectionPoint;
  62211. protected _buildBlock(state: NodeMaterialBuildState): this;
  62212. }
  62213. }
  62214. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  62215. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62216. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62217. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62218. /**
  62219. * Block used to divide 2 vectors
  62220. */
  62221. export class DivideBlock extends NodeMaterialBlock {
  62222. /**
  62223. * Creates a new DivideBlock
  62224. * @param name defines the block name
  62225. */
  62226. constructor(name: string);
  62227. /**
  62228. * Gets the current class name
  62229. * @returns the class name
  62230. */
  62231. getClassName(): string;
  62232. /**
  62233. * Gets the left operand input component
  62234. */
  62235. get left(): NodeMaterialConnectionPoint;
  62236. /**
  62237. * Gets the right operand input component
  62238. */
  62239. get right(): NodeMaterialConnectionPoint;
  62240. /**
  62241. * Gets the output component
  62242. */
  62243. get output(): NodeMaterialConnectionPoint;
  62244. protected _buildBlock(state: NodeMaterialBuildState): this;
  62245. }
  62246. }
  62247. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  62248. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62249. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62250. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62251. /**
  62252. * Block used to subtract 2 vectors
  62253. */
  62254. export class SubtractBlock extends NodeMaterialBlock {
  62255. /**
  62256. * Creates a new SubtractBlock
  62257. * @param name defines the block name
  62258. */
  62259. constructor(name: string);
  62260. /**
  62261. * Gets the current class name
  62262. * @returns the class name
  62263. */
  62264. getClassName(): string;
  62265. /**
  62266. * Gets the left operand input component
  62267. */
  62268. get left(): NodeMaterialConnectionPoint;
  62269. /**
  62270. * Gets the right operand input component
  62271. */
  62272. get right(): NodeMaterialConnectionPoint;
  62273. /**
  62274. * Gets the output component
  62275. */
  62276. get output(): NodeMaterialConnectionPoint;
  62277. protected _buildBlock(state: NodeMaterialBuildState): this;
  62278. }
  62279. }
  62280. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  62281. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62282. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62283. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62284. /**
  62285. * Block used to step a value
  62286. */
  62287. export class StepBlock extends NodeMaterialBlock {
  62288. /**
  62289. * Creates a new StepBlock
  62290. * @param name defines the block name
  62291. */
  62292. constructor(name: string);
  62293. /**
  62294. * Gets the current class name
  62295. * @returns the class name
  62296. */
  62297. getClassName(): string;
  62298. /**
  62299. * Gets the value operand input component
  62300. */
  62301. get value(): NodeMaterialConnectionPoint;
  62302. /**
  62303. * Gets the edge operand input component
  62304. */
  62305. get edge(): NodeMaterialConnectionPoint;
  62306. /**
  62307. * Gets the output component
  62308. */
  62309. get output(): NodeMaterialConnectionPoint;
  62310. protected _buildBlock(state: NodeMaterialBuildState): this;
  62311. }
  62312. }
  62313. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  62314. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62315. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62316. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62317. /**
  62318. * Block used to get the opposite (1 - x) of a value
  62319. */
  62320. export class OneMinusBlock extends NodeMaterialBlock {
  62321. /**
  62322. * Creates a new OneMinusBlock
  62323. * @param name defines the block name
  62324. */
  62325. constructor(name: string);
  62326. /**
  62327. * Gets the current class name
  62328. * @returns the class name
  62329. */
  62330. getClassName(): string;
  62331. /**
  62332. * Gets the input component
  62333. */
  62334. get input(): NodeMaterialConnectionPoint;
  62335. /**
  62336. * Gets the output component
  62337. */
  62338. get output(): NodeMaterialConnectionPoint;
  62339. protected _buildBlock(state: NodeMaterialBuildState): this;
  62340. }
  62341. }
  62342. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  62343. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62344. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62345. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62346. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62347. /**
  62348. * Block used to get the view direction
  62349. */
  62350. export class ViewDirectionBlock extends NodeMaterialBlock {
  62351. /**
  62352. * Creates a new ViewDirectionBlock
  62353. * @param name defines the block name
  62354. */
  62355. constructor(name: string);
  62356. /**
  62357. * Gets the current class name
  62358. * @returns the class name
  62359. */
  62360. getClassName(): string;
  62361. /**
  62362. * Gets the world position component
  62363. */
  62364. get worldPosition(): NodeMaterialConnectionPoint;
  62365. /**
  62366. * Gets the camera position component
  62367. */
  62368. get cameraPosition(): NodeMaterialConnectionPoint;
  62369. /**
  62370. * Gets the output component
  62371. */
  62372. get output(): NodeMaterialConnectionPoint;
  62373. autoConfigure(material: NodeMaterial): void;
  62374. protected _buildBlock(state: NodeMaterialBuildState): this;
  62375. }
  62376. }
  62377. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  62378. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62379. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62380. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62381. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62382. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  62383. /**
  62384. * Block used to compute fresnel value
  62385. */
  62386. export class FresnelBlock extends NodeMaterialBlock {
  62387. /**
  62388. * Create a new FresnelBlock
  62389. * @param name defines the block name
  62390. */
  62391. constructor(name: string);
  62392. /**
  62393. * Gets the current class name
  62394. * @returns the class name
  62395. */
  62396. getClassName(): string;
  62397. /**
  62398. * Gets the world normal input component
  62399. */
  62400. get worldNormal(): NodeMaterialConnectionPoint;
  62401. /**
  62402. * Gets the view direction input component
  62403. */
  62404. get viewDirection(): NodeMaterialConnectionPoint;
  62405. /**
  62406. * Gets the bias input component
  62407. */
  62408. get bias(): NodeMaterialConnectionPoint;
  62409. /**
  62410. * Gets the camera (or eye) position component
  62411. */
  62412. get power(): NodeMaterialConnectionPoint;
  62413. /**
  62414. * Gets the fresnel output component
  62415. */
  62416. get fresnel(): NodeMaterialConnectionPoint;
  62417. autoConfigure(material: NodeMaterial): void;
  62418. protected _buildBlock(state: NodeMaterialBuildState): this;
  62419. }
  62420. }
  62421. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  62422. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62423. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62424. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62425. /**
  62426. * Block used to get the max of 2 values
  62427. */
  62428. export class MaxBlock extends NodeMaterialBlock {
  62429. /**
  62430. * Creates a new MaxBlock
  62431. * @param name defines the block name
  62432. */
  62433. constructor(name: string);
  62434. /**
  62435. * Gets the current class name
  62436. * @returns the class name
  62437. */
  62438. getClassName(): string;
  62439. /**
  62440. * Gets the left operand input component
  62441. */
  62442. get left(): NodeMaterialConnectionPoint;
  62443. /**
  62444. * Gets the right operand input component
  62445. */
  62446. get right(): NodeMaterialConnectionPoint;
  62447. /**
  62448. * Gets the output component
  62449. */
  62450. get output(): NodeMaterialConnectionPoint;
  62451. protected _buildBlock(state: NodeMaterialBuildState): this;
  62452. }
  62453. }
  62454. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  62455. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62456. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62457. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62458. /**
  62459. * Block used to get the min of 2 values
  62460. */
  62461. export class MinBlock extends NodeMaterialBlock {
  62462. /**
  62463. * Creates a new MinBlock
  62464. * @param name defines the block name
  62465. */
  62466. constructor(name: string);
  62467. /**
  62468. * Gets the current class name
  62469. * @returns the class name
  62470. */
  62471. getClassName(): string;
  62472. /**
  62473. * Gets the left operand input component
  62474. */
  62475. get left(): NodeMaterialConnectionPoint;
  62476. /**
  62477. * Gets the right operand input component
  62478. */
  62479. get right(): NodeMaterialConnectionPoint;
  62480. /**
  62481. * Gets the output component
  62482. */
  62483. get output(): NodeMaterialConnectionPoint;
  62484. protected _buildBlock(state: NodeMaterialBuildState): this;
  62485. }
  62486. }
  62487. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  62488. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62489. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62490. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62491. /**
  62492. * Block used to get the distance between 2 values
  62493. */
  62494. export class DistanceBlock extends NodeMaterialBlock {
  62495. /**
  62496. * Creates a new DistanceBlock
  62497. * @param name defines the block name
  62498. */
  62499. constructor(name: string);
  62500. /**
  62501. * Gets the current class name
  62502. * @returns the class name
  62503. */
  62504. getClassName(): string;
  62505. /**
  62506. * Gets the left operand input component
  62507. */
  62508. get left(): NodeMaterialConnectionPoint;
  62509. /**
  62510. * Gets the right operand input component
  62511. */
  62512. get right(): NodeMaterialConnectionPoint;
  62513. /**
  62514. * Gets the output component
  62515. */
  62516. get output(): NodeMaterialConnectionPoint;
  62517. protected _buildBlock(state: NodeMaterialBuildState): this;
  62518. }
  62519. }
  62520. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  62521. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62522. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62523. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62524. /**
  62525. * Block used to get the length of a vector
  62526. */
  62527. export class LengthBlock extends NodeMaterialBlock {
  62528. /**
  62529. * Creates a new LengthBlock
  62530. * @param name defines the block name
  62531. */
  62532. constructor(name: string);
  62533. /**
  62534. * Gets the current class name
  62535. * @returns the class name
  62536. */
  62537. getClassName(): string;
  62538. /**
  62539. * Gets the value input component
  62540. */
  62541. get value(): NodeMaterialConnectionPoint;
  62542. /**
  62543. * Gets the output component
  62544. */
  62545. get output(): NodeMaterialConnectionPoint;
  62546. protected _buildBlock(state: NodeMaterialBuildState): this;
  62547. }
  62548. }
  62549. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  62550. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62551. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62552. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62553. /**
  62554. * Block used to get negative version of a value (i.e. x * -1)
  62555. */
  62556. export class NegateBlock extends NodeMaterialBlock {
  62557. /**
  62558. * Creates a new NegateBlock
  62559. * @param name defines the block name
  62560. */
  62561. constructor(name: string);
  62562. /**
  62563. * Gets the current class name
  62564. * @returns the class name
  62565. */
  62566. getClassName(): string;
  62567. /**
  62568. * Gets the value input component
  62569. */
  62570. get value(): NodeMaterialConnectionPoint;
  62571. /**
  62572. * Gets the output component
  62573. */
  62574. get output(): NodeMaterialConnectionPoint;
  62575. protected _buildBlock(state: NodeMaterialBuildState): this;
  62576. }
  62577. }
  62578. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  62579. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62580. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62581. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62582. /**
  62583. * Block used to get the value of the first parameter raised to the power of the second
  62584. */
  62585. export class PowBlock extends NodeMaterialBlock {
  62586. /**
  62587. * Creates a new PowBlock
  62588. * @param name defines the block name
  62589. */
  62590. constructor(name: string);
  62591. /**
  62592. * Gets the current class name
  62593. * @returns the class name
  62594. */
  62595. getClassName(): string;
  62596. /**
  62597. * Gets the value operand input component
  62598. */
  62599. get value(): NodeMaterialConnectionPoint;
  62600. /**
  62601. * Gets the power operand input component
  62602. */
  62603. get power(): NodeMaterialConnectionPoint;
  62604. /**
  62605. * Gets the output component
  62606. */
  62607. get output(): NodeMaterialConnectionPoint;
  62608. protected _buildBlock(state: NodeMaterialBuildState): this;
  62609. }
  62610. }
  62611. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  62612. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62613. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62614. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62615. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62616. /**
  62617. * Block used to get a random number
  62618. */
  62619. export class RandomNumberBlock extends NodeMaterialBlock {
  62620. /**
  62621. * Creates a new RandomNumberBlock
  62622. * @param name defines the block name
  62623. */
  62624. constructor(name: string);
  62625. /**
  62626. * Gets the current class name
  62627. * @returns the class name
  62628. */
  62629. getClassName(): string;
  62630. /**
  62631. * Gets the seed input component
  62632. */
  62633. get seed(): NodeMaterialConnectionPoint;
  62634. /**
  62635. * Gets the output component
  62636. */
  62637. get output(): NodeMaterialConnectionPoint;
  62638. protected _buildBlock(state: NodeMaterialBuildState): this;
  62639. }
  62640. }
  62641. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  62642. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62643. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62644. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62645. /**
  62646. * Block used to compute arc tangent of 2 values
  62647. */
  62648. export class ArcTan2Block extends NodeMaterialBlock {
  62649. /**
  62650. * Creates a new ArcTan2Block
  62651. * @param name defines the block name
  62652. */
  62653. constructor(name: string);
  62654. /**
  62655. * Gets the current class name
  62656. * @returns the class name
  62657. */
  62658. getClassName(): string;
  62659. /**
  62660. * Gets the x operand input component
  62661. */
  62662. get x(): NodeMaterialConnectionPoint;
  62663. /**
  62664. * Gets the y operand input component
  62665. */
  62666. get y(): NodeMaterialConnectionPoint;
  62667. /**
  62668. * Gets the output component
  62669. */
  62670. get output(): NodeMaterialConnectionPoint;
  62671. protected _buildBlock(state: NodeMaterialBuildState): this;
  62672. }
  62673. }
  62674. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  62675. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62676. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62677. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62678. /**
  62679. * Block used to smooth step a value
  62680. */
  62681. export class SmoothStepBlock extends NodeMaterialBlock {
  62682. /**
  62683. * Creates a new SmoothStepBlock
  62684. * @param name defines the block name
  62685. */
  62686. constructor(name: string);
  62687. /**
  62688. * Gets the current class name
  62689. * @returns the class name
  62690. */
  62691. getClassName(): string;
  62692. /**
  62693. * Gets the value operand input component
  62694. */
  62695. get value(): NodeMaterialConnectionPoint;
  62696. /**
  62697. * Gets the first edge operand input component
  62698. */
  62699. get edge0(): NodeMaterialConnectionPoint;
  62700. /**
  62701. * Gets the second edge operand input component
  62702. */
  62703. get edge1(): NodeMaterialConnectionPoint;
  62704. /**
  62705. * Gets the output component
  62706. */
  62707. get output(): NodeMaterialConnectionPoint;
  62708. protected _buildBlock(state: NodeMaterialBuildState): this;
  62709. }
  62710. }
  62711. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  62712. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62713. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62714. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62715. /**
  62716. * Block used to get the reciprocal (1 / x) of a value
  62717. */
  62718. export class ReciprocalBlock extends NodeMaterialBlock {
  62719. /**
  62720. * Creates a new ReciprocalBlock
  62721. * @param name defines the block name
  62722. */
  62723. constructor(name: string);
  62724. /**
  62725. * Gets the current class name
  62726. * @returns the class name
  62727. */
  62728. getClassName(): string;
  62729. /**
  62730. * Gets the input component
  62731. */
  62732. get input(): NodeMaterialConnectionPoint;
  62733. /**
  62734. * Gets the output component
  62735. */
  62736. get output(): NodeMaterialConnectionPoint;
  62737. protected _buildBlock(state: NodeMaterialBuildState): this;
  62738. }
  62739. }
  62740. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  62741. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62742. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62743. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62744. /**
  62745. * Block used to replace a color by another one
  62746. */
  62747. export class ReplaceColorBlock extends NodeMaterialBlock {
  62748. /**
  62749. * Creates a new ReplaceColorBlock
  62750. * @param name defines the block name
  62751. */
  62752. constructor(name: string);
  62753. /**
  62754. * Gets the current class name
  62755. * @returns the class name
  62756. */
  62757. getClassName(): string;
  62758. /**
  62759. * Gets the value input component
  62760. */
  62761. get value(): NodeMaterialConnectionPoint;
  62762. /**
  62763. * Gets the reference input component
  62764. */
  62765. get reference(): NodeMaterialConnectionPoint;
  62766. /**
  62767. * Gets the distance input component
  62768. */
  62769. get distance(): NodeMaterialConnectionPoint;
  62770. /**
  62771. * Gets the replacement input component
  62772. */
  62773. get replacement(): NodeMaterialConnectionPoint;
  62774. /**
  62775. * Gets the output component
  62776. */
  62777. get output(): NodeMaterialConnectionPoint;
  62778. protected _buildBlock(state: NodeMaterialBuildState): this;
  62779. }
  62780. }
  62781. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  62782. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62783. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62784. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62785. /**
  62786. * Block used to posterize a value
  62787. * @see https://en.wikipedia.org/wiki/Posterization
  62788. */
  62789. export class PosterizeBlock extends NodeMaterialBlock {
  62790. /**
  62791. * Creates a new PosterizeBlock
  62792. * @param name defines the block name
  62793. */
  62794. constructor(name: string);
  62795. /**
  62796. * Gets the current class name
  62797. * @returns the class name
  62798. */
  62799. getClassName(): string;
  62800. /**
  62801. * Gets the value input component
  62802. */
  62803. get value(): NodeMaterialConnectionPoint;
  62804. /**
  62805. * Gets the steps input component
  62806. */
  62807. get steps(): NodeMaterialConnectionPoint;
  62808. /**
  62809. * Gets the output component
  62810. */
  62811. get output(): NodeMaterialConnectionPoint;
  62812. protected _buildBlock(state: NodeMaterialBuildState): this;
  62813. }
  62814. }
  62815. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  62816. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62817. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62818. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62819. import { Scene } from "babylonjs/scene";
  62820. /**
  62821. * Operations supported by the Wave block
  62822. */
  62823. export enum WaveBlockKind {
  62824. /** SawTooth */
  62825. SawTooth = 0,
  62826. /** Square */
  62827. Square = 1,
  62828. /** Triangle */
  62829. Triangle = 2
  62830. }
  62831. /**
  62832. * Block used to apply wave operation to floats
  62833. */
  62834. export class WaveBlock extends NodeMaterialBlock {
  62835. /**
  62836. * Gets or sets the kibnd of wave to be applied by the block
  62837. */
  62838. kind: WaveBlockKind;
  62839. /**
  62840. * Creates a new WaveBlock
  62841. * @param name defines the block name
  62842. */
  62843. constructor(name: string);
  62844. /**
  62845. * Gets the current class name
  62846. * @returns the class name
  62847. */
  62848. getClassName(): string;
  62849. /**
  62850. * Gets the input component
  62851. */
  62852. get input(): NodeMaterialConnectionPoint;
  62853. /**
  62854. * Gets the output component
  62855. */
  62856. get output(): NodeMaterialConnectionPoint;
  62857. protected _buildBlock(state: NodeMaterialBuildState): this;
  62858. serialize(): any;
  62859. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62860. }
  62861. }
  62862. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  62863. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62864. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62865. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62866. import { Color3 } from "babylonjs/Maths/math.color";
  62867. import { Scene } from "babylonjs/scene";
  62868. /**
  62869. * Class used to store a color step for the GradientBlock
  62870. */
  62871. export class GradientBlockColorStep {
  62872. /**
  62873. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62874. */
  62875. step: number;
  62876. /**
  62877. * Gets or sets the color associated with this step
  62878. */
  62879. color: Color3;
  62880. /**
  62881. * Creates a new GradientBlockColorStep
  62882. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62883. * @param color defines the color associated with this step
  62884. */
  62885. constructor(
  62886. /**
  62887. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62888. */
  62889. step: number,
  62890. /**
  62891. * Gets or sets the color associated with this step
  62892. */
  62893. color: Color3);
  62894. }
  62895. /**
  62896. * Block used to return a color from a gradient based on an input value between 0 and 1
  62897. */
  62898. export class GradientBlock extends NodeMaterialBlock {
  62899. /**
  62900. * Gets or sets the list of color steps
  62901. */
  62902. colorSteps: GradientBlockColorStep[];
  62903. /**
  62904. * Creates a new GradientBlock
  62905. * @param name defines the block name
  62906. */
  62907. constructor(name: string);
  62908. /**
  62909. * Gets the current class name
  62910. * @returns the class name
  62911. */
  62912. getClassName(): string;
  62913. /**
  62914. * Gets the gradient input component
  62915. */
  62916. get gradient(): NodeMaterialConnectionPoint;
  62917. /**
  62918. * Gets the output component
  62919. */
  62920. get output(): NodeMaterialConnectionPoint;
  62921. private _writeColorConstant;
  62922. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62923. serialize(): any;
  62924. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62925. protected _dumpPropertiesCode(): string;
  62926. }
  62927. }
  62928. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  62929. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62930. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62931. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62932. /**
  62933. * Block used to normalize lerp between 2 values
  62934. */
  62935. export class NLerpBlock extends NodeMaterialBlock {
  62936. /**
  62937. * Creates a new NLerpBlock
  62938. * @param name defines the block name
  62939. */
  62940. constructor(name: string);
  62941. /**
  62942. * Gets the current class name
  62943. * @returns the class name
  62944. */
  62945. getClassName(): string;
  62946. /**
  62947. * Gets the left operand input component
  62948. */
  62949. get left(): NodeMaterialConnectionPoint;
  62950. /**
  62951. * Gets the right operand input component
  62952. */
  62953. get right(): NodeMaterialConnectionPoint;
  62954. /**
  62955. * Gets the gradient operand input component
  62956. */
  62957. get gradient(): NodeMaterialConnectionPoint;
  62958. /**
  62959. * Gets the output component
  62960. */
  62961. get output(): NodeMaterialConnectionPoint;
  62962. protected _buildBlock(state: NodeMaterialBuildState): this;
  62963. }
  62964. }
  62965. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  62966. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62967. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62968. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62969. import { Scene } from "babylonjs/scene";
  62970. /**
  62971. * block used to Generate a Worley Noise 3D Noise Pattern
  62972. */
  62973. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62974. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62975. manhattanDistance: boolean;
  62976. /**
  62977. * Creates a new WorleyNoise3DBlock
  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 seed input component
  62988. */
  62989. get seed(): NodeMaterialConnectionPoint;
  62990. /**
  62991. * Gets the jitter input component
  62992. */
  62993. get jitter(): NodeMaterialConnectionPoint;
  62994. /**
  62995. * Gets the output component
  62996. */
  62997. get output(): NodeMaterialConnectionPoint;
  62998. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62999. /**
  63000. * Exposes the properties to the UI?
  63001. */
  63002. protected _dumpPropertiesCode(): string;
  63003. /**
  63004. * Exposes the properties to the Seralize?
  63005. */
  63006. serialize(): any;
  63007. /**
  63008. * Exposes the properties to the deseralize?
  63009. */
  63010. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63011. }
  63012. }
  63013. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  63014. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63015. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63016. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63017. /**
  63018. * block used to Generate a Simplex Perlin 3d Noise Pattern
  63019. */
  63020. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  63021. /**
  63022. * Creates a new SimplexPerlin3DBlock
  63023. * @param name defines the block name
  63024. */
  63025. constructor(name: string);
  63026. /**
  63027. * Gets the current class name
  63028. * @returns the class name
  63029. */
  63030. getClassName(): string;
  63031. /**
  63032. * Gets the seed operand input component
  63033. */
  63034. get seed(): NodeMaterialConnectionPoint;
  63035. /**
  63036. * Gets the output component
  63037. */
  63038. get output(): NodeMaterialConnectionPoint;
  63039. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63040. }
  63041. }
  63042. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  63043. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63044. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63045. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63046. /**
  63047. * Block used to blend normals
  63048. */
  63049. export class NormalBlendBlock extends NodeMaterialBlock {
  63050. /**
  63051. * Creates a new NormalBlendBlock
  63052. * @param name defines the block name
  63053. */
  63054. constructor(name: string);
  63055. /**
  63056. * Gets the current class name
  63057. * @returns the class name
  63058. */
  63059. getClassName(): string;
  63060. /**
  63061. * Gets the first input component
  63062. */
  63063. get normalMap0(): NodeMaterialConnectionPoint;
  63064. /**
  63065. * Gets the second input component
  63066. */
  63067. get normalMap1(): NodeMaterialConnectionPoint;
  63068. /**
  63069. * Gets the output component
  63070. */
  63071. get output(): NodeMaterialConnectionPoint;
  63072. protected _buildBlock(state: NodeMaterialBuildState): this;
  63073. }
  63074. }
  63075. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  63076. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63077. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63078. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63079. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  63080. /**
  63081. * Block used to rotate a 2d vector by a given angle
  63082. */
  63083. export class Rotate2dBlock extends NodeMaterialBlock {
  63084. /**
  63085. * Creates a new Rotate2dBlock
  63086. * @param name defines the block name
  63087. */
  63088. constructor(name: string);
  63089. /**
  63090. * Gets the current class name
  63091. * @returns the class name
  63092. */
  63093. getClassName(): string;
  63094. /**
  63095. * Gets the input vector
  63096. */
  63097. get input(): NodeMaterialConnectionPoint;
  63098. /**
  63099. * Gets the input angle
  63100. */
  63101. get angle(): NodeMaterialConnectionPoint;
  63102. /**
  63103. * Gets the output component
  63104. */
  63105. get output(): NodeMaterialConnectionPoint;
  63106. autoConfigure(material: NodeMaterial): void;
  63107. protected _buildBlock(state: NodeMaterialBuildState): this;
  63108. }
  63109. }
  63110. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  63111. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63112. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63113. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63114. /**
  63115. * Block used to get the reflected vector from a direction and a normal
  63116. */
  63117. export class ReflectBlock extends NodeMaterialBlock {
  63118. /**
  63119. * Creates a new ReflectBlock
  63120. * @param name defines the block name
  63121. */
  63122. constructor(name: string);
  63123. /**
  63124. * Gets the current class name
  63125. * @returns the class name
  63126. */
  63127. getClassName(): string;
  63128. /**
  63129. * Gets the incident component
  63130. */
  63131. get incident(): NodeMaterialConnectionPoint;
  63132. /**
  63133. * Gets the normal component
  63134. */
  63135. get normal(): NodeMaterialConnectionPoint;
  63136. /**
  63137. * Gets the output component
  63138. */
  63139. get output(): NodeMaterialConnectionPoint;
  63140. protected _buildBlock(state: NodeMaterialBuildState): this;
  63141. }
  63142. }
  63143. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  63144. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63145. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63146. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63147. /**
  63148. * Block used to get the refracted vector from a direction and a normal
  63149. */
  63150. export class RefractBlock extends NodeMaterialBlock {
  63151. /**
  63152. * Creates a new RefractBlock
  63153. * @param name defines the block name
  63154. */
  63155. constructor(name: string);
  63156. /**
  63157. * Gets the current class name
  63158. * @returns the class name
  63159. */
  63160. getClassName(): string;
  63161. /**
  63162. * Gets the incident component
  63163. */
  63164. get incident(): NodeMaterialConnectionPoint;
  63165. /**
  63166. * Gets the normal component
  63167. */
  63168. get normal(): NodeMaterialConnectionPoint;
  63169. /**
  63170. * Gets the index of refraction component
  63171. */
  63172. get ior(): NodeMaterialConnectionPoint;
  63173. /**
  63174. * Gets the output component
  63175. */
  63176. get output(): NodeMaterialConnectionPoint;
  63177. protected _buildBlock(state: NodeMaterialBuildState): this;
  63178. }
  63179. }
  63180. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  63181. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63182. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63183. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63184. /**
  63185. * Block used to desaturate a color
  63186. */
  63187. export class DesaturateBlock extends NodeMaterialBlock {
  63188. /**
  63189. * Creates a new DesaturateBlock
  63190. * @param name defines the block name
  63191. */
  63192. constructor(name: string);
  63193. /**
  63194. * Gets the current class name
  63195. * @returns the class name
  63196. */
  63197. getClassName(): string;
  63198. /**
  63199. * Gets the color operand input component
  63200. */
  63201. get color(): NodeMaterialConnectionPoint;
  63202. /**
  63203. * Gets the level operand input component
  63204. */
  63205. get level(): NodeMaterialConnectionPoint;
  63206. /**
  63207. * Gets the output component
  63208. */
  63209. get output(): NodeMaterialConnectionPoint;
  63210. protected _buildBlock(state: NodeMaterialBuildState): this;
  63211. }
  63212. }
  63213. declare module "babylonjs/Materials/Node/Blocks/index" {
  63214. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  63215. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  63216. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  63217. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  63218. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  63219. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  63220. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  63221. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  63222. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  63223. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  63224. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  63225. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  63226. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  63227. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  63228. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  63229. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  63230. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  63231. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  63232. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  63233. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  63234. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  63235. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  63236. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  63237. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  63238. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  63239. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  63240. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  63241. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  63242. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  63243. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  63244. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  63245. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  63246. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  63247. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  63248. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  63249. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  63250. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  63251. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  63252. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  63253. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  63254. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  63255. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  63256. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  63257. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  63258. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  63259. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  63260. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  63261. }
  63262. declare module "babylonjs/Materials/Node/Optimizers/index" {
  63263. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  63264. }
  63265. declare module "babylonjs/Materials/Node/index" {
  63266. export * from "babylonjs/Materials/Node/Enums/index";
  63267. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63268. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  63269. export * from "babylonjs/Materials/Node/nodeMaterial";
  63270. export * from "babylonjs/Materials/Node/Blocks/index";
  63271. export * from "babylonjs/Materials/Node/Optimizers/index";
  63272. }
  63273. declare module "babylonjs/Materials/effectRenderer" {
  63274. import { Nullable } from "babylonjs/types";
  63275. import { Texture } from "babylonjs/Materials/Textures/texture";
  63276. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63277. import { Viewport } from "babylonjs/Maths/math.viewport";
  63278. import { Observable } from "babylonjs/Misc/observable";
  63279. import { Effect } from "babylonjs/Materials/effect";
  63280. import "babylonjs/Engines/Extensions/engine.renderTarget";
  63281. import "babylonjs/Shaders/postprocess.vertex";
  63282. /**
  63283. * Effect Render Options
  63284. */
  63285. export interface IEffectRendererOptions {
  63286. /**
  63287. * Defines the vertices positions.
  63288. */
  63289. positions?: number[];
  63290. /**
  63291. * Defines the indices.
  63292. */
  63293. indices?: number[];
  63294. }
  63295. /**
  63296. * Helper class to render one or more effects
  63297. */
  63298. export class EffectRenderer {
  63299. private engine;
  63300. private static _DefaultOptions;
  63301. private _vertexBuffers;
  63302. private _indexBuffer;
  63303. private _ringBufferIndex;
  63304. private _ringScreenBuffer;
  63305. private _fullscreenViewport;
  63306. private _getNextFrameBuffer;
  63307. /**
  63308. * Creates an effect renderer
  63309. * @param engine the engine to use for rendering
  63310. * @param options defines the options of the effect renderer
  63311. */
  63312. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63313. /**
  63314. * Sets the current viewport in normalized coordinates 0-1
  63315. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63316. */
  63317. setViewport(viewport?: Viewport): void;
  63318. /**
  63319. * Binds the embedded attributes buffer to the effect.
  63320. * @param effect Defines the effect to bind the attributes for
  63321. */
  63322. bindBuffers(effect: Effect): void;
  63323. /**
  63324. * Sets the current effect wrapper to use during draw.
  63325. * The effect needs to be ready before calling this api.
  63326. * This also sets the default full screen position attribute.
  63327. * @param effectWrapper Defines the effect to draw with
  63328. */
  63329. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63330. /**
  63331. * Draws a full screen quad.
  63332. */
  63333. draw(): void;
  63334. /**
  63335. * renders one or more effects to a specified texture
  63336. * @param effectWrappers list of effects to renderer
  63337. * @param outputTexture texture to draw to, if null it will render to the screen
  63338. */
  63339. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  63340. /**
  63341. * Disposes of the effect renderer
  63342. */
  63343. dispose(): void;
  63344. }
  63345. /**
  63346. * Options to create an EffectWrapper
  63347. */
  63348. interface EffectWrapperCreationOptions {
  63349. /**
  63350. * Engine to use to create the effect
  63351. */
  63352. engine: ThinEngine;
  63353. /**
  63354. * Fragment shader for the effect
  63355. */
  63356. fragmentShader: string;
  63357. /**
  63358. * Vertex shader for the effect
  63359. */
  63360. vertexShader?: string;
  63361. /**
  63362. * Attributes to use in the shader
  63363. */
  63364. attributeNames?: Array<string>;
  63365. /**
  63366. * Uniforms to use in the shader
  63367. */
  63368. uniformNames?: Array<string>;
  63369. /**
  63370. * Texture sampler names to use in the shader
  63371. */
  63372. samplerNames?: Array<string>;
  63373. /**
  63374. * The friendly name of the effect displayed in Spector.
  63375. */
  63376. name?: string;
  63377. }
  63378. /**
  63379. * Wraps an effect to be used for rendering
  63380. */
  63381. export class EffectWrapper {
  63382. /**
  63383. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63384. */
  63385. onApplyObservable: Observable<{}>;
  63386. /**
  63387. * The underlying effect
  63388. */
  63389. effect: Effect;
  63390. /**
  63391. * Creates an effect to be renderer
  63392. * @param creationOptions options to create the effect
  63393. */
  63394. constructor(creationOptions: EffectWrapperCreationOptions);
  63395. /**
  63396. * Disposes of the effect wrapper
  63397. */
  63398. dispose(): void;
  63399. }
  63400. }
  63401. declare module "babylonjs/Materials/index" {
  63402. export * from "babylonjs/Materials/Background/index";
  63403. export * from "babylonjs/Materials/colorCurves";
  63404. export * from "babylonjs/Materials/iEffectFallbacks";
  63405. export * from "babylonjs/Materials/effectFallbacks";
  63406. export * from "babylonjs/Materials/effect";
  63407. export * from "babylonjs/Materials/fresnelParameters";
  63408. export * from "babylonjs/Materials/imageProcessingConfiguration";
  63409. export * from "babylonjs/Materials/material";
  63410. export * from "babylonjs/Materials/materialDefines";
  63411. export * from "babylonjs/Materials/materialHelper";
  63412. export * from "babylonjs/Materials/multiMaterial";
  63413. export * from "babylonjs/Materials/PBR/index";
  63414. export * from "babylonjs/Materials/pushMaterial";
  63415. export * from "babylonjs/Materials/shaderMaterial";
  63416. export * from "babylonjs/Materials/standardMaterial";
  63417. export * from "babylonjs/Materials/Textures/index";
  63418. export * from "babylonjs/Materials/uniformBuffer";
  63419. export * from "babylonjs/Materials/materialFlags";
  63420. export * from "babylonjs/Materials/Node/index";
  63421. export * from "babylonjs/Materials/effectRenderer";
  63422. }
  63423. declare module "babylonjs/Maths/index" {
  63424. export * from "babylonjs/Maths/math.scalar";
  63425. export * from "babylonjs/Maths/math";
  63426. export * from "babylonjs/Maths/sphericalPolynomial";
  63427. }
  63428. declare module "babylonjs/Misc/workerPool" {
  63429. import { IDisposable } from "babylonjs/scene";
  63430. /**
  63431. * Helper class to push actions to a pool of workers.
  63432. */
  63433. export class WorkerPool implements IDisposable {
  63434. private _workerInfos;
  63435. private _pendingActions;
  63436. /**
  63437. * Constructor
  63438. * @param workers Array of workers to use for actions
  63439. */
  63440. constructor(workers: Array<Worker>);
  63441. /**
  63442. * Terminates all workers and clears any pending actions.
  63443. */
  63444. dispose(): void;
  63445. /**
  63446. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63447. * pended until a worker has completed its action.
  63448. * @param action The action to perform. Call onComplete when the action is complete.
  63449. */
  63450. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63451. private _execute;
  63452. }
  63453. }
  63454. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  63455. import { IDisposable } from "babylonjs/scene";
  63456. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63457. /**
  63458. * Configuration for Draco compression
  63459. */
  63460. export interface IDracoCompressionConfiguration {
  63461. /**
  63462. * Configuration for the decoder.
  63463. */
  63464. decoder: {
  63465. /**
  63466. * The url to the WebAssembly module.
  63467. */
  63468. wasmUrl?: string;
  63469. /**
  63470. * The url to the WebAssembly binary.
  63471. */
  63472. wasmBinaryUrl?: string;
  63473. /**
  63474. * The url to the fallback JavaScript module.
  63475. */
  63476. fallbackUrl?: string;
  63477. };
  63478. }
  63479. /**
  63480. * Draco compression (https://google.github.io/draco/)
  63481. *
  63482. * This class wraps the Draco module.
  63483. *
  63484. * **Encoder**
  63485. *
  63486. * The encoder is not currently implemented.
  63487. *
  63488. * **Decoder**
  63489. *
  63490. * 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.
  63491. *
  63492. * To update the configuration, use the following code:
  63493. * ```javascript
  63494. * DracoCompression.Configuration = {
  63495. * decoder: {
  63496. * wasmUrl: "<url to the WebAssembly library>",
  63497. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63498. * fallbackUrl: "<url to the fallback JavaScript library>",
  63499. * }
  63500. * };
  63501. * ```
  63502. *
  63503. * 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.
  63504. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63505. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63506. *
  63507. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63508. * ```javascript
  63509. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63510. * ```
  63511. *
  63512. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63513. */
  63514. export class DracoCompression implements IDisposable {
  63515. private _workerPoolPromise?;
  63516. private _decoderModulePromise?;
  63517. /**
  63518. * The configuration. Defaults to the following urls:
  63519. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63520. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63521. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63522. */
  63523. static Configuration: IDracoCompressionConfiguration;
  63524. /**
  63525. * Returns true if the decoder configuration is available.
  63526. */
  63527. static get DecoderAvailable(): boolean;
  63528. /**
  63529. * Default number of workers to create when creating the draco compression object.
  63530. */
  63531. static DefaultNumWorkers: number;
  63532. private static GetDefaultNumWorkers;
  63533. private static _Default;
  63534. /**
  63535. * Default instance for the draco compression object.
  63536. */
  63537. static get Default(): DracoCompression;
  63538. /**
  63539. * Constructor
  63540. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63541. */
  63542. constructor(numWorkers?: number);
  63543. /**
  63544. * Stop all async operations and release resources.
  63545. */
  63546. dispose(): void;
  63547. /**
  63548. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63549. * @returns a promise that resolves when ready
  63550. */
  63551. whenReadyAsync(): Promise<void>;
  63552. /**
  63553. * Decode Draco compressed mesh data to vertex data.
  63554. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63555. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63556. * @returns A promise that resolves with the decoded vertex data
  63557. */
  63558. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63559. [kind: string]: number;
  63560. }): Promise<VertexData>;
  63561. }
  63562. }
  63563. declare module "babylonjs/Meshes/Compression/index" {
  63564. export * from "babylonjs/Meshes/Compression/dracoCompression";
  63565. }
  63566. declare module "babylonjs/Meshes/csg" {
  63567. import { Nullable } from "babylonjs/types";
  63568. import { Scene } from "babylonjs/scene";
  63569. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63570. import { Mesh } from "babylonjs/Meshes/mesh";
  63571. import { Material } from "babylonjs/Materials/material";
  63572. /**
  63573. * Class for building Constructive Solid Geometry
  63574. */
  63575. export class CSG {
  63576. private polygons;
  63577. /**
  63578. * The world matrix
  63579. */
  63580. matrix: Matrix;
  63581. /**
  63582. * Stores the position
  63583. */
  63584. position: Vector3;
  63585. /**
  63586. * Stores the rotation
  63587. */
  63588. rotation: Vector3;
  63589. /**
  63590. * Stores the rotation quaternion
  63591. */
  63592. rotationQuaternion: Nullable<Quaternion>;
  63593. /**
  63594. * Stores the scaling vector
  63595. */
  63596. scaling: Vector3;
  63597. /**
  63598. * Convert the Mesh to CSG
  63599. * @param mesh The Mesh to convert to CSG
  63600. * @returns A new CSG from the Mesh
  63601. */
  63602. static FromMesh(mesh: Mesh): CSG;
  63603. /**
  63604. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63605. * @param polygons Polygons used to construct a CSG solid
  63606. */
  63607. private static FromPolygons;
  63608. /**
  63609. * Clones, or makes a deep copy, of the CSG
  63610. * @returns A new CSG
  63611. */
  63612. clone(): CSG;
  63613. /**
  63614. * Unions this CSG with another CSG
  63615. * @param csg The CSG to union against this CSG
  63616. * @returns The unioned CSG
  63617. */
  63618. union(csg: CSG): CSG;
  63619. /**
  63620. * Unions this CSG with another CSG in place
  63621. * @param csg The CSG to union against this CSG
  63622. */
  63623. unionInPlace(csg: CSG): void;
  63624. /**
  63625. * Subtracts this CSG with another CSG
  63626. * @param csg The CSG to subtract against this CSG
  63627. * @returns A new CSG
  63628. */
  63629. subtract(csg: CSG): CSG;
  63630. /**
  63631. * Subtracts this CSG with another CSG in place
  63632. * @param csg The CSG to subtact against this CSG
  63633. */
  63634. subtractInPlace(csg: CSG): void;
  63635. /**
  63636. * Intersect this CSG with another CSG
  63637. * @param csg The CSG to intersect against this CSG
  63638. * @returns A new CSG
  63639. */
  63640. intersect(csg: CSG): CSG;
  63641. /**
  63642. * Intersects this CSG with another CSG in place
  63643. * @param csg The CSG to intersect against this CSG
  63644. */
  63645. intersectInPlace(csg: CSG): void;
  63646. /**
  63647. * Return a new CSG solid with solid and empty space switched. This solid is
  63648. * not modified.
  63649. * @returns A new CSG solid with solid and empty space switched
  63650. */
  63651. inverse(): CSG;
  63652. /**
  63653. * Inverses the CSG in place
  63654. */
  63655. inverseInPlace(): void;
  63656. /**
  63657. * This is used to keep meshes transformations so they can be restored
  63658. * when we build back a Babylon Mesh
  63659. * NB : All CSG operations are performed in world coordinates
  63660. * @param csg The CSG to copy the transform attributes from
  63661. * @returns This CSG
  63662. */
  63663. copyTransformAttributes(csg: CSG): CSG;
  63664. /**
  63665. * Build Raw mesh from CSG
  63666. * Coordinates here are in world space
  63667. * @param name The name of the mesh geometry
  63668. * @param scene The Scene
  63669. * @param keepSubMeshes Specifies if the submeshes should be kept
  63670. * @returns A new Mesh
  63671. */
  63672. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63673. /**
  63674. * Build Mesh from CSG taking material and transforms into account
  63675. * @param name The name of the Mesh
  63676. * @param material The material of the Mesh
  63677. * @param scene The Scene
  63678. * @param keepSubMeshes Specifies if submeshes should be kept
  63679. * @returns The new Mesh
  63680. */
  63681. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63682. }
  63683. }
  63684. declare module "babylonjs/Meshes/trailMesh" {
  63685. import { Mesh } from "babylonjs/Meshes/mesh";
  63686. import { Scene } from "babylonjs/scene";
  63687. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63688. /**
  63689. * Class used to create a trail following a mesh
  63690. */
  63691. export class TrailMesh extends Mesh {
  63692. private _generator;
  63693. private _autoStart;
  63694. private _running;
  63695. private _diameter;
  63696. private _length;
  63697. private _sectionPolygonPointsCount;
  63698. private _sectionVectors;
  63699. private _sectionNormalVectors;
  63700. private _beforeRenderObserver;
  63701. /**
  63702. * @constructor
  63703. * @param name The value used by scene.getMeshByName() to do a lookup.
  63704. * @param generator The mesh or transform node to generate a trail.
  63705. * @param scene The scene to add this mesh to.
  63706. * @param diameter Diameter of trailing mesh. Default is 1.
  63707. * @param length Length of trailing mesh. Default is 60.
  63708. * @param autoStart Automatically start trailing mesh. Default true.
  63709. */
  63710. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  63711. /**
  63712. * "TrailMesh"
  63713. * @returns "TrailMesh"
  63714. */
  63715. getClassName(): string;
  63716. private _createMesh;
  63717. /**
  63718. * Start trailing mesh.
  63719. */
  63720. start(): void;
  63721. /**
  63722. * Stop trailing mesh.
  63723. */
  63724. stop(): void;
  63725. /**
  63726. * Update trailing mesh geometry.
  63727. */
  63728. update(): void;
  63729. /**
  63730. * Returns a new TrailMesh object.
  63731. * @param name is a string, the name given to the new mesh
  63732. * @param newGenerator use new generator object for cloned trail mesh
  63733. * @returns a new mesh
  63734. */
  63735. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  63736. /**
  63737. * Serializes this trail mesh
  63738. * @param serializationObject object to write serialization to
  63739. */
  63740. serialize(serializationObject: any): void;
  63741. /**
  63742. * Parses a serialized trail mesh
  63743. * @param parsedMesh the serialized mesh
  63744. * @param scene the scene to create the trail mesh in
  63745. * @returns the created trail mesh
  63746. */
  63747. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  63748. }
  63749. }
  63750. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  63751. import { Nullable } from "babylonjs/types";
  63752. import { Scene } from "babylonjs/scene";
  63753. import { Vector4 } from "babylonjs/Maths/math.vector";
  63754. import { Color4 } from "babylonjs/Maths/math.color";
  63755. import { Mesh } from "babylonjs/Meshes/mesh";
  63756. /**
  63757. * Class containing static functions to help procedurally build meshes
  63758. */
  63759. export class TiledBoxBuilder {
  63760. /**
  63761. * Creates a box mesh
  63762. * 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)
  63763. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63765. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  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. * @param name defines the name of the mesh
  63768. * @param options defines the options used to create the mesh
  63769. * @param scene defines the hosting scene
  63770. * @returns the box mesh
  63771. */
  63772. static CreateTiledBox(name: string, options: {
  63773. pattern?: number;
  63774. width?: number;
  63775. height?: number;
  63776. depth?: number;
  63777. tileSize?: number;
  63778. tileWidth?: number;
  63779. tileHeight?: number;
  63780. alignHorizontal?: number;
  63781. alignVertical?: number;
  63782. faceUV?: Vector4[];
  63783. faceColors?: Color4[];
  63784. sideOrientation?: number;
  63785. updatable?: boolean;
  63786. }, scene?: Nullable<Scene>): Mesh;
  63787. }
  63788. }
  63789. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  63790. import { Vector4 } from "babylonjs/Maths/math.vector";
  63791. import { Mesh } from "babylonjs/Meshes/mesh";
  63792. /**
  63793. * Class containing static functions to help procedurally build meshes
  63794. */
  63795. export class TorusKnotBuilder {
  63796. /**
  63797. * Creates a torus knot mesh
  63798. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63799. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63800. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63801. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63802. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63803. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63804. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63805. * @param name defines the name of the mesh
  63806. * @param options defines the options used to create the mesh
  63807. * @param scene defines the hosting scene
  63808. * @returns the torus knot mesh
  63809. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63810. */
  63811. static CreateTorusKnot(name: string, options: {
  63812. radius?: number;
  63813. tube?: number;
  63814. radialSegments?: number;
  63815. tubularSegments?: number;
  63816. p?: number;
  63817. q?: number;
  63818. updatable?: boolean;
  63819. sideOrientation?: number;
  63820. frontUVs?: Vector4;
  63821. backUVs?: Vector4;
  63822. }, scene: any): Mesh;
  63823. }
  63824. }
  63825. declare module "babylonjs/Meshes/polygonMesh" {
  63826. import { Scene } from "babylonjs/scene";
  63827. import { Vector2 } from "babylonjs/Maths/math.vector";
  63828. import { Mesh } from "babylonjs/Meshes/mesh";
  63829. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63830. import { Path2 } from "babylonjs/Maths/math.path";
  63831. /**
  63832. * Polygon
  63833. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  63834. */
  63835. export class Polygon {
  63836. /**
  63837. * Creates a rectangle
  63838. * @param xmin bottom X coord
  63839. * @param ymin bottom Y coord
  63840. * @param xmax top X coord
  63841. * @param ymax top Y coord
  63842. * @returns points that make the resulting rectation
  63843. */
  63844. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  63845. /**
  63846. * Creates a circle
  63847. * @param radius radius of circle
  63848. * @param cx scale in x
  63849. * @param cy scale in y
  63850. * @param numberOfSides number of sides that make up the circle
  63851. * @returns points that make the resulting circle
  63852. */
  63853. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  63854. /**
  63855. * Creates a polygon from input string
  63856. * @param input Input polygon data
  63857. * @returns the parsed points
  63858. */
  63859. static Parse(input: string): Vector2[];
  63860. /**
  63861. * Starts building a polygon from x and y coordinates
  63862. * @param x x coordinate
  63863. * @param y y coordinate
  63864. * @returns the started path2
  63865. */
  63866. static StartingAt(x: number, y: number): Path2;
  63867. }
  63868. /**
  63869. * Builds a polygon
  63870. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  63871. */
  63872. export class PolygonMeshBuilder {
  63873. private _points;
  63874. private _outlinepoints;
  63875. private _holes;
  63876. private _name;
  63877. private _scene;
  63878. private _epoints;
  63879. private _eholes;
  63880. private _addToepoint;
  63881. /**
  63882. * Babylon reference to the earcut plugin.
  63883. */
  63884. bjsEarcut: any;
  63885. /**
  63886. * Creates a PolygonMeshBuilder
  63887. * @param name name of the builder
  63888. * @param contours Path of the polygon
  63889. * @param scene scene to add to when creating the mesh
  63890. * @param earcutInjection can be used to inject your own earcut reference
  63891. */
  63892. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  63893. /**
  63894. * Adds a whole within the polygon
  63895. * @param hole Array of points defining the hole
  63896. * @returns this
  63897. */
  63898. addHole(hole: Vector2[]): PolygonMeshBuilder;
  63899. /**
  63900. * Creates the polygon
  63901. * @param updatable If the mesh should be updatable
  63902. * @param depth The depth of the mesh created
  63903. * @returns the created mesh
  63904. */
  63905. build(updatable?: boolean, depth?: number): Mesh;
  63906. /**
  63907. * Creates the polygon
  63908. * @param depth The depth of the mesh created
  63909. * @returns the created VertexData
  63910. */
  63911. buildVertexData(depth?: number): VertexData;
  63912. /**
  63913. * Adds a side to the polygon
  63914. * @param positions points that make the polygon
  63915. * @param normals normals of the polygon
  63916. * @param uvs uvs of the polygon
  63917. * @param indices indices of the polygon
  63918. * @param bounds bounds of the polygon
  63919. * @param points points of the polygon
  63920. * @param depth depth of the polygon
  63921. * @param flip flip of the polygon
  63922. */
  63923. private addSide;
  63924. }
  63925. }
  63926. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  63927. import { Scene } from "babylonjs/scene";
  63928. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63929. import { Color4 } from "babylonjs/Maths/math.color";
  63930. import { Mesh } from "babylonjs/Meshes/mesh";
  63931. import { Nullable } from "babylonjs/types";
  63932. /**
  63933. * Class containing static functions to help procedurally build meshes
  63934. */
  63935. export class PolygonBuilder {
  63936. /**
  63937. * Creates a polygon mesh
  63938. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63939. * * 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
  63940. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63941. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63942. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  63943. * * Remember you can only change the shape positions, not their number when updating a polygon
  63944. * @param name defines the name of the mesh
  63945. * @param options defines the options used to create the mesh
  63946. * @param scene defines the hosting scene
  63947. * @param earcutInjection can be used to inject your own earcut reference
  63948. * @returns the polygon mesh
  63949. */
  63950. static CreatePolygon(name: string, options: {
  63951. shape: Vector3[];
  63952. holes?: Vector3[][];
  63953. depth?: number;
  63954. faceUV?: Vector4[];
  63955. faceColors?: Color4[];
  63956. updatable?: boolean;
  63957. sideOrientation?: number;
  63958. frontUVs?: Vector4;
  63959. backUVs?: Vector4;
  63960. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63961. /**
  63962. * Creates an extruded polygon mesh, with depth in the Y direction.
  63963. * * 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)
  63964. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63965. * @param name defines the name of the mesh
  63966. * @param options defines the options used to create the mesh
  63967. * @param scene defines the hosting scene
  63968. * @param earcutInjection can be used to inject your own earcut reference
  63969. * @returns the polygon mesh
  63970. */
  63971. static ExtrudePolygon(name: string, options: {
  63972. shape: Vector3[];
  63973. holes?: Vector3[][];
  63974. depth?: number;
  63975. faceUV?: Vector4[];
  63976. faceColors?: Color4[];
  63977. updatable?: boolean;
  63978. sideOrientation?: number;
  63979. frontUVs?: Vector4;
  63980. backUVs?: Vector4;
  63981. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63982. }
  63983. }
  63984. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  63985. import { Scene } from "babylonjs/scene";
  63986. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63987. import { Mesh } from "babylonjs/Meshes/mesh";
  63988. import { Nullable } from "babylonjs/types";
  63989. /**
  63990. * Class containing static functions to help procedurally build meshes
  63991. */
  63992. export class LatheBuilder {
  63993. /**
  63994. * Creates lathe mesh.
  63995. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63996. * * 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
  63997. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63998. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63999. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64000. * * 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
  64001. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64002. * * 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
  64003. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64004. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64005. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64006. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64007. * @param name defines the name of the mesh
  64008. * @param options defines the options used to create the mesh
  64009. * @param scene defines the hosting scene
  64010. * @returns the lathe mesh
  64011. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64012. */
  64013. static CreateLathe(name: string, options: {
  64014. shape: Vector3[];
  64015. radius?: number;
  64016. tessellation?: number;
  64017. clip?: number;
  64018. arc?: number;
  64019. closed?: boolean;
  64020. updatable?: boolean;
  64021. sideOrientation?: number;
  64022. frontUVs?: Vector4;
  64023. backUVs?: Vector4;
  64024. cap?: number;
  64025. invertUV?: boolean;
  64026. }, scene?: Nullable<Scene>): Mesh;
  64027. }
  64028. }
  64029. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  64030. import { Nullable } from "babylonjs/types";
  64031. import { Scene } from "babylonjs/scene";
  64032. import { Vector4 } from "babylonjs/Maths/math.vector";
  64033. import { Mesh } from "babylonjs/Meshes/mesh";
  64034. /**
  64035. * Class containing static functions to help procedurally build meshes
  64036. */
  64037. export class TiledPlaneBuilder {
  64038. /**
  64039. * Creates a tiled plane mesh
  64040. * * The parameter `pattern` will, depending on value, do nothing or
  64041. * * * flip (reflect about central vertical) alternate tiles across and up
  64042. * * * flip every tile on alternate rows
  64043. * * * rotate (180 degs) alternate tiles across and up
  64044. * * * rotate every tile on alternate rows
  64045. * * * flip and rotate alternate tiles across and up
  64046. * * * flip and rotate every tile on alternate rows
  64047. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  64048. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  64049. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64050. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64051. * * 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)
  64052. * * 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)
  64053. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64054. * @param name defines the name of the mesh
  64055. * @param options defines the options used to create the mesh
  64056. * @param scene defines the hosting scene
  64057. * @returns the box mesh
  64058. */
  64059. static CreateTiledPlane(name: string, options: {
  64060. pattern?: number;
  64061. tileSize?: number;
  64062. tileWidth?: number;
  64063. tileHeight?: number;
  64064. size?: number;
  64065. width?: number;
  64066. height?: number;
  64067. alignHorizontal?: number;
  64068. alignVertical?: number;
  64069. sideOrientation?: number;
  64070. frontUVs?: Vector4;
  64071. backUVs?: Vector4;
  64072. updatable?: boolean;
  64073. }, scene?: Nullable<Scene>): Mesh;
  64074. }
  64075. }
  64076. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  64077. import { Nullable } from "babylonjs/types";
  64078. import { Scene } from "babylonjs/scene";
  64079. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  64080. import { Mesh } from "babylonjs/Meshes/mesh";
  64081. /**
  64082. * Class containing static functions to help procedurally build meshes
  64083. */
  64084. export class TubeBuilder {
  64085. /**
  64086. * Creates a tube mesh.
  64087. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64088. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64089. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64090. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64091. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64092. * * 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)
  64093. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64094. * * 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
  64095. * * 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
  64096. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64097. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64098. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64100. * @param name defines the name of the mesh
  64101. * @param options defines the options used to create the mesh
  64102. * @param scene defines the hosting scene
  64103. * @returns the tube mesh
  64104. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64105. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64106. */
  64107. static CreateTube(name: string, options: {
  64108. path: Vector3[];
  64109. radius?: number;
  64110. tessellation?: number;
  64111. radiusFunction?: {
  64112. (i: number, distance: number): number;
  64113. };
  64114. cap?: number;
  64115. arc?: number;
  64116. updatable?: boolean;
  64117. sideOrientation?: number;
  64118. frontUVs?: Vector4;
  64119. backUVs?: Vector4;
  64120. instance?: Mesh;
  64121. invertUV?: boolean;
  64122. }, scene?: Nullable<Scene>): Mesh;
  64123. }
  64124. }
  64125. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  64126. import { Scene } from "babylonjs/scene";
  64127. import { Vector4 } from "babylonjs/Maths/math.vector";
  64128. import { Mesh } from "babylonjs/Meshes/mesh";
  64129. import { Nullable } from "babylonjs/types";
  64130. /**
  64131. * Class containing static functions to help procedurally build meshes
  64132. */
  64133. export class IcoSphereBuilder {
  64134. /**
  64135. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64136. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64137. * * 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`)
  64138. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64139. * * 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
  64140. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64141. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64142. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64143. * @param name defines the name of the mesh
  64144. * @param options defines the options used to create the mesh
  64145. * @param scene defines the hosting scene
  64146. * @returns the icosahedron mesh
  64147. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64148. */
  64149. static CreateIcoSphere(name: string, options: {
  64150. radius?: number;
  64151. radiusX?: number;
  64152. radiusY?: number;
  64153. radiusZ?: number;
  64154. flat?: boolean;
  64155. subdivisions?: number;
  64156. sideOrientation?: number;
  64157. frontUVs?: Vector4;
  64158. backUVs?: Vector4;
  64159. updatable?: boolean;
  64160. }, scene?: Nullable<Scene>): Mesh;
  64161. }
  64162. }
  64163. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  64164. import { Vector3 } from "babylonjs/Maths/math.vector";
  64165. import { Mesh } from "babylonjs/Meshes/mesh";
  64166. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64167. /**
  64168. * Class containing static functions to help procedurally build meshes
  64169. */
  64170. export class DecalBuilder {
  64171. /**
  64172. * Creates a decal mesh.
  64173. * 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
  64174. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64175. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64176. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64177. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64178. * @param name defines the name of the mesh
  64179. * @param sourceMesh defines the mesh where the decal must be applied
  64180. * @param options defines the options used to create the mesh
  64181. * @param scene defines the hosting scene
  64182. * @returns the decal mesh
  64183. * @see https://doc.babylonjs.com/how_to/decals
  64184. */
  64185. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64186. position?: Vector3;
  64187. normal?: Vector3;
  64188. size?: Vector3;
  64189. angle?: number;
  64190. }): Mesh;
  64191. }
  64192. }
  64193. declare module "babylonjs/Meshes/meshBuilder" {
  64194. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  64195. import { Nullable } from "babylonjs/types";
  64196. import { Scene } from "babylonjs/scene";
  64197. import { Mesh } from "babylonjs/Meshes/mesh";
  64198. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  64199. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  64200. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64201. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  64202. import { Plane } from "babylonjs/Maths/math.plane";
  64203. /**
  64204. * Class containing static functions to help procedurally build meshes
  64205. */
  64206. export class MeshBuilder {
  64207. /**
  64208. * Creates a box mesh
  64209. * * The parameter `size` sets the size (float) of each box side (default 1)
  64210. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64211. * * 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)
  64212. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64213. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64214. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64215. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64216. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64217. * @param name defines the name of the mesh
  64218. * @param options defines the options used to create the mesh
  64219. * @param scene defines the hosting scene
  64220. * @returns the box mesh
  64221. */
  64222. static CreateBox(name: string, options: {
  64223. size?: number;
  64224. width?: number;
  64225. height?: number;
  64226. depth?: number;
  64227. faceUV?: Vector4[];
  64228. faceColors?: Color4[];
  64229. sideOrientation?: number;
  64230. frontUVs?: Vector4;
  64231. backUVs?: Vector4;
  64232. updatable?: boolean;
  64233. }, scene?: Nullable<Scene>): Mesh;
  64234. /**
  64235. * Creates a tiled box mesh
  64236. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64237. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64238. * @param name defines the name of the mesh
  64239. * @param options defines the options used to create the mesh
  64240. * @param scene defines the hosting scene
  64241. * @returns the tiled box mesh
  64242. */
  64243. static CreateTiledBox(name: string, options: {
  64244. pattern?: number;
  64245. size?: number;
  64246. width?: number;
  64247. height?: number;
  64248. depth: number;
  64249. tileSize?: number;
  64250. tileWidth?: number;
  64251. tileHeight?: number;
  64252. faceUV?: Vector4[];
  64253. faceColors?: Color4[];
  64254. alignHorizontal?: number;
  64255. alignVertical?: number;
  64256. sideOrientation?: number;
  64257. updatable?: boolean;
  64258. }, scene?: Nullable<Scene>): Mesh;
  64259. /**
  64260. * Creates a sphere mesh
  64261. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64262. * * 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`)
  64263. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64264. * * 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
  64265. * * 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)
  64266. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64267. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64269. * @param name defines the name of the mesh
  64270. * @param options defines the options used to create the mesh
  64271. * @param scene defines the hosting scene
  64272. * @returns the sphere mesh
  64273. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64274. */
  64275. static CreateSphere(name: string, options: {
  64276. segments?: number;
  64277. diameter?: number;
  64278. diameterX?: number;
  64279. diameterY?: number;
  64280. diameterZ?: number;
  64281. arc?: number;
  64282. slice?: number;
  64283. sideOrientation?: number;
  64284. frontUVs?: Vector4;
  64285. backUVs?: Vector4;
  64286. updatable?: boolean;
  64287. }, scene?: Nullable<Scene>): Mesh;
  64288. /**
  64289. * Creates a plane polygonal mesh. By default, this is a disc
  64290. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64291. * * 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
  64292. * * 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
  64293. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64294. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64295. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64296. * @param name defines the name of the mesh
  64297. * @param options defines the options used to create the mesh
  64298. * @param scene defines the hosting scene
  64299. * @returns the plane polygonal mesh
  64300. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64301. */
  64302. static CreateDisc(name: string, options: {
  64303. radius?: number;
  64304. tessellation?: number;
  64305. arc?: number;
  64306. updatable?: boolean;
  64307. sideOrientation?: number;
  64308. frontUVs?: Vector4;
  64309. backUVs?: Vector4;
  64310. }, scene?: Nullable<Scene>): Mesh;
  64311. /**
  64312. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64313. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64314. * * 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`)
  64315. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64316. * * 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
  64317. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64318. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64320. * @param name defines the name of the mesh
  64321. * @param options defines the options used to create the mesh
  64322. * @param scene defines the hosting scene
  64323. * @returns the icosahedron mesh
  64324. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64325. */
  64326. static CreateIcoSphere(name: string, options: {
  64327. radius?: number;
  64328. radiusX?: number;
  64329. radiusY?: number;
  64330. radiusZ?: number;
  64331. flat?: boolean;
  64332. subdivisions?: number;
  64333. sideOrientation?: number;
  64334. frontUVs?: Vector4;
  64335. backUVs?: Vector4;
  64336. updatable?: boolean;
  64337. }, scene?: Nullable<Scene>): Mesh;
  64338. /**
  64339. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64340. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64341. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64342. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64343. * * 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
  64344. * * 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
  64345. * * 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
  64346. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64347. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64348. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64349. * * 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
  64350. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64351. * * 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
  64352. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  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 ribbon mesh
  64358. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64359. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64360. */
  64361. static CreateRibbon(name: string, options: {
  64362. pathArray: Vector3[][];
  64363. closeArray?: boolean;
  64364. closePath?: boolean;
  64365. offset?: number;
  64366. updatable?: boolean;
  64367. sideOrientation?: number;
  64368. frontUVs?: Vector4;
  64369. backUVs?: Vector4;
  64370. instance?: Mesh;
  64371. invertUV?: boolean;
  64372. uvs?: Vector2[];
  64373. colors?: Color4[];
  64374. }, scene?: Nullable<Scene>): Mesh;
  64375. /**
  64376. * Creates a cylinder or a cone mesh
  64377. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64378. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64379. * * 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.
  64380. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64381. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64382. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64383. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64384. * * 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).
  64385. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64386. * * 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).
  64387. * * 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
  64388. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64389. * * 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
  64390. * * 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.
  64391. * * If `enclose` is false, a ring surface is one element.
  64392. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64393. * * 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
  64394. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64395. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64396. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64397. * @param name defines the name of the mesh
  64398. * @param options defines the options used to create the mesh
  64399. * @param scene defines the hosting scene
  64400. * @returns the cylinder mesh
  64401. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64402. */
  64403. static CreateCylinder(name: string, options: {
  64404. height?: number;
  64405. diameterTop?: number;
  64406. diameterBottom?: number;
  64407. diameter?: number;
  64408. tessellation?: number;
  64409. subdivisions?: number;
  64410. arc?: number;
  64411. faceColors?: Color4[];
  64412. faceUV?: Vector4[];
  64413. updatable?: boolean;
  64414. hasRings?: boolean;
  64415. enclose?: boolean;
  64416. cap?: number;
  64417. sideOrientation?: number;
  64418. frontUVs?: Vector4;
  64419. backUVs?: Vector4;
  64420. }, scene?: Nullable<Scene>): Mesh;
  64421. /**
  64422. * Creates a torus mesh
  64423. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64424. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64425. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64426. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64427. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64428. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64429. * @param name defines the name of the mesh
  64430. * @param options defines the options used to create the mesh
  64431. * @param scene defines the hosting scene
  64432. * @returns the torus mesh
  64433. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64434. */
  64435. static CreateTorus(name: string, options: {
  64436. diameter?: number;
  64437. thickness?: number;
  64438. tessellation?: number;
  64439. updatable?: boolean;
  64440. sideOrientation?: number;
  64441. frontUVs?: Vector4;
  64442. backUVs?: Vector4;
  64443. }, scene?: Nullable<Scene>): Mesh;
  64444. /**
  64445. * Creates a torus knot mesh
  64446. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64447. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64448. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64449. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64450. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64451. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64453. * @param name defines the name of the mesh
  64454. * @param options defines the options used to create the mesh
  64455. * @param scene defines the hosting scene
  64456. * @returns the torus knot mesh
  64457. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64458. */
  64459. static CreateTorusKnot(name: string, options: {
  64460. radius?: number;
  64461. tube?: number;
  64462. radialSegments?: number;
  64463. tubularSegments?: number;
  64464. p?: number;
  64465. q?: number;
  64466. updatable?: boolean;
  64467. sideOrientation?: number;
  64468. frontUVs?: Vector4;
  64469. backUVs?: Vector4;
  64470. }, scene?: Nullable<Scene>): Mesh;
  64471. /**
  64472. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64473. * * 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
  64474. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64475. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64476. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64477. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64478. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64479. * * 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
  64480. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  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. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64483. * @param name defines the name of the new line system
  64484. * @param options defines the options used to create the line system
  64485. * @param scene defines the hosting scene
  64486. * @returns a new line system mesh
  64487. */
  64488. static CreateLineSystem(name: string, options: {
  64489. lines: Vector3[][];
  64490. updatable?: boolean;
  64491. instance?: Nullable<LinesMesh>;
  64492. colors?: Nullable<Color4[][]>;
  64493. useVertexAlpha?: boolean;
  64494. }, scene: Nullable<Scene>): LinesMesh;
  64495. /**
  64496. * Creates a line mesh
  64497. * 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
  64498. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64499. * * The parameter `points` is an array successive Vector3
  64500. * * 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
  64501. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64502. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64503. * * When updating an instance, remember that only point positions can change, not the number of points
  64504. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64505. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64506. * @param name defines the name of the new line system
  64507. * @param options defines the options used to create the line system
  64508. * @param scene defines the hosting scene
  64509. * @returns a new line mesh
  64510. */
  64511. static CreateLines(name: string, options: {
  64512. points: Vector3[];
  64513. updatable?: boolean;
  64514. instance?: Nullable<LinesMesh>;
  64515. colors?: Color4[];
  64516. useVertexAlpha?: boolean;
  64517. }, scene?: Nullable<Scene>): LinesMesh;
  64518. /**
  64519. * Creates a dashed line mesh
  64520. * * 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
  64521. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64522. * * The parameter `points` is an array successive Vector3
  64523. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64524. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64525. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64526. * * 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
  64527. * * When updating an instance, remember that only point positions can change, not the number of points
  64528. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64529. * @param name defines the name of the mesh
  64530. * @param options defines the options used to create the mesh
  64531. * @param scene defines the hosting scene
  64532. * @returns the dashed line mesh
  64533. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64534. */
  64535. static CreateDashedLines(name: string, options: {
  64536. points: Vector3[];
  64537. dashSize?: number;
  64538. gapSize?: number;
  64539. dashNb?: number;
  64540. updatable?: boolean;
  64541. instance?: LinesMesh;
  64542. }, scene?: Nullable<Scene>): LinesMesh;
  64543. /**
  64544. * 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.
  64545. * * 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.
  64546. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64547. * * 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.
  64548. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64549. * * 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
  64550. * * 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
  64551. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64552. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64553. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64554. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64556. * @param name defines the name of the mesh
  64557. * @param options defines the options used to create the mesh
  64558. * @param scene defines the hosting scene
  64559. * @returns the extruded shape mesh
  64560. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64561. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64562. */
  64563. static ExtrudeShape(name: string, options: {
  64564. shape: Vector3[];
  64565. path: Vector3[];
  64566. scale?: number;
  64567. rotation?: number;
  64568. cap?: number;
  64569. updatable?: boolean;
  64570. sideOrientation?: number;
  64571. frontUVs?: Vector4;
  64572. backUVs?: Vector4;
  64573. instance?: Mesh;
  64574. invertUV?: boolean;
  64575. }, scene?: Nullable<Scene>): Mesh;
  64576. /**
  64577. * Creates an custom extruded shape mesh.
  64578. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64579. * * 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.
  64580. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64581. * * 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
  64582. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64583. * * 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
  64584. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64585. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64586. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64587. * * 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
  64588. * * 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
  64589. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64590. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64591. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64592. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64593. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64594. * @param name defines the name of the mesh
  64595. * @param options defines the options used to create the mesh
  64596. * @param scene defines the hosting scene
  64597. * @returns the custom extruded shape mesh
  64598. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64599. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64600. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64601. */
  64602. static ExtrudeShapeCustom(name: string, options: {
  64603. shape: Vector3[];
  64604. path: Vector3[];
  64605. scaleFunction?: any;
  64606. rotationFunction?: any;
  64607. ribbonCloseArray?: boolean;
  64608. ribbonClosePath?: boolean;
  64609. cap?: number;
  64610. updatable?: boolean;
  64611. sideOrientation?: number;
  64612. frontUVs?: Vector4;
  64613. backUVs?: Vector4;
  64614. instance?: Mesh;
  64615. invertUV?: boolean;
  64616. }, scene?: Nullable<Scene>): Mesh;
  64617. /**
  64618. * Creates lathe mesh.
  64619. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64620. * * 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
  64621. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64622. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64623. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64624. * * 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
  64625. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64626. * * 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
  64627. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64628. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64629. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64630. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64631. * @param name defines the name of the mesh
  64632. * @param options defines the options used to create the mesh
  64633. * @param scene defines the hosting scene
  64634. * @returns the lathe mesh
  64635. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64636. */
  64637. static CreateLathe(name: string, options: {
  64638. shape: Vector3[];
  64639. radius?: number;
  64640. tessellation?: number;
  64641. clip?: number;
  64642. arc?: number;
  64643. closed?: boolean;
  64644. updatable?: boolean;
  64645. sideOrientation?: number;
  64646. frontUVs?: Vector4;
  64647. backUVs?: Vector4;
  64648. cap?: number;
  64649. invertUV?: boolean;
  64650. }, scene?: Nullable<Scene>): Mesh;
  64651. /**
  64652. * Creates a tiled plane mesh
  64653. * * You can set a limited pattern arrangement with the tiles
  64654. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64655. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64656. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64657. * @param name defines the name of the mesh
  64658. * @param options defines the options used to create the mesh
  64659. * @param scene defines the hosting scene
  64660. * @returns the plane mesh
  64661. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64662. */
  64663. static CreateTiledPlane(name: string, options: {
  64664. pattern?: number;
  64665. tileSize?: number;
  64666. tileWidth?: number;
  64667. tileHeight?: number;
  64668. size?: number;
  64669. width?: number;
  64670. height?: number;
  64671. alignHorizontal?: number;
  64672. alignVertical?: number;
  64673. sideOrientation?: number;
  64674. frontUVs?: Vector4;
  64675. backUVs?: Vector4;
  64676. updatable?: boolean;
  64677. }, scene?: Nullable<Scene>): Mesh;
  64678. /**
  64679. * Creates a plane mesh
  64680. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64681. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64682. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64683. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64684. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64685. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64686. * @param name defines the name of the mesh
  64687. * @param options defines the options used to create the mesh
  64688. * @param scene defines the hosting scene
  64689. * @returns the plane mesh
  64690. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64691. */
  64692. static CreatePlane(name: string, options: {
  64693. size?: number;
  64694. width?: number;
  64695. height?: number;
  64696. sideOrientation?: number;
  64697. frontUVs?: Vector4;
  64698. backUVs?: Vector4;
  64699. updatable?: boolean;
  64700. sourcePlane?: Plane;
  64701. }, scene?: Nullable<Scene>): Mesh;
  64702. /**
  64703. * Creates a ground mesh
  64704. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  64705. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  64706. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64707. * @param name defines the name of the mesh
  64708. * @param options defines the options used to create the mesh
  64709. * @param scene defines the hosting scene
  64710. * @returns the ground mesh
  64711. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  64712. */
  64713. static CreateGround(name: string, options: {
  64714. width?: number;
  64715. height?: number;
  64716. subdivisions?: number;
  64717. subdivisionsX?: number;
  64718. subdivisionsY?: number;
  64719. updatable?: boolean;
  64720. }, scene?: Nullable<Scene>): Mesh;
  64721. /**
  64722. * Creates a tiled ground mesh
  64723. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  64724. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  64725. * * 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
  64726. * * 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
  64727. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64728. * @param name defines the name of the mesh
  64729. * @param options defines the options used to create the mesh
  64730. * @param scene defines the hosting scene
  64731. * @returns the tiled ground mesh
  64732. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  64733. */
  64734. static CreateTiledGround(name: string, options: {
  64735. xmin: number;
  64736. zmin: number;
  64737. xmax: number;
  64738. zmax: number;
  64739. subdivisions?: {
  64740. w: number;
  64741. h: number;
  64742. };
  64743. precision?: {
  64744. w: number;
  64745. h: number;
  64746. };
  64747. updatable?: boolean;
  64748. }, scene?: Nullable<Scene>): Mesh;
  64749. /**
  64750. * Creates a ground mesh from a height map
  64751. * * The parameter `url` sets the URL of the height map image resource.
  64752. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  64753. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  64754. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  64755. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  64756. * * 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.
  64757. * * 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).
  64758. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  64759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64760. * @param name defines the name of the mesh
  64761. * @param url defines the url to the height map
  64762. * @param options defines the options used to create the mesh
  64763. * @param scene defines the hosting scene
  64764. * @returns the ground mesh
  64765. * @see https://doc.babylonjs.com/babylon101/height_map
  64766. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  64767. */
  64768. static CreateGroundFromHeightMap(name: string, url: string, options: {
  64769. width?: number;
  64770. height?: number;
  64771. subdivisions?: number;
  64772. minHeight?: number;
  64773. maxHeight?: number;
  64774. colorFilter?: Color3;
  64775. alphaFilter?: number;
  64776. updatable?: boolean;
  64777. onReady?: (mesh: GroundMesh) => void;
  64778. }, scene?: Nullable<Scene>): GroundMesh;
  64779. /**
  64780. * Creates a polygon mesh
  64781. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64782. * * 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
  64783. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64784. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64785. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  64786. * * Remember you can only change the shape positions, not their number when updating a polygon
  64787. * @param name defines the name of the mesh
  64788. * @param options defines the options used to create the mesh
  64789. * @param scene defines the hosting scene
  64790. * @param earcutInjection can be used to inject your own earcut reference
  64791. * @returns the polygon mesh
  64792. */
  64793. static CreatePolygon(name: string, options: {
  64794. shape: Vector3[];
  64795. holes?: Vector3[][];
  64796. depth?: number;
  64797. faceUV?: Vector4[];
  64798. faceColors?: Color4[];
  64799. updatable?: boolean;
  64800. sideOrientation?: number;
  64801. frontUVs?: Vector4;
  64802. backUVs?: Vector4;
  64803. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64804. /**
  64805. * Creates an extruded polygon mesh, with depth in the Y direction.
  64806. * * 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)
  64807. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64808. * @param name defines the name of the mesh
  64809. * @param options defines the options used to create the mesh
  64810. * @param scene defines the hosting scene
  64811. * @param earcutInjection can be used to inject your own earcut reference
  64812. * @returns the polygon mesh
  64813. */
  64814. static ExtrudePolygon(name: string, options: {
  64815. shape: Vector3[];
  64816. holes?: Vector3[][];
  64817. depth?: number;
  64818. faceUV?: Vector4[];
  64819. faceColors?: Color4[];
  64820. updatable?: boolean;
  64821. sideOrientation?: number;
  64822. frontUVs?: Vector4;
  64823. backUVs?: Vector4;
  64824. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64825. /**
  64826. * Creates a tube mesh.
  64827. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64828. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64829. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64830. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64831. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64832. * * 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)
  64833. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64834. * * 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
  64835. * * 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
  64836. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64837. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64838. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64839. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64840. * @param name defines the name of the mesh
  64841. * @param options defines the options used to create the mesh
  64842. * @param scene defines the hosting scene
  64843. * @returns the tube mesh
  64844. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64845. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64846. */
  64847. static CreateTube(name: string, options: {
  64848. path: Vector3[];
  64849. radius?: number;
  64850. tessellation?: number;
  64851. radiusFunction?: {
  64852. (i: number, distance: number): number;
  64853. };
  64854. cap?: number;
  64855. arc?: number;
  64856. updatable?: boolean;
  64857. sideOrientation?: number;
  64858. frontUVs?: Vector4;
  64859. backUVs?: Vector4;
  64860. instance?: Mesh;
  64861. invertUV?: boolean;
  64862. }, scene?: Nullable<Scene>): Mesh;
  64863. /**
  64864. * Creates a polyhedron mesh
  64865. * * 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
  64866. * * The parameter `size` (positive float, default 1) sets the polygon size
  64867. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  64868. * * 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`
  64869. * * 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
  64870. * * 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)`)
  64871. * * 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
  64872. * * 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
  64873. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64874. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64876. * @param name defines the name of the mesh
  64877. * @param options defines the options used to create the mesh
  64878. * @param scene defines the hosting scene
  64879. * @returns the polyhedron mesh
  64880. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  64881. */
  64882. static CreatePolyhedron(name: string, options: {
  64883. type?: number;
  64884. size?: number;
  64885. sizeX?: number;
  64886. sizeY?: number;
  64887. sizeZ?: number;
  64888. custom?: any;
  64889. faceUV?: Vector4[];
  64890. faceColors?: Color4[];
  64891. flat?: boolean;
  64892. updatable?: boolean;
  64893. sideOrientation?: number;
  64894. frontUVs?: Vector4;
  64895. backUVs?: Vector4;
  64896. }, scene?: Nullable<Scene>): Mesh;
  64897. /**
  64898. * Creates a decal mesh.
  64899. * 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
  64900. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64901. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64902. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64903. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64904. * @param name defines the name of the mesh
  64905. * @param sourceMesh defines the mesh where the decal must be applied
  64906. * @param options defines the options used to create the mesh
  64907. * @param scene defines the hosting scene
  64908. * @returns the decal mesh
  64909. * @see https://doc.babylonjs.com/how_to/decals
  64910. */
  64911. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64912. position?: Vector3;
  64913. normal?: Vector3;
  64914. size?: Vector3;
  64915. angle?: number;
  64916. }): Mesh;
  64917. }
  64918. }
  64919. declare module "babylonjs/Meshes/meshSimplification" {
  64920. import { Mesh } from "babylonjs/Meshes/mesh";
  64921. /**
  64922. * A simplifier interface for future simplification implementations
  64923. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64924. */
  64925. export interface ISimplifier {
  64926. /**
  64927. * Simplification of a given mesh according to the given settings.
  64928. * Since this requires computation, it is assumed that the function runs async.
  64929. * @param settings The settings of the simplification, including quality and distance
  64930. * @param successCallback A callback that will be called after the mesh was simplified.
  64931. * @param errorCallback in case of an error, this callback will be called. optional.
  64932. */
  64933. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  64934. }
  64935. /**
  64936. * Expected simplification settings.
  64937. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  64938. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64939. */
  64940. export interface ISimplificationSettings {
  64941. /**
  64942. * Gets or sets the expected quality
  64943. */
  64944. quality: number;
  64945. /**
  64946. * Gets or sets the distance when this optimized version should be used
  64947. */
  64948. distance: number;
  64949. /**
  64950. * Gets an already optimized mesh
  64951. */
  64952. optimizeMesh?: boolean;
  64953. }
  64954. /**
  64955. * Class used to specify simplification options
  64956. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64957. */
  64958. export class SimplificationSettings implements ISimplificationSettings {
  64959. /** expected quality */
  64960. quality: number;
  64961. /** distance when this optimized version should be used */
  64962. distance: number;
  64963. /** already optimized mesh */
  64964. optimizeMesh?: boolean | undefined;
  64965. /**
  64966. * Creates a SimplificationSettings
  64967. * @param quality expected quality
  64968. * @param distance distance when this optimized version should be used
  64969. * @param optimizeMesh already optimized mesh
  64970. */
  64971. constructor(
  64972. /** expected quality */
  64973. quality: number,
  64974. /** distance when this optimized version should be used */
  64975. distance: number,
  64976. /** already optimized mesh */
  64977. optimizeMesh?: boolean | undefined);
  64978. }
  64979. /**
  64980. * Interface used to define a simplification task
  64981. */
  64982. export interface ISimplificationTask {
  64983. /**
  64984. * Array of settings
  64985. */
  64986. settings: Array<ISimplificationSettings>;
  64987. /**
  64988. * Simplification type
  64989. */
  64990. simplificationType: SimplificationType;
  64991. /**
  64992. * Mesh to simplify
  64993. */
  64994. mesh: Mesh;
  64995. /**
  64996. * Callback called on success
  64997. */
  64998. successCallback?: () => void;
  64999. /**
  65000. * Defines if parallel processing can be used
  65001. */
  65002. parallelProcessing: boolean;
  65003. }
  65004. /**
  65005. * Queue used to order the simplification tasks
  65006. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65007. */
  65008. export class SimplificationQueue {
  65009. private _simplificationArray;
  65010. /**
  65011. * Gets a boolean indicating that the process is still running
  65012. */
  65013. running: boolean;
  65014. /**
  65015. * Creates a new queue
  65016. */
  65017. constructor();
  65018. /**
  65019. * Adds a new simplification task
  65020. * @param task defines a task to add
  65021. */
  65022. addTask(task: ISimplificationTask): void;
  65023. /**
  65024. * Execute next task
  65025. */
  65026. executeNext(): void;
  65027. /**
  65028. * Execute a simplification task
  65029. * @param task defines the task to run
  65030. */
  65031. runSimplification(task: ISimplificationTask): void;
  65032. private getSimplifier;
  65033. }
  65034. /**
  65035. * The implemented types of simplification
  65036. * At the moment only Quadratic Error Decimation is implemented
  65037. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65038. */
  65039. export enum SimplificationType {
  65040. /** Quadratic error decimation */
  65041. QUADRATIC = 0
  65042. }
  65043. /**
  65044. * An implementation of the Quadratic Error simplification algorithm.
  65045. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  65046. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  65047. * @author RaananW
  65048. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65049. */
  65050. export class QuadraticErrorSimplification implements ISimplifier {
  65051. private _mesh;
  65052. private triangles;
  65053. private vertices;
  65054. private references;
  65055. private _reconstructedMesh;
  65056. /** Gets or sets the number pf sync interations */
  65057. syncIterations: number;
  65058. /** Gets or sets the aggressiveness of the simplifier */
  65059. aggressiveness: number;
  65060. /** Gets or sets the number of allowed iterations for decimation */
  65061. decimationIterations: number;
  65062. /** Gets or sets the espilon to use for bounding box computation */
  65063. boundingBoxEpsilon: number;
  65064. /**
  65065. * Creates a new QuadraticErrorSimplification
  65066. * @param _mesh defines the target mesh
  65067. */
  65068. constructor(_mesh: Mesh);
  65069. /**
  65070. * Simplification of a given mesh according to the given settings.
  65071. * Since this requires computation, it is assumed that the function runs async.
  65072. * @param settings The settings of the simplification, including quality and distance
  65073. * @param successCallback A callback that will be called after the mesh was simplified.
  65074. */
  65075. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  65076. private runDecimation;
  65077. private initWithMesh;
  65078. private init;
  65079. private reconstructMesh;
  65080. private initDecimatedMesh;
  65081. private isFlipped;
  65082. private updateTriangles;
  65083. private identifyBorder;
  65084. private updateMesh;
  65085. private vertexError;
  65086. private calculateError;
  65087. }
  65088. }
  65089. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  65090. import { Scene } from "babylonjs/scene";
  65091. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  65092. import { ISceneComponent } from "babylonjs/sceneComponent";
  65093. module "babylonjs/scene" {
  65094. interface Scene {
  65095. /** @hidden (Backing field) */
  65096. _simplificationQueue: SimplificationQueue;
  65097. /**
  65098. * Gets or sets the simplification queue attached to the scene
  65099. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65100. */
  65101. simplificationQueue: SimplificationQueue;
  65102. }
  65103. }
  65104. module "babylonjs/Meshes/mesh" {
  65105. interface Mesh {
  65106. /**
  65107. * Simplify the mesh according to the given array of settings.
  65108. * Function will return immediately and will simplify async
  65109. * @param settings a collection of simplification settings
  65110. * @param parallelProcessing should all levels calculate parallel or one after the other
  65111. * @param simplificationType the type of simplification to run
  65112. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  65113. * @returns the current mesh
  65114. */
  65115. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  65116. }
  65117. }
  65118. /**
  65119. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  65120. * created in a scene
  65121. */
  65122. export class SimplicationQueueSceneComponent implements ISceneComponent {
  65123. /**
  65124. * The component name helpfull to identify the component in the list of scene components.
  65125. */
  65126. readonly name: string;
  65127. /**
  65128. * The scene the component belongs to.
  65129. */
  65130. scene: Scene;
  65131. /**
  65132. * Creates a new instance of the component for the given scene
  65133. * @param scene Defines the scene to register the component in
  65134. */
  65135. constructor(scene: Scene);
  65136. /**
  65137. * Registers the component in a given scene
  65138. */
  65139. register(): void;
  65140. /**
  65141. * Rebuilds the elements related to this component in case of
  65142. * context lost for instance.
  65143. */
  65144. rebuild(): void;
  65145. /**
  65146. * Disposes the component and the associated ressources
  65147. */
  65148. dispose(): void;
  65149. private _beforeCameraUpdate;
  65150. }
  65151. }
  65152. declare module "babylonjs/Meshes/Builders/index" {
  65153. export * from "babylonjs/Meshes/Builders/boxBuilder";
  65154. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  65155. export * from "babylonjs/Meshes/Builders/discBuilder";
  65156. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  65157. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  65158. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  65159. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  65160. export * from "babylonjs/Meshes/Builders/torusBuilder";
  65161. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  65162. export * from "babylonjs/Meshes/Builders/linesBuilder";
  65163. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  65164. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  65165. export * from "babylonjs/Meshes/Builders/latheBuilder";
  65166. export * from "babylonjs/Meshes/Builders/planeBuilder";
  65167. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  65168. export * from "babylonjs/Meshes/Builders/groundBuilder";
  65169. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  65170. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  65171. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  65172. export * from "babylonjs/Meshes/Builders/decalBuilder";
  65173. }
  65174. declare module "babylonjs/Meshes/index" {
  65175. export * from "babylonjs/Meshes/abstractMesh";
  65176. export * from "babylonjs/Meshes/buffer";
  65177. export * from "babylonjs/Meshes/Compression/index";
  65178. export * from "babylonjs/Meshes/csg";
  65179. export * from "babylonjs/Meshes/geometry";
  65180. export * from "babylonjs/Meshes/groundMesh";
  65181. export * from "babylonjs/Meshes/trailMesh";
  65182. export * from "babylonjs/Meshes/instancedMesh";
  65183. export * from "babylonjs/Meshes/linesMesh";
  65184. export * from "babylonjs/Meshes/mesh";
  65185. export * from "babylonjs/Meshes/mesh.vertexData";
  65186. export * from "babylonjs/Meshes/meshBuilder";
  65187. export * from "babylonjs/Meshes/meshSimplification";
  65188. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  65189. export * from "babylonjs/Meshes/polygonMesh";
  65190. export * from "babylonjs/Meshes/subMesh";
  65191. export * from "babylonjs/Meshes/meshLODLevel";
  65192. export * from "babylonjs/Meshes/transformNode";
  65193. export * from "babylonjs/Meshes/Builders/index";
  65194. export * from "babylonjs/Meshes/dataBuffer";
  65195. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  65196. }
  65197. declare module "babylonjs/Morph/index" {
  65198. export * from "babylonjs/Morph/morphTarget";
  65199. export * from "babylonjs/Morph/morphTargetManager";
  65200. }
  65201. declare module "babylonjs/Navigation/INavigationEngine" {
  65202. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65203. import { Vector3 } from "babylonjs/Maths/math";
  65204. import { Mesh } from "babylonjs/Meshes/mesh";
  65205. import { Scene } from "babylonjs/scene";
  65206. /**
  65207. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65208. */
  65209. export interface INavigationEnginePlugin {
  65210. /**
  65211. * plugin name
  65212. */
  65213. name: string;
  65214. /**
  65215. * Creates a navigation mesh
  65216. * @param meshes array of all the geometry used to compute the navigatio mesh
  65217. * @param parameters bunch of parameters used to filter geometry
  65218. */
  65219. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65220. /**
  65221. * Create a navigation mesh debug mesh
  65222. * @param scene is where the mesh will be added
  65223. * @returns debug display mesh
  65224. */
  65225. createDebugNavMesh(scene: Scene): Mesh;
  65226. /**
  65227. * Get a navigation mesh constrained position, closest to the parameter position
  65228. * @param position world position
  65229. * @returns the closest point to position constrained by the navigation mesh
  65230. */
  65231. getClosestPoint(position: Vector3): Vector3;
  65232. /**
  65233. * Get a navigation mesh constrained position, within a particular radius
  65234. * @param position world position
  65235. * @param maxRadius the maximum distance to the constrained world position
  65236. * @returns the closest point to position constrained by the navigation mesh
  65237. */
  65238. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65239. /**
  65240. * Compute the final position from a segment made of destination-position
  65241. * @param position world position
  65242. * @param destination world position
  65243. * @returns the resulting point along the navmesh
  65244. */
  65245. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65246. /**
  65247. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65248. * @param start world position
  65249. * @param end world position
  65250. * @returns array containing world position composing the path
  65251. */
  65252. computePath(start: Vector3, end: Vector3): Vector3[];
  65253. /**
  65254. * If this plugin is supported
  65255. * @returns true if plugin is supported
  65256. */
  65257. isSupported(): boolean;
  65258. /**
  65259. * Create a new Crowd so you can add agents
  65260. * @param maxAgents the maximum agent count in the crowd
  65261. * @param maxAgentRadius the maximum radius an agent can have
  65262. * @param scene to attach the crowd to
  65263. * @returns the crowd you can add agents to
  65264. */
  65265. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65266. /**
  65267. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65268. * The queries will try to find a solution within those bounds
  65269. * default is (1,1,1)
  65270. * @param extent x,y,z value that define the extent around the queries point of reference
  65271. */
  65272. setDefaultQueryExtent(extent: Vector3): void;
  65273. /**
  65274. * Get the Bounding box extent specified by setDefaultQueryExtent
  65275. * @returns the box extent values
  65276. */
  65277. getDefaultQueryExtent(): Vector3;
  65278. /**
  65279. * Release all resources
  65280. */
  65281. dispose(): void;
  65282. }
  65283. /**
  65284. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65285. */
  65286. export interface ICrowd {
  65287. /**
  65288. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65289. * You can attach anything to that node. The node position is updated in the scene update tick.
  65290. * @param pos world position that will be constrained by the navigation mesh
  65291. * @param parameters agent parameters
  65292. * @param transform hooked to the agent that will be update by the scene
  65293. * @returns agent index
  65294. */
  65295. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65296. /**
  65297. * Returns the agent position in world space
  65298. * @param index agent index returned by addAgent
  65299. * @returns world space position
  65300. */
  65301. getAgentPosition(index: number): Vector3;
  65302. /**
  65303. * Gets the agent velocity in world space
  65304. * @param index agent index returned by addAgent
  65305. * @returns world space velocity
  65306. */
  65307. getAgentVelocity(index: number): Vector3;
  65308. /**
  65309. * remove a particular agent previously created
  65310. * @param index agent index returned by addAgent
  65311. */
  65312. removeAgent(index: number): void;
  65313. /**
  65314. * get the list of all agents attached to this crowd
  65315. * @returns list of agent indices
  65316. */
  65317. getAgents(): number[];
  65318. /**
  65319. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65320. * @param deltaTime in seconds
  65321. */
  65322. update(deltaTime: number): void;
  65323. /**
  65324. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65325. * @param index agent index returned by addAgent
  65326. * @param destination targeted world position
  65327. */
  65328. agentGoto(index: number, destination: Vector3): void;
  65329. /**
  65330. * Teleport the agent to a new position
  65331. * @param index agent index returned by addAgent
  65332. * @param destination targeted world position
  65333. */
  65334. agentTeleport(index: number, destination: Vector3): void;
  65335. /**
  65336. * Update agent parameters
  65337. * @param index agent index returned by addAgent
  65338. * @param parameters agent parameters
  65339. */
  65340. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65341. /**
  65342. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65343. * The queries will try to find a solution within those bounds
  65344. * default is (1,1,1)
  65345. * @param extent x,y,z value that define the extent around the queries point of reference
  65346. */
  65347. setDefaultQueryExtent(extent: Vector3): void;
  65348. /**
  65349. * Get the Bounding box extent specified by setDefaultQueryExtent
  65350. * @returns the box extent values
  65351. */
  65352. getDefaultQueryExtent(): Vector3;
  65353. /**
  65354. * Release all resources
  65355. */
  65356. dispose(): void;
  65357. }
  65358. /**
  65359. * Configures an agent
  65360. */
  65361. export interface IAgentParameters {
  65362. /**
  65363. * Agent radius. [Limit: >= 0]
  65364. */
  65365. radius: number;
  65366. /**
  65367. * Agent height. [Limit: > 0]
  65368. */
  65369. height: number;
  65370. /**
  65371. * Maximum allowed acceleration. [Limit: >= 0]
  65372. */
  65373. maxAcceleration: number;
  65374. /**
  65375. * Maximum allowed speed. [Limit: >= 0]
  65376. */
  65377. maxSpeed: number;
  65378. /**
  65379. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65380. */
  65381. collisionQueryRange: number;
  65382. /**
  65383. * The path visibility optimization range. [Limit: > 0]
  65384. */
  65385. pathOptimizationRange: number;
  65386. /**
  65387. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65388. */
  65389. separationWeight: number;
  65390. }
  65391. /**
  65392. * Configures the navigation mesh creation
  65393. */
  65394. export interface INavMeshParameters {
  65395. /**
  65396. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65397. */
  65398. cs: number;
  65399. /**
  65400. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65401. */
  65402. ch: number;
  65403. /**
  65404. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65405. */
  65406. walkableSlopeAngle: number;
  65407. /**
  65408. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65409. * be considered walkable. [Limit: >= 3] [Units: vx]
  65410. */
  65411. walkableHeight: number;
  65412. /**
  65413. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65414. */
  65415. walkableClimb: number;
  65416. /**
  65417. * The distance to erode/shrink the walkable area of the heightfield away from
  65418. * obstructions. [Limit: >=0] [Units: vx]
  65419. */
  65420. walkableRadius: number;
  65421. /**
  65422. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65423. */
  65424. maxEdgeLen: number;
  65425. /**
  65426. * The maximum distance a simplfied contour's border edges should deviate
  65427. * the original raw contour. [Limit: >=0] [Units: vx]
  65428. */
  65429. maxSimplificationError: number;
  65430. /**
  65431. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65432. */
  65433. minRegionArea: number;
  65434. /**
  65435. * Any regions with a span count smaller than this value will, if possible,
  65436. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65437. */
  65438. mergeRegionArea: number;
  65439. /**
  65440. * The maximum number of vertices allowed for polygons generated during the
  65441. * contour to polygon conversion process. [Limit: >= 3]
  65442. */
  65443. maxVertsPerPoly: number;
  65444. /**
  65445. * Sets the sampling distance to use when generating the detail mesh.
  65446. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65447. */
  65448. detailSampleDist: number;
  65449. /**
  65450. * The maximum distance the detail mesh surface should deviate from heightfield
  65451. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65452. */
  65453. detailSampleMaxError: number;
  65454. }
  65455. }
  65456. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  65457. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  65458. import { Mesh } from "babylonjs/Meshes/mesh";
  65459. import { Scene } from "babylonjs/scene";
  65460. import { Vector3 } from "babylonjs/Maths/math";
  65461. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65462. /**
  65463. * RecastJS navigation plugin
  65464. */
  65465. export class RecastJSPlugin implements INavigationEnginePlugin {
  65466. /**
  65467. * Reference to the Recast library
  65468. */
  65469. bjsRECAST: any;
  65470. /**
  65471. * plugin name
  65472. */
  65473. name: string;
  65474. /**
  65475. * the first navmesh created. We might extend this to support multiple navmeshes
  65476. */
  65477. navMesh: any;
  65478. /**
  65479. * Initializes the recastJS plugin
  65480. * @param recastInjection can be used to inject your own recast reference
  65481. */
  65482. constructor(recastInjection?: any);
  65483. /**
  65484. * Creates a navigation mesh
  65485. * @param meshes array of all the geometry used to compute the navigatio mesh
  65486. * @param parameters bunch of parameters used to filter geometry
  65487. */
  65488. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65489. /**
  65490. * Create a navigation mesh debug mesh
  65491. * @param scene is where the mesh will be added
  65492. * @returns debug display mesh
  65493. */
  65494. createDebugNavMesh(scene: Scene): Mesh;
  65495. /**
  65496. * Get a navigation mesh constrained position, closest to the parameter position
  65497. * @param position world position
  65498. * @returns the closest point to position constrained by the navigation mesh
  65499. */
  65500. getClosestPoint(position: Vector3): Vector3;
  65501. /**
  65502. * Get a navigation mesh constrained position, within a particular radius
  65503. * @param position world position
  65504. * @param maxRadius the maximum distance to the constrained world position
  65505. * @returns the closest point to position constrained by the navigation mesh
  65506. */
  65507. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65508. /**
  65509. * Compute the final position from a segment made of destination-position
  65510. * @param position world position
  65511. * @param destination world position
  65512. * @returns the resulting point along the navmesh
  65513. */
  65514. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65515. /**
  65516. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65517. * @param start world position
  65518. * @param end world position
  65519. * @returns array containing world position composing the path
  65520. */
  65521. computePath(start: Vector3, end: Vector3): Vector3[];
  65522. /**
  65523. * Create a new Crowd so you can add agents
  65524. * @param maxAgents the maximum agent count in the crowd
  65525. * @param maxAgentRadius the maximum radius an agent can have
  65526. * @param scene to attach the crowd to
  65527. * @returns the crowd you can add agents to
  65528. */
  65529. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65530. /**
  65531. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65532. * The queries will try to find a solution within those bounds
  65533. * default is (1,1,1)
  65534. * @param extent x,y,z value that define the extent around the queries point of reference
  65535. */
  65536. setDefaultQueryExtent(extent: Vector3): void;
  65537. /**
  65538. * Get the Bounding box extent specified by setDefaultQueryExtent
  65539. * @returns the box extent values
  65540. */
  65541. getDefaultQueryExtent(): Vector3;
  65542. /**
  65543. * Disposes
  65544. */
  65545. dispose(): void;
  65546. /**
  65547. * If this plugin is supported
  65548. * @returns true if plugin is supported
  65549. */
  65550. isSupported(): boolean;
  65551. }
  65552. /**
  65553. * Recast detour crowd implementation
  65554. */
  65555. export class RecastJSCrowd implements ICrowd {
  65556. /**
  65557. * Recast/detour plugin
  65558. */
  65559. bjsRECASTPlugin: RecastJSPlugin;
  65560. /**
  65561. * Link to the detour crowd
  65562. */
  65563. recastCrowd: any;
  65564. /**
  65565. * One transform per agent
  65566. */
  65567. transforms: TransformNode[];
  65568. /**
  65569. * All agents created
  65570. */
  65571. agents: number[];
  65572. /**
  65573. * Link to the scene is kept to unregister the crowd from the scene
  65574. */
  65575. private _scene;
  65576. /**
  65577. * Observer for crowd updates
  65578. */
  65579. private _onBeforeAnimationsObserver;
  65580. /**
  65581. * Constructor
  65582. * @param plugin recastJS plugin
  65583. * @param maxAgents the maximum agent count in the crowd
  65584. * @param maxAgentRadius the maximum radius an agent can have
  65585. * @param scene to attach the crowd to
  65586. * @returns the crowd you can add agents to
  65587. */
  65588. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65589. /**
  65590. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65591. * You can attach anything to that node. The node position is updated in the scene update tick.
  65592. * @param pos world position that will be constrained by the navigation mesh
  65593. * @param parameters agent parameters
  65594. * @param transform hooked to the agent that will be update by the scene
  65595. * @returns agent index
  65596. */
  65597. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65598. /**
  65599. * Returns the agent position in world space
  65600. * @param index agent index returned by addAgent
  65601. * @returns world space position
  65602. */
  65603. getAgentPosition(index: number): Vector3;
  65604. /**
  65605. * Returns the agent velocity in world space
  65606. * @param index agent index returned by addAgent
  65607. * @returns world space velocity
  65608. */
  65609. getAgentVelocity(index: number): Vector3;
  65610. /**
  65611. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65612. * @param index agent index returned by addAgent
  65613. * @param destination targeted world position
  65614. */
  65615. agentGoto(index: number, destination: Vector3): void;
  65616. /**
  65617. * Teleport the agent to a new position
  65618. * @param index agent index returned by addAgent
  65619. * @param destination targeted world position
  65620. */
  65621. agentTeleport(index: number, destination: Vector3): void;
  65622. /**
  65623. * Update agent parameters
  65624. * @param index agent index returned by addAgent
  65625. * @param parameters agent parameters
  65626. */
  65627. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65628. /**
  65629. * remove a particular agent previously created
  65630. * @param index agent index returned by addAgent
  65631. */
  65632. removeAgent(index: number): void;
  65633. /**
  65634. * get the list of all agents attached to this crowd
  65635. * @returns list of agent indices
  65636. */
  65637. getAgents(): number[];
  65638. /**
  65639. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65640. * @param deltaTime in seconds
  65641. */
  65642. update(deltaTime: number): void;
  65643. /**
  65644. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65645. * The queries will try to find a solution within those bounds
  65646. * default is (1,1,1)
  65647. * @param extent x,y,z value that define the extent around the queries point of reference
  65648. */
  65649. setDefaultQueryExtent(extent: Vector3): void;
  65650. /**
  65651. * Get the Bounding box extent specified by setDefaultQueryExtent
  65652. * @returns the box extent values
  65653. */
  65654. getDefaultQueryExtent(): Vector3;
  65655. /**
  65656. * Release all resources
  65657. */
  65658. dispose(): void;
  65659. }
  65660. }
  65661. declare module "babylonjs/Navigation/Plugins/index" {
  65662. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  65663. }
  65664. declare module "babylonjs/Navigation/index" {
  65665. export * from "babylonjs/Navigation/INavigationEngine";
  65666. export * from "babylonjs/Navigation/Plugins/index";
  65667. }
  65668. declare module "babylonjs/Offline/database" {
  65669. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  65670. /**
  65671. * Class used to enable access to IndexedDB
  65672. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  65673. */
  65674. export class Database implements IOfflineProvider {
  65675. private _callbackManifestChecked;
  65676. private _currentSceneUrl;
  65677. private _db;
  65678. private _enableSceneOffline;
  65679. private _enableTexturesOffline;
  65680. private _manifestVersionFound;
  65681. private _mustUpdateRessources;
  65682. private _hasReachedQuota;
  65683. private _isSupported;
  65684. private _idbFactory;
  65685. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  65686. private static IsUASupportingBlobStorage;
  65687. /**
  65688. * Gets a boolean indicating if Database storate is enabled (off by default)
  65689. */
  65690. static IDBStorageEnabled: boolean;
  65691. /**
  65692. * Gets a boolean indicating if scene must be saved in the database
  65693. */
  65694. get enableSceneOffline(): boolean;
  65695. /**
  65696. * Gets a boolean indicating if textures must be saved in the database
  65697. */
  65698. get enableTexturesOffline(): boolean;
  65699. /**
  65700. * Creates a new Database
  65701. * @param urlToScene defines the url to load the scene
  65702. * @param callbackManifestChecked defines the callback to use when manifest is checked
  65703. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  65704. */
  65705. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  65706. private static _ParseURL;
  65707. private static _ReturnFullUrlLocation;
  65708. private _checkManifestFile;
  65709. /**
  65710. * Open the database and make it available
  65711. * @param successCallback defines the callback to call on success
  65712. * @param errorCallback defines the callback to call on error
  65713. */
  65714. open(successCallback: () => void, errorCallback: () => void): void;
  65715. /**
  65716. * Loads an image from the database
  65717. * @param url defines the url to load from
  65718. * @param image defines the target DOM image
  65719. */
  65720. loadImage(url: string, image: HTMLImageElement): void;
  65721. private _loadImageFromDBAsync;
  65722. private _saveImageIntoDBAsync;
  65723. private _checkVersionFromDB;
  65724. private _loadVersionFromDBAsync;
  65725. private _saveVersionIntoDBAsync;
  65726. /**
  65727. * Loads a file from database
  65728. * @param url defines the URL to load from
  65729. * @param sceneLoaded defines a callback to call on success
  65730. * @param progressCallBack defines a callback to call when progress changed
  65731. * @param errorCallback defines a callback to call on error
  65732. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  65733. */
  65734. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  65735. private _loadFileAsync;
  65736. private _saveFileAsync;
  65737. /**
  65738. * Validates if xhr data is correct
  65739. * @param xhr defines the request to validate
  65740. * @param dataType defines the expected data type
  65741. * @returns true if data is correct
  65742. */
  65743. private static _ValidateXHRData;
  65744. }
  65745. }
  65746. declare module "babylonjs/Offline/index" {
  65747. export * from "babylonjs/Offline/database";
  65748. export * from "babylonjs/Offline/IOfflineProvider";
  65749. }
  65750. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  65751. /** @hidden */
  65752. export var gpuUpdateParticlesPixelShader: {
  65753. name: string;
  65754. shader: string;
  65755. };
  65756. }
  65757. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  65758. /** @hidden */
  65759. export var gpuUpdateParticlesVertexShader: {
  65760. name: string;
  65761. shader: string;
  65762. };
  65763. }
  65764. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  65765. /** @hidden */
  65766. export var clipPlaneFragmentDeclaration2: {
  65767. name: string;
  65768. shader: string;
  65769. };
  65770. }
  65771. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  65772. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  65773. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65774. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65775. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65776. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  65777. /** @hidden */
  65778. export var gpuRenderParticlesPixelShader: {
  65779. name: string;
  65780. shader: string;
  65781. };
  65782. }
  65783. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  65784. /** @hidden */
  65785. export var clipPlaneVertexDeclaration2: {
  65786. name: string;
  65787. shader: string;
  65788. };
  65789. }
  65790. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  65791. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  65792. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  65793. /** @hidden */
  65794. export var gpuRenderParticlesVertexShader: {
  65795. name: string;
  65796. shader: string;
  65797. };
  65798. }
  65799. declare module "babylonjs/Particles/gpuParticleSystem" {
  65800. import { Nullable } from "babylonjs/types";
  65801. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  65802. import { Observable } from "babylonjs/Misc/observable";
  65803. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  65804. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65805. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  65806. import { Scene, IDisposable } from "babylonjs/scene";
  65807. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  65808. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65809. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  65810. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  65811. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  65812. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  65813. /**
  65814. * This represents a GPU particle system in Babylon
  65815. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  65816. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  65817. */
  65818. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  65819. /**
  65820. * The layer mask we are rendering the particles through.
  65821. */
  65822. layerMask: number;
  65823. private _capacity;
  65824. private _activeCount;
  65825. private _currentActiveCount;
  65826. private _accumulatedCount;
  65827. private _renderEffect;
  65828. private _updateEffect;
  65829. private _buffer0;
  65830. private _buffer1;
  65831. private _spriteBuffer;
  65832. private _updateVAO;
  65833. private _renderVAO;
  65834. private _targetIndex;
  65835. private _sourceBuffer;
  65836. private _targetBuffer;
  65837. private _engine;
  65838. private _currentRenderId;
  65839. private _started;
  65840. private _stopped;
  65841. private _timeDelta;
  65842. private _randomTexture;
  65843. private _randomTexture2;
  65844. private _attributesStrideSize;
  65845. private _updateEffectOptions;
  65846. private _randomTextureSize;
  65847. private _actualFrame;
  65848. private readonly _rawTextureWidth;
  65849. /**
  65850. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  65851. */
  65852. static get IsSupported(): boolean;
  65853. /**
  65854. * An event triggered when the system is disposed.
  65855. */
  65856. onDisposeObservable: Observable<GPUParticleSystem>;
  65857. /**
  65858. * Gets the maximum number of particles active at the same time.
  65859. * @returns The max number of active particles.
  65860. */
  65861. getCapacity(): number;
  65862. /**
  65863. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  65864. * to override the particles.
  65865. */
  65866. forceDepthWrite: boolean;
  65867. /**
  65868. * Gets or set the number of active particles
  65869. */
  65870. get activeParticleCount(): number;
  65871. set activeParticleCount(value: number);
  65872. private _preWarmDone;
  65873. /**
  65874. * Specifies if the particles are updated in emitter local space or world space.
  65875. * This is always false for GPU particles
  65876. */
  65877. get isLocal(): boolean;
  65878. set isLocal(value: boolean);
  65879. /**
  65880. * Is this system ready to be used/rendered
  65881. * @return true if the system is ready
  65882. */
  65883. isReady(): boolean;
  65884. /**
  65885. * Gets if the system has been started. (Note: this will still be true after stop is called)
  65886. * @returns True if it has been started, otherwise false.
  65887. */
  65888. isStarted(): boolean;
  65889. /**
  65890. * Starts the particle system and begins to emit
  65891. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  65892. */
  65893. start(delay?: number): void;
  65894. /**
  65895. * Stops the particle system.
  65896. */
  65897. stop(): void;
  65898. /**
  65899. * Remove all active particles
  65900. */
  65901. reset(): void;
  65902. /**
  65903. * Returns the string "GPUParticleSystem"
  65904. * @returns a string containing the class name
  65905. */
  65906. getClassName(): string;
  65907. private _colorGradientsTexture;
  65908. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  65909. /**
  65910. * Adds a new color gradient
  65911. * @param gradient defines the gradient to use (between 0 and 1)
  65912. * @param color1 defines the color to affect to the specified gradient
  65913. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  65914. * @returns the current particle system
  65915. */
  65916. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  65917. /**
  65918. * Remove a specific color gradient
  65919. * @param gradient defines the gradient to remove
  65920. * @returns the current particle system
  65921. */
  65922. removeColorGradient(gradient: number): GPUParticleSystem;
  65923. private _angularSpeedGradientsTexture;
  65924. private _sizeGradientsTexture;
  65925. private _velocityGradientsTexture;
  65926. private _limitVelocityGradientsTexture;
  65927. private _dragGradientsTexture;
  65928. private _addFactorGradient;
  65929. /**
  65930. * Adds a new size gradient
  65931. * @param gradient defines the gradient to use (between 0 and 1)
  65932. * @param factor defines the size factor to affect to the specified gradient
  65933. * @returns the current particle system
  65934. */
  65935. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  65936. /**
  65937. * Remove a specific size gradient
  65938. * @param gradient defines the gradient to remove
  65939. * @returns the current particle system
  65940. */
  65941. removeSizeGradient(gradient: number): GPUParticleSystem;
  65942. /**
  65943. * Adds a new angular speed gradient
  65944. * @param gradient defines the gradient to use (between 0 and 1)
  65945. * @param factor defines the angular speed to affect to the specified gradient
  65946. * @returns the current particle system
  65947. */
  65948. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  65949. /**
  65950. * Remove a specific angular speed gradient
  65951. * @param gradient defines the gradient to remove
  65952. * @returns the current particle system
  65953. */
  65954. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  65955. /**
  65956. * Adds a new velocity gradient
  65957. * @param gradient defines the gradient to use (between 0 and 1)
  65958. * @param factor defines the velocity to affect to the specified gradient
  65959. * @returns the current particle system
  65960. */
  65961. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65962. /**
  65963. * Remove a specific velocity gradient
  65964. * @param gradient defines the gradient to remove
  65965. * @returns the current particle system
  65966. */
  65967. removeVelocityGradient(gradient: number): GPUParticleSystem;
  65968. /**
  65969. * Adds a new limit velocity gradient
  65970. * @param gradient defines the gradient to use (between 0 and 1)
  65971. * @param factor defines the limit velocity value to affect to the specified gradient
  65972. * @returns the current particle system
  65973. */
  65974. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65975. /**
  65976. * Remove a specific limit velocity gradient
  65977. * @param gradient defines the gradient to remove
  65978. * @returns the current particle system
  65979. */
  65980. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  65981. /**
  65982. * Adds a new drag gradient
  65983. * @param gradient defines the gradient to use (between 0 and 1)
  65984. * @param factor defines the drag value to affect to the specified gradient
  65985. * @returns the current particle system
  65986. */
  65987. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  65988. /**
  65989. * Remove a specific drag gradient
  65990. * @param gradient defines the gradient to remove
  65991. * @returns the current particle system
  65992. */
  65993. removeDragGradient(gradient: number): GPUParticleSystem;
  65994. /**
  65995. * Not supported by GPUParticleSystem
  65996. * @param gradient defines the gradient to use (between 0 and 1)
  65997. * @param factor defines the emit rate value to affect to the specified gradient
  65998. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65999. * @returns the current particle system
  66000. */
  66001. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66002. /**
  66003. * Not supported by GPUParticleSystem
  66004. * @param gradient defines the gradient to remove
  66005. * @returns the current particle system
  66006. */
  66007. removeEmitRateGradient(gradient: number): IParticleSystem;
  66008. /**
  66009. * Not supported by GPUParticleSystem
  66010. * @param gradient defines the gradient to use (between 0 and 1)
  66011. * @param factor defines the start size value to affect to the specified gradient
  66012. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66013. * @returns the current particle system
  66014. */
  66015. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66016. /**
  66017. * Not supported by GPUParticleSystem
  66018. * @param gradient defines the gradient to remove
  66019. * @returns the current particle system
  66020. */
  66021. removeStartSizeGradient(gradient: number): IParticleSystem;
  66022. /**
  66023. * Not supported by GPUParticleSystem
  66024. * @param gradient defines the gradient to use (between 0 and 1)
  66025. * @param min defines the color remap minimal range
  66026. * @param max defines the color remap maximal range
  66027. * @returns the current particle system
  66028. */
  66029. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66030. /**
  66031. * Not supported by GPUParticleSystem
  66032. * @param gradient defines the gradient to remove
  66033. * @returns the current particle system
  66034. */
  66035. removeColorRemapGradient(): IParticleSystem;
  66036. /**
  66037. * Not supported by GPUParticleSystem
  66038. * @param gradient defines the gradient to use (between 0 and 1)
  66039. * @param min defines the alpha remap minimal range
  66040. * @param max defines the alpha remap maximal range
  66041. * @returns the current particle system
  66042. */
  66043. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66044. /**
  66045. * Not supported by GPUParticleSystem
  66046. * @param gradient defines the gradient to remove
  66047. * @returns the current particle system
  66048. */
  66049. removeAlphaRemapGradient(): IParticleSystem;
  66050. /**
  66051. * Not supported by GPUParticleSystem
  66052. * @param gradient defines the gradient to use (between 0 and 1)
  66053. * @param color defines the color to affect to the specified gradient
  66054. * @returns the current particle system
  66055. */
  66056. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  66057. /**
  66058. * Not supported by GPUParticleSystem
  66059. * @param gradient defines the gradient to remove
  66060. * @returns the current particle system
  66061. */
  66062. removeRampGradient(): IParticleSystem;
  66063. /**
  66064. * Not supported by GPUParticleSystem
  66065. * @returns the list of ramp gradients
  66066. */
  66067. getRampGradients(): Nullable<Array<Color3Gradient>>;
  66068. /**
  66069. * Not supported by GPUParticleSystem
  66070. * Gets or sets a boolean indicating that ramp gradients must be used
  66071. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  66072. */
  66073. get useRampGradients(): boolean;
  66074. set useRampGradients(value: boolean);
  66075. /**
  66076. * Not supported by GPUParticleSystem
  66077. * @param gradient defines the gradient to use (between 0 and 1)
  66078. * @param factor defines the life time factor to affect to the specified gradient
  66079. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66080. * @returns the current particle system
  66081. */
  66082. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66083. /**
  66084. * Not supported by GPUParticleSystem
  66085. * @param gradient defines the gradient to remove
  66086. * @returns the current particle system
  66087. */
  66088. removeLifeTimeGradient(gradient: number): IParticleSystem;
  66089. /**
  66090. * Instantiates a GPU particle system.
  66091. * 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.
  66092. * @param name The name of the particle system
  66093. * @param options The options used to create the system
  66094. * @param scene The scene the particle system belongs to
  66095. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  66096. */
  66097. constructor(name: string, options: Partial<{
  66098. capacity: number;
  66099. randomTextureSize: number;
  66100. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  66101. protected _reset(): void;
  66102. private _createUpdateVAO;
  66103. private _createRenderVAO;
  66104. private _initialize;
  66105. /** @hidden */
  66106. _recreateUpdateEffect(): void;
  66107. /** @hidden */
  66108. _recreateRenderEffect(): void;
  66109. /**
  66110. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  66111. * @param preWarm defines if we are in the pre-warmimg phase
  66112. */
  66113. animate(preWarm?: boolean): void;
  66114. private _createFactorGradientTexture;
  66115. private _createSizeGradientTexture;
  66116. private _createAngularSpeedGradientTexture;
  66117. private _createVelocityGradientTexture;
  66118. private _createLimitVelocityGradientTexture;
  66119. private _createDragGradientTexture;
  66120. private _createColorGradientTexture;
  66121. /**
  66122. * Renders the particle system in its current state
  66123. * @param preWarm defines if the system should only update the particles but not render them
  66124. * @returns the current number of particles
  66125. */
  66126. render(preWarm?: boolean): number;
  66127. /**
  66128. * Rebuilds the particle system
  66129. */
  66130. rebuild(): void;
  66131. private _releaseBuffers;
  66132. private _releaseVAOs;
  66133. /**
  66134. * Disposes the particle system and free the associated resources
  66135. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  66136. */
  66137. dispose(disposeTexture?: boolean): void;
  66138. /**
  66139. * Clones the particle system.
  66140. * @param name The name of the cloned object
  66141. * @param newEmitter The new emitter to use
  66142. * @returns the cloned particle system
  66143. */
  66144. clone(name: string, newEmitter: any): GPUParticleSystem;
  66145. /**
  66146. * Serializes the particle system to a JSON object.
  66147. * @returns the JSON object
  66148. */
  66149. serialize(): any;
  66150. /**
  66151. * Parses a JSON object to create a GPU particle system.
  66152. * @param parsedParticleSystem The JSON object to parse
  66153. * @param scene The scene to create the particle system in
  66154. * @param rootUrl The root url to use to load external dependencies like texture
  66155. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  66156. * @returns the parsed GPU particle system
  66157. */
  66158. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  66159. }
  66160. }
  66161. declare module "babylonjs/Particles/particleSystemSet" {
  66162. import { Nullable } from "babylonjs/types";
  66163. import { Color3 } from "babylonjs/Maths/math.color";
  66164. import { TransformNode } from "babylonjs/Meshes/transformNode";
  66165. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66166. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66167. import { Scene, IDisposable } from "babylonjs/scene";
  66168. /**
  66169. * Represents a set of particle systems working together to create a specific effect
  66170. */
  66171. export class ParticleSystemSet implements IDisposable {
  66172. /**
  66173. * Gets or sets base Assets URL
  66174. */
  66175. static BaseAssetsUrl: string;
  66176. private _emitterCreationOptions;
  66177. private _emitterNode;
  66178. /**
  66179. * Gets the particle system list
  66180. */
  66181. systems: IParticleSystem[];
  66182. /**
  66183. * Gets the emitter node used with this set
  66184. */
  66185. get emitterNode(): Nullable<TransformNode>;
  66186. /**
  66187. * Creates a new emitter mesh as a sphere
  66188. * @param options defines the options used to create the sphere
  66189. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  66190. * @param scene defines the hosting scene
  66191. */
  66192. setEmitterAsSphere(options: {
  66193. diameter: number;
  66194. segments: number;
  66195. color: Color3;
  66196. }, renderingGroupId: number, scene: Scene): void;
  66197. /**
  66198. * Starts all particle systems of the set
  66199. * @param emitter defines an optional mesh to use as emitter for the particle systems
  66200. */
  66201. start(emitter?: AbstractMesh): void;
  66202. /**
  66203. * Release all associated resources
  66204. */
  66205. dispose(): void;
  66206. /**
  66207. * Serialize the set into a JSON compatible object
  66208. * @returns a JSON compatible representation of the set
  66209. */
  66210. serialize(): any;
  66211. /**
  66212. * Parse a new ParticleSystemSet from a serialized source
  66213. * @param data defines a JSON compatible representation of the set
  66214. * @param scene defines the hosting scene
  66215. * @param gpu defines if we want GPU particles or CPU particles
  66216. * @returns a new ParticleSystemSet
  66217. */
  66218. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66219. }
  66220. }
  66221. declare module "babylonjs/Particles/particleHelper" {
  66222. import { Nullable } from "babylonjs/types";
  66223. import { Scene } from "babylonjs/scene";
  66224. import { Vector3 } from "babylonjs/Maths/math.vector";
  66225. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66226. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66227. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  66228. /**
  66229. * This class is made for on one-liner static method to help creating particle system set.
  66230. */
  66231. export class ParticleHelper {
  66232. /**
  66233. * Gets or sets base Assets URL
  66234. */
  66235. static BaseAssetsUrl: string;
  66236. /**
  66237. * Create a default particle system that you can tweak
  66238. * @param emitter defines the emitter to use
  66239. * @param capacity defines the system capacity (default is 500 particles)
  66240. * @param scene defines the hosting scene
  66241. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66242. * @returns the new Particle system
  66243. */
  66244. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66245. /**
  66246. * This is the main static method (one-liner) of this helper to create different particle systems
  66247. * @param type This string represents the type to the particle system to create
  66248. * @param scene The scene where the particle system should live
  66249. * @param gpu If the system will use gpu
  66250. * @returns the ParticleSystemSet created
  66251. */
  66252. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66253. /**
  66254. * Static function used to export a particle system to a ParticleSystemSet variable.
  66255. * Please note that the emitter shape is not exported
  66256. * @param systems defines the particle systems to export
  66257. * @returns the created particle system set
  66258. */
  66259. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66260. }
  66261. }
  66262. declare module "babylonjs/Particles/particleSystemComponent" {
  66263. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66264. import { Effect } from "babylonjs/Materials/effect";
  66265. import "babylonjs/Shaders/particles.vertex";
  66266. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66267. module "babylonjs/Engines/engine" {
  66268. interface Engine {
  66269. /**
  66270. * Create an effect to use with particle systems.
  66271. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  66272. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66273. * @param uniformsNames defines a list of attribute names
  66274. * @param samplers defines an array of string used to represent textures
  66275. * @param defines defines the string containing the defines to use to compile the shaders
  66276. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66277. * @param onCompiled defines a function to call when the effect creation is successful
  66278. * @param onError defines a function to call when the effect creation has failed
  66279. * @returns the new Effect
  66280. */
  66281. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  66282. }
  66283. }
  66284. module "babylonjs/Meshes/mesh" {
  66285. interface Mesh {
  66286. /**
  66287. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66288. * @returns an array of IParticleSystem
  66289. */
  66290. getEmittedParticleSystems(): IParticleSystem[];
  66291. /**
  66292. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66293. * @returns an array of IParticleSystem
  66294. */
  66295. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66296. }
  66297. }
  66298. /**
  66299. * @hidden
  66300. */
  66301. export var _IDoNeedToBeInTheBuild: number;
  66302. }
  66303. declare module "babylonjs/Particles/pointsCloudSystem" {
  66304. import { Color4 } from "babylonjs/Maths/math";
  66305. import { Mesh } from "babylonjs/Meshes/mesh";
  66306. import { Scene, IDisposable } from "babylonjs/scene";
  66307. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  66308. /** Defines the 4 color options */
  66309. export enum PointColor {
  66310. /** color value */
  66311. Color = 2,
  66312. /** uv value */
  66313. UV = 1,
  66314. /** random value */
  66315. Random = 0,
  66316. /** stated value */
  66317. Stated = 3
  66318. }
  66319. /**
  66320. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66321. * 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.
  66322. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66323. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66324. *
  66325. * Full documentation here : TO BE ENTERED
  66326. */
  66327. export class PointsCloudSystem implements IDisposable {
  66328. /**
  66329. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66330. * Example : var p = SPS.particles[i];
  66331. */
  66332. particles: CloudPoint[];
  66333. /**
  66334. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66335. */
  66336. nbParticles: number;
  66337. /**
  66338. * This a counter for your own usage. It's not set by any SPS functions.
  66339. */
  66340. counter: number;
  66341. /**
  66342. * The PCS name. This name is also given to the underlying mesh.
  66343. */
  66344. name: string;
  66345. /**
  66346. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66347. */
  66348. mesh: Mesh;
  66349. /**
  66350. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66351. * Please read :
  66352. */
  66353. vars: any;
  66354. /**
  66355. * @hidden
  66356. */
  66357. _size: number;
  66358. private _scene;
  66359. private _promises;
  66360. private _positions;
  66361. private _indices;
  66362. private _normals;
  66363. private _colors;
  66364. private _uvs;
  66365. private _indices32;
  66366. private _positions32;
  66367. private _colors32;
  66368. private _uvs32;
  66369. private _updatable;
  66370. private _isVisibilityBoxLocked;
  66371. private _alwaysVisible;
  66372. private _groups;
  66373. private _groupCounter;
  66374. private _computeParticleColor;
  66375. private _computeParticleTexture;
  66376. private _computeParticleRotation;
  66377. private _computeBoundingBox;
  66378. private _isReady;
  66379. /**
  66380. * Creates a PCS (Points Cloud System) object
  66381. * @param name (String) is the PCS name, this will be the underlying mesh name
  66382. * @param pointSize (number) is the size for each point
  66383. * @param scene (Scene) is the scene in which the PCS is added
  66384. * @param options defines the options of the PCS e.g.
  66385. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66386. */
  66387. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66388. updatable?: boolean;
  66389. });
  66390. /**
  66391. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66392. * If no points were added to the PCS, the returned mesh is just a single point.
  66393. * @returns a promise for the created mesh
  66394. */
  66395. buildMeshAsync(): Promise<Mesh>;
  66396. /**
  66397. * @hidden
  66398. */
  66399. private _buildMesh;
  66400. private _addParticle;
  66401. private _randomUnitVector;
  66402. private _getColorIndicesForCoord;
  66403. private _setPointsColorOrUV;
  66404. private _colorFromTexture;
  66405. private _calculateDensity;
  66406. /**
  66407. * Adds points to the PCS in random positions within a unit sphere
  66408. * @param nb (positive integer) the number of particles to be created from this model
  66409. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66410. * @returns the number of groups in the system
  66411. */
  66412. addPoints(nb: number, pointFunction?: any): number;
  66413. /**
  66414. * Adds points to the PCS from the surface of the model shape
  66415. * @param mesh is any Mesh object that will be used as a surface model for the points
  66416. * @param nb (positive integer) the number of particles to be created from this model
  66417. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66418. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66419. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66420. * @returns the number of groups in the system
  66421. */
  66422. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66423. /**
  66424. * Adds points to the PCS inside the model shape
  66425. * @param mesh is any Mesh object that will be used as a surface model for the points
  66426. * @param nb (positive integer) the number of particles to be created from this model
  66427. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66428. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66429. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66430. * @returns the number of groups in the system
  66431. */
  66432. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66433. /**
  66434. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66435. * This method calls `updateParticle()` for each particle of the SPS.
  66436. * For an animated SPS, it is usually called within the render loop.
  66437. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66438. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66439. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66440. * @returns the PCS.
  66441. */
  66442. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66443. /**
  66444. * Disposes the PCS.
  66445. */
  66446. dispose(): void;
  66447. /**
  66448. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66449. * doc :
  66450. * @returns the PCS.
  66451. */
  66452. refreshVisibleSize(): PointsCloudSystem;
  66453. /**
  66454. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66455. * @param size the size (float) of the visibility box
  66456. * note : this doesn't lock the PCS mesh bounding box.
  66457. * doc :
  66458. */
  66459. setVisibilityBox(size: number): void;
  66460. /**
  66461. * Gets whether the PCS is always visible or not
  66462. * doc :
  66463. */
  66464. get isAlwaysVisible(): boolean;
  66465. /**
  66466. * Sets the PCS as always visible or not
  66467. * doc :
  66468. */
  66469. set isAlwaysVisible(val: boolean);
  66470. /**
  66471. * Tells to `setParticles()` to compute the particle rotations or not
  66472. * Default value : false. The PCS is faster when it's set to false
  66473. * Note : particle rotations are only applied to parent particles
  66474. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66475. */
  66476. set computeParticleRotation(val: boolean);
  66477. /**
  66478. * Tells to `setParticles()` to compute the particle colors or not.
  66479. * Default value : true. The PCS is faster when it's set to false.
  66480. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66481. */
  66482. set computeParticleColor(val: boolean);
  66483. set computeParticleTexture(val: boolean);
  66484. /**
  66485. * Gets if `setParticles()` computes the particle colors or not.
  66486. * Default value : false. The PCS is faster when it's set to false.
  66487. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66488. */
  66489. get computeParticleColor(): boolean;
  66490. /**
  66491. * Gets if `setParticles()` computes the particle textures or not.
  66492. * Default value : false. The PCS is faster when it's set to false.
  66493. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66494. */
  66495. get computeParticleTexture(): boolean;
  66496. /**
  66497. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66498. */
  66499. set computeBoundingBox(val: boolean);
  66500. /**
  66501. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66502. */
  66503. get computeBoundingBox(): boolean;
  66504. /**
  66505. * This function does nothing. It may be overwritten to set all the particle first values.
  66506. * The PCS doesn't call this function, you may have to call it by your own.
  66507. * doc :
  66508. */
  66509. initParticles(): void;
  66510. /**
  66511. * This function does nothing. It may be overwritten to recycle a particle
  66512. * The PCS doesn't call this function, you can to call it
  66513. * doc :
  66514. * @param particle The particle to recycle
  66515. * @returns the recycled particle
  66516. */
  66517. recycleParticle(particle: CloudPoint): CloudPoint;
  66518. /**
  66519. * Updates a particle : this function should be overwritten by the user.
  66520. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66521. * doc :
  66522. * @example : just set a particle position or velocity and recycle conditions
  66523. * @param particle The particle to update
  66524. * @returns the updated particle
  66525. */
  66526. updateParticle(particle: CloudPoint): CloudPoint;
  66527. /**
  66528. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66529. * This does nothing and may be overwritten by the user.
  66530. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66531. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66532. * @param update the boolean update value actually passed to setParticles()
  66533. */
  66534. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66535. /**
  66536. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66537. * This will be passed three parameters.
  66538. * This does nothing and may be overwritten by the user.
  66539. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66540. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66541. * @param update the boolean update value actually passed to setParticles()
  66542. */
  66543. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66544. }
  66545. }
  66546. declare module "babylonjs/Particles/cloudPoint" {
  66547. import { Nullable } from "babylonjs/types";
  66548. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  66549. import { Mesh } from "babylonjs/Meshes/mesh";
  66550. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  66551. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  66552. /**
  66553. * Represents one particle of a points cloud system.
  66554. */
  66555. export class CloudPoint {
  66556. /**
  66557. * particle global index
  66558. */
  66559. idx: number;
  66560. /**
  66561. * The color of the particle
  66562. */
  66563. color: Nullable<Color4>;
  66564. /**
  66565. * The world space position of the particle.
  66566. */
  66567. position: Vector3;
  66568. /**
  66569. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  66570. */
  66571. rotation: Vector3;
  66572. /**
  66573. * The world space rotation quaternion of the particle.
  66574. */
  66575. rotationQuaternion: Nullable<Quaternion>;
  66576. /**
  66577. * The uv of the particle.
  66578. */
  66579. uv: Nullable<Vector2>;
  66580. /**
  66581. * The current speed of the particle.
  66582. */
  66583. velocity: Vector3;
  66584. /**
  66585. * The pivot point in the particle local space.
  66586. */
  66587. pivot: Vector3;
  66588. /**
  66589. * Must the particle be translated from its pivot point in its local space ?
  66590. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  66591. * Default : false
  66592. */
  66593. translateFromPivot: boolean;
  66594. /**
  66595. * Index of this particle in the global "positions" array (Internal use)
  66596. * @hidden
  66597. */
  66598. _pos: number;
  66599. /**
  66600. * @hidden Index of this particle in the global "indices" array (Internal use)
  66601. */
  66602. _ind: number;
  66603. /**
  66604. * Group this particle belongs to
  66605. */
  66606. _group: PointsGroup;
  66607. /**
  66608. * Group id of this particle
  66609. */
  66610. groupId: number;
  66611. /**
  66612. * Index of the particle in its group id (Internal use)
  66613. */
  66614. idxInGroup: number;
  66615. /**
  66616. * @hidden Particle BoundingInfo object (Internal use)
  66617. */
  66618. _boundingInfo: BoundingInfo;
  66619. /**
  66620. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  66621. */
  66622. _pcs: PointsCloudSystem;
  66623. /**
  66624. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  66625. */
  66626. _stillInvisible: boolean;
  66627. /**
  66628. * @hidden Last computed particle rotation matrix
  66629. */
  66630. _rotationMatrix: number[];
  66631. /**
  66632. * Parent particle Id, if any.
  66633. * Default null.
  66634. */
  66635. parentId: Nullable<number>;
  66636. /**
  66637. * @hidden Internal global position in the PCS.
  66638. */
  66639. _globalPosition: Vector3;
  66640. /**
  66641. * Creates a Point Cloud object.
  66642. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  66643. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  66644. * @param group (PointsGroup) is the group the particle belongs to
  66645. * @param groupId (integer) is the group identifier in the PCS.
  66646. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  66647. * @param pcs defines the PCS it is associated to
  66648. */
  66649. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  66650. /**
  66651. * get point size
  66652. */
  66653. get size(): Vector3;
  66654. /**
  66655. * Set point size
  66656. */
  66657. set size(scale: Vector3);
  66658. /**
  66659. * Legacy support, changed quaternion to rotationQuaternion
  66660. */
  66661. get quaternion(): Nullable<Quaternion>;
  66662. /**
  66663. * Legacy support, changed quaternion to rotationQuaternion
  66664. */
  66665. set quaternion(q: Nullable<Quaternion>);
  66666. /**
  66667. * Returns a boolean. True if the particle intersects a mesh, else false
  66668. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  66669. * @param target is the object (point or mesh) what the intersection is computed against
  66670. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  66671. * @returns true if it intersects
  66672. */
  66673. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  66674. /**
  66675. * get the rotation matrix of the particle
  66676. * @hidden
  66677. */
  66678. getRotationMatrix(m: Matrix): void;
  66679. }
  66680. /**
  66681. * Represents a group of points in a points cloud system
  66682. * * PCS internal tool, don't use it manually.
  66683. */
  66684. export class PointsGroup {
  66685. /**
  66686. * The group id
  66687. * @hidden
  66688. */
  66689. groupID: number;
  66690. /**
  66691. * image data for group (internal use)
  66692. * @hidden
  66693. */
  66694. _groupImageData: Nullable<ArrayBufferView>;
  66695. /**
  66696. * Image Width (internal use)
  66697. * @hidden
  66698. */
  66699. _groupImgWidth: number;
  66700. /**
  66701. * Image Height (internal use)
  66702. * @hidden
  66703. */
  66704. _groupImgHeight: number;
  66705. /**
  66706. * Custom position function (internal use)
  66707. * @hidden
  66708. */
  66709. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  66710. /**
  66711. * density per facet for surface points
  66712. * @hidden
  66713. */
  66714. _groupDensity: number[];
  66715. /**
  66716. * Only when points are colored by texture carries pointer to texture list array
  66717. * @hidden
  66718. */
  66719. _textureNb: number;
  66720. /**
  66721. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  66722. * PCS internal tool, don't use it manually.
  66723. * @hidden
  66724. */
  66725. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  66726. }
  66727. }
  66728. declare module "babylonjs/Particles/index" {
  66729. export * from "babylonjs/Particles/baseParticleSystem";
  66730. export * from "babylonjs/Particles/EmitterTypes/index";
  66731. export * from "babylonjs/Particles/gpuParticleSystem";
  66732. export * from "babylonjs/Particles/IParticleSystem";
  66733. export * from "babylonjs/Particles/particle";
  66734. export * from "babylonjs/Particles/particleHelper";
  66735. export * from "babylonjs/Particles/particleSystem";
  66736. export * from "babylonjs/Particles/particleSystemComponent";
  66737. export * from "babylonjs/Particles/particleSystemSet";
  66738. export * from "babylonjs/Particles/solidParticle";
  66739. export * from "babylonjs/Particles/solidParticleSystem";
  66740. export * from "babylonjs/Particles/cloudPoint";
  66741. export * from "babylonjs/Particles/pointsCloudSystem";
  66742. export * from "babylonjs/Particles/subEmitter";
  66743. }
  66744. declare module "babylonjs/Physics/physicsEngineComponent" {
  66745. import { Nullable } from "babylonjs/types";
  66746. import { Observable, Observer } from "babylonjs/Misc/observable";
  66747. import { Vector3 } from "babylonjs/Maths/math.vector";
  66748. import { Mesh } from "babylonjs/Meshes/mesh";
  66749. import { ISceneComponent } from "babylonjs/sceneComponent";
  66750. import { Scene } from "babylonjs/scene";
  66751. import { Node } from "babylonjs/node";
  66752. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  66753. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66754. module "babylonjs/scene" {
  66755. interface Scene {
  66756. /** @hidden (Backing field) */
  66757. _physicsEngine: Nullable<IPhysicsEngine>;
  66758. /** @hidden */
  66759. _physicsTimeAccumulator: number;
  66760. /**
  66761. * Gets the current physics engine
  66762. * @returns a IPhysicsEngine or null if none attached
  66763. */
  66764. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  66765. /**
  66766. * Enables physics to the current scene
  66767. * @param gravity defines the scene's gravity for the physics engine
  66768. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  66769. * @return a boolean indicating if the physics engine was initialized
  66770. */
  66771. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  66772. /**
  66773. * Disables and disposes the physics engine associated with the scene
  66774. */
  66775. disablePhysicsEngine(): void;
  66776. /**
  66777. * Gets a boolean indicating if there is an active physics engine
  66778. * @returns a boolean indicating if there is an active physics engine
  66779. */
  66780. isPhysicsEnabled(): boolean;
  66781. /**
  66782. * Deletes a physics compound impostor
  66783. * @param compound defines the compound to delete
  66784. */
  66785. deleteCompoundImpostor(compound: any): void;
  66786. /**
  66787. * An event triggered when physic simulation is about to be run
  66788. */
  66789. onBeforePhysicsObservable: Observable<Scene>;
  66790. /**
  66791. * An event triggered when physic simulation has been done
  66792. */
  66793. onAfterPhysicsObservable: Observable<Scene>;
  66794. }
  66795. }
  66796. module "babylonjs/Meshes/abstractMesh" {
  66797. interface AbstractMesh {
  66798. /** @hidden */
  66799. _physicsImpostor: Nullable<PhysicsImpostor>;
  66800. /**
  66801. * Gets or sets impostor used for physic simulation
  66802. * @see http://doc.babylonjs.com/features/physics_engine
  66803. */
  66804. physicsImpostor: Nullable<PhysicsImpostor>;
  66805. /**
  66806. * Gets the current physics impostor
  66807. * @see http://doc.babylonjs.com/features/physics_engine
  66808. * @returns a physics impostor or null
  66809. */
  66810. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  66811. /** Apply a physic impulse to the mesh
  66812. * @param force defines the force to apply
  66813. * @param contactPoint defines where to apply the force
  66814. * @returns the current mesh
  66815. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  66816. */
  66817. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  66818. /**
  66819. * Creates a physic joint between two meshes
  66820. * @param otherMesh defines the other mesh to use
  66821. * @param pivot1 defines the pivot to use on this mesh
  66822. * @param pivot2 defines the pivot to use on the other mesh
  66823. * @param options defines additional options (can be plugin dependent)
  66824. * @returns the current mesh
  66825. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  66826. */
  66827. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  66828. /** @hidden */
  66829. _disposePhysicsObserver: Nullable<Observer<Node>>;
  66830. }
  66831. }
  66832. /**
  66833. * Defines the physics engine scene component responsible to manage a physics engine
  66834. */
  66835. export class PhysicsEngineSceneComponent implements ISceneComponent {
  66836. /**
  66837. * The component name helpful to identify the component in the list of scene components.
  66838. */
  66839. readonly name: string;
  66840. /**
  66841. * The scene the component belongs to.
  66842. */
  66843. scene: Scene;
  66844. /**
  66845. * Creates a new instance of the component for the given scene
  66846. * @param scene Defines the scene to register the component in
  66847. */
  66848. constructor(scene: Scene);
  66849. /**
  66850. * Registers the component in a given scene
  66851. */
  66852. register(): void;
  66853. /**
  66854. * Rebuilds the elements related to this component in case of
  66855. * context lost for instance.
  66856. */
  66857. rebuild(): void;
  66858. /**
  66859. * Disposes the component and the associated ressources
  66860. */
  66861. dispose(): void;
  66862. }
  66863. }
  66864. declare module "babylonjs/Physics/physicsHelper" {
  66865. import { Nullable } from "babylonjs/types";
  66866. import { Vector3 } from "babylonjs/Maths/math.vector";
  66867. import { Mesh } from "babylonjs/Meshes/mesh";
  66868. import { Scene } from "babylonjs/scene";
  66869. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66870. /**
  66871. * A helper for physics simulations
  66872. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66873. */
  66874. export class PhysicsHelper {
  66875. private _scene;
  66876. private _physicsEngine;
  66877. /**
  66878. * Initializes the Physics helper
  66879. * @param scene Babylon.js scene
  66880. */
  66881. constructor(scene: Scene);
  66882. /**
  66883. * Applies a radial explosion impulse
  66884. * @param origin the origin of the explosion
  66885. * @param radiusOrEventOptions the radius or the options of radial explosion
  66886. * @param strength the explosion strength
  66887. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66888. * @returns A physics radial explosion event, or null
  66889. */
  66890. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66891. /**
  66892. * Applies a radial explosion force
  66893. * @param origin the origin of the explosion
  66894. * @param radiusOrEventOptions the radius or the options of radial explosion
  66895. * @param strength the explosion strength
  66896. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66897. * @returns A physics radial explosion event, or null
  66898. */
  66899. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66900. /**
  66901. * Creates a gravitational field
  66902. * @param origin the origin of the explosion
  66903. * @param radiusOrEventOptions the radius or the options of radial explosion
  66904. * @param strength the explosion strength
  66905. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66906. * @returns A physics gravitational field event, or null
  66907. */
  66908. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  66909. /**
  66910. * Creates a physics updraft event
  66911. * @param origin the origin of the updraft
  66912. * @param radiusOrEventOptions the radius or the options of the updraft
  66913. * @param strength the strength of the updraft
  66914. * @param height the height of the updraft
  66915. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  66916. * @returns A physics updraft event, or null
  66917. */
  66918. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  66919. /**
  66920. * Creates a physics vortex event
  66921. * @param origin the of the vortex
  66922. * @param radiusOrEventOptions the radius or the options of the vortex
  66923. * @param strength the strength of the vortex
  66924. * @param height the height of the vortex
  66925. * @returns a Physics vortex event, or null
  66926. * A physics vortex event or null
  66927. */
  66928. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  66929. }
  66930. /**
  66931. * Represents a physics radial explosion event
  66932. */
  66933. class PhysicsRadialExplosionEvent {
  66934. private _scene;
  66935. private _options;
  66936. private _sphere;
  66937. private _dataFetched;
  66938. /**
  66939. * Initializes a radial explosioin event
  66940. * @param _scene BabylonJS scene
  66941. * @param _options The options for the vortex event
  66942. */
  66943. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  66944. /**
  66945. * Returns the data related to the radial explosion event (sphere).
  66946. * @returns The radial explosion event data
  66947. */
  66948. getData(): PhysicsRadialExplosionEventData;
  66949. /**
  66950. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  66951. * @param impostor A physics imposter
  66952. * @param origin the origin of the explosion
  66953. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  66954. */
  66955. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  66956. /**
  66957. * Triggers affecterd impostors callbacks
  66958. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  66959. */
  66960. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  66961. /**
  66962. * Disposes the sphere.
  66963. * @param force Specifies if the sphere should be disposed by force
  66964. */
  66965. dispose(force?: boolean): void;
  66966. /*** Helpers ***/
  66967. private _prepareSphere;
  66968. private _intersectsWithSphere;
  66969. }
  66970. /**
  66971. * Represents a gravitational field event
  66972. */
  66973. class PhysicsGravitationalFieldEvent {
  66974. private _physicsHelper;
  66975. private _scene;
  66976. private _origin;
  66977. private _options;
  66978. private _tickCallback;
  66979. private _sphere;
  66980. private _dataFetched;
  66981. /**
  66982. * Initializes the physics gravitational field event
  66983. * @param _physicsHelper A physics helper
  66984. * @param _scene BabylonJS scene
  66985. * @param _origin The origin position of the gravitational field event
  66986. * @param _options The options for the vortex event
  66987. */
  66988. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  66989. /**
  66990. * Returns the data related to the gravitational field event (sphere).
  66991. * @returns A gravitational field event
  66992. */
  66993. getData(): PhysicsGravitationalFieldEventData;
  66994. /**
  66995. * Enables the gravitational field.
  66996. */
  66997. enable(): void;
  66998. /**
  66999. * Disables the gravitational field.
  67000. */
  67001. disable(): void;
  67002. /**
  67003. * Disposes the sphere.
  67004. * @param force The force to dispose from the gravitational field event
  67005. */
  67006. dispose(force?: boolean): void;
  67007. private _tick;
  67008. }
  67009. /**
  67010. * Represents a physics updraft event
  67011. */
  67012. class PhysicsUpdraftEvent {
  67013. private _scene;
  67014. private _origin;
  67015. private _options;
  67016. private _physicsEngine;
  67017. private _originTop;
  67018. private _originDirection;
  67019. private _tickCallback;
  67020. private _cylinder;
  67021. private _cylinderPosition;
  67022. private _dataFetched;
  67023. /**
  67024. * Initializes the physics updraft event
  67025. * @param _scene BabylonJS scene
  67026. * @param _origin The origin position of the updraft
  67027. * @param _options The options for the updraft event
  67028. */
  67029. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  67030. /**
  67031. * Returns the data related to the updraft event (cylinder).
  67032. * @returns A physics updraft event
  67033. */
  67034. getData(): PhysicsUpdraftEventData;
  67035. /**
  67036. * Enables the updraft.
  67037. */
  67038. enable(): void;
  67039. /**
  67040. * Disables the updraft.
  67041. */
  67042. disable(): void;
  67043. /**
  67044. * Disposes the cylinder.
  67045. * @param force Specifies if the updraft should be disposed by force
  67046. */
  67047. dispose(force?: boolean): void;
  67048. private getImpostorHitData;
  67049. private _tick;
  67050. /*** Helpers ***/
  67051. private _prepareCylinder;
  67052. private _intersectsWithCylinder;
  67053. }
  67054. /**
  67055. * Represents a physics vortex event
  67056. */
  67057. class PhysicsVortexEvent {
  67058. private _scene;
  67059. private _origin;
  67060. private _options;
  67061. private _physicsEngine;
  67062. private _originTop;
  67063. private _tickCallback;
  67064. private _cylinder;
  67065. private _cylinderPosition;
  67066. private _dataFetched;
  67067. /**
  67068. * Initializes the physics vortex event
  67069. * @param _scene The BabylonJS scene
  67070. * @param _origin The origin position of the vortex
  67071. * @param _options The options for the vortex event
  67072. */
  67073. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  67074. /**
  67075. * Returns the data related to the vortex event (cylinder).
  67076. * @returns The physics vortex event data
  67077. */
  67078. getData(): PhysicsVortexEventData;
  67079. /**
  67080. * Enables the vortex.
  67081. */
  67082. enable(): void;
  67083. /**
  67084. * Disables the cortex.
  67085. */
  67086. disable(): void;
  67087. /**
  67088. * Disposes the sphere.
  67089. * @param force
  67090. */
  67091. dispose(force?: boolean): void;
  67092. private getImpostorHitData;
  67093. private _tick;
  67094. /*** Helpers ***/
  67095. private _prepareCylinder;
  67096. private _intersectsWithCylinder;
  67097. }
  67098. /**
  67099. * Options fot the radial explosion event
  67100. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67101. */
  67102. export class PhysicsRadialExplosionEventOptions {
  67103. /**
  67104. * The radius of the sphere for the radial explosion.
  67105. */
  67106. radius: number;
  67107. /**
  67108. * The strenth of the explosion.
  67109. */
  67110. strength: number;
  67111. /**
  67112. * The strenght of the force in correspondence to the distance of the affected object
  67113. */
  67114. falloff: PhysicsRadialImpulseFalloff;
  67115. /**
  67116. * Sphere options for the radial explosion.
  67117. */
  67118. sphere: {
  67119. segments: number;
  67120. diameter: number;
  67121. };
  67122. /**
  67123. * Sphere options for the radial explosion.
  67124. */
  67125. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  67126. }
  67127. /**
  67128. * Options fot the updraft event
  67129. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67130. */
  67131. export class PhysicsUpdraftEventOptions {
  67132. /**
  67133. * The radius of the cylinder for the vortex
  67134. */
  67135. radius: number;
  67136. /**
  67137. * The strenth of the updraft.
  67138. */
  67139. strength: number;
  67140. /**
  67141. * The height of the cylinder for the updraft.
  67142. */
  67143. height: number;
  67144. /**
  67145. * The mode for the the updraft.
  67146. */
  67147. updraftMode: PhysicsUpdraftMode;
  67148. }
  67149. /**
  67150. * Options fot the vortex event
  67151. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67152. */
  67153. export class PhysicsVortexEventOptions {
  67154. /**
  67155. * The radius of the cylinder for the vortex
  67156. */
  67157. radius: number;
  67158. /**
  67159. * The strenth of the vortex.
  67160. */
  67161. strength: number;
  67162. /**
  67163. * The height of the cylinder for the vortex.
  67164. */
  67165. height: number;
  67166. /**
  67167. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  67168. */
  67169. centripetalForceThreshold: number;
  67170. /**
  67171. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  67172. */
  67173. centripetalForceMultiplier: number;
  67174. /**
  67175. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  67176. */
  67177. centrifugalForceMultiplier: number;
  67178. /**
  67179. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  67180. */
  67181. updraftForceMultiplier: number;
  67182. }
  67183. /**
  67184. * The strenght of the force in correspondence to the distance of the affected object
  67185. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67186. */
  67187. export enum PhysicsRadialImpulseFalloff {
  67188. /** Defines that impulse is constant in strength across it's whole radius */
  67189. Constant = 0,
  67190. /** Defines that impulse gets weaker if it's further from the origin */
  67191. Linear = 1
  67192. }
  67193. /**
  67194. * The strength of the force in correspondence to the distance of the affected object
  67195. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67196. */
  67197. export enum PhysicsUpdraftMode {
  67198. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  67199. Center = 0,
  67200. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  67201. Perpendicular = 1
  67202. }
  67203. /**
  67204. * Interface for a physics hit data
  67205. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67206. */
  67207. export interface PhysicsHitData {
  67208. /**
  67209. * The force applied at the contact point
  67210. */
  67211. force: Vector3;
  67212. /**
  67213. * The contact point
  67214. */
  67215. contactPoint: Vector3;
  67216. /**
  67217. * The distance from the origin to the contact point
  67218. */
  67219. distanceFromOrigin: number;
  67220. }
  67221. /**
  67222. * Interface for radial explosion event data
  67223. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67224. */
  67225. export interface PhysicsRadialExplosionEventData {
  67226. /**
  67227. * A sphere used for the radial explosion event
  67228. */
  67229. sphere: Mesh;
  67230. }
  67231. /**
  67232. * Interface for gravitational field event data
  67233. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67234. */
  67235. export interface PhysicsGravitationalFieldEventData {
  67236. /**
  67237. * A sphere mesh used for the gravitational field event
  67238. */
  67239. sphere: Mesh;
  67240. }
  67241. /**
  67242. * Interface for updraft event data
  67243. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67244. */
  67245. export interface PhysicsUpdraftEventData {
  67246. /**
  67247. * A cylinder used for the updraft event
  67248. */
  67249. cylinder: Mesh;
  67250. }
  67251. /**
  67252. * Interface for vortex event data
  67253. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67254. */
  67255. export interface PhysicsVortexEventData {
  67256. /**
  67257. * A cylinder used for the vortex event
  67258. */
  67259. cylinder: Mesh;
  67260. }
  67261. /**
  67262. * Interface for an affected physics impostor
  67263. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67264. */
  67265. export interface PhysicsAffectedImpostorWithData {
  67266. /**
  67267. * The impostor affected by the effect
  67268. */
  67269. impostor: PhysicsImpostor;
  67270. /**
  67271. * The data about the hit/horce from the explosion
  67272. */
  67273. hitData: PhysicsHitData;
  67274. }
  67275. }
  67276. declare module "babylonjs/Physics/Plugins/index" {
  67277. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  67278. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  67279. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  67280. }
  67281. declare module "babylonjs/Physics/index" {
  67282. export * from "babylonjs/Physics/IPhysicsEngine";
  67283. export * from "babylonjs/Physics/physicsEngine";
  67284. export * from "babylonjs/Physics/physicsEngineComponent";
  67285. export * from "babylonjs/Physics/physicsHelper";
  67286. export * from "babylonjs/Physics/physicsImpostor";
  67287. export * from "babylonjs/Physics/physicsJoint";
  67288. export * from "babylonjs/Physics/Plugins/index";
  67289. }
  67290. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  67291. /** @hidden */
  67292. export var blackAndWhitePixelShader: {
  67293. name: string;
  67294. shader: string;
  67295. };
  67296. }
  67297. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  67298. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67299. import { Camera } from "babylonjs/Cameras/camera";
  67300. import { Engine } from "babylonjs/Engines/engine";
  67301. import "babylonjs/Shaders/blackAndWhite.fragment";
  67302. /**
  67303. * Post process used to render in black and white
  67304. */
  67305. export class BlackAndWhitePostProcess extends PostProcess {
  67306. /**
  67307. * Linear about to convert he result to black and white (default: 1)
  67308. */
  67309. degree: number;
  67310. /**
  67311. * Creates a black and white post process
  67312. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67313. * @param name The name of the effect.
  67314. * @param options The required width/height ratio to downsize to before computing the render pass.
  67315. * @param camera The camera to apply the render pass to.
  67316. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67317. * @param engine The engine which the post process will be applied. (default: current engine)
  67318. * @param reusable If the post process can be reused on the same frame. (default: false)
  67319. */
  67320. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67321. }
  67322. }
  67323. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  67324. import { Nullable } from "babylonjs/types";
  67325. import { Camera } from "babylonjs/Cameras/camera";
  67326. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67327. import { Engine } from "babylonjs/Engines/engine";
  67328. /**
  67329. * This represents a set of one or more post processes in Babylon.
  67330. * A post process can be used to apply a shader to a texture after it is rendered.
  67331. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67332. */
  67333. export class PostProcessRenderEffect {
  67334. private _postProcesses;
  67335. private _getPostProcesses;
  67336. private _singleInstance;
  67337. private _cameras;
  67338. private _indicesForCamera;
  67339. /**
  67340. * Name of the effect
  67341. * @hidden
  67342. */
  67343. _name: string;
  67344. /**
  67345. * Instantiates a post process render effect.
  67346. * A post process can be used to apply a shader to a texture after it is rendered.
  67347. * @param engine The engine the effect is tied to
  67348. * @param name The name of the effect
  67349. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67350. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67351. */
  67352. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67353. /**
  67354. * Checks if all the post processes in the effect are supported.
  67355. */
  67356. get isSupported(): boolean;
  67357. /**
  67358. * Updates the current state of the effect
  67359. * @hidden
  67360. */
  67361. _update(): void;
  67362. /**
  67363. * Attaches the effect on cameras
  67364. * @param cameras The camera to attach to.
  67365. * @hidden
  67366. */
  67367. _attachCameras(cameras: Camera): void;
  67368. /**
  67369. * Attaches the effect on cameras
  67370. * @param cameras The camera to attach to.
  67371. * @hidden
  67372. */
  67373. _attachCameras(cameras: Camera[]): void;
  67374. /**
  67375. * Detaches the effect on cameras
  67376. * @param cameras The camera to detatch from.
  67377. * @hidden
  67378. */
  67379. _detachCameras(cameras: Camera): void;
  67380. /**
  67381. * Detatches the effect on cameras
  67382. * @param cameras The camera to detatch from.
  67383. * @hidden
  67384. */
  67385. _detachCameras(cameras: Camera[]): void;
  67386. /**
  67387. * Enables the effect on given cameras
  67388. * @param cameras The camera to enable.
  67389. * @hidden
  67390. */
  67391. _enable(cameras: Camera): void;
  67392. /**
  67393. * Enables the effect on given cameras
  67394. * @param cameras The camera to enable.
  67395. * @hidden
  67396. */
  67397. _enable(cameras: Nullable<Camera[]>): void;
  67398. /**
  67399. * Disables the effect on the given cameras
  67400. * @param cameras The camera to disable.
  67401. * @hidden
  67402. */
  67403. _disable(cameras: Camera): void;
  67404. /**
  67405. * Disables the effect on the given cameras
  67406. * @param cameras The camera to disable.
  67407. * @hidden
  67408. */
  67409. _disable(cameras: Nullable<Camera[]>): void;
  67410. /**
  67411. * Gets a list of the post processes contained in the effect.
  67412. * @param camera The camera to get the post processes on.
  67413. * @returns The list of the post processes in the effect.
  67414. */
  67415. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67416. }
  67417. }
  67418. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  67419. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67420. /** @hidden */
  67421. export var extractHighlightsPixelShader: {
  67422. name: string;
  67423. shader: string;
  67424. };
  67425. }
  67426. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  67427. import { Nullable } from "babylonjs/types";
  67428. import { Camera } from "babylonjs/Cameras/camera";
  67429. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67430. import { Engine } from "babylonjs/Engines/engine";
  67431. import "babylonjs/Shaders/extractHighlights.fragment";
  67432. /**
  67433. * 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.
  67434. */
  67435. export class ExtractHighlightsPostProcess extends PostProcess {
  67436. /**
  67437. * The luminance threshold, pixels below this value will be set to black.
  67438. */
  67439. threshold: number;
  67440. /** @hidden */
  67441. _exposure: number;
  67442. /**
  67443. * Post process which has the input texture to be used when performing highlight extraction
  67444. * @hidden
  67445. */
  67446. _inputPostProcess: Nullable<PostProcess>;
  67447. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67448. }
  67449. }
  67450. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  67451. /** @hidden */
  67452. export var bloomMergePixelShader: {
  67453. name: string;
  67454. shader: string;
  67455. };
  67456. }
  67457. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  67458. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67459. import { Nullable } from "babylonjs/types";
  67460. import { Engine } from "babylonjs/Engines/engine";
  67461. import { Camera } from "babylonjs/Cameras/camera";
  67462. import "babylonjs/Shaders/bloomMerge.fragment";
  67463. /**
  67464. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67465. */
  67466. export class BloomMergePostProcess extends PostProcess {
  67467. /** Weight of the bloom to be added to the original input. */
  67468. weight: number;
  67469. /**
  67470. * Creates a new instance of @see BloomMergePostProcess
  67471. * @param name The name of the effect.
  67472. * @param originalFromInput Post process which's input will be used for the merge.
  67473. * @param blurred Blurred highlights post process which's output will be used.
  67474. * @param weight Weight of the bloom to be added to the original input.
  67475. * @param options The required width/height ratio to downsize to before computing the render pass.
  67476. * @param camera The camera to apply the render pass to.
  67477. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67478. * @param engine The engine which the post process will be applied. (default: current engine)
  67479. * @param reusable If the post process can be reused on the same frame. (default: false)
  67480. * @param textureType Type of textures used when performing the post process. (default: 0)
  67481. * @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)
  67482. */
  67483. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67484. /** Weight of the bloom to be added to the original input. */
  67485. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67486. }
  67487. }
  67488. declare module "babylonjs/PostProcesses/bloomEffect" {
  67489. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67490. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67491. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  67492. import { Camera } from "babylonjs/Cameras/camera";
  67493. import { Scene } from "babylonjs/scene";
  67494. /**
  67495. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67496. */
  67497. export class BloomEffect extends PostProcessRenderEffect {
  67498. private bloomScale;
  67499. /**
  67500. * @hidden Internal
  67501. */
  67502. _effects: Array<PostProcess>;
  67503. /**
  67504. * @hidden Internal
  67505. */
  67506. _downscale: ExtractHighlightsPostProcess;
  67507. private _blurX;
  67508. private _blurY;
  67509. private _merge;
  67510. /**
  67511. * The luminance threshold to find bright areas of the image to bloom.
  67512. */
  67513. get threshold(): number;
  67514. set threshold(value: number);
  67515. /**
  67516. * The strength of the bloom.
  67517. */
  67518. get weight(): number;
  67519. set weight(value: number);
  67520. /**
  67521. * Specifies the size of the bloom blur kernel, relative to the final output size
  67522. */
  67523. get kernel(): number;
  67524. set kernel(value: number);
  67525. /**
  67526. * Creates a new instance of @see BloomEffect
  67527. * @param scene The scene the effect belongs to.
  67528. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67529. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67530. * @param bloomWeight The the strength of bloom.
  67531. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67532. * @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)
  67533. */
  67534. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67535. /**
  67536. * Disposes each of the internal effects for a given camera.
  67537. * @param camera The camera to dispose the effect on.
  67538. */
  67539. disposeEffects(camera: Camera): void;
  67540. /**
  67541. * @hidden Internal
  67542. */
  67543. _updateEffects(): void;
  67544. /**
  67545. * Internal
  67546. * @returns if all the contained post processes are ready.
  67547. * @hidden
  67548. */
  67549. _isReady(): boolean;
  67550. }
  67551. }
  67552. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  67553. /** @hidden */
  67554. export var chromaticAberrationPixelShader: {
  67555. name: string;
  67556. shader: string;
  67557. };
  67558. }
  67559. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  67560. import { Vector2 } from "babylonjs/Maths/math.vector";
  67561. import { Nullable } from "babylonjs/types";
  67562. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67563. import { Camera } from "babylonjs/Cameras/camera";
  67564. import { Engine } from "babylonjs/Engines/engine";
  67565. import "babylonjs/Shaders/chromaticAberration.fragment";
  67566. /**
  67567. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67568. */
  67569. export class ChromaticAberrationPostProcess extends PostProcess {
  67570. /**
  67571. * The amount of seperation of rgb channels (default: 30)
  67572. */
  67573. aberrationAmount: number;
  67574. /**
  67575. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67576. */
  67577. radialIntensity: number;
  67578. /**
  67579. * 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))
  67580. */
  67581. direction: Vector2;
  67582. /**
  67583. * 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))
  67584. */
  67585. centerPosition: Vector2;
  67586. /**
  67587. * Creates a new instance ChromaticAberrationPostProcess
  67588. * @param name The name of the effect.
  67589. * @param screenWidth The width of the screen to apply the effect on.
  67590. * @param screenHeight The height of the screen to apply the effect on.
  67591. * @param options The required width/height ratio to downsize to before computing the render pass.
  67592. * @param camera The camera to apply the render pass to.
  67593. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67594. * @param engine The engine which the post process will be applied. (default: current engine)
  67595. * @param reusable If the post process can be reused on the same frame. (default: false)
  67596. * @param textureType Type of textures used when performing the post process. (default: 0)
  67597. * @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)
  67598. */
  67599. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67600. }
  67601. }
  67602. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  67603. /** @hidden */
  67604. export var circleOfConfusionPixelShader: {
  67605. name: string;
  67606. shader: string;
  67607. };
  67608. }
  67609. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  67610. import { Nullable } from "babylonjs/types";
  67611. import { Engine } from "babylonjs/Engines/engine";
  67612. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67613. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67614. import { Camera } from "babylonjs/Cameras/camera";
  67615. import "babylonjs/Shaders/circleOfConfusion.fragment";
  67616. /**
  67617. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67618. */
  67619. export class CircleOfConfusionPostProcess extends PostProcess {
  67620. /**
  67621. * 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.
  67622. */
  67623. lensSize: number;
  67624. /**
  67625. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67626. */
  67627. fStop: number;
  67628. /**
  67629. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67630. */
  67631. focusDistance: number;
  67632. /**
  67633. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67634. */
  67635. focalLength: number;
  67636. private _depthTexture;
  67637. /**
  67638. * Creates a new instance CircleOfConfusionPostProcess
  67639. * @param name The name of the effect.
  67640. * @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.
  67641. * @param options The required width/height ratio to downsize to before computing the render pass.
  67642. * @param camera The camera to apply the render pass to.
  67643. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67644. * @param engine The engine which the post process will be applied. (default: current engine)
  67645. * @param reusable If the post process can be reused on the same frame. (default: false)
  67646. * @param textureType Type of textures used when performing the post process. (default: 0)
  67647. * @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)
  67648. */
  67649. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67650. /**
  67651. * 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.
  67652. */
  67653. set depthTexture(value: RenderTargetTexture);
  67654. }
  67655. }
  67656. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  67657. /** @hidden */
  67658. export var colorCorrectionPixelShader: {
  67659. name: string;
  67660. shader: string;
  67661. };
  67662. }
  67663. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  67664. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67665. import { Engine } from "babylonjs/Engines/engine";
  67666. import { Camera } from "babylonjs/Cameras/camera";
  67667. import "babylonjs/Shaders/colorCorrection.fragment";
  67668. /**
  67669. *
  67670. * This post-process allows the modification of rendered colors by using
  67671. * a 'look-up table' (LUT). This effect is also called Color Grading.
  67672. *
  67673. * The object needs to be provided an url to a texture containing the color
  67674. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  67675. * Use an image editing software to tweak the LUT to match your needs.
  67676. *
  67677. * For an example of a color LUT, see here:
  67678. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  67679. * For explanations on color grading, see here:
  67680. * @see http://udn.epicgames.com/Three/ColorGrading.html
  67681. *
  67682. */
  67683. export class ColorCorrectionPostProcess extends PostProcess {
  67684. private _colorTableTexture;
  67685. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67686. }
  67687. }
  67688. declare module "babylonjs/Shaders/convolution.fragment" {
  67689. /** @hidden */
  67690. export var convolutionPixelShader: {
  67691. name: string;
  67692. shader: string;
  67693. };
  67694. }
  67695. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  67696. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67697. import { Nullable } from "babylonjs/types";
  67698. import { Camera } from "babylonjs/Cameras/camera";
  67699. import { Engine } from "babylonjs/Engines/engine";
  67700. import "babylonjs/Shaders/convolution.fragment";
  67701. /**
  67702. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  67703. * input texture to perform effects such as edge detection or sharpening
  67704. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67705. */
  67706. export class ConvolutionPostProcess extends PostProcess {
  67707. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67708. kernel: number[];
  67709. /**
  67710. * Creates a new instance ConvolutionPostProcess
  67711. * @param name The name of the effect.
  67712. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  67713. * @param options The required width/height ratio to downsize to before computing the render pass.
  67714. * @param camera The camera to apply the render pass to.
  67715. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67716. * @param engine The engine which the post process will be applied. (default: current engine)
  67717. * @param reusable If the post process can be reused on the same frame. (default: false)
  67718. * @param textureType Type of textures used when performing the post process. (default: 0)
  67719. */
  67720. constructor(name: string,
  67721. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67722. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67723. /**
  67724. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67725. */
  67726. static EdgeDetect0Kernel: number[];
  67727. /**
  67728. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67729. */
  67730. static EdgeDetect1Kernel: number[];
  67731. /**
  67732. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67733. */
  67734. static EdgeDetect2Kernel: number[];
  67735. /**
  67736. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67737. */
  67738. static SharpenKernel: number[];
  67739. /**
  67740. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67741. */
  67742. static EmbossKernel: number[];
  67743. /**
  67744. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67745. */
  67746. static GaussianKernel: number[];
  67747. }
  67748. }
  67749. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  67750. import { Nullable } from "babylonjs/types";
  67751. import { Vector2 } from "babylonjs/Maths/math.vector";
  67752. import { Camera } from "babylonjs/Cameras/camera";
  67753. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67754. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  67755. import { Engine } from "babylonjs/Engines/engine";
  67756. import { Scene } from "babylonjs/scene";
  67757. /**
  67758. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  67759. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  67760. * based on samples that have a large difference in distance than the center pixel.
  67761. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  67762. */
  67763. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  67764. direction: Vector2;
  67765. /**
  67766. * Creates a new instance CircleOfConfusionPostProcess
  67767. * @param name The name of the effect.
  67768. * @param scene The scene the effect belongs to.
  67769. * @param direction The direction the blur should be applied.
  67770. * @param kernel The size of the kernel used to blur.
  67771. * @param options The required width/height ratio to downsize to before computing the render pass.
  67772. * @param camera The camera to apply the render pass to.
  67773. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  67774. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  67775. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67776. * @param engine The engine which the post process will be applied. (default: current engine)
  67777. * @param reusable If the post process can be reused on the same frame. (default: false)
  67778. * @param textureType Type of textures used when performing the post process. (default: 0)
  67779. * @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)
  67780. */
  67781. 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);
  67782. }
  67783. }
  67784. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  67785. /** @hidden */
  67786. export var depthOfFieldMergePixelShader: {
  67787. name: string;
  67788. shader: string;
  67789. };
  67790. }
  67791. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  67792. import { Nullable } from "babylonjs/types";
  67793. import { Camera } from "babylonjs/Cameras/camera";
  67794. import { Effect } from "babylonjs/Materials/effect";
  67795. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67796. import { Engine } from "babylonjs/Engines/engine";
  67797. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  67798. /**
  67799. * Options to be set when merging outputs from the default pipeline.
  67800. */
  67801. export class DepthOfFieldMergePostProcessOptions {
  67802. /**
  67803. * The original image to merge on top of
  67804. */
  67805. originalFromInput: PostProcess;
  67806. /**
  67807. * Parameters to perform the merge of the depth of field effect
  67808. */
  67809. depthOfField?: {
  67810. circleOfConfusion: PostProcess;
  67811. blurSteps: Array<PostProcess>;
  67812. };
  67813. /**
  67814. * Parameters to perform the merge of bloom effect
  67815. */
  67816. bloom?: {
  67817. blurred: PostProcess;
  67818. weight: number;
  67819. };
  67820. }
  67821. /**
  67822. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67823. */
  67824. export class DepthOfFieldMergePostProcess extends PostProcess {
  67825. private blurSteps;
  67826. /**
  67827. * Creates a new instance of DepthOfFieldMergePostProcess
  67828. * @param name The name of the effect.
  67829. * @param originalFromInput Post process which's input will be used for the merge.
  67830. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  67831. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  67832. * @param options The required width/height ratio to downsize to before computing the render pass.
  67833. * @param camera The camera to apply the render pass to.
  67834. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67835. * @param engine The engine which the post process will be applied. (default: current engine)
  67836. * @param reusable If the post process can be reused on the same frame. (default: false)
  67837. * @param textureType Type of textures used when performing the post process. (default: 0)
  67838. * @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)
  67839. */
  67840. 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);
  67841. /**
  67842. * Updates the effect with the current post process compile time values and recompiles the shader.
  67843. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67844. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67845. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67846. * @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
  67847. * @param onCompiled Called when the shader has been compiled.
  67848. * @param onError Called if there is an error when compiling a shader.
  67849. */
  67850. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67851. }
  67852. }
  67853. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  67854. import { Nullable } from "babylonjs/types";
  67855. import { Camera } from "babylonjs/Cameras/camera";
  67856. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67857. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67858. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67859. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  67860. import { Scene } from "babylonjs/scene";
  67861. /**
  67862. * Specifies the level of max blur that should be applied when using the depth of field effect
  67863. */
  67864. export enum DepthOfFieldEffectBlurLevel {
  67865. /**
  67866. * Subtle blur
  67867. */
  67868. Low = 0,
  67869. /**
  67870. * Medium blur
  67871. */
  67872. Medium = 1,
  67873. /**
  67874. * Large blur
  67875. */
  67876. High = 2
  67877. }
  67878. /**
  67879. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  67880. */
  67881. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  67882. private _circleOfConfusion;
  67883. /**
  67884. * @hidden Internal, blurs from high to low
  67885. */
  67886. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  67887. private _depthOfFieldBlurY;
  67888. private _dofMerge;
  67889. /**
  67890. * @hidden Internal post processes in depth of field effect
  67891. */
  67892. _effects: Array<PostProcess>;
  67893. /**
  67894. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  67895. */
  67896. set focalLength(value: number);
  67897. get focalLength(): number;
  67898. /**
  67899. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67900. */
  67901. set fStop(value: number);
  67902. get fStop(): number;
  67903. /**
  67904. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67905. */
  67906. set focusDistance(value: number);
  67907. get focusDistance(): number;
  67908. /**
  67909. * 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.
  67910. */
  67911. set lensSize(value: number);
  67912. get lensSize(): number;
  67913. /**
  67914. * Creates a new instance DepthOfFieldEffect
  67915. * @param scene The scene the effect belongs to.
  67916. * @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.
  67917. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67918. * @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)
  67919. */
  67920. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  67921. /**
  67922. * Get the current class name of the current effet
  67923. * @returns "DepthOfFieldEffect"
  67924. */
  67925. getClassName(): string;
  67926. /**
  67927. * 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.
  67928. */
  67929. set depthTexture(value: RenderTargetTexture);
  67930. /**
  67931. * Disposes each of the internal effects for a given camera.
  67932. * @param camera The camera to dispose the effect on.
  67933. */
  67934. disposeEffects(camera: Camera): void;
  67935. /**
  67936. * @hidden Internal
  67937. */
  67938. _updateEffects(): void;
  67939. /**
  67940. * Internal
  67941. * @returns if all the contained post processes are ready.
  67942. * @hidden
  67943. */
  67944. _isReady(): boolean;
  67945. }
  67946. }
  67947. declare module "babylonjs/Shaders/displayPass.fragment" {
  67948. /** @hidden */
  67949. export var displayPassPixelShader: {
  67950. name: string;
  67951. shader: string;
  67952. };
  67953. }
  67954. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  67955. import { Nullable } from "babylonjs/types";
  67956. import { Camera } from "babylonjs/Cameras/camera";
  67957. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67958. import { Engine } from "babylonjs/Engines/engine";
  67959. import "babylonjs/Shaders/displayPass.fragment";
  67960. /**
  67961. * DisplayPassPostProcess which produces an output the same as it's input
  67962. */
  67963. export class DisplayPassPostProcess extends PostProcess {
  67964. /**
  67965. * Creates the DisplayPassPostProcess
  67966. * @param name The name of the effect.
  67967. * @param options The required width/height ratio to downsize to before computing the render pass.
  67968. * @param camera The camera to apply the render pass to.
  67969. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67970. * @param engine The engine which the post process will be applied. (default: current engine)
  67971. * @param reusable If the post process can be reused on the same frame. (default: false)
  67972. */
  67973. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67974. }
  67975. }
  67976. declare module "babylonjs/Shaders/filter.fragment" {
  67977. /** @hidden */
  67978. export var filterPixelShader: {
  67979. name: string;
  67980. shader: string;
  67981. };
  67982. }
  67983. declare module "babylonjs/PostProcesses/filterPostProcess" {
  67984. import { Nullable } from "babylonjs/types";
  67985. import { Matrix } from "babylonjs/Maths/math.vector";
  67986. import { Camera } from "babylonjs/Cameras/camera";
  67987. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67988. import { Engine } from "babylonjs/Engines/engine";
  67989. import "babylonjs/Shaders/filter.fragment";
  67990. /**
  67991. * Applies a kernel filter to the image
  67992. */
  67993. export class FilterPostProcess extends PostProcess {
  67994. /** The matrix to be applied to the image */
  67995. kernelMatrix: Matrix;
  67996. /**
  67997. *
  67998. * @param name The name of the effect.
  67999. * @param kernelMatrix The matrix to be applied to the image
  68000. * @param options The required width/height ratio to downsize to before computing the render pass.
  68001. * @param camera The camera to apply the render pass to.
  68002. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68003. * @param engine The engine which the post process will be applied. (default: current engine)
  68004. * @param reusable If the post process can be reused on the same frame. (default: false)
  68005. */
  68006. constructor(name: string,
  68007. /** The matrix to be applied to the image */
  68008. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68009. }
  68010. }
  68011. declare module "babylonjs/Shaders/fxaa.fragment" {
  68012. /** @hidden */
  68013. export var fxaaPixelShader: {
  68014. name: string;
  68015. shader: string;
  68016. };
  68017. }
  68018. declare module "babylonjs/Shaders/fxaa.vertex" {
  68019. /** @hidden */
  68020. export var fxaaVertexShader: {
  68021. name: string;
  68022. shader: string;
  68023. };
  68024. }
  68025. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  68026. import { Nullable } from "babylonjs/types";
  68027. import { Camera } from "babylonjs/Cameras/camera";
  68028. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68029. import { Engine } from "babylonjs/Engines/engine";
  68030. import "babylonjs/Shaders/fxaa.fragment";
  68031. import "babylonjs/Shaders/fxaa.vertex";
  68032. /**
  68033. * Fxaa post process
  68034. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  68035. */
  68036. export class FxaaPostProcess extends PostProcess {
  68037. /** @hidden */
  68038. texelWidth: number;
  68039. /** @hidden */
  68040. texelHeight: number;
  68041. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68042. private _getDefines;
  68043. }
  68044. }
  68045. declare module "babylonjs/Shaders/grain.fragment" {
  68046. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  68047. /** @hidden */
  68048. export var grainPixelShader: {
  68049. name: string;
  68050. shader: string;
  68051. };
  68052. }
  68053. declare module "babylonjs/PostProcesses/grainPostProcess" {
  68054. import { Nullable } from "babylonjs/types";
  68055. import { Camera } from "babylonjs/Cameras/camera";
  68056. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68057. import { Engine } from "babylonjs/Engines/engine";
  68058. import "babylonjs/Shaders/grain.fragment";
  68059. /**
  68060. * The GrainPostProcess adds noise to the image at mid luminance levels
  68061. */
  68062. export class GrainPostProcess extends PostProcess {
  68063. /**
  68064. * The intensity of the grain added (default: 30)
  68065. */
  68066. intensity: number;
  68067. /**
  68068. * If the grain should be randomized on every frame
  68069. */
  68070. animated: boolean;
  68071. /**
  68072. * Creates a new instance of @see GrainPostProcess
  68073. * @param name The name of the effect.
  68074. * @param options The required width/height ratio to downsize to before computing the render pass.
  68075. * @param camera The camera to apply the render pass to.
  68076. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68077. * @param engine The engine which the post process will be applied. (default: current engine)
  68078. * @param reusable If the post process can be reused on the same frame. (default: false)
  68079. * @param textureType Type of textures used when performing the post process. (default: 0)
  68080. * @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)
  68081. */
  68082. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68083. }
  68084. }
  68085. declare module "babylonjs/Shaders/highlights.fragment" {
  68086. /** @hidden */
  68087. export var highlightsPixelShader: {
  68088. name: string;
  68089. shader: string;
  68090. };
  68091. }
  68092. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  68093. import { Nullable } from "babylonjs/types";
  68094. import { Camera } from "babylonjs/Cameras/camera";
  68095. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68096. import { Engine } from "babylonjs/Engines/engine";
  68097. import "babylonjs/Shaders/highlights.fragment";
  68098. /**
  68099. * Extracts highlights from the image
  68100. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68101. */
  68102. export class HighlightsPostProcess extends PostProcess {
  68103. /**
  68104. * Extracts highlights from the image
  68105. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68106. * @param name The name of the effect.
  68107. * @param options The required width/height ratio to downsize to before computing the render pass.
  68108. * @param camera The camera to apply the render pass to.
  68109. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68110. * @param engine The engine which the post process will be applied. (default: current engine)
  68111. * @param reusable If the post process can be reused on the same frame. (default: false)
  68112. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  68113. */
  68114. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68115. }
  68116. }
  68117. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  68118. /** @hidden */
  68119. export var mrtFragmentDeclaration: {
  68120. name: string;
  68121. shader: string;
  68122. };
  68123. }
  68124. declare module "babylonjs/Shaders/geometry.fragment" {
  68125. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  68126. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  68127. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  68128. /** @hidden */
  68129. export var geometryPixelShader: {
  68130. name: string;
  68131. shader: string;
  68132. };
  68133. }
  68134. declare module "babylonjs/Shaders/geometry.vertex" {
  68135. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  68136. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  68137. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  68138. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  68139. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  68140. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  68141. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  68142. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  68143. /** @hidden */
  68144. export var geometryVertexShader: {
  68145. name: string;
  68146. shader: string;
  68147. };
  68148. }
  68149. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  68150. import { Matrix } from "babylonjs/Maths/math.vector";
  68151. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68152. import { Mesh } from "babylonjs/Meshes/mesh";
  68153. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  68154. import { Effect } from "babylonjs/Materials/effect";
  68155. import { Scene } from "babylonjs/scene";
  68156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68157. import "babylonjs/Shaders/geometry.fragment";
  68158. import "babylonjs/Shaders/geometry.vertex";
  68159. /** @hidden */
  68160. interface ISavedTransformationMatrix {
  68161. world: Matrix;
  68162. viewProjection: Matrix;
  68163. }
  68164. /**
  68165. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  68166. */
  68167. export class GeometryBufferRenderer {
  68168. /**
  68169. * Constant used to retrieve the position texture index in the G-Buffer textures array
  68170. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  68171. */
  68172. static readonly POSITION_TEXTURE_TYPE: number;
  68173. /**
  68174. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  68175. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  68176. */
  68177. static readonly VELOCITY_TEXTURE_TYPE: number;
  68178. /**
  68179. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  68180. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  68181. */
  68182. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  68183. /**
  68184. * Dictionary used to store the previous transformation matrices of each rendered mesh
  68185. * in order to compute objects velocities when enableVelocity is set to "true"
  68186. * @hidden
  68187. */
  68188. _previousTransformationMatrices: {
  68189. [index: number]: ISavedTransformationMatrix;
  68190. };
  68191. /**
  68192. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  68193. * in order to compute objects velocities when enableVelocity is set to "true"
  68194. * @hidden
  68195. */
  68196. _previousBonesTransformationMatrices: {
  68197. [index: number]: Float32Array;
  68198. };
  68199. /**
  68200. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  68201. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  68202. */
  68203. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  68204. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  68205. renderTransparentMeshes: boolean;
  68206. private _scene;
  68207. private _multiRenderTarget;
  68208. private _ratio;
  68209. private _enablePosition;
  68210. private _enableVelocity;
  68211. private _enableReflectivity;
  68212. private _positionIndex;
  68213. private _velocityIndex;
  68214. private _reflectivityIndex;
  68215. protected _effect: Effect;
  68216. protected _cachedDefines: string;
  68217. /**
  68218. * Set the render list (meshes to be rendered) used in the G buffer.
  68219. */
  68220. set renderList(meshes: Mesh[]);
  68221. /**
  68222. * Gets wether or not G buffer are supported by the running hardware.
  68223. * This requires draw buffer supports
  68224. */
  68225. get isSupported(): boolean;
  68226. /**
  68227. * Returns the index of the given texture type in the G-Buffer textures array
  68228. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68229. * @returns the index of the given texture type in the G-Buffer textures array
  68230. */
  68231. getTextureIndex(textureType: number): number;
  68232. /**
  68233. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68234. */
  68235. get enablePosition(): boolean;
  68236. /**
  68237. * Sets whether or not objects positions are enabled for the G buffer.
  68238. */
  68239. set enablePosition(enable: boolean);
  68240. /**
  68241. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68242. */
  68243. get enableVelocity(): boolean;
  68244. /**
  68245. * Sets wether or not objects velocities are enabled for the G buffer.
  68246. */
  68247. set enableVelocity(enable: boolean);
  68248. /**
  68249. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68250. */
  68251. get enableReflectivity(): boolean;
  68252. /**
  68253. * Sets wether or not objects roughness are enabled for the G buffer.
  68254. */
  68255. set enableReflectivity(enable: boolean);
  68256. /**
  68257. * Gets the scene associated with the buffer.
  68258. */
  68259. get scene(): Scene;
  68260. /**
  68261. * Gets the ratio used by the buffer during its creation.
  68262. * How big is the buffer related to the main canvas.
  68263. */
  68264. get ratio(): number;
  68265. /** @hidden */
  68266. static _SceneComponentInitialization: (scene: Scene) => void;
  68267. /**
  68268. * Creates a new G Buffer for the scene
  68269. * @param scene The scene the buffer belongs to
  68270. * @param ratio How big is the buffer related to the main canvas.
  68271. */
  68272. constructor(scene: Scene, ratio?: number);
  68273. /**
  68274. * Checks wether everything is ready to render a submesh to the G buffer.
  68275. * @param subMesh the submesh to check readiness for
  68276. * @param useInstances is the mesh drawn using instance or not
  68277. * @returns true if ready otherwise false
  68278. */
  68279. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68280. /**
  68281. * Gets the current underlying G Buffer.
  68282. * @returns the buffer
  68283. */
  68284. getGBuffer(): MultiRenderTarget;
  68285. /**
  68286. * Gets the number of samples used to render the buffer (anti aliasing).
  68287. */
  68288. get samples(): number;
  68289. /**
  68290. * Sets the number of samples used to render the buffer (anti aliasing).
  68291. */
  68292. set samples(value: number);
  68293. /**
  68294. * Disposes the renderer and frees up associated resources.
  68295. */
  68296. dispose(): void;
  68297. protected _createRenderTargets(): void;
  68298. private _copyBonesTransformationMatrices;
  68299. }
  68300. }
  68301. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  68302. import { Nullable } from "babylonjs/types";
  68303. import { Scene } from "babylonjs/scene";
  68304. import { ISceneComponent } from "babylonjs/sceneComponent";
  68305. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  68306. module "babylonjs/scene" {
  68307. interface Scene {
  68308. /** @hidden (Backing field) */
  68309. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68310. /**
  68311. * Gets or Sets the current geometry buffer associated to the scene.
  68312. */
  68313. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68314. /**
  68315. * Enables a GeometryBufferRender and associates it with the scene
  68316. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68317. * @returns the GeometryBufferRenderer
  68318. */
  68319. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68320. /**
  68321. * Disables the GeometryBufferRender associated with the scene
  68322. */
  68323. disableGeometryBufferRenderer(): void;
  68324. }
  68325. }
  68326. /**
  68327. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68328. * in several rendering techniques.
  68329. */
  68330. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68331. /**
  68332. * The component name helpful to identify the component in the list of scene components.
  68333. */
  68334. readonly name: string;
  68335. /**
  68336. * The scene the component belongs to.
  68337. */
  68338. scene: Scene;
  68339. /**
  68340. * Creates a new instance of the component for the given scene
  68341. * @param scene Defines the scene to register the component in
  68342. */
  68343. constructor(scene: Scene);
  68344. /**
  68345. * Registers the component in a given scene
  68346. */
  68347. register(): void;
  68348. /**
  68349. * Rebuilds the elements related to this component in case of
  68350. * context lost for instance.
  68351. */
  68352. rebuild(): void;
  68353. /**
  68354. * Disposes the component and the associated ressources
  68355. */
  68356. dispose(): void;
  68357. private _gatherRenderTargets;
  68358. }
  68359. }
  68360. declare module "babylonjs/Shaders/motionBlur.fragment" {
  68361. /** @hidden */
  68362. export var motionBlurPixelShader: {
  68363. name: string;
  68364. shader: string;
  68365. };
  68366. }
  68367. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  68368. import { Nullable } from "babylonjs/types";
  68369. import { Camera } from "babylonjs/Cameras/camera";
  68370. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68371. import { Scene } from "babylonjs/scene";
  68372. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68373. import "babylonjs/Animations/animatable";
  68374. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  68375. import "babylonjs/Shaders/motionBlur.fragment";
  68376. import { Engine } from "babylonjs/Engines/engine";
  68377. /**
  68378. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68379. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68380. * As an example, all you have to do is to create the post-process:
  68381. * var mb = new BABYLON.MotionBlurPostProcess(
  68382. * 'mb', // The name of the effect.
  68383. * scene, // The scene containing the objects to blur according to their velocity.
  68384. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68385. * camera // The camera to apply the render pass to.
  68386. * );
  68387. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68388. */
  68389. export class MotionBlurPostProcess extends PostProcess {
  68390. /**
  68391. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68392. */
  68393. motionStrength: number;
  68394. /**
  68395. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68396. */
  68397. get motionBlurSamples(): number;
  68398. /**
  68399. * Sets the number of iterations to be used for motion blur quality
  68400. */
  68401. set motionBlurSamples(samples: number);
  68402. private _motionBlurSamples;
  68403. private _geometryBufferRenderer;
  68404. /**
  68405. * Creates a new instance MotionBlurPostProcess
  68406. * @param name The name of the effect.
  68407. * @param scene The scene containing the objects to blur according to their velocity.
  68408. * @param options The required width/height ratio to downsize to before computing the render pass.
  68409. * @param camera The camera to apply the render pass to.
  68410. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68411. * @param engine The engine which the post process will be applied. (default: current engine)
  68412. * @param reusable If the post process can be reused on the same frame. (default: false)
  68413. * @param textureType Type of textures used when performing the post process. (default: 0)
  68414. * @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)
  68415. */
  68416. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68417. /**
  68418. * Excludes the given skinned mesh from computing bones velocities.
  68419. * 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.
  68420. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68421. */
  68422. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68423. /**
  68424. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68425. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68426. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68427. */
  68428. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68429. /**
  68430. * Disposes the post process.
  68431. * @param camera The camera to dispose the post process on.
  68432. */
  68433. dispose(camera?: Camera): void;
  68434. }
  68435. }
  68436. declare module "babylonjs/Shaders/refraction.fragment" {
  68437. /** @hidden */
  68438. export var refractionPixelShader: {
  68439. name: string;
  68440. shader: string;
  68441. };
  68442. }
  68443. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  68444. import { Color3 } from "babylonjs/Maths/math.color";
  68445. import { Camera } from "babylonjs/Cameras/camera";
  68446. import { Texture } from "babylonjs/Materials/Textures/texture";
  68447. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68448. import { Engine } from "babylonjs/Engines/engine";
  68449. import "babylonjs/Shaders/refraction.fragment";
  68450. /**
  68451. * Post process which applies a refractin texture
  68452. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68453. */
  68454. export class RefractionPostProcess extends PostProcess {
  68455. /** the base color of the refraction (used to taint the rendering) */
  68456. color: Color3;
  68457. /** simulated refraction depth */
  68458. depth: number;
  68459. /** the coefficient of the base color (0 to remove base color tainting) */
  68460. colorLevel: number;
  68461. private _refTexture;
  68462. private _ownRefractionTexture;
  68463. /**
  68464. * Gets or sets the refraction texture
  68465. * Please note that you are responsible for disposing the texture if you set it manually
  68466. */
  68467. get refractionTexture(): Texture;
  68468. set refractionTexture(value: Texture);
  68469. /**
  68470. * Initializes the RefractionPostProcess
  68471. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68472. * @param name The name of the effect.
  68473. * @param refractionTextureUrl Url of the refraction texture to use
  68474. * @param color the base color of the refraction (used to taint the rendering)
  68475. * @param depth simulated refraction depth
  68476. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68477. * @param camera The camera to apply the render pass to.
  68478. * @param options The required width/height ratio to downsize to before computing the render pass.
  68479. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68480. * @param engine The engine which the post process will be applied. (default: current engine)
  68481. * @param reusable If the post process can be reused on the same frame. (default: false)
  68482. */
  68483. constructor(name: string, refractionTextureUrl: string,
  68484. /** the base color of the refraction (used to taint the rendering) */
  68485. color: Color3,
  68486. /** simulated refraction depth */
  68487. depth: number,
  68488. /** the coefficient of the base color (0 to remove base color tainting) */
  68489. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68490. /**
  68491. * Disposes of the post process
  68492. * @param camera Camera to dispose post process on
  68493. */
  68494. dispose(camera: Camera): void;
  68495. }
  68496. }
  68497. declare module "babylonjs/Shaders/sharpen.fragment" {
  68498. /** @hidden */
  68499. export var sharpenPixelShader: {
  68500. name: string;
  68501. shader: string;
  68502. };
  68503. }
  68504. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  68505. import { Nullable } from "babylonjs/types";
  68506. import { Camera } from "babylonjs/Cameras/camera";
  68507. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68508. import "babylonjs/Shaders/sharpen.fragment";
  68509. import { Engine } from "babylonjs/Engines/engine";
  68510. /**
  68511. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68512. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68513. */
  68514. export class SharpenPostProcess extends PostProcess {
  68515. /**
  68516. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68517. */
  68518. colorAmount: number;
  68519. /**
  68520. * How much sharpness should be applied (default: 0.3)
  68521. */
  68522. edgeAmount: number;
  68523. /**
  68524. * Creates a new instance ConvolutionPostProcess
  68525. * @param name The name of the effect.
  68526. * @param options The required width/height ratio to downsize to before computing the render pass.
  68527. * @param camera The camera to apply the render pass to.
  68528. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68529. * @param engine The engine which the post process will be applied. (default: current engine)
  68530. * @param reusable If the post process can be reused on the same frame. (default: false)
  68531. * @param textureType Type of textures used when performing the post process. (default: 0)
  68532. * @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)
  68533. */
  68534. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68535. }
  68536. }
  68537. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  68538. import { Nullable } from "babylonjs/types";
  68539. import { Camera } from "babylonjs/Cameras/camera";
  68540. import { Engine } from "babylonjs/Engines/engine";
  68541. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68542. import { IInspectable } from "babylonjs/Misc/iInspectable";
  68543. /**
  68544. * PostProcessRenderPipeline
  68545. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68546. */
  68547. export class PostProcessRenderPipeline {
  68548. private engine;
  68549. private _renderEffects;
  68550. private _renderEffectsForIsolatedPass;
  68551. /**
  68552. * List of inspectable custom properties (used by the Inspector)
  68553. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68554. */
  68555. inspectableCustomProperties: IInspectable[];
  68556. /**
  68557. * @hidden
  68558. */
  68559. protected _cameras: Camera[];
  68560. /** @hidden */
  68561. _name: string;
  68562. /**
  68563. * Gets pipeline name
  68564. */
  68565. get name(): string;
  68566. /** Gets the list of attached cameras */
  68567. get cameras(): Camera[];
  68568. /**
  68569. * Initializes a PostProcessRenderPipeline
  68570. * @param engine engine to add the pipeline to
  68571. * @param name name of the pipeline
  68572. */
  68573. constructor(engine: Engine, name: string);
  68574. /**
  68575. * Gets the class name
  68576. * @returns "PostProcessRenderPipeline"
  68577. */
  68578. getClassName(): string;
  68579. /**
  68580. * If all the render effects in the pipeline are supported
  68581. */
  68582. get isSupported(): boolean;
  68583. /**
  68584. * Adds an effect to the pipeline
  68585. * @param renderEffect the effect to add
  68586. */
  68587. addEffect(renderEffect: PostProcessRenderEffect): void;
  68588. /** @hidden */
  68589. _rebuild(): void;
  68590. /** @hidden */
  68591. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68592. /** @hidden */
  68593. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68594. /** @hidden */
  68595. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68596. /** @hidden */
  68597. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68598. /** @hidden */
  68599. _attachCameras(cameras: Camera, unique: boolean): void;
  68600. /** @hidden */
  68601. _attachCameras(cameras: Camera[], unique: boolean): void;
  68602. /** @hidden */
  68603. _detachCameras(cameras: Camera): void;
  68604. /** @hidden */
  68605. _detachCameras(cameras: Nullable<Camera[]>): void;
  68606. /** @hidden */
  68607. _update(): void;
  68608. /** @hidden */
  68609. _reset(): void;
  68610. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68611. /**
  68612. * Disposes of the pipeline
  68613. */
  68614. dispose(): void;
  68615. }
  68616. }
  68617. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  68618. import { Camera } from "babylonjs/Cameras/camera";
  68619. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68620. /**
  68621. * PostProcessRenderPipelineManager class
  68622. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68623. */
  68624. export class PostProcessRenderPipelineManager {
  68625. private _renderPipelines;
  68626. /**
  68627. * Initializes a PostProcessRenderPipelineManager
  68628. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68629. */
  68630. constructor();
  68631. /**
  68632. * Gets the list of supported render pipelines
  68633. */
  68634. get supportedPipelines(): PostProcessRenderPipeline[];
  68635. /**
  68636. * Adds a pipeline to the manager
  68637. * @param renderPipeline The pipeline to add
  68638. */
  68639. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68640. /**
  68641. * Attaches a camera to the pipeline
  68642. * @param renderPipelineName The name of the pipeline to attach to
  68643. * @param cameras the camera to attach
  68644. * @param unique if the camera can be attached multiple times to the pipeline
  68645. */
  68646. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68647. /**
  68648. * Detaches a camera from the pipeline
  68649. * @param renderPipelineName The name of the pipeline to detach from
  68650. * @param cameras the camera to detach
  68651. */
  68652. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68653. /**
  68654. * Enables an effect by name on a pipeline
  68655. * @param renderPipelineName the name of the pipeline to enable the effect in
  68656. * @param renderEffectName the name of the effect to enable
  68657. * @param cameras the cameras that the effect should be enabled on
  68658. */
  68659. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68660. /**
  68661. * Disables an effect by name on a pipeline
  68662. * @param renderPipelineName the name of the pipeline to disable the effect in
  68663. * @param renderEffectName the name of the effect to disable
  68664. * @param cameras the cameras that the effect should be disabled on
  68665. */
  68666. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68667. /**
  68668. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68669. */
  68670. update(): void;
  68671. /** @hidden */
  68672. _rebuild(): void;
  68673. /**
  68674. * Disposes of the manager and pipelines
  68675. */
  68676. dispose(): void;
  68677. }
  68678. }
  68679. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  68680. import { ISceneComponent } from "babylonjs/sceneComponent";
  68681. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  68682. import { Scene } from "babylonjs/scene";
  68683. module "babylonjs/scene" {
  68684. interface Scene {
  68685. /** @hidden (Backing field) */
  68686. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68687. /**
  68688. * Gets the postprocess render pipeline manager
  68689. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68690. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68691. */
  68692. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68693. }
  68694. }
  68695. /**
  68696. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68697. */
  68698. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68699. /**
  68700. * The component name helpfull to identify the component in the list of scene components.
  68701. */
  68702. readonly name: string;
  68703. /**
  68704. * The scene the component belongs to.
  68705. */
  68706. scene: Scene;
  68707. /**
  68708. * Creates a new instance of the component for the given scene
  68709. * @param scene Defines the scene to register the component in
  68710. */
  68711. constructor(scene: Scene);
  68712. /**
  68713. * Registers the component in a given scene
  68714. */
  68715. register(): void;
  68716. /**
  68717. * Rebuilds the elements related to this component in case of
  68718. * context lost for instance.
  68719. */
  68720. rebuild(): void;
  68721. /**
  68722. * Disposes the component and the associated ressources
  68723. */
  68724. dispose(): void;
  68725. private _gatherRenderTargets;
  68726. }
  68727. }
  68728. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  68729. import { Nullable } from "babylonjs/types";
  68730. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  68731. import { Camera } from "babylonjs/Cameras/camera";
  68732. import { IDisposable } from "babylonjs/scene";
  68733. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  68734. import { Scene } from "babylonjs/scene";
  68735. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  68736. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  68737. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  68738. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  68739. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  68740. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68741. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  68742. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68743. import { Animation } from "babylonjs/Animations/animation";
  68744. /**
  68745. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68746. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68747. */
  68748. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68749. private _scene;
  68750. private _camerasToBeAttached;
  68751. /**
  68752. * ID of the sharpen post process,
  68753. */
  68754. private readonly SharpenPostProcessId;
  68755. /**
  68756. * @ignore
  68757. * ID of the image processing post process;
  68758. */
  68759. readonly ImageProcessingPostProcessId: string;
  68760. /**
  68761. * @ignore
  68762. * ID of the Fast Approximate Anti-Aliasing post process;
  68763. */
  68764. readonly FxaaPostProcessId: string;
  68765. /**
  68766. * ID of the chromatic aberration post process,
  68767. */
  68768. private readonly ChromaticAberrationPostProcessId;
  68769. /**
  68770. * ID of the grain post process
  68771. */
  68772. private readonly GrainPostProcessId;
  68773. /**
  68774. * Sharpen post process which will apply a sharpen convolution to enhance edges
  68775. */
  68776. sharpen: SharpenPostProcess;
  68777. private _sharpenEffect;
  68778. private bloom;
  68779. /**
  68780. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  68781. */
  68782. depthOfField: DepthOfFieldEffect;
  68783. /**
  68784. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68785. */
  68786. fxaa: FxaaPostProcess;
  68787. /**
  68788. * Image post processing pass used to perform operations such as tone mapping or color grading.
  68789. */
  68790. imageProcessing: ImageProcessingPostProcess;
  68791. /**
  68792. * Chromatic aberration post process which will shift rgb colors in the image
  68793. */
  68794. chromaticAberration: ChromaticAberrationPostProcess;
  68795. private _chromaticAberrationEffect;
  68796. /**
  68797. * Grain post process which add noise to the image
  68798. */
  68799. grain: GrainPostProcess;
  68800. private _grainEffect;
  68801. /**
  68802. * Glow post process which adds a glow to emissive areas of the image
  68803. */
  68804. private _glowLayer;
  68805. /**
  68806. * Animations which can be used to tweak settings over a period of time
  68807. */
  68808. animations: Animation[];
  68809. private _imageProcessingConfigurationObserver;
  68810. private _sharpenEnabled;
  68811. private _bloomEnabled;
  68812. private _depthOfFieldEnabled;
  68813. private _depthOfFieldBlurLevel;
  68814. private _fxaaEnabled;
  68815. private _imageProcessingEnabled;
  68816. private _defaultPipelineTextureType;
  68817. private _bloomScale;
  68818. private _chromaticAberrationEnabled;
  68819. private _grainEnabled;
  68820. private _buildAllowed;
  68821. /**
  68822. * Gets active scene
  68823. */
  68824. get scene(): Scene;
  68825. /**
  68826. * Enable or disable the sharpen process from the pipeline
  68827. */
  68828. set sharpenEnabled(enabled: boolean);
  68829. get sharpenEnabled(): boolean;
  68830. private _resizeObserver;
  68831. private _hardwareScaleLevel;
  68832. private _bloomKernel;
  68833. /**
  68834. * Specifies the size of the bloom blur kernel, relative to the final output size
  68835. */
  68836. get bloomKernel(): number;
  68837. set bloomKernel(value: number);
  68838. /**
  68839. * Specifies the weight of the bloom in the final rendering
  68840. */
  68841. private _bloomWeight;
  68842. /**
  68843. * Specifies the luma threshold for the area that will be blurred by the bloom
  68844. */
  68845. private _bloomThreshold;
  68846. private _hdr;
  68847. /**
  68848. * The strength of the bloom.
  68849. */
  68850. set bloomWeight(value: number);
  68851. get bloomWeight(): number;
  68852. /**
  68853. * The strength of the bloom.
  68854. */
  68855. set bloomThreshold(value: number);
  68856. get bloomThreshold(): number;
  68857. /**
  68858. * The scale of the bloom, lower value will provide better performance.
  68859. */
  68860. set bloomScale(value: number);
  68861. get bloomScale(): number;
  68862. /**
  68863. * Enable or disable the bloom from the pipeline
  68864. */
  68865. set bloomEnabled(enabled: boolean);
  68866. get bloomEnabled(): boolean;
  68867. private _rebuildBloom;
  68868. /**
  68869. * If the depth of field is enabled.
  68870. */
  68871. get depthOfFieldEnabled(): boolean;
  68872. set depthOfFieldEnabled(enabled: boolean);
  68873. /**
  68874. * Blur level of the depth of field effect. (Higher blur will effect performance)
  68875. */
  68876. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  68877. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  68878. /**
  68879. * If the anti aliasing is enabled.
  68880. */
  68881. set fxaaEnabled(enabled: boolean);
  68882. get fxaaEnabled(): boolean;
  68883. private _samples;
  68884. /**
  68885. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68886. */
  68887. set samples(sampleCount: number);
  68888. get samples(): number;
  68889. /**
  68890. * If image processing is enabled.
  68891. */
  68892. set imageProcessingEnabled(enabled: boolean);
  68893. get imageProcessingEnabled(): boolean;
  68894. /**
  68895. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  68896. */
  68897. set glowLayerEnabled(enabled: boolean);
  68898. get glowLayerEnabled(): boolean;
  68899. /**
  68900. * Gets the glow layer (or null if not defined)
  68901. */
  68902. get glowLayer(): Nullable<GlowLayer>;
  68903. /**
  68904. * Enable or disable the chromaticAberration process from the pipeline
  68905. */
  68906. set chromaticAberrationEnabled(enabled: boolean);
  68907. get chromaticAberrationEnabled(): boolean;
  68908. /**
  68909. * Enable or disable the grain process from the pipeline
  68910. */
  68911. set grainEnabled(enabled: boolean);
  68912. get grainEnabled(): boolean;
  68913. /**
  68914. * @constructor
  68915. * @param name - The rendering pipeline name (default: "")
  68916. * @param hdr - If high dynamic range textures should be used (default: true)
  68917. * @param scene - The scene linked to this pipeline (default: the last created scene)
  68918. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  68919. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  68920. */
  68921. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  68922. /**
  68923. * Get the class name
  68924. * @returns "DefaultRenderingPipeline"
  68925. */
  68926. getClassName(): string;
  68927. /**
  68928. * Force the compilation of the entire pipeline.
  68929. */
  68930. prepare(): void;
  68931. private _hasCleared;
  68932. private _prevPostProcess;
  68933. private _prevPrevPostProcess;
  68934. private _setAutoClearAndTextureSharing;
  68935. private _depthOfFieldSceneObserver;
  68936. private _buildPipeline;
  68937. private _disposePostProcesses;
  68938. /**
  68939. * Adds a camera to the pipeline
  68940. * @param camera the camera to be added
  68941. */
  68942. addCamera(camera: Camera): void;
  68943. /**
  68944. * Removes a camera from the pipeline
  68945. * @param camera the camera to remove
  68946. */
  68947. removeCamera(camera: Camera): void;
  68948. /**
  68949. * Dispose of the pipeline and stop all post processes
  68950. */
  68951. dispose(): void;
  68952. /**
  68953. * Serialize the rendering pipeline (Used when exporting)
  68954. * @returns the serialized object
  68955. */
  68956. serialize(): any;
  68957. /**
  68958. * Parse the serialized pipeline
  68959. * @param source Source pipeline.
  68960. * @param scene The scene to load the pipeline to.
  68961. * @param rootUrl The URL of the serialized pipeline.
  68962. * @returns An instantiated pipeline from the serialized object.
  68963. */
  68964. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  68965. }
  68966. }
  68967. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  68968. /** @hidden */
  68969. export var lensHighlightsPixelShader: {
  68970. name: string;
  68971. shader: string;
  68972. };
  68973. }
  68974. declare module "babylonjs/Shaders/depthOfField.fragment" {
  68975. /** @hidden */
  68976. export var depthOfFieldPixelShader: {
  68977. name: string;
  68978. shader: string;
  68979. };
  68980. }
  68981. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  68982. import { Camera } from "babylonjs/Cameras/camera";
  68983. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68984. import { Scene } from "babylonjs/scene";
  68985. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68986. import "babylonjs/Shaders/chromaticAberration.fragment";
  68987. import "babylonjs/Shaders/lensHighlights.fragment";
  68988. import "babylonjs/Shaders/depthOfField.fragment";
  68989. /**
  68990. * BABYLON.JS Chromatic Aberration GLSL Shader
  68991. * Author: Olivier Guyot
  68992. * Separates very slightly R, G and B colors on the edges of the screen
  68993. * Inspired by Francois Tarlier & Martins Upitis
  68994. */
  68995. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  68996. /**
  68997. * @ignore
  68998. * The chromatic aberration PostProcess id in the pipeline
  68999. */
  69000. LensChromaticAberrationEffect: string;
  69001. /**
  69002. * @ignore
  69003. * The highlights enhancing PostProcess id in the pipeline
  69004. */
  69005. HighlightsEnhancingEffect: string;
  69006. /**
  69007. * @ignore
  69008. * The depth-of-field PostProcess id in the pipeline
  69009. */
  69010. LensDepthOfFieldEffect: string;
  69011. private _scene;
  69012. private _depthTexture;
  69013. private _grainTexture;
  69014. private _chromaticAberrationPostProcess;
  69015. private _highlightsPostProcess;
  69016. private _depthOfFieldPostProcess;
  69017. private _edgeBlur;
  69018. private _grainAmount;
  69019. private _chromaticAberration;
  69020. private _distortion;
  69021. private _highlightsGain;
  69022. private _highlightsThreshold;
  69023. private _dofDistance;
  69024. private _dofAperture;
  69025. private _dofDarken;
  69026. private _dofPentagon;
  69027. private _blurNoise;
  69028. /**
  69029. * @constructor
  69030. *
  69031. * Effect parameters are as follow:
  69032. * {
  69033. * chromatic_aberration: number; // from 0 to x (1 for realism)
  69034. * edge_blur: number; // from 0 to x (1 for realism)
  69035. * distortion: number; // from 0 to x (1 for realism)
  69036. * grain_amount: number; // from 0 to 1
  69037. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  69038. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  69039. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  69040. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  69041. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  69042. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  69043. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  69044. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  69045. * }
  69046. * Note: if an effect parameter is unset, effect is disabled
  69047. *
  69048. * @param name The rendering pipeline name
  69049. * @param parameters - An object containing all parameters (see above)
  69050. * @param scene The scene linked to this pipeline
  69051. * @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)
  69052. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69053. */
  69054. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  69055. /**
  69056. * Get the class name
  69057. * @returns "LensRenderingPipeline"
  69058. */
  69059. getClassName(): string;
  69060. /**
  69061. * Gets associated scene
  69062. */
  69063. get scene(): Scene;
  69064. /**
  69065. * Gets or sets the edge blur
  69066. */
  69067. get edgeBlur(): number;
  69068. set edgeBlur(value: number);
  69069. /**
  69070. * Gets or sets the grain amount
  69071. */
  69072. get grainAmount(): number;
  69073. set grainAmount(value: number);
  69074. /**
  69075. * Gets or sets the chromatic aberration amount
  69076. */
  69077. get chromaticAberration(): number;
  69078. set chromaticAberration(value: number);
  69079. /**
  69080. * Gets or sets the depth of field aperture
  69081. */
  69082. get dofAperture(): number;
  69083. set dofAperture(value: number);
  69084. /**
  69085. * Gets or sets the edge distortion
  69086. */
  69087. get edgeDistortion(): number;
  69088. set edgeDistortion(value: number);
  69089. /**
  69090. * Gets or sets the depth of field distortion
  69091. */
  69092. get dofDistortion(): number;
  69093. set dofDistortion(value: number);
  69094. /**
  69095. * Gets or sets the darken out of focus amount
  69096. */
  69097. get darkenOutOfFocus(): number;
  69098. set darkenOutOfFocus(value: number);
  69099. /**
  69100. * Gets or sets a boolean indicating if blur noise is enabled
  69101. */
  69102. get blurNoise(): boolean;
  69103. set blurNoise(value: boolean);
  69104. /**
  69105. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  69106. */
  69107. get pentagonBokeh(): boolean;
  69108. set pentagonBokeh(value: boolean);
  69109. /**
  69110. * Gets or sets the highlight grain amount
  69111. */
  69112. get highlightsGain(): number;
  69113. set highlightsGain(value: number);
  69114. /**
  69115. * Gets or sets the highlight threshold
  69116. */
  69117. get highlightsThreshold(): number;
  69118. set highlightsThreshold(value: number);
  69119. /**
  69120. * Sets the amount of blur at the edges
  69121. * @param amount blur amount
  69122. */
  69123. setEdgeBlur(amount: number): void;
  69124. /**
  69125. * Sets edge blur to 0
  69126. */
  69127. disableEdgeBlur(): void;
  69128. /**
  69129. * Sets the amout of grain
  69130. * @param amount Amount of grain
  69131. */
  69132. setGrainAmount(amount: number): void;
  69133. /**
  69134. * Set grain amount to 0
  69135. */
  69136. disableGrain(): void;
  69137. /**
  69138. * Sets the chromatic aberration amount
  69139. * @param amount amount of chromatic aberration
  69140. */
  69141. setChromaticAberration(amount: number): void;
  69142. /**
  69143. * Sets chromatic aberration amount to 0
  69144. */
  69145. disableChromaticAberration(): void;
  69146. /**
  69147. * Sets the EdgeDistortion amount
  69148. * @param amount amount of EdgeDistortion
  69149. */
  69150. setEdgeDistortion(amount: number): void;
  69151. /**
  69152. * Sets edge distortion to 0
  69153. */
  69154. disableEdgeDistortion(): void;
  69155. /**
  69156. * Sets the FocusDistance amount
  69157. * @param amount amount of FocusDistance
  69158. */
  69159. setFocusDistance(amount: number): void;
  69160. /**
  69161. * Disables depth of field
  69162. */
  69163. disableDepthOfField(): void;
  69164. /**
  69165. * Sets the Aperture amount
  69166. * @param amount amount of Aperture
  69167. */
  69168. setAperture(amount: number): void;
  69169. /**
  69170. * Sets the DarkenOutOfFocus amount
  69171. * @param amount amount of DarkenOutOfFocus
  69172. */
  69173. setDarkenOutOfFocus(amount: number): void;
  69174. private _pentagonBokehIsEnabled;
  69175. /**
  69176. * Creates a pentagon bokeh effect
  69177. */
  69178. enablePentagonBokeh(): void;
  69179. /**
  69180. * Disables the pentagon bokeh effect
  69181. */
  69182. disablePentagonBokeh(): void;
  69183. /**
  69184. * Enables noise blur
  69185. */
  69186. enableNoiseBlur(): void;
  69187. /**
  69188. * Disables noise blur
  69189. */
  69190. disableNoiseBlur(): void;
  69191. /**
  69192. * Sets the HighlightsGain amount
  69193. * @param amount amount of HighlightsGain
  69194. */
  69195. setHighlightsGain(amount: number): void;
  69196. /**
  69197. * Sets the HighlightsThreshold amount
  69198. * @param amount amount of HighlightsThreshold
  69199. */
  69200. setHighlightsThreshold(amount: number): void;
  69201. /**
  69202. * Disables highlights
  69203. */
  69204. disableHighlights(): void;
  69205. /**
  69206. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  69207. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  69208. */
  69209. dispose(disableDepthRender?: boolean): void;
  69210. private _createChromaticAberrationPostProcess;
  69211. private _createHighlightsPostProcess;
  69212. private _createDepthOfFieldPostProcess;
  69213. private _createGrainTexture;
  69214. }
  69215. }
  69216. declare module "babylonjs/Shaders/ssao2.fragment" {
  69217. /** @hidden */
  69218. export var ssao2PixelShader: {
  69219. name: string;
  69220. shader: string;
  69221. };
  69222. }
  69223. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  69224. /** @hidden */
  69225. export var ssaoCombinePixelShader: {
  69226. name: string;
  69227. shader: string;
  69228. };
  69229. }
  69230. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  69231. import { Camera } from "babylonjs/Cameras/camera";
  69232. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69233. import { Scene } from "babylonjs/scene";
  69234. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69235. import "babylonjs/Shaders/ssao2.fragment";
  69236. import "babylonjs/Shaders/ssaoCombine.fragment";
  69237. /**
  69238. * Render pipeline to produce ssao effect
  69239. */
  69240. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69241. /**
  69242. * @ignore
  69243. * The PassPostProcess id in the pipeline that contains the original scene color
  69244. */
  69245. SSAOOriginalSceneColorEffect: string;
  69246. /**
  69247. * @ignore
  69248. * The SSAO PostProcess id in the pipeline
  69249. */
  69250. SSAORenderEffect: string;
  69251. /**
  69252. * @ignore
  69253. * The horizontal blur PostProcess id in the pipeline
  69254. */
  69255. SSAOBlurHRenderEffect: string;
  69256. /**
  69257. * @ignore
  69258. * The vertical blur PostProcess id in the pipeline
  69259. */
  69260. SSAOBlurVRenderEffect: string;
  69261. /**
  69262. * @ignore
  69263. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69264. */
  69265. SSAOCombineRenderEffect: string;
  69266. /**
  69267. * The output strength of the SSAO post-process. Default value is 1.0.
  69268. */
  69269. totalStrength: number;
  69270. /**
  69271. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69272. */
  69273. maxZ: number;
  69274. /**
  69275. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69276. */
  69277. minZAspect: number;
  69278. private _samples;
  69279. /**
  69280. * Number of samples used for the SSAO calculations. Default value is 8
  69281. */
  69282. set samples(n: number);
  69283. get samples(): number;
  69284. private _textureSamples;
  69285. /**
  69286. * Number of samples to use for antialiasing
  69287. */
  69288. set textureSamples(n: number);
  69289. get textureSamples(): number;
  69290. /**
  69291. * Ratio object used for SSAO ratio and blur ratio
  69292. */
  69293. private _ratio;
  69294. /**
  69295. * Dynamically generated sphere sampler.
  69296. */
  69297. private _sampleSphere;
  69298. /**
  69299. * Blur filter offsets
  69300. */
  69301. private _samplerOffsets;
  69302. private _expensiveBlur;
  69303. /**
  69304. * If bilateral blur should be used
  69305. */
  69306. set expensiveBlur(b: boolean);
  69307. get expensiveBlur(): boolean;
  69308. /**
  69309. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69310. */
  69311. radius: number;
  69312. /**
  69313. * The base color of the SSAO post-process
  69314. * The final result is "base + ssao" between [0, 1]
  69315. */
  69316. base: number;
  69317. /**
  69318. * Support test.
  69319. */
  69320. static get IsSupported(): boolean;
  69321. private _scene;
  69322. private _depthTexture;
  69323. private _normalTexture;
  69324. private _randomTexture;
  69325. private _originalColorPostProcess;
  69326. private _ssaoPostProcess;
  69327. private _blurHPostProcess;
  69328. private _blurVPostProcess;
  69329. private _ssaoCombinePostProcess;
  69330. /**
  69331. * Gets active scene
  69332. */
  69333. get scene(): Scene;
  69334. /**
  69335. * @constructor
  69336. * @param name The rendering pipeline name
  69337. * @param scene The scene linked to this pipeline
  69338. * @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 }
  69339. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69340. */
  69341. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69342. /**
  69343. * Get the class name
  69344. * @returns "SSAO2RenderingPipeline"
  69345. */
  69346. getClassName(): string;
  69347. /**
  69348. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69349. */
  69350. dispose(disableGeometryBufferRenderer?: boolean): void;
  69351. private _createBlurPostProcess;
  69352. /** @hidden */
  69353. _rebuild(): void;
  69354. private _bits;
  69355. private _radicalInverse_VdC;
  69356. private _hammersley;
  69357. private _hemisphereSample_uniform;
  69358. private _generateHemisphere;
  69359. private _createSSAOPostProcess;
  69360. private _createSSAOCombinePostProcess;
  69361. private _createRandomTexture;
  69362. /**
  69363. * Serialize the rendering pipeline (Used when exporting)
  69364. * @returns the serialized object
  69365. */
  69366. serialize(): any;
  69367. /**
  69368. * Parse the serialized pipeline
  69369. * @param source Source pipeline.
  69370. * @param scene The scene to load the pipeline to.
  69371. * @param rootUrl The URL of the serialized pipeline.
  69372. * @returns An instantiated pipeline from the serialized object.
  69373. */
  69374. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69375. }
  69376. }
  69377. declare module "babylonjs/Shaders/ssao.fragment" {
  69378. /** @hidden */
  69379. export var ssaoPixelShader: {
  69380. name: string;
  69381. shader: string;
  69382. };
  69383. }
  69384. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  69385. import { Camera } from "babylonjs/Cameras/camera";
  69386. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69387. import { Scene } from "babylonjs/scene";
  69388. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69389. import "babylonjs/Shaders/ssao.fragment";
  69390. import "babylonjs/Shaders/ssaoCombine.fragment";
  69391. /**
  69392. * Render pipeline to produce ssao effect
  69393. */
  69394. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69395. /**
  69396. * @ignore
  69397. * The PassPostProcess id in the pipeline that contains the original scene color
  69398. */
  69399. SSAOOriginalSceneColorEffect: string;
  69400. /**
  69401. * @ignore
  69402. * The SSAO PostProcess id in the pipeline
  69403. */
  69404. SSAORenderEffect: string;
  69405. /**
  69406. * @ignore
  69407. * The horizontal blur PostProcess id in the pipeline
  69408. */
  69409. SSAOBlurHRenderEffect: string;
  69410. /**
  69411. * @ignore
  69412. * The vertical blur PostProcess id in the pipeline
  69413. */
  69414. SSAOBlurVRenderEffect: string;
  69415. /**
  69416. * @ignore
  69417. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69418. */
  69419. SSAOCombineRenderEffect: string;
  69420. /**
  69421. * The output strength of the SSAO post-process. Default value is 1.0.
  69422. */
  69423. totalStrength: number;
  69424. /**
  69425. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69426. */
  69427. radius: number;
  69428. /**
  69429. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69430. * Must not be equal to fallOff and superior to fallOff.
  69431. * Default value is 0.0075
  69432. */
  69433. area: number;
  69434. /**
  69435. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69436. * Must not be equal to area and inferior to area.
  69437. * Default value is 0.000001
  69438. */
  69439. fallOff: number;
  69440. /**
  69441. * The base color of the SSAO post-process
  69442. * The final result is "base + ssao" between [0, 1]
  69443. */
  69444. base: number;
  69445. private _scene;
  69446. private _depthTexture;
  69447. private _randomTexture;
  69448. private _originalColorPostProcess;
  69449. private _ssaoPostProcess;
  69450. private _blurHPostProcess;
  69451. private _blurVPostProcess;
  69452. private _ssaoCombinePostProcess;
  69453. private _firstUpdate;
  69454. /**
  69455. * Gets active scene
  69456. */
  69457. get scene(): Scene;
  69458. /**
  69459. * @constructor
  69460. * @param name - The rendering pipeline name
  69461. * @param scene - The scene linked to this pipeline
  69462. * @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 }
  69463. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69464. */
  69465. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69466. /**
  69467. * Get the class name
  69468. * @returns "SSAORenderingPipeline"
  69469. */
  69470. getClassName(): string;
  69471. /**
  69472. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69473. */
  69474. dispose(disableDepthRender?: boolean): void;
  69475. private _createBlurPostProcess;
  69476. /** @hidden */
  69477. _rebuild(): void;
  69478. private _createSSAOPostProcess;
  69479. private _createSSAOCombinePostProcess;
  69480. private _createRandomTexture;
  69481. }
  69482. }
  69483. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  69484. /** @hidden */
  69485. export var screenSpaceReflectionPixelShader: {
  69486. name: string;
  69487. shader: string;
  69488. };
  69489. }
  69490. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  69491. import { Nullable } from "babylonjs/types";
  69492. import { Camera } from "babylonjs/Cameras/camera";
  69493. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69494. import { Scene } from "babylonjs/scene";
  69495. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  69496. import { Engine } from "babylonjs/Engines/engine";
  69497. /**
  69498. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69499. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69500. */
  69501. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69502. /**
  69503. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69504. */
  69505. threshold: number;
  69506. /**
  69507. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69508. */
  69509. strength: number;
  69510. /**
  69511. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69512. */
  69513. reflectionSpecularFalloffExponent: number;
  69514. /**
  69515. * 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]
  69516. */
  69517. step: number;
  69518. /**
  69519. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69520. */
  69521. roughnessFactor: number;
  69522. private _geometryBufferRenderer;
  69523. private _enableSmoothReflections;
  69524. private _reflectionSamples;
  69525. private _smoothSteps;
  69526. /**
  69527. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69528. * @param name The name of the effect.
  69529. * @param scene The scene containing the objects to calculate reflections.
  69530. * @param options The required width/height ratio to downsize to before computing the render pass.
  69531. * @param camera The camera to apply the render pass to.
  69532. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69533. * @param engine The engine which the post process will be applied. (default: current engine)
  69534. * @param reusable If the post process can be reused on the same frame. (default: false)
  69535. * @param textureType Type of textures used when performing the post process. (default: 0)
  69536. * @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)
  69537. */
  69538. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69539. /**
  69540. * Gets wether or not smoothing reflections is enabled.
  69541. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69542. */
  69543. get enableSmoothReflections(): boolean;
  69544. /**
  69545. * Sets wether or not smoothing reflections is enabled.
  69546. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69547. */
  69548. set enableSmoothReflections(enabled: boolean);
  69549. /**
  69550. * Gets the number of samples taken while computing reflections. More samples count is high,
  69551. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69552. */
  69553. get reflectionSamples(): number;
  69554. /**
  69555. * Sets the number of samples taken while computing reflections. More samples count is high,
  69556. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69557. */
  69558. set reflectionSamples(samples: number);
  69559. /**
  69560. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69561. * more the post-process will require GPU power and can generate a drop in FPS.
  69562. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69563. */
  69564. get smoothSteps(): number;
  69565. set smoothSteps(steps: number);
  69566. private _updateEffectDefines;
  69567. }
  69568. }
  69569. declare module "babylonjs/Shaders/standard.fragment" {
  69570. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  69571. /** @hidden */
  69572. export var standardPixelShader: {
  69573. name: string;
  69574. shader: string;
  69575. };
  69576. }
  69577. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  69578. import { Nullable } from "babylonjs/types";
  69579. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69580. import { Camera } from "babylonjs/Cameras/camera";
  69581. import { Texture } from "babylonjs/Materials/Textures/texture";
  69582. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69583. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69584. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  69585. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  69586. import { IDisposable } from "babylonjs/scene";
  69587. import { SpotLight } from "babylonjs/Lights/spotLight";
  69588. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  69589. import { Scene } from "babylonjs/scene";
  69590. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  69591. import { Animation } from "babylonjs/Animations/animation";
  69592. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69593. import "babylonjs/Shaders/standard.fragment";
  69594. /**
  69595. * Standard rendering pipeline
  69596. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69597. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69598. */
  69599. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69600. /**
  69601. * Public members
  69602. */
  69603. /**
  69604. * Post-process which contains the original scene color before the pipeline applies all the effects
  69605. */
  69606. originalPostProcess: Nullable<PostProcess>;
  69607. /**
  69608. * Post-process used to down scale an image x4
  69609. */
  69610. downSampleX4PostProcess: Nullable<PostProcess>;
  69611. /**
  69612. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69613. */
  69614. brightPassPostProcess: Nullable<PostProcess>;
  69615. /**
  69616. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69617. */
  69618. blurHPostProcesses: PostProcess[];
  69619. /**
  69620. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69621. */
  69622. blurVPostProcesses: PostProcess[];
  69623. /**
  69624. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69625. */
  69626. textureAdderPostProcess: Nullable<PostProcess>;
  69627. /**
  69628. * Post-process used to create volumetric lighting effect
  69629. */
  69630. volumetricLightPostProcess: Nullable<PostProcess>;
  69631. /**
  69632. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69633. */
  69634. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69635. /**
  69636. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69637. */
  69638. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69639. /**
  69640. * Post-process used to merge the volumetric light effect and the real scene color
  69641. */
  69642. volumetricLightMergePostProces: Nullable<PostProcess>;
  69643. /**
  69644. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69645. */
  69646. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69647. /**
  69648. * Base post-process used to calculate the average luminance of the final image for HDR
  69649. */
  69650. luminancePostProcess: Nullable<PostProcess>;
  69651. /**
  69652. * Post-processes used to create down sample post-processes in order to get
  69653. * the average luminance of the final image for HDR
  69654. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69655. */
  69656. luminanceDownSamplePostProcesses: PostProcess[];
  69657. /**
  69658. * Post-process used to create a HDR effect (light adaptation)
  69659. */
  69660. hdrPostProcess: Nullable<PostProcess>;
  69661. /**
  69662. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69663. */
  69664. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69665. /**
  69666. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69667. */
  69668. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69669. /**
  69670. * Post-process used to merge the final HDR post-process and the real scene color
  69671. */
  69672. hdrFinalPostProcess: Nullable<PostProcess>;
  69673. /**
  69674. * Post-process used to create a lens flare effect
  69675. */
  69676. lensFlarePostProcess: Nullable<PostProcess>;
  69677. /**
  69678. * Post-process that merges the result of the lens flare post-process and the real scene color
  69679. */
  69680. lensFlareComposePostProcess: Nullable<PostProcess>;
  69681. /**
  69682. * Post-process used to create a motion blur effect
  69683. */
  69684. motionBlurPostProcess: Nullable<PostProcess>;
  69685. /**
  69686. * Post-process used to create a depth of field effect
  69687. */
  69688. depthOfFieldPostProcess: Nullable<PostProcess>;
  69689. /**
  69690. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69691. */
  69692. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69693. /**
  69694. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69695. */
  69696. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69697. /**
  69698. * Represents the brightness threshold in order to configure the illuminated surfaces
  69699. */
  69700. brightThreshold: number;
  69701. /**
  69702. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69703. */
  69704. blurWidth: number;
  69705. /**
  69706. * Sets if the blur for highlighted surfaces must be only horizontal
  69707. */
  69708. horizontalBlur: boolean;
  69709. /**
  69710. * Gets the overall exposure used by the pipeline
  69711. */
  69712. get exposure(): number;
  69713. /**
  69714. * Sets the overall exposure used by the pipeline
  69715. */
  69716. set exposure(value: number);
  69717. /**
  69718. * Texture used typically to simulate "dirty" on camera lens
  69719. */
  69720. lensTexture: Nullable<Texture>;
  69721. /**
  69722. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69723. */
  69724. volumetricLightCoefficient: number;
  69725. /**
  69726. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69727. */
  69728. volumetricLightPower: number;
  69729. /**
  69730. * Used the set the blur intensity to smooth the volumetric lights
  69731. */
  69732. volumetricLightBlurScale: number;
  69733. /**
  69734. * Light (spot or directional) used to generate the volumetric lights rays
  69735. * The source light must have a shadow generate so the pipeline can get its
  69736. * depth map
  69737. */
  69738. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69739. /**
  69740. * For eye adaptation, represents the minimum luminance the eye can see
  69741. */
  69742. hdrMinimumLuminance: number;
  69743. /**
  69744. * For eye adaptation, represents the decrease luminance speed
  69745. */
  69746. hdrDecreaseRate: number;
  69747. /**
  69748. * For eye adaptation, represents the increase luminance speed
  69749. */
  69750. hdrIncreaseRate: number;
  69751. /**
  69752. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69753. */
  69754. get hdrAutoExposure(): boolean;
  69755. /**
  69756. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69757. */
  69758. set hdrAutoExposure(value: boolean);
  69759. /**
  69760. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69761. */
  69762. lensColorTexture: Nullable<Texture>;
  69763. /**
  69764. * The overall strengh for the lens flare effect
  69765. */
  69766. lensFlareStrength: number;
  69767. /**
  69768. * Dispersion coefficient for lens flare ghosts
  69769. */
  69770. lensFlareGhostDispersal: number;
  69771. /**
  69772. * Main lens flare halo width
  69773. */
  69774. lensFlareHaloWidth: number;
  69775. /**
  69776. * Based on the lens distortion effect, defines how much the lens flare result
  69777. * is distorted
  69778. */
  69779. lensFlareDistortionStrength: number;
  69780. /**
  69781. * Configures the blur intensity used for for lens flare (halo)
  69782. */
  69783. lensFlareBlurWidth: number;
  69784. /**
  69785. * Lens star texture must be used to simulate rays on the flares and is available
  69786. * in the documentation
  69787. */
  69788. lensStarTexture: Nullable<Texture>;
  69789. /**
  69790. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69791. * flare effect by taking account of the dirt texture
  69792. */
  69793. lensFlareDirtTexture: Nullable<Texture>;
  69794. /**
  69795. * Represents the focal length for the depth of field effect
  69796. */
  69797. depthOfFieldDistance: number;
  69798. /**
  69799. * Represents the blur intensity for the blurred part of the depth of field effect
  69800. */
  69801. depthOfFieldBlurWidth: number;
  69802. /**
  69803. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69804. */
  69805. get motionStrength(): number;
  69806. /**
  69807. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69808. */
  69809. set motionStrength(strength: number);
  69810. /**
  69811. * Gets wether or not the motion blur post-process is object based or screen based.
  69812. */
  69813. get objectBasedMotionBlur(): boolean;
  69814. /**
  69815. * Sets wether or not the motion blur post-process should be object based or screen based
  69816. */
  69817. set objectBasedMotionBlur(value: boolean);
  69818. /**
  69819. * List of animations for the pipeline (IAnimatable implementation)
  69820. */
  69821. animations: Animation[];
  69822. /**
  69823. * Private members
  69824. */
  69825. private _scene;
  69826. private _currentDepthOfFieldSource;
  69827. private _basePostProcess;
  69828. private _fixedExposure;
  69829. private _currentExposure;
  69830. private _hdrAutoExposure;
  69831. private _hdrCurrentLuminance;
  69832. private _motionStrength;
  69833. private _isObjectBasedMotionBlur;
  69834. private _floatTextureType;
  69835. private _camerasToBeAttached;
  69836. private _ratio;
  69837. private _bloomEnabled;
  69838. private _depthOfFieldEnabled;
  69839. private _vlsEnabled;
  69840. private _lensFlareEnabled;
  69841. private _hdrEnabled;
  69842. private _motionBlurEnabled;
  69843. private _fxaaEnabled;
  69844. private _screenSpaceReflectionsEnabled;
  69845. private _motionBlurSamples;
  69846. private _volumetricLightStepsCount;
  69847. private _samples;
  69848. /**
  69849. * @ignore
  69850. * Specifies if the bloom pipeline is enabled
  69851. */
  69852. get BloomEnabled(): boolean;
  69853. set BloomEnabled(enabled: boolean);
  69854. /**
  69855. * @ignore
  69856. * Specifies if the depth of field pipeline is enabed
  69857. */
  69858. get DepthOfFieldEnabled(): boolean;
  69859. set DepthOfFieldEnabled(enabled: boolean);
  69860. /**
  69861. * @ignore
  69862. * Specifies if the lens flare pipeline is enabed
  69863. */
  69864. get LensFlareEnabled(): boolean;
  69865. set LensFlareEnabled(enabled: boolean);
  69866. /**
  69867. * @ignore
  69868. * Specifies if the HDR pipeline is enabled
  69869. */
  69870. get HDREnabled(): boolean;
  69871. set HDREnabled(enabled: boolean);
  69872. /**
  69873. * @ignore
  69874. * Specifies if the volumetric lights scattering effect is enabled
  69875. */
  69876. get VLSEnabled(): boolean;
  69877. set VLSEnabled(enabled: boolean);
  69878. /**
  69879. * @ignore
  69880. * Specifies if the motion blur effect is enabled
  69881. */
  69882. get MotionBlurEnabled(): boolean;
  69883. set MotionBlurEnabled(enabled: boolean);
  69884. /**
  69885. * Specifies if anti-aliasing is enabled
  69886. */
  69887. get fxaaEnabled(): boolean;
  69888. set fxaaEnabled(enabled: boolean);
  69889. /**
  69890. * Specifies if screen space reflections are enabled.
  69891. */
  69892. get screenSpaceReflectionsEnabled(): boolean;
  69893. set screenSpaceReflectionsEnabled(enabled: boolean);
  69894. /**
  69895. * Specifies the number of steps used to calculate the volumetric lights
  69896. * Typically in interval [50, 200]
  69897. */
  69898. get volumetricLightStepsCount(): number;
  69899. set volumetricLightStepsCount(count: number);
  69900. /**
  69901. * Specifies the number of samples used for the motion blur effect
  69902. * Typically in interval [16, 64]
  69903. */
  69904. get motionBlurSamples(): number;
  69905. set motionBlurSamples(samples: number);
  69906. /**
  69907. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69908. */
  69909. get samples(): number;
  69910. set samples(sampleCount: number);
  69911. /**
  69912. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69913. * @constructor
  69914. * @param name The rendering pipeline name
  69915. * @param scene The scene linked to this pipeline
  69916. * @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)
  69917. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  69918. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69919. */
  69920. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  69921. private _buildPipeline;
  69922. private _createDownSampleX4PostProcess;
  69923. private _createBrightPassPostProcess;
  69924. private _createBlurPostProcesses;
  69925. private _createTextureAdderPostProcess;
  69926. private _createVolumetricLightPostProcess;
  69927. private _createLuminancePostProcesses;
  69928. private _createHdrPostProcess;
  69929. private _createLensFlarePostProcess;
  69930. private _createDepthOfFieldPostProcess;
  69931. private _createMotionBlurPostProcess;
  69932. private _getDepthTexture;
  69933. private _disposePostProcesses;
  69934. /**
  69935. * Dispose of the pipeline and stop all post processes
  69936. */
  69937. dispose(): void;
  69938. /**
  69939. * Serialize the rendering pipeline (Used when exporting)
  69940. * @returns the serialized object
  69941. */
  69942. serialize(): any;
  69943. /**
  69944. * Parse the serialized pipeline
  69945. * @param source Source pipeline.
  69946. * @param scene The scene to load the pipeline to.
  69947. * @param rootUrl The URL of the serialized pipeline.
  69948. * @returns An instantiated pipeline from the serialized object.
  69949. */
  69950. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  69951. /**
  69952. * Luminance steps
  69953. */
  69954. static LuminanceSteps: number;
  69955. }
  69956. }
  69957. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  69958. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  69959. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  69960. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  69961. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  69962. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  69963. }
  69964. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  69965. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  69966. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  69967. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69968. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  69969. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69970. }
  69971. declare module "babylonjs/Shaders/tonemap.fragment" {
  69972. /** @hidden */
  69973. export var tonemapPixelShader: {
  69974. name: string;
  69975. shader: string;
  69976. };
  69977. }
  69978. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  69979. import { Camera } from "babylonjs/Cameras/camera";
  69980. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69981. import "babylonjs/Shaders/tonemap.fragment";
  69982. import { Engine } from "babylonjs/Engines/engine";
  69983. /** Defines operator used for tonemapping */
  69984. export enum TonemappingOperator {
  69985. /** Hable */
  69986. Hable = 0,
  69987. /** Reinhard */
  69988. Reinhard = 1,
  69989. /** HejiDawson */
  69990. HejiDawson = 2,
  69991. /** Photographic */
  69992. Photographic = 3
  69993. }
  69994. /**
  69995. * Defines a post process to apply tone mapping
  69996. */
  69997. export class TonemapPostProcess extends PostProcess {
  69998. private _operator;
  69999. /** Defines the required exposure adjustement */
  70000. exposureAdjustment: number;
  70001. /**
  70002. * Creates a new TonemapPostProcess
  70003. * @param name defines the name of the postprocess
  70004. * @param _operator defines the operator to use
  70005. * @param exposureAdjustment defines the required exposure adjustement
  70006. * @param camera defines the camera to use (can be null)
  70007. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  70008. * @param engine defines the hosting engine (can be ignore if camera is set)
  70009. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  70010. */
  70011. constructor(name: string, _operator: TonemappingOperator,
  70012. /** Defines the required exposure adjustement */
  70013. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  70014. }
  70015. }
  70016. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  70017. /** @hidden */
  70018. export var volumetricLightScatteringPixelShader: {
  70019. name: string;
  70020. shader: string;
  70021. };
  70022. }
  70023. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  70024. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70025. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70026. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70027. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70028. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70029. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70030. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70031. /** @hidden */
  70032. export var volumetricLightScatteringPassVertexShader: {
  70033. name: string;
  70034. shader: string;
  70035. };
  70036. }
  70037. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  70038. /** @hidden */
  70039. export var volumetricLightScatteringPassPixelShader: {
  70040. name: string;
  70041. shader: string;
  70042. };
  70043. }
  70044. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  70045. import { Vector3 } from "babylonjs/Maths/math.vector";
  70046. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70047. import { Mesh } from "babylonjs/Meshes/mesh";
  70048. import { Camera } from "babylonjs/Cameras/camera";
  70049. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  70050. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70051. import { Scene } from "babylonjs/scene";
  70052. import "babylonjs/Meshes/Builders/planeBuilder";
  70053. import "babylonjs/Shaders/depth.vertex";
  70054. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  70055. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  70056. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  70057. import { Engine } from "babylonjs/Engines/engine";
  70058. /**
  70059. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  70060. */
  70061. export class VolumetricLightScatteringPostProcess extends PostProcess {
  70062. private _volumetricLightScatteringPass;
  70063. private _volumetricLightScatteringRTT;
  70064. private _viewPort;
  70065. private _screenCoordinates;
  70066. private _cachedDefines;
  70067. /**
  70068. * If not undefined, the mesh position is computed from the attached node position
  70069. */
  70070. attachedNode: {
  70071. position: Vector3;
  70072. };
  70073. /**
  70074. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  70075. */
  70076. customMeshPosition: Vector3;
  70077. /**
  70078. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  70079. */
  70080. useCustomMeshPosition: boolean;
  70081. /**
  70082. * If the post-process should inverse the light scattering direction
  70083. */
  70084. invert: boolean;
  70085. /**
  70086. * The internal mesh used by the post-process
  70087. */
  70088. mesh: Mesh;
  70089. /**
  70090. * @hidden
  70091. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  70092. */
  70093. get useDiffuseColor(): boolean;
  70094. set useDiffuseColor(useDiffuseColor: boolean);
  70095. /**
  70096. * Array containing the excluded meshes not rendered in the internal pass
  70097. */
  70098. excludedMeshes: AbstractMesh[];
  70099. /**
  70100. * Controls the overall intensity of the post-process
  70101. */
  70102. exposure: number;
  70103. /**
  70104. * Dissipates each sample's contribution in range [0, 1]
  70105. */
  70106. decay: number;
  70107. /**
  70108. * Controls the overall intensity of each sample
  70109. */
  70110. weight: number;
  70111. /**
  70112. * Controls the density of each sample
  70113. */
  70114. density: number;
  70115. /**
  70116. * @constructor
  70117. * @param name The post-process name
  70118. * @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)
  70119. * @param camera The camera that the post-process will be attached to
  70120. * @param mesh The mesh used to create the light scattering
  70121. * @param samples The post-process quality, default 100
  70122. * @param samplingModeThe post-process filtering mode
  70123. * @param engine The babylon engine
  70124. * @param reusable If the post-process is reusable
  70125. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  70126. */
  70127. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  70128. /**
  70129. * Returns the string "VolumetricLightScatteringPostProcess"
  70130. * @returns "VolumetricLightScatteringPostProcess"
  70131. */
  70132. getClassName(): string;
  70133. private _isReady;
  70134. /**
  70135. * Sets the new light position for light scattering effect
  70136. * @param position The new custom light position
  70137. */
  70138. setCustomMeshPosition(position: Vector3): void;
  70139. /**
  70140. * Returns the light position for light scattering effect
  70141. * @return Vector3 The custom light position
  70142. */
  70143. getCustomMeshPosition(): Vector3;
  70144. /**
  70145. * Disposes the internal assets and detaches the post-process from the camera
  70146. */
  70147. dispose(camera: Camera): void;
  70148. /**
  70149. * Returns the render target texture used by the post-process
  70150. * @return the render target texture used by the post-process
  70151. */
  70152. getPass(): RenderTargetTexture;
  70153. private _meshExcluded;
  70154. private _createPass;
  70155. private _updateMeshScreenCoordinates;
  70156. /**
  70157. * Creates a default mesh for the Volumeric Light Scattering post-process
  70158. * @param name The mesh name
  70159. * @param scene The scene where to create the mesh
  70160. * @return the default mesh
  70161. */
  70162. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  70163. }
  70164. }
  70165. declare module "babylonjs/PostProcesses/index" {
  70166. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  70167. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  70168. export * from "babylonjs/PostProcesses/bloomEffect";
  70169. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  70170. export * from "babylonjs/PostProcesses/blurPostProcess";
  70171. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  70172. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  70173. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  70174. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  70175. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  70176. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  70177. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  70178. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  70179. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  70180. export * from "babylonjs/PostProcesses/filterPostProcess";
  70181. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  70182. export * from "babylonjs/PostProcesses/grainPostProcess";
  70183. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  70184. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  70185. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  70186. export * from "babylonjs/PostProcesses/passPostProcess";
  70187. export * from "babylonjs/PostProcesses/postProcess";
  70188. export * from "babylonjs/PostProcesses/postProcessManager";
  70189. export * from "babylonjs/PostProcesses/refractionPostProcess";
  70190. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  70191. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  70192. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  70193. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  70194. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  70195. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  70196. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  70197. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  70198. }
  70199. declare module "babylonjs/Probes/index" {
  70200. export * from "babylonjs/Probes/reflectionProbe";
  70201. }
  70202. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  70203. import { Scene } from "babylonjs/scene";
  70204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70205. import { SmartArray } from "babylonjs/Misc/smartArray";
  70206. import { ISceneComponent } from "babylonjs/sceneComponent";
  70207. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  70208. import "babylonjs/Meshes/Builders/boxBuilder";
  70209. import "babylonjs/Shaders/color.fragment";
  70210. import "babylonjs/Shaders/color.vertex";
  70211. import { Color3 } from "babylonjs/Maths/math.color";
  70212. module "babylonjs/scene" {
  70213. interface Scene {
  70214. /** @hidden (Backing field) */
  70215. _boundingBoxRenderer: BoundingBoxRenderer;
  70216. /** @hidden (Backing field) */
  70217. _forceShowBoundingBoxes: boolean;
  70218. /**
  70219. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  70220. */
  70221. forceShowBoundingBoxes: boolean;
  70222. /**
  70223. * Gets the bounding box renderer associated with the scene
  70224. * @returns a BoundingBoxRenderer
  70225. */
  70226. getBoundingBoxRenderer(): BoundingBoxRenderer;
  70227. }
  70228. }
  70229. module "babylonjs/Meshes/abstractMesh" {
  70230. interface AbstractMesh {
  70231. /** @hidden (Backing field) */
  70232. _showBoundingBox: boolean;
  70233. /**
  70234. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  70235. */
  70236. showBoundingBox: boolean;
  70237. }
  70238. }
  70239. /**
  70240. * Component responsible of rendering the bounding box of the meshes in a scene.
  70241. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  70242. */
  70243. export class BoundingBoxRenderer implements ISceneComponent {
  70244. /**
  70245. * The component name helpfull to identify the component in the list of scene components.
  70246. */
  70247. readonly name: string;
  70248. /**
  70249. * The scene the component belongs to.
  70250. */
  70251. scene: Scene;
  70252. /**
  70253. * Color of the bounding box lines placed in front of an object
  70254. */
  70255. frontColor: Color3;
  70256. /**
  70257. * Color of the bounding box lines placed behind an object
  70258. */
  70259. backColor: Color3;
  70260. /**
  70261. * Defines if the renderer should show the back lines or not
  70262. */
  70263. showBackLines: boolean;
  70264. /**
  70265. * @hidden
  70266. */
  70267. renderList: SmartArray<BoundingBox>;
  70268. private _colorShader;
  70269. private _vertexBuffers;
  70270. private _indexBuffer;
  70271. private _fillIndexBuffer;
  70272. private _fillIndexData;
  70273. /**
  70274. * Instantiates a new bounding box renderer in a scene.
  70275. * @param scene the scene the renderer renders in
  70276. */
  70277. constructor(scene: Scene);
  70278. /**
  70279. * Registers the component in a given scene
  70280. */
  70281. register(): void;
  70282. private _evaluateSubMesh;
  70283. private _activeMesh;
  70284. private _prepareRessources;
  70285. private _createIndexBuffer;
  70286. /**
  70287. * Rebuilds the elements related to this component in case of
  70288. * context lost for instance.
  70289. */
  70290. rebuild(): void;
  70291. /**
  70292. * @hidden
  70293. */
  70294. reset(): void;
  70295. /**
  70296. * Render the bounding boxes of a specific rendering group
  70297. * @param renderingGroupId defines the rendering group to render
  70298. */
  70299. render(renderingGroupId: number): void;
  70300. /**
  70301. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70302. * @param mesh Define the mesh to render the occlusion bounding box for
  70303. */
  70304. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70305. /**
  70306. * Dispose and release the resources attached to this renderer.
  70307. */
  70308. dispose(): void;
  70309. }
  70310. }
  70311. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  70312. import { Nullable } from "babylonjs/types";
  70313. import { Scene } from "babylonjs/scene";
  70314. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  70315. import { Camera } from "babylonjs/Cameras/camera";
  70316. import { ISceneComponent } from "babylonjs/sceneComponent";
  70317. module "babylonjs/scene" {
  70318. interface Scene {
  70319. /** @hidden (Backing field) */
  70320. _depthRenderer: {
  70321. [id: string]: DepthRenderer;
  70322. };
  70323. /**
  70324. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70325. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70326. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70327. * @returns the created depth renderer
  70328. */
  70329. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70330. /**
  70331. * Disables a depth renderer for a given camera
  70332. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70333. */
  70334. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70335. }
  70336. }
  70337. /**
  70338. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70339. * in several rendering techniques.
  70340. */
  70341. export class DepthRendererSceneComponent implements ISceneComponent {
  70342. /**
  70343. * The component name helpfull to identify the component in the list of scene components.
  70344. */
  70345. readonly name: string;
  70346. /**
  70347. * The scene the component belongs to.
  70348. */
  70349. scene: Scene;
  70350. /**
  70351. * Creates a new instance of the component for the given scene
  70352. * @param scene Defines the scene to register the component in
  70353. */
  70354. constructor(scene: Scene);
  70355. /**
  70356. * Registers the component in a given scene
  70357. */
  70358. register(): void;
  70359. /**
  70360. * Rebuilds the elements related to this component in case of
  70361. * context lost for instance.
  70362. */
  70363. rebuild(): void;
  70364. /**
  70365. * Disposes the component and the associated ressources
  70366. */
  70367. dispose(): void;
  70368. private _gatherRenderTargets;
  70369. private _gatherActiveCameraRenderTargets;
  70370. }
  70371. }
  70372. declare module "babylonjs/Shaders/outline.fragment" {
  70373. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70374. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  70375. /** @hidden */
  70376. export var outlinePixelShader: {
  70377. name: string;
  70378. shader: string;
  70379. };
  70380. }
  70381. declare module "babylonjs/Shaders/outline.vertex" {
  70382. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70383. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70384. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70385. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70386. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70387. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70388. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70389. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70390. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  70391. /** @hidden */
  70392. export var outlineVertexShader: {
  70393. name: string;
  70394. shader: string;
  70395. };
  70396. }
  70397. declare module "babylonjs/Rendering/outlineRenderer" {
  70398. import { SubMesh } from "babylonjs/Meshes/subMesh";
  70399. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  70400. import { Scene } from "babylonjs/scene";
  70401. import { ISceneComponent } from "babylonjs/sceneComponent";
  70402. import "babylonjs/Shaders/outline.fragment";
  70403. import "babylonjs/Shaders/outline.vertex";
  70404. module "babylonjs/scene" {
  70405. interface Scene {
  70406. /** @hidden */
  70407. _outlineRenderer: OutlineRenderer;
  70408. /**
  70409. * Gets the outline renderer associated with the scene
  70410. * @returns a OutlineRenderer
  70411. */
  70412. getOutlineRenderer(): OutlineRenderer;
  70413. }
  70414. }
  70415. module "babylonjs/Meshes/abstractMesh" {
  70416. interface AbstractMesh {
  70417. /** @hidden (Backing field) */
  70418. _renderOutline: boolean;
  70419. /**
  70420. * Gets or sets a boolean indicating if the outline must be rendered as well
  70421. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  70422. */
  70423. renderOutline: boolean;
  70424. /** @hidden (Backing field) */
  70425. _renderOverlay: boolean;
  70426. /**
  70427. * Gets or sets a boolean indicating if the overlay must be rendered as well
  70428. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  70429. */
  70430. renderOverlay: boolean;
  70431. }
  70432. }
  70433. /**
  70434. * This class is responsible to draw bothe outline/overlay of meshes.
  70435. * It should not be used directly but through the available method on mesh.
  70436. */
  70437. export class OutlineRenderer implements ISceneComponent {
  70438. /**
  70439. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  70440. */
  70441. private static _StencilReference;
  70442. /**
  70443. * The name of the component. Each component must have a unique name.
  70444. */
  70445. name: string;
  70446. /**
  70447. * The scene the component belongs to.
  70448. */
  70449. scene: Scene;
  70450. /**
  70451. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  70452. */
  70453. zOffset: number;
  70454. private _engine;
  70455. private _effect;
  70456. private _cachedDefines;
  70457. private _savedDepthWrite;
  70458. /**
  70459. * Instantiates a new outline renderer. (There could be only one per scene).
  70460. * @param scene Defines the scene it belongs to
  70461. */
  70462. constructor(scene: Scene);
  70463. /**
  70464. * Register the component to one instance of a scene.
  70465. */
  70466. register(): void;
  70467. /**
  70468. * Rebuilds the elements related to this component in case of
  70469. * context lost for instance.
  70470. */
  70471. rebuild(): void;
  70472. /**
  70473. * Disposes the component and the associated ressources.
  70474. */
  70475. dispose(): void;
  70476. /**
  70477. * Renders the outline in the canvas.
  70478. * @param subMesh Defines the sumesh to render
  70479. * @param batch Defines the batch of meshes in case of instances
  70480. * @param useOverlay Defines if the rendering is for the overlay or the outline
  70481. */
  70482. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  70483. /**
  70484. * Returns whether or not the outline renderer is ready for a given submesh.
  70485. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  70486. * @param subMesh Defines the submesh to check readyness for
  70487. * @param useInstances Defines wheter wee are trying to render instances or not
  70488. * @returns true if ready otherwise false
  70489. */
  70490. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70491. private _beforeRenderingMesh;
  70492. private _afterRenderingMesh;
  70493. }
  70494. }
  70495. declare module "babylonjs/Rendering/index" {
  70496. export * from "babylonjs/Rendering/boundingBoxRenderer";
  70497. export * from "babylonjs/Rendering/depthRenderer";
  70498. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  70499. export * from "babylonjs/Rendering/edgesRenderer";
  70500. export * from "babylonjs/Rendering/geometryBufferRenderer";
  70501. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  70502. export * from "babylonjs/Rendering/outlineRenderer";
  70503. export * from "babylonjs/Rendering/renderingGroup";
  70504. export * from "babylonjs/Rendering/renderingManager";
  70505. export * from "babylonjs/Rendering/utilityLayerRenderer";
  70506. }
  70507. declare module "babylonjs/Sprites/ISprites" {
  70508. /**
  70509. * Defines the basic options interface of a Sprite Frame Source Size.
  70510. */
  70511. export interface ISpriteJSONSpriteSourceSize {
  70512. /**
  70513. * number of the original width of the Frame
  70514. */
  70515. w: number;
  70516. /**
  70517. * number of the original height of the Frame
  70518. */
  70519. h: number;
  70520. }
  70521. /**
  70522. * Defines the basic options interface of a Sprite Frame Data.
  70523. */
  70524. export interface ISpriteJSONSpriteFrameData {
  70525. /**
  70526. * number of the x offset of the Frame
  70527. */
  70528. x: number;
  70529. /**
  70530. * number of the y offset of the Frame
  70531. */
  70532. y: number;
  70533. /**
  70534. * number of the width of the Frame
  70535. */
  70536. w: number;
  70537. /**
  70538. * number of the height of the Frame
  70539. */
  70540. h: number;
  70541. }
  70542. /**
  70543. * Defines the basic options interface of a JSON Sprite.
  70544. */
  70545. export interface ISpriteJSONSprite {
  70546. /**
  70547. * string name of the Frame
  70548. */
  70549. filename: string;
  70550. /**
  70551. * ISpriteJSONSpriteFrame basic object of the frame data
  70552. */
  70553. frame: ISpriteJSONSpriteFrameData;
  70554. /**
  70555. * boolean to flag is the frame was rotated.
  70556. */
  70557. rotated: boolean;
  70558. /**
  70559. * boolean to flag is the frame was trimmed.
  70560. */
  70561. trimmed: boolean;
  70562. /**
  70563. * ISpriteJSONSpriteFrame basic object of the source data
  70564. */
  70565. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70566. /**
  70567. * ISpriteJSONSpriteFrame basic object of the source data
  70568. */
  70569. sourceSize: ISpriteJSONSpriteSourceSize;
  70570. }
  70571. /**
  70572. * Defines the basic options interface of a JSON atlas.
  70573. */
  70574. export interface ISpriteJSONAtlas {
  70575. /**
  70576. * Array of objects that contain the frame data.
  70577. */
  70578. frames: Array<ISpriteJSONSprite>;
  70579. /**
  70580. * object basic object containing the sprite meta data.
  70581. */
  70582. meta?: object;
  70583. }
  70584. }
  70585. declare module "babylonjs/Shaders/spriteMap.fragment" {
  70586. /** @hidden */
  70587. export var spriteMapPixelShader: {
  70588. name: string;
  70589. shader: string;
  70590. };
  70591. }
  70592. declare module "babylonjs/Shaders/spriteMap.vertex" {
  70593. /** @hidden */
  70594. export var spriteMapVertexShader: {
  70595. name: string;
  70596. shader: string;
  70597. };
  70598. }
  70599. declare module "babylonjs/Sprites/spriteMap" {
  70600. import { IDisposable, Scene } from "babylonjs/scene";
  70601. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  70602. import { Texture } from "babylonjs/Materials/Textures/texture";
  70603. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  70604. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  70605. import "babylonjs/Meshes/Builders/planeBuilder";
  70606. import "babylonjs/Shaders/spriteMap.fragment";
  70607. import "babylonjs/Shaders/spriteMap.vertex";
  70608. /**
  70609. * Defines the basic options interface of a SpriteMap
  70610. */
  70611. export interface ISpriteMapOptions {
  70612. /**
  70613. * Vector2 of the number of cells in the grid.
  70614. */
  70615. stageSize?: Vector2;
  70616. /**
  70617. * Vector2 of the size of the output plane in World Units.
  70618. */
  70619. outputSize?: Vector2;
  70620. /**
  70621. * Vector3 of the position of the output plane in World Units.
  70622. */
  70623. outputPosition?: Vector3;
  70624. /**
  70625. * Vector3 of the rotation of the output plane.
  70626. */
  70627. outputRotation?: Vector3;
  70628. /**
  70629. * number of layers that the system will reserve in resources.
  70630. */
  70631. layerCount?: number;
  70632. /**
  70633. * number of max animation frames a single cell will reserve in resources.
  70634. */
  70635. maxAnimationFrames?: number;
  70636. /**
  70637. * number cell index of the base tile when the system compiles.
  70638. */
  70639. baseTile?: number;
  70640. /**
  70641. * boolean flip the sprite after its been repositioned by the framing data.
  70642. */
  70643. flipU?: boolean;
  70644. /**
  70645. * Vector3 scalar of the global RGB values of the SpriteMap.
  70646. */
  70647. colorMultiply?: Vector3;
  70648. }
  70649. /**
  70650. * Defines the IDisposable interface in order to be cleanable from resources.
  70651. */
  70652. export interface ISpriteMap extends IDisposable {
  70653. /**
  70654. * String name of the SpriteMap.
  70655. */
  70656. name: string;
  70657. /**
  70658. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70659. */
  70660. atlasJSON: ISpriteJSONAtlas;
  70661. /**
  70662. * Texture of the SpriteMap.
  70663. */
  70664. spriteSheet: Texture;
  70665. /**
  70666. * The parameters to initialize the SpriteMap with.
  70667. */
  70668. options: ISpriteMapOptions;
  70669. }
  70670. /**
  70671. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70672. */
  70673. export class SpriteMap implements ISpriteMap {
  70674. /** The Name of the spriteMap */
  70675. name: string;
  70676. /** The JSON file with the frame and meta data */
  70677. atlasJSON: ISpriteJSONAtlas;
  70678. /** The systems Sprite Sheet Texture */
  70679. spriteSheet: Texture;
  70680. /** Arguments passed with the Constructor */
  70681. options: ISpriteMapOptions;
  70682. /** Public Sprite Storage array, parsed from atlasJSON */
  70683. sprites: Array<ISpriteJSONSprite>;
  70684. /** Returns the Number of Sprites in the System */
  70685. get spriteCount(): number;
  70686. /** Returns the Position of Output Plane*/
  70687. get position(): Vector3;
  70688. /** Returns the Position of Output Plane*/
  70689. set position(v: Vector3);
  70690. /** Returns the Rotation of Output Plane*/
  70691. get rotation(): Vector3;
  70692. /** Returns the Rotation of Output Plane*/
  70693. set rotation(v: Vector3);
  70694. /** Sets the AnimationMap*/
  70695. get animationMap(): RawTexture;
  70696. /** Sets the AnimationMap*/
  70697. set animationMap(v: RawTexture);
  70698. /** Scene that the SpriteMap was created in */
  70699. private _scene;
  70700. /** Texture Buffer of Float32 that holds tile frame data*/
  70701. private _frameMap;
  70702. /** Texture Buffers of Float32 that holds tileMap data*/
  70703. private _tileMaps;
  70704. /** Texture Buffer of Float32 that holds Animation Data*/
  70705. private _animationMap;
  70706. /** Custom ShaderMaterial Central to the System*/
  70707. private _material;
  70708. /** Custom ShaderMaterial Central to the System*/
  70709. private _output;
  70710. /** Systems Time Ticker*/
  70711. private _time;
  70712. /**
  70713. * Creates a new SpriteMap
  70714. * @param name defines the SpriteMaps Name
  70715. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70716. * @param spriteSheet is the Texture that the Sprites are on.
  70717. * @param options a basic deployment configuration
  70718. * @param scene The Scene that the map is deployed on
  70719. */
  70720. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70721. /**
  70722. * Returns tileID location
  70723. * @returns Vector2 the cell position ID
  70724. */
  70725. getTileID(): Vector2;
  70726. /**
  70727. * Gets the UV location of the mouse over the SpriteMap.
  70728. * @returns Vector2 the UV position of the mouse interaction
  70729. */
  70730. getMousePosition(): Vector2;
  70731. /**
  70732. * Creates the "frame" texture Buffer
  70733. * -------------------------------------
  70734. * Structure of frames
  70735. * "filename": "Falling-Water-2.png",
  70736. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70737. * "rotated": true,
  70738. * "trimmed": true,
  70739. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70740. * "sourceSize": {"w":32,"h":32}
  70741. * @returns RawTexture of the frameMap
  70742. */
  70743. private _createFrameBuffer;
  70744. /**
  70745. * Creates the tileMap texture Buffer
  70746. * @param buffer normally and array of numbers, or a false to generate from scratch
  70747. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70748. * @returns RawTexture of the tileMap
  70749. */
  70750. private _createTileBuffer;
  70751. /**
  70752. * Modifies the data of the tileMaps
  70753. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70754. * @param pos is the iVector2 Coordinates of the Tile
  70755. * @param tile The SpriteIndex of the new Tile
  70756. */
  70757. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70758. /**
  70759. * Creates the animationMap texture Buffer
  70760. * @param buffer normally and array of numbers, or a false to generate from scratch
  70761. * @returns RawTexture of the animationMap
  70762. */
  70763. private _createTileAnimationBuffer;
  70764. /**
  70765. * Modifies the data of the animationMap
  70766. * @param cellID is the Index of the Sprite
  70767. * @param _frame is the target Animation frame
  70768. * @param toCell is the Target Index of the next frame of the animation
  70769. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70770. * @param speed is a global scalar of the time variable on the map.
  70771. */
  70772. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70773. /**
  70774. * Exports the .tilemaps file
  70775. */
  70776. saveTileMaps(): void;
  70777. /**
  70778. * Imports the .tilemaps file
  70779. * @param url of the .tilemaps file
  70780. */
  70781. loadTileMaps(url: string): void;
  70782. /**
  70783. * Release associated resources
  70784. */
  70785. dispose(): void;
  70786. }
  70787. }
  70788. declare module "babylonjs/Sprites/spritePackedManager" {
  70789. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  70790. import { Scene } from "babylonjs/scene";
  70791. /**
  70792. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70793. * @see http://doc.babylonjs.com/babylon101/sprites
  70794. */
  70795. export class SpritePackedManager extends SpriteManager {
  70796. /** defines the packed manager's name */
  70797. name: string;
  70798. /**
  70799. * Creates a new sprite manager from a packed sprite sheet
  70800. * @param name defines the manager's name
  70801. * @param imgUrl defines the sprite sheet url
  70802. * @param capacity defines the maximum allowed number of sprites
  70803. * @param scene defines the hosting scene
  70804. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70805. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70806. * @param samplingMode defines the smapling mode to use with spritesheet
  70807. * @param fromPacked set to true; do not alter
  70808. */
  70809. constructor(
  70810. /** defines the packed manager's name */
  70811. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70812. }
  70813. }
  70814. declare module "babylonjs/Sprites/index" {
  70815. export * from "babylonjs/Sprites/sprite";
  70816. export * from "babylonjs/Sprites/ISprites";
  70817. export * from "babylonjs/Sprites/spriteManager";
  70818. export * from "babylonjs/Sprites/spriteMap";
  70819. export * from "babylonjs/Sprites/spritePackedManager";
  70820. export * from "babylonjs/Sprites/spriteSceneComponent";
  70821. }
  70822. declare module "babylonjs/States/index" {
  70823. export * from "babylonjs/States/alphaCullingState";
  70824. export * from "babylonjs/States/depthCullingState";
  70825. export * from "babylonjs/States/stencilState";
  70826. }
  70827. declare module "babylonjs/Misc/assetsManager" {
  70828. import { Scene } from "babylonjs/scene";
  70829. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70830. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70831. import { Skeleton } from "babylonjs/Bones/skeleton";
  70832. import { Observable } from "babylonjs/Misc/observable";
  70833. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  70834. import { Texture } from "babylonjs/Materials/Textures/texture";
  70835. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  70836. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  70837. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  70838. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  70839. /**
  70840. * Defines the list of states available for a task inside a AssetsManager
  70841. */
  70842. export enum AssetTaskState {
  70843. /**
  70844. * Initialization
  70845. */
  70846. INIT = 0,
  70847. /**
  70848. * Running
  70849. */
  70850. RUNNING = 1,
  70851. /**
  70852. * Done
  70853. */
  70854. DONE = 2,
  70855. /**
  70856. * Error
  70857. */
  70858. ERROR = 3
  70859. }
  70860. /**
  70861. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70862. */
  70863. export abstract class AbstractAssetTask {
  70864. /**
  70865. * Task name
  70866. */ name: string;
  70867. /**
  70868. * Callback called when the task is successful
  70869. */
  70870. onSuccess: (task: any) => void;
  70871. /**
  70872. * Callback called when the task is not successful
  70873. */
  70874. onError: (task: any, message?: string, exception?: any) => void;
  70875. /**
  70876. * Creates a new AssetsManager
  70877. * @param name defines the name of the task
  70878. */
  70879. constructor(
  70880. /**
  70881. * Task name
  70882. */ name: string);
  70883. private _isCompleted;
  70884. private _taskState;
  70885. private _errorObject;
  70886. /**
  70887. * Get if the task is completed
  70888. */
  70889. get isCompleted(): boolean;
  70890. /**
  70891. * Gets the current state of the task
  70892. */
  70893. get taskState(): AssetTaskState;
  70894. /**
  70895. * Gets the current error object (if task is in error)
  70896. */
  70897. get errorObject(): {
  70898. message?: string;
  70899. exception?: any;
  70900. };
  70901. /**
  70902. * Internal only
  70903. * @hidden
  70904. */
  70905. _setErrorObject(message?: string, exception?: any): void;
  70906. /**
  70907. * Execute the current task
  70908. * @param scene defines the scene where you want your assets to be loaded
  70909. * @param onSuccess is a callback called when the task is successfully executed
  70910. * @param onError is a callback called if an error occurs
  70911. */
  70912. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70913. /**
  70914. * Execute the current task
  70915. * @param scene defines the scene where you want your assets to be loaded
  70916. * @param onSuccess is a callback called when the task is successfully executed
  70917. * @param onError is a callback called if an error occurs
  70918. */
  70919. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70920. /**
  70921. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70922. * This can be used with failed tasks that have the reason for failure fixed.
  70923. */
  70924. reset(): void;
  70925. private onErrorCallback;
  70926. private onDoneCallback;
  70927. }
  70928. /**
  70929. * Define the interface used by progress events raised during assets loading
  70930. */
  70931. export interface IAssetsProgressEvent {
  70932. /**
  70933. * Defines the number of remaining tasks to process
  70934. */
  70935. remainingCount: number;
  70936. /**
  70937. * Defines the total number of tasks
  70938. */
  70939. totalCount: number;
  70940. /**
  70941. * Defines the task that was just processed
  70942. */
  70943. task: AbstractAssetTask;
  70944. }
  70945. /**
  70946. * Class used to share progress information about assets loading
  70947. */
  70948. export class AssetsProgressEvent implements IAssetsProgressEvent {
  70949. /**
  70950. * Defines the number of remaining tasks to process
  70951. */
  70952. remainingCount: number;
  70953. /**
  70954. * Defines the total number of tasks
  70955. */
  70956. totalCount: number;
  70957. /**
  70958. * Defines the task that was just processed
  70959. */
  70960. task: AbstractAssetTask;
  70961. /**
  70962. * Creates a AssetsProgressEvent
  70963. * @param remainingCount defines the number of remaining tasks to process
  70964. * @param totalCount defines the total number of tasks
  70965. * @param task defines the task that was just processed
  70966. */
  70967. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  70968. }
  70969. /**
  70970. * Define a task used by AssetsManager to load meshes
  70971. */
  70972. export class MeshAssetTask extends AbstractAssetTask {
  70973. /**
  70974. * Defines the name of the task
  70975. */
  70976. name: string;
  70977. /**
  70978. * Defines the list of mesh's names you want to load
  70979. */
  70980. meshesNames: any;
  70981. /**
  70982. * Defines the root url to use as a base to load your meshes and associated resources
  70983. */
  70984. rootUrl: string;
  70985. /**
  70986. * Defines the filename of the scene to load from
  70987. */
  70988. sceneFilename: string;
  70989. /**
  70990. * Gets the list of loaded meshes
  70991. */
  70992. loadedMeshes: Array<AbstractMesh>;
  70993. /**
  70994. * Gets the list of loaded particle systems
  70995. */
  70996. loadedParticleSystems: Array<IParticleSystem>;
  70997. /**
  70998. * Gets the list of loaded skeletons
  70999. */
  71000. loadedSkeletons: Array<Skeleton>;
  71001. /**
  71002. * Gets the list of loaded animation groups
  71003. */
  71004. loadedAnimationGroups: Array<AnimationGroup>;
  71005. /**
  71006. * Callback called when the task is successful
  71007. */
  71008. onSuccess: (task: MeshAssetTask) => void;
  71009. /**
  71010. * Callback called when the task is successful
  71011. */
  71012. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  71013. /**
  71014. * Creates a new MeshAssetTask
  71015. * @param name defines the name of the task
  71016. * @param meshesNames defines the list of mesh's names you want to load
  71017. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  71018. * @param sceneFilename defines the filename of the scene to load from
  71019. */
  71020. constructor(
  71021. /**
  71022. * Defines the name of the task
  71023. */
  71024. name: string,
  71025. /**
  71026. * Defines the list of mesh's names you want to load
  71027. */
  71028. meshesNames: any,
  71029. /**
  71030. * Defines the root url to use as a base to load your meshes and associated resources
  71031. */
  71032. rootUrl: string,
  71033. /**
  71034. * Defines the filename of the scene to load from
  71035. */
  71036. sceneFilename: string);
  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 text content
  71047. */
  71048. export class TextFileAssetTask extends AbstractAssetTask {
  71049. /**
  71050. * Defines the name of the task
  71051. */
  71052. name: string;
  71053. /**
  71054. * Defines the location of the file to load
  71055. */
  71056. url: string;
  71057. /**
  71058. * Gets the loaded text string
  71059. */
  71060. text: string;
  71061. /**
  71062. * Callback called when the task is successful
  71063. */
  71064. onSuccess: (task: TextFileAssetTask) => void;
  71065. /**
  71066. * Callback called when the task is successful
  71067. */
  71068. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  71069. /**
  71070. * Creates a new TextFileAssetTask object
  71071. * @param name defines the name of the task
  71072. * @param url defines the location of the file to load
  71073. */
  71074. constructor(
  71075. /**
  71076. * Defines the name of the task
  71077. */
  71078. name: string,
  71079. /**
  71080. * Defines the location of the file to load
  71081. */
  71082. url: string);
  71083. /**
  71084. * Execute the current task
  71085. * @param scene defines the scene where you want your assets to be loaded
  71086. * @param onSuccess is a callback called when the task is successfully executed
  71087. * @param onError is a callback called if an error occurs
  71088. */
  71089. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71090. }
  71091. /**
  71092. * Define a task used by AssetsManager to load binary data
  71093. */
  71094. export class BinaryFileAssetTask extends AbstractAssetTask {
  71095. /**
  71096. * Defines the name of the task
  71097. */
  71098. name: string;
  71099. /**
  71100. * Defines the location of the file to load
  71101. */
  71102. url: string;
  71103. /**
  71104. * Gets the lodaded data (as an array buffer)
  71105. */
  71106. data: ArrayBuffer;
  71107. /**
  71108. * Callback called when the task is successful
  71109. */
  71110. onSuccess: (task: BinaryFileAssetTask) => void;
  71111. /**
  71112. * Callback called when the task is successful
  71113. */
  71114. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  71115. /**
  71116. * Creates a new BinaryFileAssetTask object
  71117. * @param name defines the name of the new task
  71118. * @param url defines the location of the file to load
  71119. */
  71120. constructor(
  71121. /**
  71122. * Defines the name of the task
  71123. */
  71124. name: string,
  71125. /**
  71126. * Defines the location of the file to load
  71127. */
  71128. url: string);
  71129. /**
  71130. * Execute the current task
  71131. * @param scene defines the scene where you want your assets to be loaded
  71132. * @param onSuccess is a callback called when the task is successfully executed
  71133. * @param onError is a callback called if an error occurs
  71134. */
  71135. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71136. }
  71137. /**
  71138. * Define a task used by AssetsManager to load images
  71139. */
  71140. export class ImageAssetTask extends AbstractAssetTask {
  71141. /**
  71142. * Defines the name of the task
  71143. */
  71144. name: string;
  71145. /**
  71146. * Defines the location of the image to load
  71147. */
  71148. url: string;
  71149. /**
  71150. * Gets the loaded images
  71151. */
  71152. image: HTMLImageElement;
  71153. /**
  71154. * Callback called when the task is successful
  71155. */
  71156. onSuccess: (task: ImageAssetTask) => void;
  71157. /**
  71158. * Callback called when the task is successful
  71159. */
  71160. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  71161. /**
  71162. * Creates a new ImageAssetTask
  71163. * @param name defines the name of the task
  71164. * @param url defines the location of the image to load
  71165. */
  71166. constructor(
  71167. /**
  71168. * Defines the name of the task
  71169. */
  71170. name: string,
  71171. /**
  71172. * Defines the location of the image to load
  71173. */
  71174. url: string);
  71175. /**
  71176. * Execute the current task
  71177. * @param scene defines the scene where you want your assets to be loaded
  71178. * @param onSuccess is a callback called when the task is successfully executed
  71179. * @param onError is a callback called if an error occurs
  71180. */
  71181. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71182. }
  71183. /**
  71184. * Defines the interface used by texture loading tasks
  71185. */
  71186. export interface ITextureAssetTask<TEX extends BaseTexture> {
  71187. /**
  71188. * Gets the loaded texture
  71189. */
  71190. texture: TEX;
  71191. }
  71192. /**
  71193. * Define a task used by AssetsManager to load 2D textures
  71194. */
  71195. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  71196. /**
  71197. * Defines the name of the task
  71198. */
  71199. name: string;
  71200. /**
  71201. * Defines the location of the file to load
  71202. */
  71203. url: string;
  71204. /**
  71205. * Defines if mipmap should not be generated (default is false)
  71206. */
  71207. noMipmap?: boolean | undefined;
  71208. /**
  71209. * Defines if texture must be inverted on Y axis (default is false)
  71210. */
  71211. invertY?: boolean | undefined;
  71212. /**
  71213. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71214. */
  71215. samplingMode: number;
  71216. /**
  71217. * Gets the loaded texture
  71218. */
  71219. texture: Texture;
  71220. /**
  71221. * Callback called when the task is successful
  71222. */
  71223. onSuccess: (task: TextureAssetTask) => void;
  71224. /**
  71225. * Callback called when the task is successful
  71226. */
  71227. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  71228. /**
  71229. * Creates a new TextureAssetTask object
  71230. * @param name defines the name of the task
  71231. * @param url defines the location of the file to load
  71232. * @param noMipmap defines if mipmap should not be generated (default is false)
  71233. * @param invertY defines if texture must be inverted on Y axis (default is false)
  71234. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71235. */
  71236. constructor(
  71237. /**
  71238. * Defines the name of the task
  71239. */
  71240. name: string,
  71241. /**
  71242. * Defines the location of the file to load
  71243. */
  71244. url: string,
  71245. /**
  71246. * Defines if mipmap should not be generated (default is false)
  71247. */
  71248. noMipmap?: boolean | undefined,
  71249. /**
  71250. * Defines if texture must be inverted on Y axis (default is false)
  71251. */
  71252. invertY?: boolean | undefined,
  71253. /**
  71254. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71255. */
  71256. samplingMode?: number);
  71257. /**
  71258. * Execute the current task
  71259. * @param scene defines the scene where you want your assets to be loaded
  71260. * @param onSuccess is a callback called when the task is successfully executed
  71261. * @param onError is a callback called if an error occurs
  71262. */
  71263. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71264. }
  71265. /**
  71266. * Define a task used by AssetsManager to load cube textures
  71267. */
  71268. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71269. /**
  71270. * Defines the name of the task
  71271. */
  71272. name: string;
  71273. /**
  71274. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71275. */
  71276. url: string;
  71277. /**
  71278. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71279. */
  71280. extensions?: string[] | undefined;
  71281. /**
  71282. * Defines if mipmaps should not be generated (default is false)
  71283. */
  71284. noMipmap?: boolean | undefined;
  71285. /**
  71286. * Defines the explicit list of files (undefined by default)
  71287. */
  71288. files?: string[] | undefined;
  71289. /**
  71290. * Gets the loaded texture
  71291. */
  71292. texture: CubeTexture;
  71293. /**
  71294. * Callback called when the task is successful
  71295. */
  71296. onSuccess: (task: CubeTextureAssetTask) => void;
  71297. /**
  71298. * Callback called when the task is successful
  71299. */
  71300. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71301. /**
  71302. * Creates a new CubeTextureAssetTask
  71303. * @param name defines the name of the task
  71304. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71305. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71306. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71307. * @param files defines the explicit list of files (undefined by default)
  71308. */
  71309. constructor(
  71310. /**
  71311. * Defines the name of the task
  71312. */
  71313. name: string,
  71314. /**
  71315. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71316. */
  71317. url: string,
  71318. /**
  71319. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71320. */
  71321. extensions?: string[] | undefined,
  71322. /**
  71323. * Defines if mipmaps should not be generated (default is false)
  71324. */
  71325. noMipmap?: boolean | undefined,
  71326. /**
  71327. * Defines the explicit list of files (undefined by default)
  71328. */
  71329. files?: string[] | undefined);
  71330. /**
  71331. * Execute the current task
  71332. * @param scene defines the scene where you want your assets to be loaded
  71333. * @param onSuccess is a callback called when the task is successfully executed
  71334. * @param onError is a callback called if an error occurs
  71335. */
  71336. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71337. }
  71338. /**
  71339. * Define a task used by AssetsManager to load HDR cube textures
  71340. */
  71341. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71342. /**
  71343. * Defines the name of the task
  71344. */
  71345. name: string;
  71346. /**
  71347. * Defines the location of the file to load
  71348. */
  71349. url: string;
  71350. /**
  71351. * Defines the desired size (the more it increases the longer the generation will be)
  71352. */
  71353. size: number;
  71354. /**
  71355. * Defines if mipmaps should not be generated (default is false)
  71356. */
  71357. noMipmap: boolean;
  71358. /**
  71359. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71360. */
  71361. generateHarmonics: boolean;
  71362. /**
  71363. * 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)
  71364. */
  71365. gammaSpace: boolean;
  71366. /**
  71367. * Internal Use Only
  71368. */
  71369. reserved: boolean;
  71370. /**
  71371. * Gets the loaded texture
  71372. */
  71373. texture: HDRCubeTexture;
  71374. /**
  71375. * Callback called when the task is successful
  71376. */
  71377. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71378. /**
  71379. * Callback called when the task is successful
  71380. */
  71381. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71382. /**
  71383. * Creates a new HDRCubeTextureAssetTask object
  71384. * @param name defines the name of the task
  71385. * @param url defines the location of the file to load
  71386. * @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.
  71387. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71388. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71389. * @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)
  71390. * @param reserved Internal use only
  71391. */
  71392. constructor(
  71393. /**
  71394. * Defines the name of the task
  71395. */
  71396. name: string,
  71397. /**
  71398. * Defines the location of the file to load
  71399. */
  71400. url: string,
  71401. /**
  71402. * Defines the desired size (the more it increases the longer the generation will be)
  71403. */
  71404. size: number,
  71405. /**
  71406. * Defines if mipmaps should not be generated (default is false)
  71407. */
  71408. noMipmap?: boolean,
  71409. /**
  71410. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71411. */
  71412. generateHarmonics?: boolean,
  71413. /**
  71414. * 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)
  71415. */
  71416. gammaSpace?: boolean,
  71417. /**
  71418. * Internal Use Only
  71419. */
  71420. reserved?: boolean);
  71421. /**
  71422. * Execute the current task
  71423. * @param scene defines the scene where you want your assets to be loaded
  71424. * @param onSuccess is a callback called when the task is successfully executed
  71425. * @param onError is a callback called if an error occurs
  71426. */
  71427. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71428. }
  71429. /**
  71430. * Define a task used by AssetsManager to load Equirectangular cube textures
  71431. */
  71432. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  71433. /**
  71434. * Defines the name of the task
  71435. */
  71436. name: string;
  71437. /**
  71438. * Defines the location of the file to load
  71439. */
  71440. url: string;
  71441. /**
  71442. * Defines the desired size (the more it increases the longer the generation will be)
  71443. */
  71444. size: number;
  71445. /**
  71446. * Defines if mipmaps should not be generated (default is false)
  71447. */
  71448. noMipmap: boolean;
  71449. /**
  71450. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71451. * but the standard material would require them in Gamma space) (default is true)
  71452. */
  71453. gammaSpace: boolean;
  71454. /**
  71455. * Gets the loaded texture
  71456. */
  71457. texture: EquiRectangularCubeTexture;
  71458. /**
  71459. * Callback called when the task is successful
  71460. */
  71461. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  71462. /**
  71463. * Callback called when the task is successful
  71464. */
  71465. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  71466. /**
  71467. * Creates a new EquiRectangularCubeTextureAssetTask object
  71468. * @param name defines the name of the task
  71469. * @param url defines the location of the file to load
  71470. * @param size defines the desired size (the more it increases the longer the generation will be)
  71471. * If the size is omitted this implies you are using a preprocessed cubemap.
  71472. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71473. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  71474. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  71475. * (default is true)
  71476. */
  71477. constructor(
  71478. /**
  71479. * Defines the name of the task
  71480. */
  71481. name: string,
  71482. /**
  71483. * Defines the location of the file to load
  71484. */
  71485. url: string,
  71486. /**
  71487. * Defines the desired size (the more it increases the longer the generation will be)
  71488. */
  71489. size: number,
  71490. /**
  71491. * Defines if mipmaps should not be generated (default is false)
  71492. */
  71493. noMipmap?: boolean,
  71494. /**
  71495. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71496. * but the standard material would require them in Gamma space) (default is true)
  71497. */
  71498. gammaSpace?: boolean);
  71499. /**
  71500. * Execute the current task
  71501. * @param scene defines the scene where you want your assets to be loaded
  71502. * @param onSuccess is a callback called when the task is successfully executed
  71503. * @param onError is a callback called if an error occurs
  71504. */
  71505. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71506. }
  71507. /**
  71508. * This class can be used to easily import assets into a scene
  71509. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  71510. */
  71511. export class AssetsManager {
  71512. private _scene;
  71513. private _isLoading;
  71514. protected _tasks: AbstractAssetTask[];
  71515. protected _waitingTasksCount: number;
  71516. protected _totalTasksCount: number;
  71517. /**
  71518. * Callback called when all tasks are processed
  71519. */
  71520. onFinish: (tasks: AbstractAssetTask[]) => void;
  71521. /**
  71522. * Callback called when a task is successful
  71523. */
  71524. onTaskSuccess: (task: AbstractAssetTask) => void;
  71525. /**
  71526. * Callback called when a task had an error
  71527. */
  71528. onTaskError: (task: AbstractAssetTask) => void;
  71529. /**
  71530. * Callback called when a task is done (whatever the result is)
  71531. */
  71532. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  71533. /**
  71534. * Observable called when all tasks are processed
  71535. */
  71536. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  71537. /**
  71538. * Observable called when a task had an error
  71539. */
  71540. onTaskErrorObservable: Observable<AbstractAssetTask>;
  71541. /**
  71542. * Observable called when all tasks were executed
  71543. */
  71544. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  71545. /**
  71546. * Observable called when a task is done (whatever the result is)
  71547. */
  71548. onProgressObservable: Observable<IAssetsProgressEvent>;
  71549. /**
  71550. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  71551. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  71552. */
  71553. useDefaultLoadingScreen: boolean;
  71554. /**
  71555. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  71556. * when all assets have been downloaded.
  71557. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  71558. */
  71559. autoHideLoadingUI: boolean;
  71560. /**
  71561. * Creates a new AssetsManager
  71562. * @param scene defines the scene to work on
  71563. */
  71564. constructor(scene: Scene);
  71565. /**
  71566. * Add a MeshAssetTask to the list of active tasks
  71567. * @param taskName defines the name of the new task
  71568. * @param meshesNames defines the name of meshes to load
  71569. * @param rootUrl defines the root url to use to locate files
  71570. * @param sceneFilename defines the filename of the scene file
  71571. * @returns a new MeshAssetTask object
  71572. */
  71573. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  71574. /**
  71575. * Add a TextFileAssetTask to the list of active tasks
  71576. * @param taskName defines the name of the new task
  71577. * @param url defines the url of the file to load
  71578. * @returns a new TextFileAssetTask object
  71579. */
  71580. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  71581. /**
  71582. * Add a BinaryFileAssetTask to the list of active tasks
  71583. * @param taskName defines the name of the new task
  71584. * @param url defines the url of the file to load
  71585. * @returns a new BinaryFileAssetTask object
  71586. */
  71587. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  71588. /**
  71589. * Add a ImageAssetTask to the list of active tasks
  71590. * @param taskName defines the name of the new task
  71591. * @param url defines the url of the file to load
  71592. * @returns a new ImageAssetTask object
  71593. */
  71594. addImageTask(taskName: string, url: string): ImageAssetTask;
  71595. /**
  71596. * Add a TextureAssetTask to the list of active tasks
  71597. * @param taskName defines the name of the new task
  71598. * @param url defines the url of the file to load
  71599. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71600. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71601. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71602. * @returns a new TextureAssetTask object
  71603. */
  71604. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71605. /**
  71606. * Add a CubeTextureAssetTask to the list of active tasks
  71607. * @param taskName defines the name of the new task
  71608. * @param url defines the url of the file to load
  71609. * @param extensions defines the extension to use to load the cube map (can be null)
  71610. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71611. * @param files defines the list of files to load (can be null)
  71612. * @returns a new CubeTextureAssetTask object
  71613. */
  71614. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71615. /**
  71616. *
  71617. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71618. * @param taskName defines the name of the new task
  71619. * @param url defines the url of the file to load
  71620. * @param size defines the size you want for the cubemap (can be null)
  71621. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71622. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71623. * @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)
  71624. * @param reserved Internal use only
  71625. * @returns a new HDRCubeTextureAssetTask object
  71626. */
  71627. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71628. /**
  71629. *
  71630. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71631. * @param taskName defines the name of the new task
  71632. * @param url defines the url of the file to load
  71633. * @param size defines the size you want for the cubemap (can be null)
  71634. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71635. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71636. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71637. * @returns a new EquiRectangularCubeTextureAssetTask object
  71638. */
  71639. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71640. /**
  71641. * Remove a task from the assets manager.
  71642. * @param task the task to remove
  71643. */
  71644. removeTask(task: AbstractAssetTask): void;
  71645. private _decreaseWaitingTasksCount;
  71646. private _runTask;
  71647. /**
  71648. * Reset the AssetsManager and remove all tasks
  71649. * @return the current instance of the AssetsManager
  71650. */
  71651. reset(): AssetsManager;
  71652. /**
  71653. * Start the loading process
  71654. * @return the current instance of the AssetsManager
  71655. */
  71656. load(): AssetsManager;
  71657. /**
  71658. * Start the loading process as an async operation
  71659. * @return a promise returning the list of failed tasks
  71660. */
  71661. loadAsync(): Promise<void>;
  71662. }
  71663. }
  71664. declare module "babylonjs/Misc/deferred" {
  71665. /**
  71666. * Wrapper class for promise with external resolve and reject.
  71667. */
  71668. export class Deferred<T> {
  71669. /**
  71670. * The promise associated with this deferred object.
  71671. */
  71672. readonly promise: Promise<T>;
  71673. private _resolve;
  71674. private _reject;
  71675. /**
  71676. * The resolve method of the promise associated with this deferred object.
  71677. */
  71678. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71679. /**
  71680. * The reject method of the promise associated with this deferred object.
  71681. */
  71682. get reject(): (reason?: any) => void;
  71683. /**
  71684. * Constructor for this deferred object.
  71685. */
  71686. constructor();
  71687. }
  71688. }
  71689. declare module "babylonjs/Misc/meshExploder" {
  71690. import { Mesh } from "babylonjs/Meshes/mesh";
  71691. /**
  71692. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71693. */
  71694. export class MeshExploder {
  71695. private _centerMesh;
  71696. private _meshes;
  71697. private _meshesOrigins;
  71698. private _toCenterVectors;
  71699. private _scaledDirection;
  71700. private _newPosition;
  71701. private _centerPosition;
  71702. /**
  71703. * Explodes meshes from a center mesh.
  71704. * @param meshes The meshes to explode.
  71705. * @param centerMesh The mesh to be center of explosion.
  71706. */
  71707. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71708. private _setCenterMesh;
  71709. /**
  71710. * Get class name
  71711. * @returns "MeshExploder"
  71712. */
  71713. getClassName(): string;
  71714. /**
  71715. * "Exploded meshes"
  71716. * @returns Array of meshes with the centerMesh at index 0.
  71717. */
  71718. getMeshes(): Array<Mesh>;
  71719. /**
  71720. * Explodes meshes giving a specific direction
  71721. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71722. */
  71723. explode(direction?: number): void;
  71724. }
  71725. }
  71726. declare module "babylonjs/Misc/filesInput" {
  71727. import { Engine } from "babylonjs/Engines/engine";
  71728. import { Scene } from "babylonjs/scene";
  71729. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  71730. /**
  71731. * Class used to help managing file picking and drag'n'drop
  71732. */
  71733. export class FilesInput {
  71734. /**
  71735. * List of files ready to be loaded
  71736. */
  71737. static get FilesToLoad(): {
  71738. [key: string]: File;
  71739. };
  71740. /**
  71741. * Callback called when a file is processed
  71742. */
  71743. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71744. private _engine;
  71745. private _currentScene;
  71746. private _sceneLoadedCallback;
  71747. private _progressCallback;
  71748. private _additionalRenderLoopLogicCallback;
  71749. private _textureLoadingCallback;
  71750. private _startingProcessingFilesCallback;
  71751. private _onReloadCallback;
  71752. private _errorCallback;
  71753. private _elementToMonitor;
  71754. private _sceneFileToLoad;
  71755. private _filesToLoad;
  71756. /**
  71757. * Creates a new FilesInput
  71758. * @param engine defines the rendering engine
  71759. * @param scene defines the hosting scene
  71760. * @param sceneLoadedCallback callback called when scene is loaded
  71761. * @param progressCallback callback called to track progress
  71762. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71763. * @param textureLoadingCallback callback called when a texture is loading
  71764. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71765. * @param onReloadCallback callback called when a reload is requested
  71766. * @param errorCallback callback call if an error occurs
  71767. */
  71768. 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);
  71769. private _dragEnterHandler;
  71770. private _dragOverHandler;
  71771. private _dropHandler;
  71772. /**
  71773. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71774. * @param elementToMonitor defines the DOM element to track
  71775. */
  71776. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71777. /**
  71778. * Release all associated resources
  71779. */
  71780. dispose(): void;
  71781. private renderFunction;
  71782. private drag;
  71783. private drop;
  71784. private _traverseFolder;
  71785. private _processFiles;
  71786. /**
  71787. * Load files from a drop event
  71788. * @param event defines the drop event to use as source
  71789. */
  71790. loadFiles(event: any): void;
  71791. private _processReload;
  71792. /**
  71793. * Reload the current scene from the loaded files
  71794. */
  71795. reload(): void;
  71796. }
  71797. }
  71798. declare module "babylonjs/Misc/HighDynamicRange/index" {
  71799. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  71800. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  71801. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  71802. }
  71803. declare module "babylonjs/Misc/sceneOptimizer" {
  71804. import { Scene, IDisposable } from "babylonjs/scene";
  71805. import { Observable } from "babylonjs/Misc/observable";
  71806. /**
  71807. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71808. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71809. */
  71810. export class SceneOptimization {
  71811. /**
  71812. * Defines the priority of this optimization (0 by default which means first in the list)
  71813. */
  71814. priority: number;
  71815. /**
  71816. * Gets a string describing the action executed by the current optimization
  71817. * @returns description string
  71818. */
  71819. getDescription(): string;
  71820. /**
  71821. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71822. * @param scene defines the current scene where to apply this optimization
  71823. * @param optimizer defines the current optimizer
  71824. * @returns true if everything that can be done was applied
  71825. */
  71826. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71827. /**
  71828. * Creates the SceneOptimization object
  71829. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71830. * @param desc defines the description associated with the optimization
  71831. */
  71832. constructor(
  71833. /**
  71834. * Defines the priority of this optimization (0 by default which means first in the list)
  71835. */
  71836. priority?: number);
  71837. }
  71838. /**
  71839. * Defines an optimization used to reduce the size of render target textures
  71840. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71841. */
  71842. export class TextureOptimization extends SceneOptimization {
  71843. /**
  71844. * Defines the priority of this optimization (0 by default which means first in the list)
  71845. */
  71846. priority: number;
  71847. /**
  71848. * 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
  71849. */
  71850. maximumSize: number;
  71851. /**
  71852. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71853. */
  71854. step: number;
  71855. /**
  71856. * Gets a string describing the action executed by the current optimization
  71857. * @returns description string
  71858. */
  71859. getDescription(): string;
  71860. /**
  71861. * Creates the TextureOptimization object
  71862. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71863. * @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
  71864. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71865. */
  71866. constructor(
  71867. /**
  71868. * Defines the priority of this optimization (0 by default which means first in the list)
  71869. */
  71870. priority?: number,
  71871. /**
  71872. * 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
  71873. */
  71874. maximumSize?: number,
  71875. /**
  71876. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71877. */
  71878. step?: number);
  71879. /**
  71880. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71881. * @param scene defines the current scene where to apply this optimization
  71882. * @param optimizer defines the current optimizer
  71883. * @returns true if everything that can be done was applied
  71884. */
  71885. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71886. }
  71887. /**
  71888. * Defines an optimization used to increase or decrease the rendering resolution
  71889. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71890. */
  71891. export class HardwareScalingOptimization extends SceneOptimization {
  71892. /**
  71893. * Defines the priority of this optimization (0 by default which means first in the list)
  71894. */
  71895. priority: number;
  71896. /**
  71897. * Defines the maximum scale to use (2 by default)
  71898. */
  71899. maximumScale: number;
  71900. /**
  71901. * Defines the step to use between two passes (0.5 by default)
  71902. */
  71903. step: number;
  71904. private _currentScale;
  71905. private _directionOffset;
  71906. /**
  71907. * Gets a string describing the action executed by the current optimization
  71908. * @return description string
  71909. */
  71910. getDescription(): string;
  71911. /**
  71912. * Creates the HardwareScalingOptimization object
  71913. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71914. * @param maximumScale defines the maximum scale to use (2 by default)
  71915. * @param step defines the step to use between two passes (0.5 by default)
  71916. */
  71917. constructor(
  71918. /**
  71919. * Defines the priority of this optimization (0 by default which means first in the list)
  71920. */
  71921. priority?: number,
  71922. /**
  71923. * Defines the maximum scale to use (2 by default)
  71924. */
  71925. maximumScale?: number,
  71926. /**
  71927. * Defines the step to use between two passes (0.5 by default)
  71928. */
  71929. step?: number);
  71930. /**
  71931. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71932. * @param scene defines the current scene where to apply this optimization
  71933. * @param optimizer defines the current optimizer
  71934. * @returns true if everything that can be done was applied
  71935. */
  71936. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71937. }
  71938. /**
  71939. * Defines an optimization used to remove shadows
  71940. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71941. */
  71942. export class ShadowsOptimization extends SceneOptimization {
  71943. /**
  71944. * Gets a string describing the action executed by the current optimization
  71945. * @return description string
  71946. */
  71947. getDescription(): string;
  71948. /**
  71949. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71950. * @param scene defines the current scene where to apply this optimization
  71951. * @param optimizer defines the current optimizer
  71952. * @returns true if everything that can be done was applied
  71953. */
  71954. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71955. }
  71956. /**
  71957. * Defines an optimization used to turn post-processes off
  71958. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71959. */
  71960. export class PostProcessesOptimization extends SceneOptimization {
  71961. /**
  71962. * Gets a string describing the action executed by the current optimization
  71963. * @return description string
  71964. */
  71965. getDescription(): string;
  71966. /**
  71967. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71968. * @param scene defines the current scene where to apply this optimization
  71969. * @param optimizer defines the current optimizer
  71970. * @returns true if everything that can be done was applied
  71971. */
  71972. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71973. }
  71974. /**
  71975. * Defines an optimization used to turn lens flares off
  71976. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71977. */
  71978. export class LensFlaresOptimization extends SceneOptimization {
  71979. /**
  71980. * Gets a string describing the action executed by the current optimization
  71981. * @return description string
  71982. */
  71983. getDescription(): string;
  71984. /**
  71985. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71986. * @param scene defines the current scene where to apply this optimization
  71987. * @param optimizer defines the current optimizer
  71988. * @returns true if everything that can be done was applied
  71989. */
  71990. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71991. }
  71992. /**
  71993. * Defines an optimization based on user defined callback.
  71994. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71995. */
  71996. export class CustomOptimization extends SceneOptimization {
  71997. /**
  71998. * Callback called to apply the custom optimization.
  71999. */
  72000. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  72001. /**
  72002. * Callback called to get custom description
  72003. */
  72004. onGetDescription: () => string;
  72005. /**
  72006. * Gets a string describing the action executed by the current optimization
  72007. * @returns description string
  72008. */
  72009. getDescription(): string;
  72010. /**
  72011. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72012. * @param scene defines the current scene where to apply this optimization
  72013. * @param optimizer defines the current optimizer
  72014. * @returns true if everything that can be done was applied
  72015. */
  72016. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72017. }
  72018. /**
  72019. * Defines an optimization used to turn particles off
  72020. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72021. */
  72022. export class ParticlesOptimization extends SceneOptimization {
  72023. /**
  72024. * Gets a string describing the action executed by the current optimization
  72025. * @return description string
  72026. */
  72027. getDescription(): string;
  72028. /**
  72029. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72030. * @param scene defines the current scene where to apply this optimization
  72031. * @param optimizer defines the current optimizer
  72032. * @returns true if everything that can be done was applied
  72033. */
  72034. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72035. }
  72036. /**
  72037. * Defines an optimization used to turn render targets off
  72038. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72039. */
  72040. export class RenderTargetsOptimization extends SceneOptimization {
  72041. /**
  72042. * Gets a string describing the action executed by the current optimization
  72043. * @return description string
  72044. */
  72045. getDescription(): string;
  72046. /**
  72047. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72048. * @param scene defines the current scene where to apply this optimization
  72049. * @param optimizer defines the current optimizer
  72050. * @returns true if everything that can be done was applied
  72051. */
  72052. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72053. }
  72054. /**
  72055. * Defines an optimization used to merge meshes with compatible materials
  72056. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72057. */
  72058. export class MergeMeshesOptimization extends SceneOptimization {
  72059. private static _UpdateSelectionTree;
  72060. /**
  72061. * Gets or sets a boolean which defines if optimization octree has to be updated
  72062. */
  72063. static get UpdateSelectionTree(): boolean;
  72064. /**
  72065. * Gets or sets a boolean which defines if optimization octree has to be updated
  72066. */
  72067. static set UpdateSelectionTree(value: boolean);
  72068. /**
  72069. * Gets a string describing the action executed by the current optimization
  72070. * @return description string
  72071. */
  72072. getDescription(): string;
  72073. private _canBeMerged;
  72074. /**
  72075. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72076. * @param scene defines the current scene where to apply this optimization
  72077. * @param optimizer defines the current optimizer
  72078. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  72079. * @returns true if everything that can be done was applied
  72080. */
  72081. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  72082. }
  72083. /**
  72084. * Defines a list of options used by SceneOptimizer
  72085. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72086. */
  72087. export class SceneOptimizerOptions {
  72088. /**
  72089. * Defines the target frame rate to reach (60 by default)
  72090. */
  72091. targetFrameRate: number;
  72092. /**
  72093. * Defines the interval between two checkes (2000ms by default)
  72094. */
  72095. trackerDuration: number;
  72096. /**
  72097. * Gets the list of optimizations to apply
  72098. */
  72099. optimizations: SceneOptimization[];
  72100. /**
  72101. * Creates a new list of options used by SceneOptimizer
  72102. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  72103. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  72104. */
  72105. constructor(
  72106. /**
  72107. * Defines the target frame rate to reach (60 by default)
  72108. */
  72109. targetFrameRate?: number,
  72110. /**
  72111. * Defines the interval between two checkes (2000ms by default)
  72112. */
  72113. trackerDuration?: number);
  72114. /**
  72115. * Add a new optimization
  72116. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  72117. * @returns the current SceneOptimizerOptions
  72118. */
  72119. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  72120. /**
  72121. * Add a new custom optimization
  72122. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  72123. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  72124. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72125. * @returns the current SceneOptimizerOptions
  72126. */
  72127. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  72128. /**
  72129. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  72130. * @param targetFrameRate defines the target frame rate (60 by default)
  72131. * @returns a SceneOptimizerOptions object
  72132. */
  72133. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72134. /**
  72135. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  72136. * @param targetFrameRate defines the target frame rate (60 by default)
  72137. * @returns a SceneOptimizerOptions object
  72138. */
  72139. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72140. /**
  72141. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  72142. * @param targetFrameRate defines the target frame rate (60 by default)
  72143. * @returns a SceneOptimizerOptions object
  72144. */
  72145. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72146. }
  72147. /**
  72148. * Class used to run optimizations in order to reach a target frame rate
  72149. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72150. */
  72151. export class SceneOptimizer implements IDisposable {
  72152. private _isRunning;
  72153. private _options;
  72154. private _scene;
  72155. private _currentPriorityLevel;
  72156. private _targetFrameRate;
  72157. private _trackerDuration;
  72158. private _currentFrameRate;
  72159. private _sceneDisposeObserver;
  72160. private _improvementMode;
  72161. /**
  72162. * Defines an observable called when the optimizer reaches the target frame rate
  72163. */
  72164. onSuccessObservable: Observable<SceneOptimizer>;
  72165. /**
  72166. * Defines an observable called when the optimizer enables an optimization
  72167. */
  72168. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  72169. /**
  72170. * Defines an observable called when the optimizer is not able to reach the target frame rate
  72171. */
  72172. onFailureObservable: Observable<SceneOptimizer>;
  72173. /**
  72174. * Gets a boolean indicating if the optimizer is in improvement mode
  72175. */
  72176. get isInImprovementMode(): boolean;
  72177. /**
  72178. * Gets the current priority level (0 at start)
  72179. */
  72180. get currentPriorityLevel(): number;
  72181. /**
  72182. * Gets the current frame rate checked by the SceneOptimizer
  72183. */
  72184. get currentFrameRate(): number;
  72185. /**
  72186. * Gets or sets the current target frame rate (60 by default)
  72187. */
  72188. get targetFrameRate(): number;
  72189. /**
  72190. * Gets or sets the current target frame rate (60 by default)
  72191. */
  72192. set targetFrameRate(value: number);
  72193. /**
  72194. * Gets or sets the current interval between two checks (every 2000ms by default)
  72195. */
  72196. get trackerDuration(): number;
  72197. /**
  72198. * Gets or sets the current interval between two checks (every 2000ms by default)
  72199. */
  72200. set trackerDuration(value: number);
  72201. /**
  72202. * Gets the list of active optimizations
  72203. */
  72204. get optimizations(): SceneOptimization[];
  72205. /**
  72206. * Creates a new SceneOptimizer
  72207. * @param scene defines the scene to work on
  72208. * @param options defines the options to use with the SceneOptimizer
  72209. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  72210. * @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)
  72211. */
  72212. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  72213. /**
  72214. * Stops the current optimizer
  72215. */
  72216. stop(): void;
  72217. /**
  72218. * Reset the optimizer to initial step (current priority level = 0)
  72219. */
  72220. reset(): void;
  72221. /**
  72222. * Start the optimizer. By default it will try to reach a specific framerate
  72223. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  72224. */
  72225. start(): void;
  72226. private _checkCurrentState;
  72227. /**
  72228. * Release all resources
  72229. */
  72230. dispose(): void;
  72231. /**
  72232. * Helper function to create a SceneOptimizer with one single line of code
  72233. * @param scene defines the scene to work on
  72234. * @param options defines the options to use with the SceneOptimizer
  72235. * @param onSuccess defines a callback to call on success
  72236. * @param onFailure defines a callback to call on failure
  72237. * @returns the new SceneOptimizer object
  72238. */
  72239. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  72240. }
  72241. }
  72242. declare module "babylonjs/Misc/sceneSerializer" {
  72243. import { Scene } from "babylonjs/scene";
  72244. /**
  72245. * Class used to serialize a scene into a string
  72246. */
  72247. export class SceneSerializer {
  72248. /**
  72249. * Clear cache used by a previous serialization
  72250. */
  72251. static ClearCache(): void;
  72252. /**
  72253. * Serialize a scene into a JSON compatible object
  72254. * @param scene defines the scene to serialize
  72255. * @returns a JSON compatible object
  72256. */
  72257. static Serialize(scene: Scene): any;
  72258. /**
  72259. * Serialize a mesh into a JSON compatible object
  72260. * @param toSerialize defines the mesh to serialize
  72261. * @param withParents defines if parents must be serialized as well
  72262. * @param withChildren defines if children must be serialized as well
  72263. * @returns a JSON compatible object
  72264. */
  72265. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72266. }
  72267. }
  72268. declare module "babylonjs/Misc/textureTools" {
  72269. import { Texture } from "babylonjs/Materials/Textures/texture";
  72270. /**
  72271. * Class used to host texture specific utilities
  72272. */
  72273. export class TextureTools {
  72274. /**
  72275. * Uses the GPU to create a copy texture rescaled at a given size
  72276. * @param texture Texture to copy from
  72277. * @param width defines the desired width
  72278. * @param height defines the desired height
  72279. * @param useBilinearMode defines if bilinear mode has to be used
  72280. * @return the generated texture
  72281. */
  72282. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72283. }
  72284. }
  72285. declare module "babylonjs/Misc/videoRecorder" {
  72286. import { Nullable } from "babylonjs/types";
  72287. import { Engine } from "babylonjs/Engines/engine";
  72288. /**
  72289. * This represents the different options available for the video capture.
  72290. */
  72291. export interface VideoRecorderOptions {
  72292. /** Defines the mime type of the video. */
  72293. mimeType: string;
  72294. /** Defines the FPS the video should be recorded at. */
  72295. fps: number;
  72296. /** Defines the chunk size for the recording data. */
  72297. recordChunckSize: number;
  72298. /** The audio tracks to attach to the recording. */
  72299. audioTracks?: MediaStreamTrack[];
  72300. }
  72301. /**
  72302. * This can help with recording videos from BabylonJS.
  72303. * This is based on the available WebRTC functionalities of the browser.
  72304. *
  72305. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  72306. */
  72307. export class VideoRecorder {
  72308. private static readonly _defaultOptions;
  72309. /**
  72310. * Returns whether or not the VideoRecorder is available in your browser.
  72311. * @param engine Defines the Babylon Engine.
  72312. * @returns true if supported otherwise false.
  72313. */
  72314. static IsSupported(engine: Engine): boolean;
  72315. private readonly _options;
  72316. private _canvas;
  72317. private _mediaRecorder;
  72318. private _recordedChunks;
  72319. private _fileName;
  72320. private _resolve;
  72321. private _reject;
  72322. /**
  72323. * True when a recording is already in progress.
  72324. */
  72325. get isRecording(): boolean;
  72326. /**
  72327. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72328. * @param engine Defines the BabylonJS Engine you wish to record.
  72329. * @param options Defines options that can be used to customize the capture.
  72330. */
  72331. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72332. /**
  72333. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72334. */
  72335. stopRecording(): void;
  72336. /**
  72337. * Starts recording the canvas for a max duration specified in parameters.
  72338. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72339. * If null no automatic download will start and you can rely on the promise to get the data back.
  72340. * @param maxDuration Defines the maximum recording time in seconds.
  72341. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72342. * @return A promise callback at the end of the recording with the video data in Blob.
  72343. */
  72344. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72345. /**
  72346. * Releases internal resources used during the recording.
  72347. */
  72348. dispose(): void;
  72349. private _handleDataAvailable;
  72350. private _handleError;
  72351. private _handleStop;
  72352. }
  72353. }
  72354. declare module "babylonjs/Misc/screenshotTools" {
  72355. import { Camera } from "babylonjs/Cameras/camera";
  72356. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  72357. import { Engine } from "babylonjs/Engines/engine";
  72358. /**
  72359. * Class containing a set of static utilities functions for screenshots
  72360. */
  72361. export class ScreenshotTools {
  72362. /**
  72363. * Captures a screenshot of the current rendering
  72364. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72365. * @param engine defines the rendering engine
  72366. * @param camera defines the source camera
  72367. * @param size This parameter can be set to a single number or to an object with the
  72368. * following (optional) properties: precision, width, height. If a single number is passed,
  72369. * it will be used for both width and height. If an object is passed, the screenshot size
  72370. * will be derived from the parameters. The precision property is a multiplier allowing
  72371. * rendering at a higher or lower resolution
  72372. * @param successCallback defines the callback receives a single parameter which contains the
  72373. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72374. * src parameter of an <img> to display it
  72375. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72376. * Check your browser for supported MIME types
  72377. */
  72378. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72379. /**
  72380. * Captures a screenshot of the current rendering
  72381. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72382. * @param engine defines the rendering engine
  72383. * @param camera defines the source camera
  72384. * @param size This parameter can be set to a single number or to an object with the
  72385. * following (optional) properties: precision, width, height. If a single number is passed,
  72386. * it will be used for both width and height. If an object is passed, the screenshot size
  72387. * will be derived from the parameters. The precision property is a multiplier allowing
  72388. * rendering at a higher or lower resolution
  72389. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72390. * Check your browser for supported MIME types
  72391. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72392. * to the src parameter of an <img> to display it
  72393. */
  72394. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  72395. /**
  72396. * Generates an image screenshot from the specified camera.
  72397. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72398. * @param engine The engine to use for rendering
  72399. * @param camera The camera to use for rendering
  72400. * @param size This parameter can be set to a single number or to an object with the
  72401. * following (optional) properties: precision, width, height. If a single number is passed,
  72402. * it will be used for both width and height. If an object is passed, the screenshot size
  72403. * will be derived from the parameters. The precision property is a multiplier allowing
  72404. * rendering at a higher or lower resolution
  72405. * @param successCallback The callback receives a single parameter which contains the
  72406. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72407. * src parameter of an <img> to display it
  72408. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72409. * Check your browser for supported MIME types
  72410. * @param samples Texture samples (default: 1)
  72411. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72412. * @param fileName A name for for the downloaded file.
  72413. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72414. */
  72415. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  72416. /**
  72417. * Generates an image screenshot from the specified camera.
  72418. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72419. * @param engine The engine to use for rendering
  72420. * @param camera The camera to use for rendering
  72421. * @param size This parameter can be set to a single number or to an object with the
  72422. * following (optional) properties: precision, width, height. If a single number is passed,
  72423. * it will be used for both width and height. If an object is passed, the screenshot size
  72424. * will be derived from the parameters. The precision property is a multiplier allowing
  72425. * rendering at a higher or lower resolution
  72426. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72427. * Check your browser for supported MIME types
  72428. * @param samples Texture samples (default: 1)
  72429. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72430. * @param fileName A name for for the downloaded file.
  72431. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72432. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72433. * to the src parameter of an <img> to display it
  72434. */
  72435. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  72436. /**
  72437. * Gets height and width for screenshot size
  72438. * @private
  72439. */
  72440. private static _getScreenshotSize;
  72441. }
  72442. }
  72443. declare module "babylonjs/Misc/dataReader" {
  72444. /**
  72445. * Interface for a data buffer
  72446. */
  72447. export interface IDataBuffer {
  72448. /**
  72449. * Reads bytes from the data buffer.
  72450. * @param byteOffset The byte offset to read
  72451. * @param byteLength The byte length to read
  72452. * @returns A promise that resolves when the bytes are read
  72453. */
  72454. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  72455. /**
  72456. * The byte length of the buffer.
  72457. */
  72458. readonly byteLength: number;
  72459. }
  72460. /**
  72461. * Utility class for reading from a data buffer
  72462. */
  72463. export class DataReader {
  72464. /**
  72465. * The data buffer associated with this data reader.
  72466. */
  72467. readonly buffer: IDataBuffer;
  72468. /**
  72469. * The current byte offset from the beginning of the data buffer.
  72470. */
  72471. byteOffset: number;
  72472. private _dataView;
  72473. private _dataByteOffset;
  72474. /**
  72475. * Constructor
  72476. * @param buffer The buffer to read
  72477. */
  72478. constructor(buffer: IDataBuffer);
  72479. /**
  72480. * Loads the given byte length.
  72481. * @param byteLength The byte length to load
  72482. * @returns A promise that resolves when the load is complete
  72483. */
  72484. loadAsync(byteLength: number): Promise<void>;
  72485. /**
  72486. * Read a unsigned 32-bit integer from the currently loaded data range.
  72487. * @returns The 32-bit integer read
  72488. */
  72489. readUint32(): number;
  72490. /**
  72491. * Read a byte array from the currently loaded data range.
  72492. * @param byteLength The byte length to read
  72493. * @returns The byte array read
  72494. */
  72495. readUint8Array(byteLength: number): Uint8Array;
  72496. /**
  72497. * Read a string from the currently loaded data range.
  72498. * @param byteLength The byte length to read
  72499. * @returns The string read
  72500. */
  72501. readString(byteLength: number): string;
  72502. /**
  72503. * Skips the given byte length the currently loaded data range.
  72504. * @param byteLength The byte length to skip
  72505. */
  72506. skipBytes(byteLength: number): void;
  72507. }
  72508. }
  72509. declare module "babylonjs/Misc/dataStorage" {
  72510. /**
  72511. * Class for storing data to local storage if available or in-memory storage otherwise
  72512. */
  72513. export class DataStorage {
  72514. private static _Storage;
  72515. private static _GetStorage;
  72516. /**
  72517. * Reads a string from the data storage
  72518. * @param key The key to read
  72519. * @param defaultValue The value if the key doesn't exist
  72520. * @returns The string value
  72521. */
  72522. static ReadString(key: string, defaultValue: string): string;
  72523. /**
  72524. * Writes a string to the data storage
  72525. * @param key The key to write
  72526. * @param value The value to write
  72527. */
  72528. static WriteString(key: string, value: string): void;
  72529. /**
  72530. * Reads a boolean from the data storage
  72531. * @param key The key to read
  72532. * @param defaultValue The value if the key doesn't exist
  72533. * @returns The boolean value
  72534. */
  72535. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  72536. /**
  72537. * Writes a boolean to the data storage
  72538. * @param key The key to write
  72539. * @param value The value to write
  72540. */
  72541. static WriteBoolean(key: string, value: boolean): void;
  72542. /**
  72543. * Reads a number from the data storage
  72544. * @param key The key to read
  72545. * @param defaultValue The value if the key doesn't exist
  72546. * @returns The number value
  72547. */
  72548. static ReadNumber(key: string, defaultValue: number): number;
  72549. /**
  72550. * Writes a number to the data storage
  72551. * @param key The key to write
  72552. * @param value The value to write
  72553. */
  72554. static WriteNumber(key: string, value: number): void;
  72555. }
  72556. }
  72557. declare module "babylonjs/Misc/index" {
  72558. export * from "babylonjs/Misc/andOrNotEvaluator";
  72559. export * from "babylonjs/Misc/assetsManager";
  72560. export * from "babylonjs/Misc/basis";
  72561. export * from "babylonjs/Misc/dds";
  72562. export * from "babylonjs/Misc/decorators";
  72563. export * from "babylonjs/Misc/deferred";
  72564. export * from "babylonjs/Misc/environmentTextureTools";
  72565. export * from "babylonjs/Misc/meshExploder";
  72566. export * from "babylonjs/Misc/filesInput";
  72567. export * from "babylonjs/Misc/HighDynamicRange/index";
  72568. export * from "babylonjs/Misc/khronosTextureContainer";
  72569. export * from "babylonjs/Misc/observable";
  72570. export * from "babylonjs/Misc/performanceMonitor";
  72571. export * from "babylonjs/Misc/promise";
  72572. export * from "babylonjs/Misc/sceneOptimizer";
  72573. export * from "babylonjs/Misc/sceneSerializer";
  72574. export * from "babylonjs/Misc/smartArray";
  72575. export * from "babylonjs/Misc/stringDictionary";
  72576. export * from "babylonjs/Misc/tags";
  72577. export * from "babylonjs/Misc/textureTools";
  72578. export * from "babylonjs/Misc/tga";
  72579. export * from "babylonjs/Misc/tools";
  72580. export * from "babylonjs/Misc/videoRecorder";
  72581. export * from "babylonjs/Misc/virtualJoystick";
  72582. export * from "babylonjs/Misc/workerPool";
  72583. export * from "babylonjs/Misc/logger";
  72584. export * from "babylonjs/Misc/typeStore";
  72585. export * from "babylonjs/Misc/filesInputStore";
  72586. export * from "babylonjs/Misc/deepCopier";
  72587. export * from "babylonjs/Misc/pivotTools";
  72588. export * from "babylonjs/Misc/precisionDate";
  72589. export * from "babylonjs/Misc/screenshotTools";
  72590. export * from "babylonjs/Misc/typeStore";
  72591. export * from "babylonjs/Misc/webRequest";
  72592. export * from "babylonjs/Misc/iInspectable";
  72593. export * from "babylonjs/Misc/brdfTextureTools";
  72594. export * from "babylonjs/Misc/rgbdTextureTools";
  72595. export * from "babylonjs/Misc/gradients";
  72596. export * from "babylonjs/Misc/perfCounter";
  72597. export * from "babylonjs/Misc/fileRequest";
  72598. export * from "babylonjs/Misc/customAnimationFrameRequester";
  72599. export * from "babylonjs/Misc/retryStrategy";
  72600. export * from "babylonjs/Misc/interfaces/screenshotSize";
  72601. export * from "babylonjs/Misc/canvasGenerator";
  72602. export * from "babylonjs/Misc/fileTools";
  72603. export * from "babylonjs/Misc/stringTools";
  72604. export * from "babylonjs/Misc/dataReader";
  72605. export * from "babylonjs/Misc/minMaxReducer";
  72606. export * from "babylonjs/Misc/depthReducer";
  72607. export * from "babylonjs/Misc/dataStorage";
  72608. }
  72609. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  72610. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72611. import { Observable } from "babylonjs/Misc/observable";
  72612. import { Matrix } from "babylonjs/Maths/math.vector";
  72613. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72614. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72615. /**
  72616. * Options used for hit testing
  72617. */
  72618. export interface IWebXRHitTestOptions {
  72619. /**
  72620. * Only test when user interacted with the scene. Default - hit test every frame
  72621. */
  72622. testOnPointerDownOnly?: boolean;
  72623. /**
  72624. * The node to use to transform the local results to world coordinates
  72625. */
  72626. worldParentNode?: TransformNode;
  72627. }
  72628. /**
  72629. * Interface defining the babylon result of raycasting/hit-test
  72630. */
  72631. export interface IWebXRHitResult {
  72632. /**
  72633. * Transformation matrix that can be applied to a node that will put it in the hit point location
  72634. */
  72635. transformationMatrix: Matrix;
  72636. /**
  72637. * The native hit test result
  72638. */
  72639. xrHitResult: XRHitResult;
  72640. }
  72641. /**
  72642. * The currently-working hit-test module.
  72643. * Hit test (or Ray-casting) is used to interact with the real world.
  72644. * For further information read here - https://github.com/immersive-web/hit-test
  72645. */
  72646. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  72647. /**
  72648. * options to use when constructing this feature
  72649. */
  72650. readonly options: IWebXRHitTestOptions;
  72651. private _direction;
  72652. private _mat;
  72653. private _onSelectEnabled;
  72654. private _origin;
  72655. /**
  72656. * The module's name
  72657. */
  72658. static readonly Name: string;
  72659. /**
  72660. * The (Babylon) version of this module.
  72661. * This is an integer representing the implementation version.
  72662. * This number does not correspond to the WebXR specs version
  72663. */
  72664. static readonly Version: number;
  72665. /**
  72666. * Populated with the last native XR Hit Results
  72667. */
  72668. lastNativeXRHitResults: XRHitResult[];
  72669. /**
  72670. * Triggered when new babylon (transformed) hit test results are available
  72671. */
  72672. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72673. /**
  72674. * Creates a new instance of the (legacy version) hit test feature
  72675. * @param _xrSessionManager an instance of WebXRSessionManager
  72676. * @param options options to use when constructing this feature
  72677. */
  72678. constructor(_xrSessionManager: WebXRSessionManager,
  72679. /**
  72680. * options to use when constructing this feature
  72681. */
  72682. options?: IWebXRHitTestOptions);
  72683. /**
  72684. * execute a hit test with an XR Ray
  72685. *
  72686. * @param xrSession a native xrSession that will execute this hit test
  72687. * @param xrRay the ray (position and direction) to use for ray-casting
  72688. * @param referenceSpace native XR reference space to use for the hit-test
  72689. * @param filter filter function that will filter the results
  72690. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72691. */
  72692. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  72693. /**
  72694. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  72695. * @param event the (select) event to use to select with
  72696. * @param referenceSpace the reference space to use for this hit test
  72697. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72698. */
  72699. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72700. /**
  72701. * attach this feature
  72702. * Will usually be called by the features manager
  72703. *
  72704. * @returns true if successful.
  72705. */
  72706. attach(): boolean;
  72707. /**
  72708. * detach this feature.
  72709. * Will usually be called by the features manager
  72710. *
  72711. * @returns true if successful.
  72712. */
  72713. detach(): boolean;
  72714. /**
  72715. * Dispose this feature and all of the resources attached
  72716. */
  72717. dispose(): void;
  72718. protected _onXRFrame(frame: XRFrame): void;
  72719. private _onHitTestResults;
  72720. private _onSelect;
  72721. }
  72722. }
  72723. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  72724. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72725. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72726. import { Observable } from "babylonjs/Misc/observable";
  72727. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  72728. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72729. /**
  72730. * Options used in the plane detector module
  72731. */
  72732. export interface IWebXRPlaneDetectorOptions {
  72733. /**
  72734. * The node to use to transform the local results to world coordinates
  72735. */
  72736. worldParentNode?: TransformNode;
  72737. }
  72738. /**
  72739. * A babylon interface for a WebXR plane.
  72740. * A Plane is actually a polygon, built from N points in space
  72741. *
  72742. * Supported in chrome 79, not supported in canary 81 ATM
  72743. */
  72744. export interface IWebXRPlane {
  72745. /**
  72746. * a babylon-assigned ID for this polygon
  72747. */
  72748. id: number;
  72749. /**
  72750. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  72751. */
  72752. polygonDefinition: Array<Vector3>;
  72753. /**
  72754. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  72755. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  72756. */
  72757. transformationMatrix: Matrix;
  72758. /**
  72759. * the native xr-plane object
  72760. */
  72761. xrPlane: XRPlane;
  72762. }
  72763. /**
  72764. * The plane detector is used to detect planes in the real world when in AR
  72765. * For more information see https://github.com/immersive-web/real-world-geometry/
  72766. */
  72767. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  72768. private _options;
  72769. private _detectedPlanes;
  72770. private _enabled;
  72771. private _lastFrameDetected;
  72772. /**
  72773. * The module's name
  72774. */
  72775. static readonly Name: string;
  72776. /**
  72777. * The (Babylon) version of this module.
  72778. * This is an integer representing the implementation version.
  72779. * This number does not correspond to the WebXR specs version
  72780. */
  72781. static readonly Version: number;
  72782. /**
  72783. * Observers registered here will be executed when a new plane was added to the session
  72784. */
  72785. onPlaneAddedObservable: Observable<IWebXRPlane>;
  72786. /**
  72787. * Observers registered here will be executed when a plane is no longer detected in the session
  72788. */
  72789. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  72790. /**
  72791. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  72792. * This can execute N times every frame
  72793. */
  72794. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  72795. /**
  72796. * construct a new Plane Detector
  72797. * @param _xrSessionManager an instance of xr Session manager
  72798. * @param _options configuration to use when constructing this feature
  72799. */
  72800. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  72801. /**
  72802. * Dispose this feature and all of the resources attached
  72803. */
  72804. dispose(): void;
  72805. protected _onXRFrame(frame: XRFrame): void;
  72806. private _init;
  72807. private _updatePlaneWithXRPlane;
  72808. /**
  72809. * avoiding using Array.find for global support.
  72810. * @param xrPlane the plane to find in the array
  72811. */
  72812. private findIndexInPlaneArray;
  72813. }
  72814. }
  72815. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  72816. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72817. import { Observable } from "babylonjs/Misc/observable";
  72818. import { Matrix } from "babylonjs/Maths/math.vector";
  72819. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72820. import { WebXRPlaneDetector } from "babylonjs/XR/features/WebXRPlaneDetector";
  72821. import { WebXRHitTestLegacy } from "babylonjs/XR/features/WebXRHitTestLegacy";
  72822. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72823. /**
  72824. * Configuration options of the anchor system
  72825. */
  72826. export interface IWebXRAnchorSystemOptions {
  72827. /**
  72828. * Should a new anchor be added every time a select event is triggered
  72829. */
  72830. addAnchorOnSelect?: boolean;
  72831. /**
  72832. * should the anchor system use plane detection.
  72833. * If set to true, the plane-detection feature should be set using setPlaneDetector
  72834. */
  72835. usePlaneDetection?: boolean;
  72836. /**
  72837. * a node that will be used to convert local to world coordinates
  72838. */
  72839. worldParentNode?: TransformNode;
  72840. }
  72841. /**
  72842. * A babylon container for an XR Anchor
  72843. */
  72844. export interface IWebXRAnchor {
  72845. /**
  72846. * A babylon-assigned ID for this anchor
  72847. */
  72848. id: number;
  72849. /**
  72850. * Transformation matrix to apply to an object attached to this anchor
  72851. */
  72852. transformationMatrix: Matrix;
  72853. /**
  72854. * The native anchor object
  72855. */
  72856. xrAnchor: XRAnchor;
  72857. }
  72858. /**
  72859. * An implementation of the anchor system of WebXR.
  72860. * Note that the current documented implementation is not available in any browser. Future implementations
  72861. * will use the frame to create an anchor and not the session or a detected plane
  72862. * For further information see https://github.com/immersive-web/anchors/
  72863. */
  72864. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  72865. private _options;
  72866. private _enabled;
  72867. private _hitTestModule;
  72868. private _lastFrameDetected;
  72869. private _onSelect;
  72870. private _planeDetector;
  72871. private _trackedAnchors;
  72872. /**
  72873. * The module's name
  72874. */
  72875. static readonly Name: string;
  72876. /**
  72877. * The (Babylon) version of this module.
  72878. * This is an integer representing the implementation version.
  72879. * This number does not correspond to the WebXR specs version
  72880. */
  72881. static readonly Version: number;
  72882. /**
  72883. * Observers registered here will be executed when a new anchor was added to the session
  72884. */
  72885. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  72886. /**
  72887. * Observers registered here will be executed when an anchor was removed from the session
  72888. */
  72889. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  72890. /**
  72891. * Observers registered here will be executed when an existing anchor updates
  72892. * This can execute N times every frame
  72893. */
  72894. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  72895. /**
  72896. * constructs a new anchor system
  72897. * @param _xrSessionManager an instance of WebXRSessionManager
  72898. * @param _options configuration object for this feature
  72899. */
  72900. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  72901. /**
  72902. * Add anchor at a specific XR point.
  72903. *
  72904. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  72905. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  72906. * @returns a promise the fulfills when the anchor was created
  72907. */
  72908. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  72909. /**
  72910. * attach this feature
  72911. * Will usually be called by the features manager
  72912. *
  72913. * @returns true if successful.
  72914. */
  72915. attach(): boolean;
  72916. /**
  72917. * detach this feature.
  72918. * Will usually be called by the features manager
  72919. *
  72920. * @returns true if successful.
  72921. */
  72922. detach(): boolean;
  72923. /**
  72924. * Dispose this feature and all of the resources attached
  72925. */
  72926. dispose(): void;
  72927. /**
  72928. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  72929. * @param hitTestModule the hit-test module to use.
  72930. */
  72931. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  72932. /**
  72933. * set the plane detector to use in order to create anchors from frames
  72934. * @param planeDetector the plane-detector module to use
  72935. * @param enable enable plane-anchors. default is true
  72936. */
  72937. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  72938. protected _onXRFrame(frame: XRFrame): void;
  72939. /**
  72940. * avoiding using Array.find for global support.
  72941. * @param xrAnchor the plane to find in the array
  72942. */
  72943. private _findIndexInAnchorArray;
  72944. private _updateAnchorWithXRFrame;
  72945. }
  72946. }
  72947. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  72948. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72949. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72950. import { Observable } from "babylonjs/Misc/observable";
  72951. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72952. /**
  72953. * Options interface for the background remover plugin
  72954. */
  72955. export interface IWebXRBackgroundRemoverOptions {
  72956. /**
  72957. * Further background meshes to disable when entering AR
  72958. */
  72959. backgroundMeshes?: AbstractMesh[];
  72960. /**
  72961. * flags to configure the removal of the environment helper.
  72962. * If not set, the entire background will be removed. If set, flags should be set as well.
  72963. */
  72964. environmentHelperRemovalFlags?: {
  72965. /**
  72966. * Should the skybox be removed (default false)
  72967. */
  72968. skyBox?: boolean;
  72969. /**
  72970. * Should the ground be removed (default false)
  72971. */
  72972. ground?: boolean;
  72973. };
  72974. /**
  72975. * don't disable the environment helper
  72976. */
  72977. ignoreEnvironmentHelper?: boolean;
  72978. }
  72979. /**
  72980. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  72981. */
  72982. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  72983. /**
  72984. * read-only options to be used in this module
  72985. */
  72986. readonly options: IWebXRBackgroundRemoverOptions;
  72987. /**
  72988. * The module's name
  72989. */
  72990. static readonly Name: string;
  72991. /**
  72992. * The (Babylon) version of this module.
  72993. * This is an integer representing the implementation version.
  72994. * This number does not correspond to the WebXR specs version
  72995. */
  72996. static readonly Version: number;
  72997. /**
  72998. * registered observers will be triggered when the background state changes
  72999. */
  73000. onBackgroundStateChangedObservable: Observable<boolean>;
  73001. /**
  73002. * constructs a new background remover module
  73003. * @param _xrSessionManager the session manager for this module
  73004. * @param options read-only options to be used in this module
  73005. */
  73006. constructor(_xrSessionManager: WebXRSessionManager,
  73007. /**
  73008. * read-only options to be used in this module
  73009. */
  73010. options?: IWebXRBackgroundRemoverOptions);
  73011. /**
  73012. * attach this feature
  73013. * Will usually be called by the features manager
  73014. *
  73015. * @returns true if successful.
  73016. */
  73017. attach(): boolean;
  73018. /**
  73019. * detach this feature.
  73020. * Will usually be called by the features manager
  73021. *
  73022. * @returns true if successful.
  73023. */
  73024. detach(): boolean;
  73025. /**
  73026. * Dispose this feature and all of the resources attached
  73027. */
  73028. dispose(): void;
  73029. protected _onXRFrame(_xrFrame: XRFrame): void;
  73030. private _setBackgroundState;
  73031. }
  73032. }
  73033. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  73034. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73035. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  73036. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  73037. import { WebXRInput } from "babylonjs/XR/webXRInput";
  73038. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73039. import { Nullable } from "babylonjs/types";
  73040. /**
  73041. * Options for the controller physics feature
  73042. */
  73043. export class IWebXRControllerPhysicsOptions {
  73044. /**
  73045. * Should the headset get its own impostor
  73046. */
  73047. enableHeadsetImpostor?: boolean;
  73048. /**
  73049. * Optional parameters for the headset impostor
  73050. */
  73051. headsetImpostorParams?: {
  73052. /**
  73053. * The type of impostor to create. Default is sphere
  73054. */
  73055. impostorType: number;
  73056. /**
  73057. * the size of the impostor. Defaults to 10cm
  73058. */
  73059. impostorSize?: number | {
  73060. width: number;
  73061. height: number;
  73062. depth: number;
  73063. };
  73064. /**
  73065. * Friction definitions
  73066. */
  73067. friction?: number;
  73068. /**
  73069. * Restitution
  73070. */
  73071. restitution?: number;
  73072. };
  73073. /**
  73074. * The physics properties of the future impostors
  73075. */
  73076. physicsProperties?: {
  73077. /**
  73078. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  73079. * Note that this requires a physics engine that supports mesh impostors!
  73080. */
  73081. useControllerMesh?: boolean;
  73082. /**
  73083. * The type of impostor to create. Default is sphere
  73084. */
  73085. impostorType?: number;
  73086. /**
  73087. * the size of the impostor. Defaults to 10cm
  73088. */
  73089. impostorSize?: number | {
  73090. width: number;
  73091. height: number;
  73092. depth: number;
  73093. };
  73094. /**
  73095. * Friction definitions
  73096. */
  73097. friction?: number;
  73098. /**
  73099. * Restitution
  73100. */
  73101. restitution?: number;
  73102. };
  73103. /**
  73104. * the xr input to use with this pointer selection
  73105. */
  73106. xrInput: WebXRInput;
  73107. }
  73108. /**
  73109. * Add physics impostor to your webxr controllers,
  73110. * including naive calculation of their linear and angular velocity
  73111. */
  73112. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  73113. private readonly _options;
  73114. private _attachController;
  73115. private _controllers;
  73116. private _debugMode;
  73117. private _delta;
  73118. private _headsetImpostor?;
  73119. private _headsetMesh?;
  73120. private _lastTimestamp;
  73121. private _tmpQuaternion;
  73122. private _tmpVector;
  73123. /**
  73124. * The module's name
  73125. */
  73126. static readonly Name: string;
  73127. /**
  73128. * The (Babylon) version of this module.
  73129. * This is an integer representing the implementation version.
  73130. * This number does not correspond to the webxr specs version
  73131. */
  73132. static readonly Version: number;
  73133. /**
  73134. * Construct a new Controller Physics Feature
  73135. * @param _xrSessionManager the corresponding xr session manager
  73136. * @param _options options to create this feature with
  73137. */
  73138. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  73139. /**
  73140. * @hidden
  73141. * enable debugging - will show console outputs and the impostor mesh
  73142. */
  73143. _enablePhysicsDebug(): void;
  73144. /**
  73145. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  73146. * @param xrController the controller to add
  73147. */
  73148. addController(xrController: WebXRInputSource): void;
  73149. /**
  73150. * attach this feature
  73151. * Will usually be called by the features manager
  73152. *
  73153. * @returns true if successful.
  73154. */
  73155. attach(): boolean;
  73156. /**
  73157. * detach this feature.
  73158. * Will usually be called by the features manager
  73159. *
  73160. * @returns true if successful.
  73161. */
  73162. detach(): boolean;
  73163. /**
  73164. * Get the headset impostor, if enabled
  73165. * @returns the impostor
  73166. */
  73167. getHeadsetImpostor(): PhysicsImpostor | undefined;
  73168. /**
  73169. * Get the physics impostor of a specific controller.
  73170. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  73171. * @param controller the controller or the controller id of which to get the impostor
  73172. * @returns the impostor or null
  73173. */
  73174. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  73175. /**
  73176. * Update the physics properties provided in the constructor
  73177. * @param newProperties the new properties object
  73178. */
  73179. setPhysicsProperties(newProperties: {
  73180. impostorType?: number;
  73181. impostorSize?: number | {
  73182. width: number;
  73183. height: number;
  73184. depth: number;
  73185. };
  73186. friction?: number;
  73187. restitution?: number;
  73188. }): void;
  73189. protected _onXRFrame(_xrFrame: any): void;
  73190. private _detachController;
  73191. }
  73192. }
  73193. declare module "babylonjs/XR/features/index" {
  73194. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  73195. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  73196. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  73197. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  73198. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  73199. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  73200. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  73201. }
  73202. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  73203. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73205. import { Scene } from "babylonjs/scene";
  73206. /**
  73207. * The motion controller class for all microsoft mixed reality controllers
  73208. */
  73209. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  73210. protected readonly _mapping: {
  73211. defaultButton: {
  73212. "valueNodeName": string;
  73213. "unpressedNodeName": string;
  73214. "pressedNodeName": string;
  73215. };
  73216. defaultAxis: {
  73217. "valueNodeName": string;
  73218. "minNodeName": string;
  73219. "maxNodeName": string;
  73220. };
  73221. buttons: {
  73222. "xr-standard-trigger": {
  73223. "rootNodeName": string;
  73224. "componentProperty": string;
  73225. "states": string[];
  73226. };
  73227. "xr-standard-squeeze": {
  73228. "rootNodeName": string;
  73229. "componentProperty": string;
  73230. "states": string[];
  73231. };
  73232. "xr-standard-touchpad": {
  73233. "rootNodeName": string;
  73234. "labelAnchorNodeName": string;
  73235. "touchPointNodeName": string;
  73236. };
  73237. "xr-standard-thumbstick": {
  73238. "rootNodeName": string;
  73239. "componentProperty": string;
  73240. "states": string[];
  73241. };
  73242. };
  73243. axes: {
  73244. "xr-standard-touchpad": {
  73245. "x-axis": {
  73246. "rootNodeName": string;
  73247. };
  73248. "y-axis": {
  73249. "rootNodeName": string;
  73250. };
  73251. };
  73252. "xr-standard-thumbstick": {
  73253. "x-axis": {
  73254. "rootNodeName": string;
  73255. };
  73256. "y-axis": {
  73257. "rootNodeName": string;
  73258. };
  73259. };
  73260. };
  73261. };
  73262. /**
  73263. * The base url used to load the left and right controller models
  73264. */
  73265. static MODEL_BASE_URL: string;
  73266. /**
  73267. * The name of the left controller model file
  73268. */
  73269. static MODEL_LEFT_FILENAME: string;
  73270. /**
  73271. * The name of the right controller model file
  73272. */
  73273. static MODEL_RIGHT_FILENAME: string;
  73274. profileId: string;
  73275. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  73276. protected _getFilenameAndPath(): {
  73277. filename: string;
  73278. path: string;
  73279. };
  73280. protected _getModelLoadingConstraints(): boolean;
  73281. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73282. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73283. protected _updateModel(): void;
  73284. }
  73285. }
  73286. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  73287. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73288. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73289. import { Scene } from "babylonjs/scene";
  73290. /**
  73291. * The motion controller class for oculus touch (quest, rift).
  73292. * This class supports legacy mapping as well the standard xr mapping
  73293. */
  73294. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  73295. private _forceLegacyControllers;
  73296. private _modelRootNode;
  73297. /**
  73298. * The base url used to load the left and right controller models
  73299. */
  73300. static MODEL_BASE_URL: string;
  73301. /**
  73302. * The name of the left controller model file
  73303. */
  73304. static MODEL_LEFT_FILENAME: string;
  73305. /**
  73306. * The name of the right controller model file
  73307. */
  73308. static MODEL_RIGHT_FILENAME: string;
  73309. /**
  73310. * Base Url for the Quest controller model.
  73311. */
  73312. static QUEST_MODEL_BASE_URL: string;
  73313. profileId: string;
  73314. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  73315. protected _getFilenameAndPath(): {
  73316. filename: string;
  73317. path: string;
  73318. };
  73319. protected _getModelLoadingConstraints(): boolean;
  73320. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73321. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73322. protected _updateModel(): void;
  73323. /**
  73324. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  73325. * between the touch and touch 2.
  73326. */
  73327. private _isQuest;
  73328. }
  73329. }
  73330. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  73331. import { IMinimalMotionControllerObject, MotionControllerHandness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73332. import { Scene } from "babylonjs/scene";
  73333. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73334. /**
  73335. * The motion controller class for the standard HTC-Vive controllers
  73336. */
  73337. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  73338. private _modelRootNode;
  73339. /**
  73340. * The base url used to load the left and right controller models
  73341. */
  73342. static MODEL_BASE_URL: string;
  73343. /**
  73344. * File name for the controller model.
  73345. */
  73346. static MODEL_FILENAME: string;
  73347. profileId: string;
  73348. /**
  73349. * Create a new Vive motion controller object
  73350. * @param scene the scene to use to create this controller
  73351. * @param gamepadObject the corresponding gamepad object
  73352. * @param handness the handness of the controller
  73353. */
  73354. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  73355. protected _getFilenameAndPath(): {
  73356. filename: string;
  73357. path: string;
  73358. };
  73359. protected _getModelLoadingConstraints(): boolean;
  73360. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73361. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73362. protected _updateModel(): void;
  73363. }
  73364. }
  73365. declare module "babylonjs/XR/motionController/index" {
  73366. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73367. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  73368. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  73369. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  73370. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  73371. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  73372. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  73373. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  73374. }
  73375. declare module "babylonjs/XR/index" {
  73376. export * from "babylonjs/XR/webXRCamera";
  73377. export * from "babylonjs/XR/webXREnterExitUI";
  73378. export * from "babylonjs/XR/webXRExperienceHelper";
  73379. export * from "babylonjs/XR/webXRInput";
  73380. export * from "babylonjs/XR/webXRInputSource";
  73381. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  73382. export * from "babylonjs/XR/webXRTypes";
  73383. export * from "babylonjs/XR/webXRSessionManager";
  73384. export * from "babylonjs/XR/webXRDefaultExperience";
  73385. export * from "babylonjs/XR/webXRFeaturesManager";
  73386. export * from "babylonjs/XR/features/index";
  73387. export * from "babylonjs/XR/motionController/index";
  73388. }
  73389. declare module "babylonjs/index" {
  73390. export * from "babylonjs/abstractScene";
  73391. export * from "babylonjs/Actions/index";
  73392. export * from "babylonjs/Animations/index";
  73393. export * from "babylonjs/assetContainer";
  73394. export * from "babylonjs/Audio/index";
  73395. export * from "babylonjs/Behaviors/index";
  73396. export * from "babylonjs/Bones/index";
  73397. export * from "babylonjs/Cameras/index";
  73398. export * from "babylonjs/Collisions/index";
  73399. export * from "babylonjs/Culling/index";
  73400. export * from "babylonjs/Debug/index";
  73401. export * from "babylonjs/Engines/index";
  73402. export * from "babylonjs/Events/index";
  73403. export * from "babylonjs/Gamepads/index";
  73404. export * from "babylonjs/Gizmos/index";
  73405. export * from "babylonjs/Helpers/index";
  73406. export * from "babylonjs/Instrumentation/index";
  73407. export * from "babylonjs/Layers/index";
  73408. export * from "babylonjs/LensFlares/index";
  73409. export * from "babylonjs/Lights/index";
  73410. export * from "babylonjs/Loading/index";
  73411. export * from "babylonjs/Materials/index";
  73412. export * from "babylonjs/Maths/index";
  73413. export * from "babylonjs/Meshes/index";
  73414. export * from "babylonjs/Morph/index";
  73415. export * from "babylonjs/Navigation/index";
  73416. export * from "babylonjs/node";
  73417. export * from "babylonjs/Offline/index";
  73418. export * from "babylonjs/Particles/index";
  73419. export * from "babylonjs/Physics/index";
  73420. export * from "babylonjs/PostProcesses/index";
  73421. export * from "babylonjs/Probes/index";
  73422. export * from "babylonjs/Rendering/index";
  73423. export * from "babylonjs/scene";
  73424. export * from "babylonjs/sceneComponent";
  73425. export * from "babylonjs/Sprites/index";
  73426. export * from "babylonjs/States/index";
  73427. export * from "babylonjs/Misc/index";
  73428. export * from "babylonjs/XR/index";
  73429. export * from "babylonjs/types";
  73430. }
  73431. declare module "babylonjs/Animations/pathCursor" {
  73432. import { Vector3 } from "babylonjs/Maths/math.vector";
  73433. import { Path2 } from "babylonjs/Maths/math.path";
  73434. /**
  73435. * A cursor which tracks a point on a path
  73436. */
  73437. export class PathCursor {
  73438. private path;
  73439. /**
  73440. * Stores path cursor callbacks for when an onchange event is triggered
  73441. */
  73442. private _onchange;
  73443. /**
  73444. * The value of the path cursor
  73445. */
  73446. value: number;
  73447. /**
  73448. * The animation array of the path cursor
  73449. */
  73450. animations: Animation[];
  73451. /**
  73452. * Initializes the path cursor
  73453. * @param path The path to track
  73454. */
  73455. constructor(path: Path2);
  73456. /**
  73457. * Gets the cursor point on the path
  73458. * @returns A point on the path cursor at the cursor location
  73459. */
  73460. getPoint(): Vector3;
  73461. /**
  73462. * Moves the cursor ahead by the step amount
  73463. * @param step The amount to move the cursor forward
  73464. * @returns This path cursor
  73465. */
  73466. moveAhead(step?: number): PathCursor;
  73467. /**
  73468. * Moves the cursor behind by the step amount
  73469. * @param step The amount to move the cursor back
  73470. * @returns This path cursor
  73471. */
  73472. moveBack(step?: number): PathCursor;
  73473. /**
  73474. * Moves the cursor by the step amount
  73475. * If the step amount is greater than one, an exception is thrown
  73476. * @param step The amount to move the cursor
  73477. * @returns This path cursor
  73478. */
  73479. move(step: number): PathCursor;
  73480. /**
  73481. * Ensures that the value is limited between zero and one
  73482. * @returns This path cursor
  73483. */
  73484. private ensureLimits;
  73485. /**
  73486. * Runs onchange callbacks on change (used by the animation engine)
  73487. * @returns This path cursor
  73488. */
  73489. private raiseOnChange;
  73490. /**
  73491. * Executes a function on change
  73492. * @param f A path cursor onchange callback
  73493. * @returns This path cursor
  73494. */
  73495. onchange(f: (cursor: PathCursor) => void): PathCursor;
  73496. }
  73497. }
  73498. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  73499. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  73500. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  73501. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  73502. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  73503. }
  73504. declare module "babylonjs/Engines/Processors/Expressions/index" {
  73505. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  73506. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  73507. }
  73508. declare module "babylonjs/Engines/Processors/index" {
  73509. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  73510. export * from "babylonjs/Engines/Processors/Expressions/index";
  73511. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  73512. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  73513. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  73514. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  73515. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  73516. export * from "babylonjs/Engines/Processors/shaderProcessor";
  73517. }
  73518. declare module "babylonjs/Legacy/legacy" {
  73519. import * as Babylon from "babylonjs/index";
  73520. export * from "babylonjs/index";
  73521. }
  73522. declare module "babylonjs/Shaders/blur.fragment" {
  73523. /** @hidden */
  73524. export var blurPixelShader: {
  73525. name: string;
  73526. shader: string;
  73527. };
  73528. }
  73529. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  73530. /** @hidden */
  73531. export var pointCloudVertexDeclaration: {
  73532. name: string;
  73533. shader: string;
  73534. };
  73535. }
  73536. declare module "babylonjs" {
  73537. export * from "babylonjs/Legacy/legacy";
  73538. }
  73539. declare module BABYLON {
  73540. /** Alias type for value that can be null */
  73541. export type Nullable<T> = T | null;
  73542. /**
  73543. * Alias type for number that are floats
  73544. * @ignorenaming
  73545. */
  73546. export type float = number;
  73547. /**
  73548. * Alias type for number that are doubles.
  73549. * @ignorenaming
  73550. */
  73551. export type double = number;
  73552. /**
  73553. * Alias type for number that are integer
  73554. * @ignorenaming
  73555. */
  73556. export type int = number;
  73557. /** Alias type for number array or Float32Array */
  73558. export type FloatArray = number[] | Float32Array;
  73559. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  73560. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  73561. /**
  73562. * Alias for types that can be used by a Buffer or VertexBuffer.
  73563. */
  73564. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  73565. /**
  73566. * Alias type for primitive types
  73567. * @ignorenaming
  73568. */
  73569. type Primitive = undefined | null | boolean | string | number | Function;
  73570. /**
  73571. * Type modifier to make all the properties of an object Readonly
  73572. */
  73573. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  73574. /**
  73575. * Type modifier to make all the properties of an object Readonly recursively
  73576. */
  73577. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  73578. /**
  73579. * Type modifier to make object properties readonly.
  73580. */
  73581. export type DeepImmutableObject<T> = {
  73582. readonly [K in keyof T]: DeepImmutable<T[K]>;
  73583. };
  73584. /** @hidden */
  73585. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  73586. }
  73587. }
  73588. declare module BABYLON {
  73589. /**
  73590. * A class serves as a medium between the observable and its observers
  73591. */
  73592. export class EventState {
  73593. /**
  73594. * Create a new EventState
  73595. * @param mask defines the mask associated with this state
  73596. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  73597. * @param target defines the original target of the state
  73598. * @param currentTarget defines the current target of the state
  73599. */
  73600. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  73601. /**
  73602. * Initialize the current event state
  73603. * @param mask defines the mask associated with this state
  73604. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  73605. * @param target defines the original target of the state
  73606. * @param currentTarget defines the current target of the state
  73607. * @returns the current event state
  73608. */
  73609. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73610. /**
  73611. * An Observer can set this property to true to prevent subsequent observers of being notified
  73612. */
  73613. skipNextObservers: boolean;
  73614. /**
  73615. * Get the mask value that were used to trigger the event corresponding to this EventState object
  73616. */
  73617. mask: number;
  73618. /**
  73619. * The object that originally notified the event
  73620. */
  73621. target?: any;
  73622. /**
  73623. * The current object in the bubbling phase
  73624. */
  73625. currentTarget?: any;
  73626. /**
  73627. * This will be populated with the return value of the last function that was executed.
  73628. * If it is the first function in the callback chain it will be the event data.
  73629. */
  73630. lastReturnValue?: any;
  73631. }
  73632. /**
  73633. * Represent an Observer registered to a given Observable object.
  73634. */
  73635. export class Observer<T> {
  73636. /**
  73637. * Defines the callback to call when the observer is notified
  73638. */
  73639. callback: (eventData: T, eventState: EventState) => void;
  73640. /**
  73641. * Defines the mask of the observer (used to filter notifications)
  73642. */
  73643. mask: number;
  73644. /**
  73645. * Defines the current scope used to restore the JS context
  73646. */
  73647. scope: any;
  73648. /** @hidden */
  73649. _willBeUnregistered: boolean;
  73650. /**
  73651. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  73652. */
  73653. unregisterOnNextCall: boolean;
  73654. /**
  73655. * Creates a new observer
  73656. * @param callback defines the callback to call when the observer is notified
  73657. * @param mask defines the mask of the observer (used to filter notifications)
  73658. * @param scope defines the current scope used to restore the JS context
  73659. */
  73660. constructor(
  73661. /**
  73662. * Defines the callback to call when the observer is notified
  73663. */
  73664. callback: (eventData: T, eventState: EventState) => void,
  73665. /**
  73666. * Defines the mask of the observer (used to filter notifications)
  73667. */
  73668. mask: number,
  73669. /**
  73670. * Defines the current scope used to restore the JS context
  73671. */
  73672. scope?: any);
  73673. }
  73674. /**
  73675. * Represent a list of observers registered to multiple Observables object.
  73676. */
  73677. export class MultiObserver<T> {
  73678. private _observers;
  73679. private _observables;
  73680. /**
  73681. * Release associated resources
  73682. */
  73683. dispose(): void;
  73684. /**
  73685. * Raise a callback when one of the observable will notify
  73686. * @param observables defines a list of observables to watch
  73687. * @param callback defines the callback to call on notification
  73688. * @param mask defines the mask used to filter notifications
  73689. * @param scope defines the current scope used to restore the JS context
  73690. * @returns the new MultiObserver
  73691. */
  73692. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  73693. }
  73694. /**
  73695. * The Observable class is a simple implementation of the Observable pattern.
  73696. *
  73697. * 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.
  73698. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  73699. * 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).
  73700. * 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.
  73701. */
  73702. export class Observable<T> {
  73703. private _observers;
  73704. private _eventState;
  73705. private _onObserverAdded;
  73706. /**
  73707. * Gets the list of observers
  73708. */
  73709. get observers(): Array<Observer<T>>;
  73710. /**
  73711. * Creates a new observable
  73712. * @param onObserverAdded defines a callback to call when a new observer is added
  73713. */
  73714. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  73715. /**
  73716. * Create a new Observer with the specified callback
  73717. * @param callback the callback that will be executed for that Observer
  73718. * @param mask the mask used to filter observers
  73719. * @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.
  73720. * @param scope optional scope for the callback to be called from
  73721. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  73722. * @returns the new observer created for the callback
  73723. */
  73724. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  73725. /**
  73726. * Create a new Observer with the specified callback and unregisters after the next notification
  73727. * @param callback the callback that will be executed for that Observer
  73728. * @returns the new observer created for the callback
  73729. */
  73730. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  73731. /**
  73732. * Remove an Observer from the Observable object
  73733. * @param observer the instance of the Observer to remove
  73734. * @returns false if it doesn't belong to this Observable
  73735. */
  73736. remove(observer: Nullable<Observer<T>>): boolean;
  73737. /**
  73738. * Remove a callback from the Observable object
  73739. * @param callback the callback to remove
  73740. * @param scope optional scope. If used only the callbacks with this scope will be removed
  73741. * @returns false if it doesn't belong to this Observable
  73742. */
  73743. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  73744. private _deferUnregister;
  73745. private _remove;
  73746. /**
  73747. * Moves the observable to the top of the observer list making it get called first when notified
  73748. * @param observer the observer to move
  73749. */
  73750. makeObserverTopPriority(observer: Observer<T>): void;
  73751. /**
  73752. * Moves the observable to the bottom of the observer list making it get called last when notified
  73753. * @param observer the observer to move
  73754. */
  73755. makeObserverBottomPriority(observer: Observer<T>): void;
  73756. /**
  73757. * Notify all Observers by calling their respective callback with the given data
  73758. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  73759. * @param eventData defines the data to send to all observers
  73760. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  73761. * @param target defines the original target of the state
  73762. * @param currentTarget defines the current target of the state
  73763. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  73764. */
  73765. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  73766. /**
  73767. * Calling this will execute each callback, expecting it to be a promise or return a value.
  73768. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  73769. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  73770. * and it is crucial that all callbacks will be executed.
  73771. * The order of the callbacks is kept, callbacks are not executed parallel.
  73772. *
  73773. * @param eventData The data to be sent to each callback
  73774. * @param mask is used to filter observers defaults to -1
  73775. * @param target defines the callback target (see EventState)
  73776. * @param currentTarget defines he current object in the bubbling phase
  73777. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  73778. */
  73779. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  73780. /**
  73781. * Notify a specific observer
  73782. * @param observer defines the observer to notify
  73783. * @param eventData defines the data to be sent to each callback
  73784. * @param mask is used to filter observers defaults to -1
  73785. */
  73786. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  73787. /**
  73788. * Gets a boolean indicating if the observable has at least one observer
  73789. * @returns true is the Observable has at least one Observer registered
  73790. */
  73791. hasObservers(): boolean;
  73792. /**
  73793. * Clear the list of observers
  73794. */
  73795. clear(): void;
  73796. /**
  73797. * Clone the current observable
  73798. * @returns a new observable
  73799. */
  73800. clone(): Observable<T>;
  73801. /**
  73802. * Does this observable handles observer registered with a given mask
  73803. * @param mask defines the mask to be tested
  73804. * @return whether or not one observer registered with the given mask is handeled
  73805. **/
  73806. hasSpecificMask(mask?: number): boolean;
  73807. }
  73808. }
  73809. declare module BABYLON {
  73810. /**
  73811. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  73812. * Babylon.js
  73813. */
  73814. export class DomManagement {
  73815. /**
  73816. * Checks if the window object exists
  73817. * @returns true if the window object exists
  73818. */
  73819. static IsWindowObjectExist(): boolean;
  73820. /**
  73821. * Checks if the navigator object exists
  73822. * @returns true if the navigator object exists
  73823. */
  73824. static IsNavigatorAvailable(): boolean;
  73825. /**
  73826. * Extracts text content from a DOM element hierarchy
  73827. * @param element defines the root element
  73828. * @returns a string
  73829. */
  73830. static GetDOMTextContent(element: HTMLElement): string;
  73831. }
  73832. }
  73833. declare module BABYLON {
  73834. /**
  73835. * Logger used througouht the application to allow configuration of
  73836. * the log level required for the messages.
  73837. */
  73838. export class Logger {
  73839. /**
  73840. * No log
  73841. */
  73842. static readonly NoneLogLevel: number;
  73843. /**
  73844. * Only message logs
  73845. */
  73846. static readonly MessageLogLevel: number;
  73847. /**
  73848. * Only warning logs
  73849. */
  73850. static readonly WarningLogLevel: number;
  73851. /**
  73852. * Only error logs
  73853. */
  73854. static readonly ErrorLogLevel: number;
  73855. /**
  73856. * All logs
  73857. */
  73858. static readonly AllLogLevel: number;
  73859. private static _LogCache;
  73860. /**
  73861. * Gets a value indicating the number of loading errors
  73862. * @ignorenaming
  73863. */
  73864. static errorsCount: number;
  73865. /**
  73866. * Callback called when a new log is added
  73867. */
  73868. static OnNewCacheEntry: (entry: string) => void;
  73869. private static _AddLogEntry;
  73870. private static _FormatMessage;
  73871. private static _LogDisabled;
  73872. private static _LogEnabled;
  73873. private static _WarnDisabled;
  73874. private static _WarnEnabled;
  73875. private static _ErrorDisabled;
  73876. private static _ErrorEnabled;
  73877. /**
  73878. * Log a message to the console
  73879. */
  73880. static Log: (message: string) => void;
  73881. /**
  73882. * Write a warning message to the console
  73883. */
  73884. static Warn: (message: string) => void;
  73885. /**
  73886. * Write an error message to the console
  73887. */
  73888. static Error: (message: string) => void;
  73889. /**
  73890. * Gets current log cache (list of logs)
  73891. */
  73892. static get LogCache(): string;
  73893. /**
  73894. * Clears the log cache
  73895. */
  73896. static ClearLogCache(): void;
  73897. /**
  73898. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  73899. */
  73900. static set LogLevels(level: number);
  73901. }
  73902. }
  73903. declare module BABYLON {
  73904. /** @hidden */
  73905. export class _TypeStore {
  73906. /** @hidden */
  73907. static RegisteredTypes: {
  73908. [key: string]: Object;
  73909. };
  73910. /** @hidden */
  73911. static GetClass(fqdn: string): any;
  73912. }
  73913. }
  73914. declare module BABYLON {
  73915. /**
  73916. * Helper to manipulate strings
  73917. */
  73918. export class StringTools {
  73919. /**
  73920. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  73921. * @param str Source string
  73922. * @param suffix Suffix to search for in the source string
  73923. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73924. */
  73925. static EndsWith(str: string, suffix: string): boolean;
  73926. /**
  73927. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  73928. * @param str Source string
  73929. * @param suffix Suffix to search for in the source string
  73930. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73931. */
  73932. static StartsWith(str: string, suffix: string): boolean;
  73933. /**
  73934. * Decodes a buffer into a string
  73935. * @param buffer The buffer to decode
  73936. * @returns The decoded string
  73937. */
  73938. static Decode(buffer: Uint8Array | Uint16Array): string;
  73939. /**
  73940. * Encode a buffer to a base64 string
  73941. * @param buffer defines the buffer to encode
  73942. * @returns the encoded string
  73943. */
  73944. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  73945. /**
  73946. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  73947. * @param num the number to convert and pad
  73948. * @param length the expected length of the string
  73949. * @returns the padded string
  73950. */
  73951. static PadNumber(num: number, length: number): string;
  73952. }
  73953. }
  73954. declare module BABYLON {
  73955. /**
  73956. * Class containing a set of static utilities functions for deep copy.
  73957. */
  73958. export class DeepCopier {
  73959. /**
  73960. * Tries to copy an object by duplicating every property
  73961. * @param source defines the source object
  73962. * @param destination defines the target object
  73963. * @param doNotCopyList defines a list of properties to avoid
  73964. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  73965. */
  73966. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  73967. }
  73968. }
  73969. declare module BABYLON {
  73970. /**
  73971. * Class containing a set of static utilities functions for precision date
  73972. */
  73973. export class PrecisionDate {
  73974. /**
  73975. * Gets either window.performance.now() if supported or Date.now() else
  73976. */
  73977. static get Now(): number;
  73978. }
  73979. }
  73980. declare module BABYLON {
  73981. /** @hidden */
  73982. export class _DevTools {
  73983. static WarnImport(name: string): string;
  73984. }
  73985. }
  73986. declare module BABYLON {
  73987. /**
  73988. * Interface used to define the mechanism to get data from the network
  73989. */
  73990. export interface IWebRequest {
  73991. /**
  73992. * Returns client's response url
  73993. */
  73994. responseURL: string;
  73995. /**
  73996. * Returns client's status
  73997. */
  73998. status: number;
  73999. /**
  74000. * Returns client's status as a text
  74001. */
  74002. statusText: string;
  74003. }
  74004. }
  74005. declare module BABYLON {
  74006. /**
  74007. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  74008. */
  74009. export class WebRequest implements IWebRequest {
  74010. private _xhr;
  74011. /**
  74012. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  74013. * i.e. when loading files, where the server/service expects an Authorization header
  74014. */
  74015. static CustomRequestHeaders: {
  74016. [key: string]: string;
  74017. };
  74018. /**
  74019. * Add callback functions in this array to update all the requests before they get sent to the network
  74020. */
  74021. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  74022. private _injectCustomRequestHeaders;
  74023. /**
  74024. * Gets or sets a function to be called when loading progress changes
  74025. */
  74026. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  74027. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  74028. /**
  74029. * Returns client's state
  74030. */
  74031. get readyState(): number;
  74032. /**
  74033. * Returns client's status
  74034. */
  74035. get status(): number;
  74036. /**
  74037. * Returns client's status as a text
  74038. */
  74039. get statusText(): string;
  74040. /**
  74041. * Returns client's response
  74042. */
  74043. get response(): any;
  74044. /**
  74045. * Returns client's response url
  74046. */
  74047. get responseURL(): string;
  74048. /**
  74049. * Returns client's response as text
  74050. */
  74051. get responseText(): string;
  74052. /**
  74053. * Gets or sets the expected response type
  74054. */
  74055. get responseType(): XMLHttpRequestResponseType;
  74056. set responseType(value: XMLHttpRequestResponseType);
  74057. /** @hidden */
  74058. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  74059. /** @hidden */
  74060. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  74061. /**
  74062. * Cancels any network activity
  74063. */
  74064. abort(): void;
  74065. /**
  74066. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  74067. * @param body defines an optional request body
  74068. */
  74069. send(body?: Document | BodyInit | null): void;
  74070. /**
  74071. * Sets the request method, request URL
  74072. * @param method defines the method to use (GET, POST, etc..)
  74073. * @param url defines the url to connect with
  74074. */
  74075. open(method: string, url: string): void;
  74076. /**
  74077. * Sets the value of a request header.
  74078. * @param name The name of the header whose value is to be set
  74079. * @param value The value to set as the body of the header
  74080. */
  74081. setRequestHeader(name: string, value: string): void;
  74082. /**
  74083. * Get the string containing the text of a particular header's value.
  74084. * @param name The name of the header
  74085. * @returns The string containing the text of the given header name
  74086. */
  74087. getResponseHeader(name: string): Nullable<string>;
  74088. }
  74089. }
  74090. declare module BABYLON {
  74091. /**
  74092. * File request interface
  74093. */
  74094. export interface IFileRequest {
  74095. /**
  74096. * Raised when the request is complete (success or error).
  74097. */
  74098. onCompleteObservable: Observable<IFileRequest>;
  74099. /**
  74100. * Aborts the request for a file.
  74101. */
  74102. abort: () => void;
  74103. }
  74104. }
  74105. declare module BABYLON {
  74106. /**
  74107. * Define options used to create a render target texture
  74108. */
  74109. export class RenderTargetCreationOptions {
  74110. /**
  74111. * Specifies is mipmaps must be generated
  74112. */
  74113. generateMipMaps?: boolean;
  74114. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  74115. generateDepthBuffer?: boolean;
  74116. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  74117. generateStencilBuffer?: boolean;
  74118. /** Defines texture type (int by default) */
  74119. type?: number;
  74120. /** Defines sampling mode (trilinear by default) */
  74121. samplingMode?: number;
  74122. /** Defines format (RGBA by default) */
  74123. format?: number;
  74124. }
  74125. }
  74126. declare module BABYLON {
  74127. /** Defines the cross module used constants to avoid circular dependncies */
  74128. export class Constants {
  74129. /** Defines that alpha blending is disabled */
  74130. static readonly ALPHA_DISABLE: number;
  74131. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  74132. static readonly ALPHA_ADD: number;
  74133. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  74134. static readonly ALPHA_COMBINE: number;
  74135. /** Defines that alpha blending is DEST - SRC * DEST */
  74136. static readonly ALPHA_SUBTRACT: number;
  74137. /** Defines that alpha blending is SRC * DEST */
  74138. static readonly ALPHA_MULTIPLY: number;
  74139. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  74140. static readonly ALPHA_MAXIMIZED: number;
  74141. /** Defines that alpha blending is SRC + DEST */
  74142. static readonly ALPHA_ONEONE: number;
  74143. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  74144. static readonly ALPHA_PREMULTIPLIED: number;
  74145. /**
  74146. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  74147. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  74148. */
  74149. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  74150. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  74151. static readonly ALPHA_INTERPOLATE: number;
  74152. /**
  74153. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  74154. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  74155. */
  74156. static readonly ALPHA_SCREENMODE: number;
  74157. /**
  74158. * Defines that alpha blending is SRC + DST
  74159. * Alpha will be set to SRC ALPHA + DST ALPHA
  74160. */
  74161. static readonly ALPHA_ONEONE_ONEONE: number;
  74162. /**
  74163. * Defines that alpha blending is SRC * DST ALPHA + DST
  74164. * Alpha will be set to 0
  74165. */
  74166. static readonly ALPHA_ALPHATOCOLOR: number;
  74167. /**
  74168. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  74169. */
  74170. static readonly ALPHA_REVERSEONEMINUS: number;
  74171. /**
  74172. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  74173. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  74174. */
  74175. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  74176. /**
  74177. * Defines that alpha blending is SRC + DST
  74178. * Alpha will be set to SRC ALPHA
  74179. */
  74180. static readonly ALPHA_ONEONE_ONEZERO: number;
  74181. /**
  74182. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  74183. * Alpha will be set to DST ALPHA
  74184. */
  74185. static readonly ALPHA_EXCLUSION: number;
  74186. /** Defines that alpha blending equation a SUM */
  74187. static readonly ALPHA_EQUATION_ADD: number;
  74188. /** Defines that alpha blending equation a SUBSTRACTION */
  74189. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  74190. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  74191. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  74192. /** Defines that alpha blending equation a MAX operation */
  74193. static readonly ALPHA_EQUATION_MAX: number;
  74194. /** Defines that alpha blending equation a MIN operation */
  74195. static readonly ALPHA_EQUATION_MIN: number;
  74196. /**
  74197. * Defines that alpha blending equation a DARKEN operation:
  74198. * It takes the min of the src and sums the alpha channels.
  74199. */
  74200. static readonly ALPHA_EQUATION_DARKEN: number;
  74201. /** Defines that the ressource is not delayed*/
  74202. static readonly DELAYLOADSTATE_NONE: number;
  74203. /** Defines that the ressource was successfully delay loaded */
  74204. static readonly DELAYLOADSTATE_LOADED: number;
  74205. /** Defines that the ressource is currently delay loading */
  74206. static readonly DELAYLOADSTATE_LOADING: number;
  74207. /** Defines that the ressource is delayed and has not started loading */
  74208. static readonly DELAYLOADSTATE_NOTLOADED: number;
  74209. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  74210. static readonly NEVER: number;
  74211. /** 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 */
  74212. static readonly ALWAYS: number;
  74213. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  74214. static readonly LESS: number;
  74215. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  74216. static readonly EQUAL: number;
  74217. /** 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 */
  74218. static readonly LEQUAL: number;
  74219. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  74220. static readonly GREATER: number;
  74221. /** 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 */
  74222. static readonly GEQUAL: number;
  74223. /** 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 */
  74224. static readonly NOTEQUAL: number;
  74225. /** Passed to stencilOperation to specify that stencil value must be kept */
  74226. static readonly KEEP: number;
  74227. /** Passed to stencilOperation to specify that stencil value must be replaced */
  74228. static readonly REPLACE: number;
  74229. /** Passed to stencilOperation to specify that stencil value must be incremented */
  74230. static readonly INCR: number;
  74231. /** Passed to stencilOperation to specify that stencil value must be decremented */
  74232. static readonly DECR: number;
  74233. /** Passed to stencilOperation to specify that stencil value must be inverted */
  74234. static readonly INVERT: number;
  74235. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  74236. static readonly INCR_WRAP: number;
  74237. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  74238. static readonly DECR_WRAP: number;
  74239. /** Texture is not repeating outside of 0..1 UVs */
  74240. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  74241. /** Texture is repeating outside of 0..1 UVs */
  74242. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  74243. /** Texture is repeating and mirrored */
  74244. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  74245. /** ALPHA */
  74246. static readonly TEXTUREFORMAT_ALPHA: number;
  74247. /** LUMINANCE */
  74248. static readonly TEXTUREFORMAT_LUMINANCE: number;
  74249. /** LUMINANCE_ALPHA */
  74250. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  74251. /** RGB */
  74252. static readonly TEXTUREFORMAT_RGB: number;
  74253. /** RGBA */
  74254. static readonly TEXTUREFORMAT_RGBA: number;
  74255. /** RED */
  74256. static readonly TEXTUREFORMAT_RED: number;
  74257. /** RED (2nd reference) */
  74258. static readonly TEXTUREFORMAT_R: number;
  74259. /** RG */
  74260. static readonly TEXTUREFORMAT_RG: number;
  74261. /** RED_INTEGER */
  74262. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  74263. /** RED_INTEGER (2nd reference) */
  74264. static readonly TEXTUREFORMAT_R_INTEGER: number;
  74265. /** RG_INTEGER */
  74266. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  74267. /** RGB_INTEGER */
  74268. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  74269. /** RGBA_INTEGER */
  74270. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  74271. /** UNSIGNED_BYTE */
  74272. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  74273. /** UNSIGNED_BYTE (2nd reference) */
  74274. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  74275. /** FLOAT */
  74276. static readonly TEXTURETYPE_FLOAT: number;
  74277. /** HALF_FLOAT */
  74278. static readonly TEXTURETYPE_HALF_FLOAT: number;
  74279. /** BYTE */
  74280. static readonly TEXTURETYPE_BYTE: number;
  74281. /** SHORT */
  74282. static readonly TEXTURETYPE_SHORT: number;
  74283. /** UNSIGNED_SHORT */
  74284. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  74285. /** INT */
  74286. static readonly TEXTURETYPE_INT: number;
  74287. /** UNSIGNED_INT */
  74288. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  74289. /** UNSIGNED_SHORT_4_4_4_4 */
  74290. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  74291. /** UNSIGNED_SHORT_5_5_5_1 */
  74292. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  74293. /** UNSIGNED_SHORT_5_6_5 */
  74294. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  74295. /** UNSIGNED_INT_2_10_10_10_REV */
  74296. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  74297. /** UNSIGNED_INT_24_8 */
  74298. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  74299. /** UNSIGNED_INT_10F_11F_11F_REV */
  74300. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  74301. /** UNSIGNED_INT_5_9_9_9_REV */
  74302. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  74303. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  74304. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  74305. /** nearest is mag = nearest and min = nearest and no mip */
  74306. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  74307. /** mag = nearest and min = nearest and mip = none */
  74308. static readonly TEXTURE_NEAREST_NEAREST: number;
  74309. /** Bilinear is mag = linear and min = linear and no mip */
  74310. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  74311. /** mag = linear and min = linear and mip = none */
  74312. static readonly TEXTURE_LINEAR_LINEAR: number;
  74313. /** Trilinear is mag = linear and min = linear and mip = linear */
  74314. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  74315. /** Trilinear is mag = linear and min = linear and mip = linear */
  74316. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  74317. /** mag = nearest and min = nearest and mip = nearest */
  74318. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  74319. /** mag = nearest and min = linear and mip = nearest */
  74320. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  74321. /** mag = nearest and min = linear and mip = linear */
  74322. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  74323. /** mag = nearest and min = linear and mip = none */
  74324. static readonly TEXTURE_NEAREST_LINEAR: number;
  74325. /** nearest is mag = nearest and min = nearest and mip = linear */
  74326. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  74327. /** mag = linear and min = nearest and mip = nearest */
  74328. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  74329. /** mag = linear and min = nearest and mip = linear */
  74330. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  74331. /** Bilinear is mag = linear and min = linear and mip = nearest */
  74332. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  74333. /** mag = linear and min = nearest and mip = none */
  74334. static readonly TEXTURE_LINEAR_NEAREST: number;
  74335. /** Explicit coordinates mode */
  74336. static readonly TEXTURE_EXPLICIT_MODE: number;
  74337. /** Spherical coordinates mode */
  74338. static readonly TEXTURE_SPHERICAL_MODE: number;
  74339. /** Planar coordinates mode */
  74340. static readonly TEXTURE_PLANAR_MODE: number;
  74341. /** Cubic coordinates mode */
  74342. static readonly TEXTURE_CUBIC_MODE: number;
  74343. /** Projection coordinates mode */
  74344. static readonly TEXTURE_PROJECTION_MODE: number;
  74345. /** Skybox coordinates mode */
  74346. static readonly TEXTURE_SKYBOX_MODE: number;
  74347. /** Inverse Cubic coordinates mode */
  74348. static readonly TEXTURE_INVCUBIC_MODE: number;
  74349. /** Equirectangular coordinates mode */
  74350. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  74351. /** Equirectangular Fixed coordinates mode */
  74352. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  74353. /** Equirectangular Fixed Mirrored coordinates mode */
  74354. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  74355. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  74356. static readonly SCALEMODE_FLOOR: number;
  74357. /** Defines that texture rescaling will look for the nearest power of 2 size */
  74358. static readonly SCALEMODE_NEAREST: number;
  74359. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  74360. static readonly SCALEMODE_CEILING: number;
  74361. /**
  74362. * The dirty texture flag value
  74363. */
  74364. static readonly MATERIAL_TextureDirtyFlag: number;
  74365. /**
  74366. * The dirty light flag value
  74367. */
  74368. static readonly MATERIAL_LightDirtyFlag: number;
  74369. /**
  74370. * The dirty fresnel flag value
  74371. */
  74372. static readonly MATERIAL_FresnelDirtyFlag: number;
  74373. /**
  74374. * The dirty attribute flag value
  74375. */
  74376. static readonly MATERIAL_AttributesDirtyFlag: number;
  74377. /**
  74378. * The dirty misc flag value
  74379. */
  74380. static readonly MATERIAL_MiscDirtyFlag: number;
  74381. /**
  74382. * The all dirty flag value
  74383. */
  74384. static readonly MATERIAL_AllDirtyFlag: number;
  74385. /**
  74386. * Returns the triangle fill mode
  74387. */
  74388. static readonly MATERIAL_TriangleFillMode: number;
  74389. /**
  74390. * Returns the wireframe mode
  74391. */
  74392. static readonly MATERIAL_WireFrameFillMode: number;
  74393. /**
  74394. * Returns the point fill mode
  74395. */
  74396. static readonly MATERIAL_PointFillMode: number;
  74397. /**
  74398. * Returns the point list draw mode
  74399. */
  74400. static readonly MATERIAL_PointListDrawMode: number;
  74401. /**
  74402. * Returns the line list draw mode
  74403. */
  74404. static readonly MATERIAL_LineListDrawMode: number;
  74405. /**
  74406. * Returns the line loop draw mode
  74407. */
  74408. static readonly MATERIAL_LineLoopDrawMode: number;
  74409. /**
  74410. * Returns the line strip draw mode
  74411. */
  74412. static readonly MATERIAL_LineStripDrawMode: number;
  74413. /**
  74414. * Returns the triangle strip draw mode
  74415. */
  74416. static readonly MATERIAL_TriangleStripDrawMode: number;
  74417. /**
  74418. * Returns the triangle fan draw mode
  74419. */
  74420. static readonly MATERIAL_TriangleFanDrawMode: number;
  74421. /**
  74422. * Stores the clock-wise side orientation
  74423. */
  74424. static readonly MATERIAL_ClockWiseSideOrientation: number;
  74425. /**
  74426. * Stores the counter clock-wise side orientation
  74427. */
  74428. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  74429. /**
  74430. * Nothing
  74431. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74432. */
  74433. static readonly ACTION_NothingTrigger: number;
  74434. /**
  74435. * On pick
  74436. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74437. */
  74438. static readonly ACTION_OnPickTrigger: number;
  74439. /**
  74440. * On left pick
  74441. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74442. */
  74443. static readonly ACTION_OnLeftPickTrigger: number;
  74444. /**
  74445. * On right pick
  74446. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74447. */
  74448. static readonly ACTION_OnRightPickTrigger: number;
  74449. /**
  74450. * On center pick
  74451. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74452. */
  74453. static readonly ACTION_OnCenterPickTrigger: number;
  74454. /**
  74455. * On pick down
  74456. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74457. */
  74458. static readonly ACTION_OnPickDownTrigger: number;
  74459. /**
  74460. * On double pick
  74461. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74462. */
  74463. static readonly ACTION_OnDoublePickTrigger: number;
  74464. /**
  74465. * On pick up
  74466. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74467. */
  74468. static readonly ACTION_OnPickUpTrigger: number;
  74469. /**
  74470. * On pick out.
  74471. * This trigger will only be raised if you also declared a OnPickDown
  74472. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74473. */
  74474. static readonly ACTION_OnPickOutTrigger: number;
  74475. /**
  74476. * On long press
  74477. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74478. */
  74479. static readonly ACTION_OnLongPressTrigger: number;
  74480. /**
  74481. * On pointer over
  74482. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74483. */
  74484. static readonly ACTION_OnPointerOverTrigger: number;
  74485. /**
  74486. * On pointer out
  74487. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74488. */
  74489. static readonly ACTION_OnPointerOutTrigger: number;
  74490. /**
  74491. * On every frame
  74492. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74493. */
  74494. static readonly ACTION_OnEveryFrameTrigger: number;
  74495. /**
  74496. * On intersection enter
  74497. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74498. */
  74499. static readonly ACTION_OnIntersectionEnterTrigger: number;
  74500. /**
  74501. * On intersection exit
  74502. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74503. */
  74504. static readonly ACTION_OnIntersectionExitTrigger: number;
  74505. /**
  74506. * On key down
  74507. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74508. */
  74509. static readonly ACTION_OnKeyDownTrigger: number;
  74510. /**
  74511. * On key up
  74512. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74513. */
  74514. static readonly ACTION_OnKeyUpTrigger: number;
  74515. /**
  74516. * Billboard mode will only apply to Y axis
  74517. */
  74518. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  74519. /**
  74520. * Billboard mode will apply to all axes
  74521. */
  74522. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  74523. /**
  74524. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  74525. */
  74526. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  74527. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  74528. * Test order :
  74529. * Is the bounding sphere outside the frustum ?
  74530. * If not, are the bounding box vertices outside the frustum ?
  74531. * It not, then the cullable object is in the frustum.
  74532. */
  74533. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  74534. /** Culling strategy : Bounding Sphere Only.
  74535. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  74536. * It's also less accurate than the standard because some not visible objects can still be selected.
  74537. * Test : is the bounding sphere outside the frustum ?
  74538. * If not, then the cullable object is in the frustum.
  74539. */
  74540. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  74541. /** Culling strategy : Optimistic Inclusion.
  74542. * This in an inclusion test first, then the standard exclusion test.
  74543. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  74544. * 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.
  74545. * Anyway, it's as accurate as the standard strategy.
  74546. * Test :
  74547. * Is the cullable object bounding sphere center in the frustum ?
  74548. * If not, apply the default culling strategy.
  74549. */
  74550. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  74551. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  74552. * This in an inclusion test first, then the bounding sphere only exclusion test.
  74553. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  74554. * 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.
  74555. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  74556. * Test :
  74557. * Is the cullable object bounding sphere center in the frustum ?
  74558. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  74559. */
  74560. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  74561. /**
  74562. * No logging while loading
  74563. */
  74564. static readonly SCENELOADER_NO_LOGGING: number;
  74565. /**
  74566. * Minimal logging while loading
  74567. */
  74568. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  74569. /**
  74570. * Summary logging while loading
  74571. */
  74572. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  74573. /**
  74574. * Detailled logging while loading
  74575. */
  74576. static readonly SCENELOADER_DETAILED_LOGGING: number;
  74577. }
  74578. }
  74579. declare module BABYLON {
  74580. /**
  74581. * This represents the required contract to create a new type of texture loader.
  74582. */
  74583. export interface IInternalTextureLoader {
  74584. /**
  74585. * Defines wether the loader supports cascade loading the different faces.
  74586. */
  74587. supportCascades: boolean;
  74588. /**
  74589. * This returns if the loader support the current file information.
  74590. * @param extension defines the file extension of the file being loaded
  74591. * @returns true if the loader can load the specified file
  74592. */
  74593. canLoad(extension: string): boolean;
  74594. /**
  74595. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  74596. * @param data contains the texture data
  74597. * @param texture defines the BabylonJS internal texture
  74598. * @param createPolynomials will be true if polynomials have been requested
  74599. * @param onLoad defines the callback to trigger once the texture is ready
  74600. * @param onError defines the callback to trigger in case of error
  74601. */
  74602. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  74603. /**
  74604. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  74605. * @param data contains the texture data
  74606. * @param texture defines the BabylonJS internal texture
  74607. * @param callback defines the method to call once ready to upload
  74608. */
  74609. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  74610. }
  74611. }
  74612. declare module BABYLON {
  74613. /**
  74614. * Class used to store and describe the pipeline context associated with an effect
  74615. */
  74616. export interface IPipelineContext {
  74617. /**
  74618. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  74619. */
  74620. isAsync: boolean;
  74621. /**
  74622. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  74623. */
  74624. isReady: boolean;
  74625. /** @hidden */
  74626. _getVertexShaderCode(): string | null;
  74627. /** @hidden */
  74628. _getFragmentShaderCode(): string | null;
  74629. /** @hidden */
  74630. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  74631. }
  74632. }
  74633. declare module BABYLON {
  74634. /**
  74635. * Class used to store gfx data (like WebGLBuffer)
  74636. */
  74637. export class DataBuffer {
  74638. /**
  74639. * Gets or sets the number of objects referencing this buffer
  74640. */
  74641. references: number;
  74642. /** Gets or sets the size of the underlying buffer */
  74643. capacity: number;
  74644. /**
  74645. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  74646. */
  74647. is32Bits: boolean;
  74648. /**
  74649. * Gets the underlying buffer
  74650. */
  74651. get underlyingResource(): any;
  74652. }
  74653. }
  74654. declare module BABYLON {
  74655. /** @hidden */
  74656. export interface IShaderProcessor {
  74657. attributeProcessor?: (attribute: string) => string;
  74658. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  74659. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  74660. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  74661. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  74662. lineProcessor?: (line: string, isFragment: boolean) => string;
  74663. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  74664. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  74665. }
  74666. }
  74667. declare module BABYLON {
  74668. /** @hidden */
  74669. export interface ProcessingOptions {
  74670. defines: string[];
  74671. indexParameters: any;
  74672. isFragment: boolean;
  74673. shouldUseHighPrecisionShader: boolean;
  74674. supportsUniformBuffers: boolean;
  74675. shadersRepository: string;
  74676. includesShadersStore: {
  74677. [key: string]: string;
  74678. };
  74679. processor?: IShaderProcessor;
  74680. version: string;
  74681. platformName: string;
  74682. lookForClosingBracketForUniformBuffer?: boolean;
  74683. }
  74684. }
  74685. declare module BABYLON {
  74686. /** @hidden */
  74687. export class ShaderCodeNode {
  74688. line: string;
  74689. children: ShaderCodeNode[];
  74690. additionalDefineKey?: string;
  74691. additionalDefineValue?: string;
  74692. isValid(preprocessors: {
  74693. [key: string]: string;
  74694. }): boolean;
  74695. process(preprocessors: {
  74696. [key: string]: string;
  74697. }, options: ProcessingOptions): string;
  74698. }
  74699. }
  74700. declare module BABYLON {
  74701. /** @hidden */
  74702. export class ShaderCodeCursor {
  74703. private _lines;
  74704. lineIndex: number;
  74705. get currentLine(): string;
  74706. get canRead(): boolean;
  74707. set lines(value: string[]);
  74708. }
  74709. }
  74710. declare module BABYLON {
  74711. /** @hidden */
  74712. export class ShaderCodeConditionNode extends ShaderCodeNode {
  74713. process(preprocessors: {
  74714. [key: string]: string;
  74715. }, options: ProcessingOptions): string;
  74716. }
  74717. }
  74718. declare module BABYLON {
  74719. /** @hidden */
  74720. export class ShaderDefineExpression {
  74721. isTrue(preprocessors: {
  74722. [key: string]: string;
  74723. }): boolean;
  74724. }
  74725. }
  74726. declare module BABYLON {
  74727. /** @hidden */
  74728. export class ShaderCodeTestNode extends ShaderCodeNode {
  74729. testExpression: ShaderDefineExpression;
  74730. isValid(preprocessors: {
  74731. [key: string]: string;
  74732. }): boolean;
  74733. }
  74734. }
  74735. declare module BABYLON {
  74736. /** @hidden */
  74737. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  74738. define: string;
  74739. not: boolean;
  74740. constructor(define: string, not?: boolean);
  74741. isTrue(preprocessors: {
  74742. [key: string]: string;
  74743. }): boolean;
  74744. }
  74745. }
  74746. declare module BABYLON {
  74747. /** @hidden */
  74748. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  74749. leftOperand: ShaderDefineExpression;
  74750. rightOperand: ShaderDefineExpression;
  74751. isTrue(preprocessors: {
  74752. [key: string]: string;
  74753. }): boolean;
  74754. }
  74755. }
  74756. declare module BABYLON {
  74757. /** @hidden */
  74758. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  74759. leftOperand: ShaderDefineExpression;
  74760. rightOperand: ShaderDefineExpression;
  74761. isTrue(preprocessors: {
  74762. [key: string]: string;
  74763. }): boolean;
  74764. }
  74765. }
  74766. declare module BABYLON {
  74767. /** @hidden */
  74768. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  74769. define: string;
  74770. operand: string;
  74771. testValue: string;
  74772. constructor(define: string, operand: string, testValue: string);
  74773. isTrue(preprocessors: {
  74774. [key: string]: string;
  74775. }): boolean;
  74776. }
  74777. }
  74778. declare module BABYLON {
  74779. /**
  74780. * Class used to enable access to offline support
  74781. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  74782. */
  74783. export interface IOfflineProvider {
  74784. /**
  74785. * Gets a boolean indicating if scene must be saved in the database
  74786. */
  74787. enableSceneOffline: boolean;
  74788. /**
  74789. * Gets a boolean indicating if textures must be saved in the database
  74790. */
  74791. enableTexturesOffline: boolean;
  74792. /**
  74793. * Open the offline support and make it available
  74794. * @param successCallback defines the callback to call on success
  74795. * @param errorCallback defines the callback to call on error
  74796. */
  74797. open(successCallback: () => void, errorCallback: () => void): void;
  74798. /**
  74799. * Loads an image from the offline support
  74800. * @param url defines the url to load from
  74801. * @param image defines the target DOM image
  74802. */
  74803. loadImage(url: string, image: HTMLImageElement): void;
  74804. /**
  74805. * Loads a file from offline support
  74806. * @param url defines the URL to load from
  74807. * @param sceneLoaded defines a callback to call on success
  74808. * @param progressCallBack defines a callback to call when progress changed
  74809. * @param errorCallback defines a callback to call on error
  74810. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  74811. */
  74812. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  74813. }
  74814. }
  74815. declare module BABYLON {
  74816. /**
  74817. * Class used to help managing file picking and drag'n'drop
  74818. * File Storage
  74819. */
  74820. export class FilesInputStore {
  74821. /**
  74822. * List of files ready to be loaded
  74823. */
  74824. static FilesToLoad: {
  74825. [key: string]: File;
  74826. };
  74827. }
  74828. }
  74829. declare module BABYLON {
  74830. /**
  74831. * Class used to define a retry strategy when error happens while loading assets
  74832. */
  74833. export class RetryStrategy {
  74834. /**
  74835. * Function used to defines an exponential back off strategy
  74836. * @param maxRetries defines the maximum number of retries (3 by default)
  74837. * @param baseInterval defines the interval between retries
  74838. * @returns the strategy function to use
  74839. */
  74840. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  74841. }
  74842. }
  74843. declare module BABYLON {
  74844. /**
  74845. * @ignore
  74846. * Application error to support additional information when loading a file
  74847. */
  74848. export abstract class BaseError extends Error {
  74849. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  74850. }
  74851. }
  74852. declare module BABYLON {
  74853. /** @ignore */
  74854. export class LoadFileError extends BaseError {
  74855. request?: WebRequest;
  74856. file?: File;
  74857. /**
  74858. * Creates a new LoadFileError
  74859. * @param message defines the message of the error
  74860. * @param request defines the optional web request
  74861. * @param file defines the optional file
  74862. */
  74863. constructor(message: string, object?: WebRequest | File);
  74864. }
  74865. /** @ignore */
  74866. export class RequestFileError extends BaseError {
  74867. request: WebRequest;
  74868. /**
  74869. * Creates a new LoadFileError
  74870. * @param message defines the message of the error
  74871. * @param request defines the optional web request
  74872. */
  74873. constructor(message: string, request: WebRequest);
  74874. }
  74875. /** @ignore */
  74876. export class ReadFileError extends BaseError {
  74877. file: File;
  74878. /**
  74879. * Creates a new ReadFileError
  74880. * @param message defines the message of the error
  74881. * @param file defines the optional file
  74882. */
  74883. constructor(message: string, file: File);
  74884. }
  74885. /**
  74886. * @hidden
  74887. */
  74888. export class FileTools {
  74889. /**
  74890. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  74891. */
  74892. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  74893. /**
  74894. * Gets or sets the base URL to use to load assets
  74895. */
  74896. static BaseUrl: string;
  74897. /**
  74898. * Default behaviour for cors in the application.
  74899. * It can be a string if the expected behavior is identical in the entire app.
  74900. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  74901. */
  74902. static CorsBehavior: string | ((url: string | string[]) => string);
  74903. /**
  74904. * Gets or sets a function used to pre-process url before using them to load assets
  74905. */
  74906. static PreprocessUrl: (url: string) => string;
  74907. /**
  74908. * Removes unwanted characters from an url
  74909. * @param url defines the url to clean
  74910. * @returns the cleaned url
  74911. */
  74912. private static _CleanUrl;
  74913. /**
  74914. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  74915. * @param url define the url we are trying
  74916. * @param element define the dom element where to configure the cors policy
  74917. */
  74918. static SetCorsBehavior(url: string | string[], element: {
  74919. crossOrigin: string | null;
  74920. }): void;
  74921. /**
  74922. * Loads an image as an HTMLImageElement.
  74923. * @param input url string, ArrayBuffer, or Blob to load
  74924. * @param onLoad callback called when the image successfully loads
  74925. * @param onError callback called when the image fails to load
  74926. * @param offlineProvider offline provider for caching
  74927. * @param mimeType optional mime type
  74928. * @returns the HTMLImageElement of the loaded image
  74929. */
  74930. 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>;
  74931. /**
  74932. * Reads a file from a File object
  74933. * @param file defines the file to load
  74934. * @param onSuccess defines the callback to call when data is loaded
  74935. * @param onProgress defines the callback to call during loading process
  74936. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  74937. * @param onError defines the callback to call when an error occurs
  74938. * @returns a file request object
  74939. */
  74940. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  74941. /**
  74942. * Loads a file from a url
  74943. * @param url url to load
  74944. * @param onSuccess callback called when the file successfully loads
  74945. * @param onProgress callback called while file is loading (if the server supports this mode)
  74946. * @param offlineProvider defines the offline provider for caching
  74947. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74948. * @param onError callback called when the file fails to load
  74949. * @returns a file request object
  74950. */
  74951. 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;
  74952. /**
  74953. * Loads a file
  74954. * @param url url to load
  74955. * @param onSuccess callback called when the file successfully loads
  74956. * @param onProgress callback called while file is loading (if the server supports this mode)
  74957. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74958. * @param onError callback called when the file fails to load
  74959. * @param onOpened callback called when the web request is opened
  74960. * @returns a file request object
  74961. */
  74962. 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;
  74963. /**
  74964. * Checks if the loaded document was accessed via `file:`-Protocol.
  74965. * @returns boolean
  74966. */
  74967. static IsFileURL(): boolean;
  74968. }
  74969. }
  74970. declare module BABYLON {
  74971. /** @hidden */
  74972. export class ShaderProcessor {
  74973. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  74974. private static _ProcessPrecision;
  74975. private static _ExtractOperation;
  74976. private static _BuildSubExpression;
  74977. private static _BuildExpression;
  74978. private static _MoveCursorWithinIf;
  74979. private static _MoveCursor;
  74980. private static _EvaluatePreProcessors;
  74981. private static _PreparePreProcessors;
  74982. private static _ProcessShaderConversion;
  74983. private static _ProcessIncludes;
  74984. /**
  74985. * Loads a file from a url
  74986. * @param url url to load
  74987. * @param onSuccess callback called when the file successfully loads
  74988. * @param onProgress callback called while file is loading (if the server supports this mode)
  74989. * @param offlineProvider defines the offline provider for caching
  74990. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74991. * @param onError callback called when the file fails to load
  74992. * @returns a file request object
  74993. * @hidden
  74994. */
  74995. 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;
  74996. }
  74997. }
  74998. declare module BABYLON {
  74999. /**
  75000. * @hidden
  75001. */
  75002. export interface IColor4Like {
  75003. r: float;
  75004. g: float;
  75005. b: float;
  75006. a: float;
  75007. }
  75008. /**
  75009. * @hidden
  75010. */
  75011. export interface IColor3Like {
  75012. r: float;
  75013. g: float;
  75014. b: float;
  75015. }
  75016. /**
  75017. * @hidden
  75018. */
  75019. export interface IVector4Like {
  75020. x: float;
  75021. y: float;
  75022. z: float;
  75023. w: float;
  75024. }
  75025. /**
  75026. * @hidden
  75027. */
  75028. export interface IVector3Like {
  75029. x: float;
  75030. y: float;
  75031. z: float;
  75032. }
  75033. /**
  75034. * @hidden
  75035. */
  75036. export interface IVector2Like {
  75037. x: float;
  75038. y: float;
  75039. }
  75040. /**
  75041. * @hidden
  75042. */
  75043. export interface IMatrixLike {
  75044. toArray(): DeepImmutable<Float32Array>;
  75045. updateFlag: int;
  75046. }
  75047. /**
  75048. * @hidden
  75049. */
  75050. export interface IViewportLike {
  75051. x: float;
  75052. y: float;
  75053. width: float;
  75054. height: float;
  75055. }
  75056. /**
  75057. * @hidden
  75058. */
  75059. export interface IPlaneLike {
  75060. normal: IVector3Like;
  75061. d: float;
  75062. normalize(): void;
  75063. }
  75064. }
  75065. declare module BABYLON {
  75066. /**
  75067. * Interface used to define common properties for effect fallbacks
  75068. */
  75069. export interface IEffectFallbacks {
  75070. /**
  75071. * Removes the defines that should be removed when falling back.
  75072. * @param currentDefines defines the current define statements for the shader.
  75073. * @param effect defines the current effect we try to compile
  75074. * @returns The resulting defines with defines of the current rank removed.
  75075. */
  75076. reduce(currentDefines: string, effect: Effect): string;
  75077. /**
  75078. * Removes the fallback from the bound mesh.
  75079. */
  75080. unBindMesh(): void;
  75081. /**
  75082. * Checks to see if more fallbacks are still availible.
  75083. */
  75084. hasMoreFallbacks: boolean;
  75085. }
  75086. }
  75087. declare module BABYLON {
  75088. /**
  75089. * Class used to evalaute queries containing `and` and `or` operators
  75090. */
  75091. export class AndOrNotEvaluator {
  75092. /**
  75093. * Evaluate a query
  75094. * @param query defines the query to evaluate
  75095. * @param evaluateCallback defines the callback used to filter result
  75096. * @returns true if the query matches
  75097. */
  75098. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  75099. private static _HandleParenthesisContent;
  75100. private static _SimplifyNegation;
  75101. }
  75102. }
  75103. declare module BABYLON {
  75104. /**
  75105. * Class used to store custom tags
  75106. */
  75107. export class Tags {
  75108. /**
  75109. * Adds support for tags on the given object
  75110. * @param obj defines the object to use
  75111. */
  75112. static EnableFor(obj: any): void;
  75113. /**
  75114. * Removes tags support
  75115. * @param obj defines the object to use
  75116. */
  75117. static DisableFor(obj: any): void;
  75118. /**
  75119. * Gets a boolean indicating if the given object has tags
  75120. * @param obj defines the object to use
  75121. * @returns a boolean
  75122. */
  75123. static HasTags(obj: any): boolean;
  75124. /**
  75125. * Gets the tags available on a given object
  75126. * @param obj defines the object to use
  75127. * @param asString defines if the tags must be returned as a string instead of an array of strings
  75128. * @returns the tags
  75129. */
  75130. static GetTags(obj: any, asString?: boolean): any;
  75131. /**
  75132. * Adds tags to an object
  75133. * @param obj defines the object to use
  75134. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  75135. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  75136. */
  75137. static AddTagsTo(obj: any, tagsString: string): void;
  75138. /**
  75139. * @hidden
  75140. */
  75141. static _AddTagTo(obj: any, tag: string): void;
  75142. /**
  75143. * Removes specific tags from a specific object
  75144. * @param obj defines the object to use
  75145. * @param tagsString defines the tags to remove
  75146. */
  75147. static RemoveTagsFrom(obj: any, tagsString: string): void;
  75148. /**
  75149. * @hidden
  75150. */
  75151. static _RemoveTagFrom(obj: any, tag: string): void;
  75152. /**
  75153. * Defines if tags hosted on an object match a given query
  75154. * @param obj defines the object to use
  75155. * @param tagsQuery defines the tag query
  75156. * @returns a boolean
  75157. */
  75158. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  75159. }
  75160. }
  75161. declare module BABYLON {
  75162. /**
  75163. * Scalar computation library
  75164. */
  75165. export class Scalar {
  75166. /**
  75167. * Two pi constants convenient for computation.
  75168. */
  75169. static TwoPi: number;
  75170. /**
  75171. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  75172. * @param a number
  75173. * @param b number
  75174. * @param epsilon (default = 1.401298E-45)
  75175. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  75176. */
  75177. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  75178. /**
  75179. * Returns a string : the upper case translation of the number i to hexadecimal.
  75180. * @param i number
  75181. * @returns the upper case translation of the number i to hexadecimal.
  75182. */
  75183. static ToHex(i: number): string;
  75184. /**
  75185. * Returns -1 if value is negative and +1 is value is positive.
  75186. * @param value the value
  75187. * @returns the value itself if it's equal to zero.
  75188. */
  75189. static Sign(value: number): number;
  75190. /**
  75191. * Returns the value itself if it's between min and max.
  75192. * Returns min if the value is lower than min.
  75193. * Returns max if the value is greater than max.
  75194. * @param value the value to clmap
  75195. * @param min the min value to clamp to (default: 0)
  75196. * @param max the max value to clamp to (default: 1)
  75197. * @returns the clamped value
  75198. */
  75199. static Clamp(value: number, min?: number, max?: number): number;
  75200. /**
  75201. * the log2 of value.
  75202. * @param value the value to compute log2 of
  75203. * @returns the log2 of value.
  75204. */
  75205. static Log2(value: number): number;
  75206. /**
  75207. * Loops the value, so that it is never larger than length and never smaller than 0.
  75208. *
  75209. * This is similar to the modulo operator but it works with floating point numbers.
  75210. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  75211. * With t = 5 and length = 2.5, the result would be 0.0.
  75212. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  75213. * @param value the value
  75214. * @param length the length
  75215. * @returns the looped value
  75216. */
  75217. static Repeat(value: number, length: number): number;
  75218. /**
  75219. * Normalize the value between 0.0 and 1.0 using min and max values
  75220. * @param value value to normalize
  75221. * @param min max to normalize between
  75222. * @param max min to normalize between
  75223. * @returns the normalized value
  75224. */
  75225. static Normalize(value: number, min: number, max: number): number;
  75226. /**
  75227. * Denormalize the value from 0.0 and 1.0 using min and max values
  75228. * @param normalized value to denormalize
  75229. * @param min max to denormalize between
  75230. * @param max min to denormalize between
  75231. * @returns the denormalized value
  75232. */
  75233. static Denormalize(normalized: number, min: number, max: number): number;
  75234. /**
  75235. * Calculates the shortest difference between two given angles given in degrees.
  75236. * @param current current angle in degrees
  75237. * @param target target angle in degrees
  75238. * @returns the delta
  75239. */
  75240. static DeltaAngle(current: number, target: number): number;
  75241. /**
  75242. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  75243. * @param tx value
  75244. * @param length length
  75245. * @returns The returned value will move back and forth between 0 and length
  75246. */
  75247. static PingPong(tx: number, length: number): number;
  75248. /**
  75249. * Interpolates between min and max with smoothing at the limits.
  75250. *
  75251. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  75252. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  75253. * @param from from
  75254. * @param to to
  75255. * @param tx value
  75256. * @returns the smooth stepped value
  75257. */
  75258. static SmoothStep(from: number, to: number, tx: number): number;
  75259. /**
  75260. * Moves a value current towards target.
  75261. *
  75262. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  75263. * Negative values of maxDelta pushes the value away from target.
  75264. * @param current current value
  75265. * @param target target value
  75266. * @param maxDelta max distance to move
  75267. * @returns resulting value
  75268. */
  75269. static MoveTowards(current: number, target: number, maxDelta: number): number;
  75270. /**
  75271. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  75272. *
  75273. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  75274. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  75275. * @param current current value
  75276. * @param target target value
  75277. * @param maxDelta max distance to move
  75278. * @returns resulting angle
  75279. */
  75280. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  75281. /**
  75282. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  75283. * @param start start value
  75284. * @param end target value
  75285. * @param amount amount to lerp between
  75286. * @returns the lerped value
  75287. */
  75288. static Lerp(start: number, end: number, amount: number): number;
  75289. /**
  75290. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  75291. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  75292. * @param start start value
  75293. * @param end target value
  75294. * @param amount amount to lerp between
  75295. * @returns the lerped value
  75296. */
  75297. static LerpAngle(start: number, end: number, amount: number): number;
  75298. /**
  75299. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  75300. * @param a start value
  75301. * @param b target value
  75302. * @param value value between a and b
  75303. * @returns the inverseLerp value
  75304. */
  75305. static InverseLerp(a: number, b: number, value: number): number;
  75306. /**
  75307. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  75308. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  75309. * @param value1 spline value
  75310. * @param tangent1 spline value
  75311. * @param value2 spline value
  75312. * @param tangent2 spline value
  75313. * @param amount input value
  75314. * @returns hermite result
  75315. */
  75316. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  75317. /**
  75318. * Returns a random float number between and min and max values
  75319. * @param min min value of random
  75320. * @param max max value of random
  75321. * @returns random value
  75322. */
  75323. static RandomRange(min: number, max: number): number;
  75324. /**
  75325. * This function returns percentage of a number in a given range.
  75326. *
  75327. * RangeToPercent(40,20,60) will return 0.5 (50%)
  75328. * RangeToPercent(34,0,100) will return 0.34 (34%)
  75329. * @param number to convert to percentage
  75330. * @param min min range
  75331. * @param max max range
  75332. * @returns the percentage
  75333. */
  75334. static RangeToPercent(number: number, min: number, max: number): number;
  75335. /**
  75336. * This function returns number that corresponds to the percentage in a given range.
  75337. *
  75338. * PercentToRange(0.34,0,100) will return 34.
  75339. * @param percent to convert to number
  75340. * @param min min range
  75341. * @param max max range
  75342. * @returns the number
  75343. */
  75344. static PercentToRange(percent: number, min: number, max: number): number;
  75345. /**
  75346. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  75347. * @param angle The angle to normalize in radian.
  75348. * @return The converted angle.
  75349. */
  75350. static NormalizeRadians(angle: number): number;
  75351. }
  75352. }
  75353. declare module BABYLON {
  75354. /**
  75355. * Constant used to convert a value to gamma space
  75356. * @ignorenaming
  75357. */
  75358. export const ToGammaSpace: number;
  75359. /**
  75360. * Constant used to convert a value to linear space
  75361. * @ignorenaming
  75362. */
  75363. export const ToLinearSpace = 2.2;
  75364. /**
  75365. * Constant used to define the minimal number value in Babylon.js
  75366. * @ignorenaming
  75367. */
  75368. let Epsilon: number;
  75369. }
  75370. declare module BABYLON {
  75371. /**
  75372. * Class used to represent a viewport on screen
  75373. */
  75374. export class Viewport {
  75375. /** viewport left coordinate */
  75376. x: number;
  75377. /** viewport top coordinate */
  75378. y: number;
  75379. /**viewport width */
  75380. width: number;
  75381. /** viewport height */
  75382. height: number;
  75383. /**
  75384. * Creates a Viewport object located at (x, y) and sized (width, height)
  75385. * @param x defines viewport left coordinate
  75386. * @param y defines viewport top coordinate
  75387. * @param width defines the viewport width
  75388. * @param height defines the viewport height
  75389. */
  75390. constructor(
  75391. /** viewport left coordinate */
  75392. x: number,
  75393. /** viewport top coordinate */
  75394. y: number,
  75395. /**viewport width */
  75396. width: number,
  75397. /** viewport height */
  75398. height: number);
  75399. /**
  75400. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  75401. * @param renderWidth defines the rendering width
  75402. * @param renderHeight defines the rendering height
  75403. * @returns a new Viewport
  75404. */
  75405. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  75406. /**
  75407. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  75408. * @param renderWidth defines the rendering width
  75409. * @param renderHeight defines the rendering height
  75410. * @param ref defines the target viewport
  75411. * @returns the current viewport
  75412. */
  75413. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  75414. /**
  75415. * Returns a new Viewport copied from the current one
  75416. * @returns a new Viewport
  75417. */
  75418. clone(): Viewport;
  75419. }
  75420. }
  75421. declare module BABYLON {
  75422. /**
  75423. * Class containing a set of static utilities functions for arrays.
  75424. */
  75425. export class ArrayTools {
  75426. /**
  75427. * Returns an array of the given size filled with element built from the given constructor and the paramters
  75428. * @param size the number of element to construct and put in the array
  75429. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  75430. * @returns a new array filled with new objects
  75431. */
  75432. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  75433. }
  75434. }
  75435. declare module BABYLON {
  75436. /**
  75437. * Class representing a vector containing 2 coordinates
  75438. */
  75439. export class Vector2 {
  75440. /** defines the first coordinate */
  75441. x: number;
  75442. /** defines the second coordinate */
  75443. y: number;
  75444. /**
  75445. * Creates a new Vector2 from the given x and y coordinates
  75446. * @param x defines the first coordinate
  75447. * @param y defines the second coordinate
  75448. */
  75449. constructor(
  75450. /** defines the first coordinate */
  75451. x?: number,
  75452. /** defines the second coordinate */
  75453. y?: number);
  75454. /**
  75455. * Gets a string with the Vector2 coordinates
  75456. * @returns a string with the Vector2 coordinates
  75457. */
  75458. toString(): string;
  75459. /**
  75460. * Gets class name
  75461. * @returns the string "Vector2"
  75462. */
  75463. getClassName(): string;
  75464. /**
  75465. * Gets current vector hash code
  75466. * @returns the Vector2 hash code as a number
  75467. */
  75468. getHashCode(): number;
  75469. /**
  75470. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  75471. * @param array defines the source array
  75472. * @param index defines the offset in source array
  75473. * @returns the current Vector2
  75474. */
  75475. toArray(array: FloatArray, index?: number): Vector2;
  75476. /**
  75477. * Copy the current vector to an array
  75478. * @returns a new array with 2 elements: the Vector2 coordinates.
  75479. */
  75480. asArray(): number[];
  75481. /**
  75482. * Sets the Vector2 coordinates with the given Vector2 coordinates
  75483. * @param source defines the source Vector2
  75484. * @returns the current updated Vector2
  75485. */
  75486. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  75487. /**
  75488. * Sets the Vector2 coordinates with the given floats
  75489. * @param x defines the first coordinate
  75490. * @param y defines the second coordinate
  75491. * @returns the current updated Vector2
  75492. */
  75493. copyFromFloats(x: number, y: number): Vector2;
  75494. /**
  75495. * Sets the Vector2 coordinates with the given floats
  75496. * @param x defines the first coordinate
  75497. * @param y defines the second coordinate
  75498. * @returns the current updated Vector2
  75499. */
  75500. set(x: number, y: number): Vector2;
  75501. /**
  75502. * Add another vector with the current one
  75503. * @param otherVector defines the other vector
  75504. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  75505. */
  75506. add(otherVector: DeepImmutable<Vector2>): Vector2;
  75507. /**
  75508. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  75509. * @param otherVector defines the other vector
  75510. * @param result defines the target vector
  75511. * @returns the unmodified current Vector2
  75512. */
  75513. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75514. /**
  75515. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  75516. * @param otherVector defines the other vector
  75517. * @returns the current updated Vector2
  75518. */
  75519. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75520. /**
  75521. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  75522. * @param otherVector defines the other vector
  75523. * @returns a new Vector2
  75524. */
  75525. addVector3(otherVector: Vector3): Vector2;
  75526. /**
  75527. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  75528. * @param otherVector defines the other vector
  75529. * @returns a new Vector2
  75530. */
  75531. subtract(otherVector: Vector2): Vector2;
  75532. /**
  75533. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  75534. * @param otherVector defines the other vector
  75535. * @param result defines the target vector
  75536. * @returns the unmodified current Vector2
  75537. */
  75538. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75539. /**
  75540. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  75541. * @param otherVector defines the other vector
  75542. * @returns the current updated Vector2
  75543. */
  75544. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75545. /**
  75546. * Multiplies in place the current Vector2 coordinates by the given ones
  75547. * @param otherVector defines the other vector
  75548. * @returns the current updated Vector2
  75549. */
  75550. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75551. /**
  75552. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  75553. * @param otherVector defines the other vector
  75554. * @returns a new Vector2
  75555. */
  75556. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  75557. /**
  75558. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  75559. * @param otherVector defines the other vector
  75560. * @param result defines the target vector
  75561. * @returns the unmodified current Vector2
  75562. */
  75563. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75564. /**
  75565. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  75566. * @param x defines the first coordinate
  75567. * @param y defines the second coordinate
  75568. * @returns a new Vector2
  75569. */
  75570. multiplyByFloats(x: number, y: number): Vector2;
  75571. /**
  75572. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  75573. * @param otherVector defines the other vector
  75574. * @returns a new Vector2
  75575. */
  75576. divide(otherVector: Vector2): Vector2;
  75577. /**
  75578. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  75579. * @param otherVector defines the other vector
  75580. * @param result defines the target vector
  75581. * @returns the unmodified current Vector2
  75582. */
  75583. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75584. /**
  75585. * Divides the current Vector2 coordinates by the given ones
  75586. * @param otherVector defines the other vector
  75587. * @returns the current updated Vector2
  75588. */
  75589. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75590. /**
  75591. * Gets a new Vector2 with current Vector2 negated coordinates
  75592. * @returns a new Vector2
  75593. */
  75594. negate(): Vector2;
  75595. /**
  75596. * Negate this vector in place
  75597. * @returns this
  75598. */
  75599. negateInPlace(): Vector2;
  75600. /**
  75601. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  75602. * @param result defines the Vector3 object where to store the result
  75603. * @returns the current Vector2
  75604. */
  75605. negateToRef(result: Vector2): Vector2;
  75606. /**
  75607. * Multiply the Vector2 coordinates by scale
  75608. * @param scale defines the scaling factor
  75609. * @returns the current updated Vector2
  75610. */
  75611. scaleInPlace(scale: number): Vector2;
  75612. /**
  75613. * Returns a new Vector2 scaled by "scale" from the current Vector2
  75614. * @param scale defines the scaling factor
  75615. * @returns a new Vector2
  75616. */
  75617. scale(scale: number): Vector2;
  75618. /**
  75619. * Scale the current Vector2 values by a factor to a given Vector2
  75620. * @param scale defines the scale factor
  75621. * @param result defines the Vector2 object where to store the result
  75622. * @returns the unmodified current Vector2
  75623. */
  75624. scaleToRef(scale: number, result: Vector2): Vector2;
  75625. /**
  75626. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  75627. * @param scale defines the scale factor
  75628. * @param result defines the Vector2 object where to store the result
  75629. * @returns the unmodified current Vector2
  75630. */
  75631. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  75632. /**
  75633. * Gets a boolean if two vectors are equals
  75634. * @param otherVector defines the other vector
  75635. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  75636. */
  75637. equals(otherVector: DeepImmutable<Vector2>): boolean;
  75638. /**
  75639. * Gets a boolean if two vectors are equals (using an epsilon value)
  75640. * @param otherVector defines the other vector
  75641. * @param epsilon defines the minimal distance to consider equality
  75642. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  75643. */
  75644. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  75645. /**
  75646. * Gets a new Vector2 from current Vector2 floored values
  75647. * @returns a new Vector2
  75648. */
  75649. floor(): Vector2;
  75650. /**
  75651. * Gets a new Vector2 from current Vector2 floored values
  75652. * @returns a new Vector2
  75653. */
  75654. fract(): Vector2;
  75655. /**
  75656. * Gets the length of the vector
  75657. * @returns the vector length (float)
  75658. */
  75659. length(): number;
  75660. /**
  75661. * Gets the vector squared length
  75662. * @returns the vector squared length (float)
  75663. */
  75664. lengthSquared(): number;
  75665. /**
  75666. * Normalize the vector
  75667. * @returns the current updated Vector2
  75668. */
  75669. normalize(): Vector2;
  75670. /**
  75671. * Gets a new Vector2 copied from the Vector2
  75672. * @returns a new Vector2
  75673. */
  75674. clone(): Vector2;
  75675. /**
  75676. * Gets a new Vector2(0, 0)
  75677. * @returns a new Vector2
  75678. */
  75679. static Zero(): Vector2;
  75680. /**
  75681. * Gets a new Vector2(1, 1)
  75682. * @returns a new Vector2
  75683. */
  75684. static One(): Vector2;
  75685. /**
  75686. * Gets a new Vector2 set from the given index element of the given array
  75687. * @param array defines the data source
  75688. * @param offset defines the offset in the data source
  75689. * @returns a new Vector2
  75690. */
  75691. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  75692. /**
  75693. * Sets "result" from the given index element of the given array
  75694. * @param array defines the data source
  75695. * @param offset defines the offset in the data source
  75696. * @param result defines the target vector
  75697. */
  75698. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  75699. /**
  75700. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  75701. * @param value1 defines 1st point of control
  75702. * @param value2 defines 2nd point of control
  75703. * @param value3 defines 3rd point of control
  75704. * @param value4 defines 4th point of control
  75705. * @param amount defines the interpolation factor
  75706. * @returns a new Vector2
  75707. */
  75708. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  75709. /**
  75710. * 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".
  75711. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  75712. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  75713. * @param value defines the value to clamp
  75714. * @param min defines the lower limit
  75715. * @param max defines the upper limit
  75716. * @returns a new Vector2
  75717. */
  75718. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  75719. /**
  75720. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  75721. * @param value1 defines the 1st control point
  75722. * @param tangent1 defines the outgoing tangent
  75723. * @param value2 defines the 2nd control point
  75724. * @param tangent2 defines the incoming tangent
  75725. * @param amount defines the interpolation factor
  75726. * @returns a new Vector2
  75727. */
  75728. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  75729. /**
  75730. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  75731. * @param start defines the start vector
  75732. * @param end defines the end vector
  75733. * @param amount defines the interpolation factor
  75734. * @returns a new Vector2
  75735. */
  75736. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  75737. /**
  75738. * Gets the dot product of the vector "left" and the vector "right"
  75739. * @param left defines first vector
  75740. * @param right defines second vector
  75741. * @returns the dot product (float)
  75742. */
  75743. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  75744. /**
  75745. * Returns a new Vector2 equal to the normalized given vector
  75746. * @param vector defines the vector to normalize
  75747. * @returns a new Vector2
  75748. */
  75749. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  75750. /**
  75751. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  75752. * @param left defines 1st vector
  75753. * @param right defines 2nd vector
  75754. * @returns a new Vector2
  75755. */
  75756. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75757. /**
  75758. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  75759. * @param left defines 1st vector
  75760. * @param right defines 2nd vector
  75761. * @returns a new Vector2
  75762. */
  75763. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75764. /**
  75765. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  75766. * @param vector defines the vector to transform
  75767. * @param transformation defines the matrix to apply
  75768. * @returns a new Vector2
  75769. */
  75770. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  75771. /**
  75772. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  75773. * @param vector defines the vector to transform
  75774. * @param transformation defines the matrix to apply
  75775. * @param result defines the target vector
  75776. */
  75777. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  75778. /**
  75779. * Determines if a given vector is included in a triangle
  75780. * @param p defines the vector to test
  75781. * @param p0 defines 1st triangle point
  75782. * @param p1 defines 2nd triangle point
  75783. * @param p2 defines 3rd triangle point
  75784. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  75785. */
  75786. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  75787. /**
  75788. * Gets the distance between the vectors "value1" and "value2"
  75789. * @param value1 defines first vector
  75790. * @param value2 defines second vector
  75791. * @returns the distance between vectors
  75792. */
  75793. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75794. /**
  75795. * Returns the squared distance between the vectors "value1" and "value2"
  75796. * @param value1 defines first vector
  75797. * @param value2 defines second vector
  75798. * @returns the squared distance between vectors
  75799. */
  75800. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75801. /**
  75802. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  75803. * @param value1 defines first vector
  75804. * @param value2 defines second vector
  75805. * @returns a new Vector2
  75806. */
  75807. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  75808. /**
  75809. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  75810. * @param p defines the middle point
  75811. * @param segA defines one point of the segment
  75812. * @param segB defines the other point of the segment
  75813. * @returns the shortest distance
  75814. */
  75815. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  75816. }
  75817. /**
  75818. * Class used to store (x,y,z) vector representation
  75819. * A Vector3 is the main object used in 3D geometry
  75820. * It can represent etiher the coordinates of a point the space, either a direction
  75821. * Reminder: js uses a left handed forward facing system
  75822. */
  75823. export class Vector3 {
  75824. /**
  75825. * Defines the first coordinates (on X axis)
  75826. */
  75827. x: number;
  75828. /**
  75829. * Defines the second coordinates (on Y axis)
  75830. */
  75831. y: number;
  75832. /**
  75833. * Defines the third coordinates (on Z axis)
  75834. */
  75835. z: number;
  75836. private static _UpReadOnly;
  75837. private static _ZeroReadOnly;
  75838. /**
  75839. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  75840. * @param x defines the first coordinates (on X axis)
  75841. * @param y defines the second coordinates (on Y axis)
  75842. * @param z defines the third coordinates (on Z axis)
  75843. */
  75844. constructor(
  75845. /**
  75846. * Defines the first coordinates (on X axis)
  75847. */
  75848. x?: number,
  75849. /**
  75850. * Defines the second coordinates (on Y axis)
  75851. */
  75852. y?: number,
  75853. /**
  75854. * Defines the third coordinates (on Z axis)
  75855. */
  75856. z?: number);
  75857. /**
  75858. * Creates a string representation of the Vector3
  75859. * @returns a string with the Vector3 coordinates.
  75860. */
  75861. toString(): string;
  75862. /**
  75863. * Gets the class name
  75864. * @returns the string "Vector3"
  75865. */
  75866. getClassName(): string;
  75867. /**
  75868. * Creates the Vector3 hash code
  75869. * @returns a number which tends to be unique between Vector3 instances
  75870. */
  75871. getHashCode(): number;
  75872. /**
  75873. * Creates an array containing three elements : the coordinates of the Vector3
  75874. * @returns a new array of numbers
  75875. */
  75876. asArray(): number[];
  75877. /**
  75878. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  75879. * @param array defines the destination array
  75880. * @param index defines the offset in the destination array
  75881. * @returns the current Vector3
  75882. */
  75883. toArray(array: FloatArray, index?: number): Vector3;
  75884. /**
  75885. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  75886. * @returns a new Quaternion object, computed from the Vector3 coordinates
  75887. */
  75888. toQuaternion(): Quaternion;
  75889. /**
  75890. * Adds the given vector to the current Vector3
  75891. * @param otherVector defines the second operand
  75892. * @returns the current updated Vector3
  75893. */
  75894. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75895. /**
  75896. * Adds the given coordinates to the current Vector3
  75897. * @param x defines the x coordinate of the operand
  75898. * @param y defines the y coordinate of the operand
  75899. * @param z defines the z coordinate of the operand
  75900. * @returns the current updated Vector3
  75901. */
  75902. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75903. /**
  75904. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  75905. * @param otherVector defines the second operand
  75906. * @returns the resulting Vector3
  75907. */
  75908. add(otherVector: DeepImmutable<Vector3>): Vector3;
  75909. /**
  75910. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  75911. * @param otherVector defines the second operand
  75912. * @param result defines the Vector3 object where to store the result
  75913. * @returns the current Vector3
  75914. */
  75915. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75916. /**
  75917. * Subtract the given vector from the current Vector3
  75918. * @param otherVector defines the second operand
  75919. * @returns the current updated Vector3
  75920. */
  75921. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75922. /**
  75923. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  75924. * @param otherVector defines the second operand
  75925. * @returns the resulting Vector3
  75926. */
  75927. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  75928. /**
  75929. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  75930. * @param otherVector defines the second operand
  75931. * @param result defines the Vector3 object where to store the result
  75932. * @returns the current Vector3
  75933. */
  75934. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75935. /**
  75936. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  75937. * @param x defines the x coordinate of the operand
  75938. * @param y defines the y coordinate of the operand
  75939. * @param z defines the z coordinate of the operand
  75940. * @returns the resulting Vector3
  75941. */
  75942. subtractFromFloats(x: number, y: number, z: number): Vector3;
  75943. /**
  75944. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  75945. * @param x defines the x coordinate of the operand
  75946. * @param y defines the y coordinate of the operand
  75947. * @param z defines the z coordinate of the operand
  75948. * @param result defines the Vector3 object where to store the result
  75949. * @returns the current Vector3
  75950. */
  75951. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  75952. /**
  75953. * Gets a new Vector3 set with the current Vector3 negated coordinates
  75954. * @returns a new Vector3
  75955. */
  75956. negate(): Vector3;
  75957. /**
  75958. * Negate this vector in place
  75959. * @returns this
  75960. */
  75961. negateInPlace(): Vector3;
  75962. /**
  75963. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  75964. * @param result defines the Vector3 object where to store the result
  75965. * @returns the current Vector3
  75966. */
  75967. negateToRef(result: Vector3): Vector3;
  75968. /**
  75969. * Multiplies the Vector3 coordinates by the float "scale"
  75970. * @param scale defines the multiplier factor
  75971. * @returns the current updated Vector3
  75972. */
  75973. scaleInPlace(scale: number): Vector3;
  75974. /**
  75975. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  75976. * @param scale defines the multiplier factor
  75977. * @returns a new Vector3
  75978. */
  75979. scale(scale: number): Vector3;
  75980. /**
  75981. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  75982. * @param scale defines the multiplier factor
  75983. * @param result defines the Vector3 object where to store the result
  75984. * @returns the current Vector3
  75985. */
  75986. scaleToRef(scale: number, result: Vector3): Vector3;
  75987. /**
  75988. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  75989. * @param scale defines the scale factor
  75990. * @param result defines the Vector3 object where to store the result
  75991. * @returns the unmodified current Vector3
  75992. */
  75993. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  75994. /**
  75995. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  75996. * @param otherVector defines the second operand
  75997. * @returns true if both vectors are equals
  75998. */
  75999. equals(otherVector: DeepImmutable<Vector3>): boolean;
  76000. /**
  76001. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  76002. * @param otherVector defines the second operand
  76003. * @param epsilon defines the minimal distance to define values as equals
  76004. * @returns true if both vectors are distant less than epsilon
  76005. */
  76006. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  76007. /**
  76008. * Returns true if the current Vector3 coordinates equals the given floats
  76009. * @param x defines the x coordinate of the operand
  76010. * @param y defines the y coordinate of the operand
  76011. * @param z defines the z coordinate of the operand
  76012. * @returns true if both vectors are equals
  76013. */
  76014. equalsToFloats(x: number, y: number, z: number): boolean;
  76015. /**
  76016. * Multiplies the current Vector3 coordinates by the given ones
  76017. * @param otherVector defines the second operand
  76018. * @returns the current updated Vector3
  76019. */
  76020. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  76021. /**
  76022. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  76023. * @param otherVector defines the second operand
  76024. * @returns the new Vector3
  76025. */
  76026. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  76027. /**
  76028. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  76029. * @param otherVector defines the second operand
  76030. * @param result defines the Vector3 object where to store the result
  76031. * @returns the current Vector3
  76032. */
  76033. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  76034. /**
  76035. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  76036. * @param x defines the x coordinate of the operand
  76037. * @param y defines the y coordinate of the operand
  76038. * @param z defines the z coordinate of the operand
  76039. * @returns the new Vector3
  76040. */
  76041. multiplyByFloats(x: number, y: number, z: number): Vector3;
  76042. /**
  76043. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  76044. * @param otherVector defines the second operand
  76045. * @returns the new Vector3
  76046. */
  76047. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  76048. /**
  76049. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  76050. * @param otherVector defines the second operand
  76051. * @param result defines the Vector3 object where to store the result
  76052. * @returns the current Vector3
  76053. */
  76054. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  76055. /**
  76056. * Divides the current Vector3 coordinates by the given ones.
  76057. * @param otherVector defines the second operand
  76058. * @returns the current updated Vector3
  76059. */
  76060. divideInPlace(otherVector: Vector3): Vector3;
  76061. /**
  76062. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  76063. * @param other defines the second operand
  76064. * @returns the current updated Vector3
  76065. */
  76066. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  76067. /**
  76068. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  76069. * @param other defines the second operand
  76070. * @returns the current updated Vector3
  76071. */
  76072. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  76073. /**
  76074. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  76075. * @param x defines the x coordinate of the operand
  76076. * @param y defines the y coordinate of the operand
  76077. * @param z defines the z coordinate of the operand
  76078. * @returns the current updated Vector3
  76079. */
  76080. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  76081. /**
  76082. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  76083. * @param x defines the x coordinate of the operand
  76084. * @param y defines the y coordinate of the operand
  76085. * @param z defines the z coordinate of the operand
  76086. * @returns the current updated Vector3
  76087. */
  76088. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  76089. /**
  76090. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  76091. * Check if is non uniform within a certain amount of decimal places to account for this
  76092. * @param epsilon the amount the values can differ
  76093. * @returns if the the vector is non uniform to a certain number of decimal places
  76094. */
  76095. isNonUniformWithinEpsilon(epsilon: number): boolean;
  76096. /**
  76097. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  76098. */
  76099. get isNonUniform(): boolean;
  76100. /**
  76101. * Gets a new Vector3 from current Vector3 floored values
  76102. * @returns a new Vector3
  76103. */
  76104. floor(): Vector3;
  76105. /**
  76106. * Gets a new Vector3 from current Vector3 floored values
  76107. * @returns a new Vector3
  76108. */
  76109. fract(): Vector3;
  76110. /**
  76111. * Gets the length of the Vector3
  76112. * @returns the length of the Vector3
  76113. */
  76114. length(): number;
  76115. /**
  76116. * Gets the squared length of the Vector3
  76117. * @returns squared length of the Vector3
  76118. */
  76119. lengthSquared(): number;
  76120. /**
  76121. * Normalize the current Vector3.
  76122. * Please note that this is an in place operation.
  76123. * @returns the current updated Vector3
  76124. */
  76125. normalize(): Vector3;
  76126. /**
  76127. * Reorders the x y z properties of the vector in place
  76128. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  76129. * @returns the current updated vector
  76130. */
  76131. reorderInPlace(order: string): this;
  76132. /**
  76133. * Rotates the vector around 0,0,0 by a quaternion
  76134. * @param quaternion the rotation quaternion
  76135. * @param result vector to store the result
  76136. * @returns the resulting vector
  76137. */
  76138. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  76139. /**
  76140. * Rotates a vector around a given point
  76141. * @param quaternion the rotation quaternion
  76142. * @param point the point to rotate around
  76143. * @param result vector to store the result
  76144. * @returns the resulting vector
  76145. */
  76146. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  76147. /**
  76148. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  76149. * The cross product is then orthogonal to both current and "other"
  76150. * @param other defines the right operand
  76151. * @returns the cross product
  76152. */
  76153. cross(other: Vector3): Vector3;
  76154. /**
  76155. * Normalize the current Vector3 with the given input length.
  76156. * Please note that this is an in place operation.
  76157. * @param len the length of the vector
  76158. * @returns the current updated Vector3
  76159. */
  76160. normalizeFromLength(len: number): Vector3;
  76161. /**
  76162. * Normalize the current Vector3 to a new vector
  76163. * @returns the new Vector3
  76164. */
  76165. normalizeToNew(): Vector3;
  76166. /**
  76167. * Normalize the current Vector3 to the reference
  76168. * @param reference define the Vector3 to update
  76169. * @returns the updated Vector3
  76170. */
  76171. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  76172. /**
  76173. * Creates a new Vector3 copied from the current Vector3
  76174. * @returns the new Vector3
  76175. */
  76176. clone(): Vector3;
  76177. /**
  76178. * Copies the given vector coordinates to the current Vector3 ones
  76179. * @param source defines the source Vector3
  76180. * @returns the current updated Vector3
  76181. */
  76182. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  76183. /**
  76184. * Copies the given floats to the current Vector3 coordinates
  76185. * @param x defines the x coordinate of the operand
  76186. * @param y defines the y coordinate of the operand
  76187. * @param z defines the z coordinate of the operand
  76188. * @returns the current updated Vector3
  76189. */
  76190. copyFromFloats(x: number, y: number, z: number): Vector3;
  76191. /**
  76192. * Copies the given floats to the current Vector3 coordinates
  76193. * @param x defines the x coordinate of the operand
  76194. * @param y defines the y coordinate of the operand
  76195. * @param z defines the z coordinate of the operand
  76196. * @returns the current updated Vector3
  76197. */
  76198. set(x: number, y: number, z: number): Vector3;
  76199. /**
  76200. * Copies the given float to the current Vector3 coordinates
  76201. * @param v defines the x, y and z coordinates of the operand
  76202. * @returns the current updated Vector3
  76203. */
  76204. setAll(v: number): Vector3;
  76205. /**
  76206. * Get the clip factor between two vectors
  76207. * @param vector0 defines the first operand
  76208. * @param vector1 defines the second operand
  76209. * @param axis defines the axis to use
  76210. * @param size defines the size along the axis
  76211. * @returns the clip factor
  76212. */
  76213. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  76214. /**
  76215. * Get angle between two vectors
  76216. * @param vector0 angle between vector0 and vector1
  76217. * @param vector1 angle between vector0 and vector1
  76218. * @param normal direction of the normal
  76219. * @return the angle between vector0 and vector1
  76220. */
  76221. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  76222. /**
  76223. * Returns a new Vector3 set from the index "offset" of the given array
  76224. * @param array defines the source array
  76225. * @param offset defines the offset in the source array
  76226. * @returns the new Vector3
  76227. */
  76228. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  76229. /**
  76230. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  76231. * @param array defines the source array
  76232. * @param offset defines the offset in the source array
  76233. * @returns the new Vector3
  76234. * @deprecated Please use FromArray instead.
  76235. */
  76236. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  76237. /**
  76238. * Sets the given vector "result" with the element values from the index "offset" of the given array
  76239. * @param array defines the source array
  76240. * @param offset defines the offset in the source array
  76241. * @param result defines the Vector3 where to store the result
  76242. */
  76243. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  76244. /**
  76245. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  76246. * @param array defines the source array
  76247. * @param offset defines the offset in the source array
  76248. * @param result defines the Vector3 where to store the result
  76249. * @deprecated Please use FromArrayToRef instead.
  76250. */
  76251. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  76252. /**
  76253. * Sets the given vector "result" with the given floats.
  76254. * @param x defines the x coordinate of the source
  76255. * @param y defines the y coordinate of the source
  76256. * @param z defines the z coordinate of the source
  76257. * @param result defines the Vector3 where to store the result
  76258. */
  76259. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  76260. /**
  76261. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  76262. * @returns a new empty Vector3
  76263. */
  76264. static Zero(): Vector3;
  76265. /**
  76266. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  76267. * @returns a new unit Vector3
  76268. */
  76269. static One(): Vector3;
  76270. /**
  76271. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  76272. * @returns a new up Vector3
  76273. */
  76274. static Up(): Vector3;
  76275. /**
  76276. * Gets a up Vector3 that must not be updated
  76277. */
  76278. static get UpReadOnly(): DeepImmutable<Vector3>;
  76279. /**
  76280. * Gets a zero Vector3 that must not be updated
  76281. */
  76282. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  76283. /**
  76284. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  76285. * @returns a new down Vector3
  76286. */
  76287. static Down(): Vector3;
  76288. /**
  76289. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  76290. * @returns a new forward Vector3
  76291. */
  76292. static Forward(): Vector3;
  76293. /**
  76294. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  76295. * @returns a new forward Vector3
  76296. */
  76297. static Backward(): Vector3;
  76298. /**
  76299. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  76300. * @returns a new right Vector3
  76301. */
  76302. static Right(): Vector3;
  76303. /**
  76304. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  76305. * @returns a new left Vector3
  76306. */
  76307. static Left(): Vector3;
  76308. /**
  76309. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  76310. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  76311. * @param vector defines the Vector3 to transform
  76312. * @param transformation defines the transformation matrix
  76313. * @returns the transformed Vector3
  76314. */
  76315. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  76316. /**
  76317. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  76318. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  76319. * @param vector defines the Vector3 to transform
  76320. * @param transformation defines the transformation matrix
  76321. * @param result defines the Vector3 where to store the result
  76322. */
  76323. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76324. /**
  76325. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  76326. * This method computes tranformed coordinates only, not transformed direction vectors
  76327. * @param x define the x coordinate of the source vector
  76328. * @param y define the y coordinate of the source vector
  76329. * @param z define the z coordinate of the source vector
  76330. * @param transformation defines the transformation matrix
  76331. * @param result defines the Vector3 where to store the result
  76332. */
  76333. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76334. /**
  76335. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  76336. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76337. * @param vector defines the Vector3 to transform
  76338. * @param transformation defines the transformation matrix
  76339. * @returns the new Vector3
  76340. */
  76341. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  76342. /**
  76343. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  76344. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76345. * @param vector defines the Vector3 to transform
  76346. * @param transformation defines the transformation matrix
  76347. * @param result defines the Vector3 where to store the result
  76348. */
  76349. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76350. /**
  76351. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  76352. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76353. * @param x define the x coordinate of the source vector
  76354. * @param y define the y coordinate of the source vector
  76355. * @param z define the z coordinate of the source vector
  76356. * @param transformation defines the transformation matrix
  76357. * @param result defines the Vector3 where to store the result
  76358. */
  76359. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76360. /**
  76361. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  76362. * @param value1 defines the first control point
  76363. * @param value2 defines the second control point
  76364. * @param value3 defines the third control point
  76365. * @param value4 defines the fourth control point
  76366. * @param amount defines the amount on the spline to use
  76367. * @returns the new Vector3
  76368. */
  76369. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  76370. /**
  76371. * 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"
  76372. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76373. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76374. * @param value defines the current value
  76375. * @param min defines the lower range value
  76376. * @param max defines the upper range value
  76377. * @returns the new Vector3
  76378. */
  76379. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  76380. /**
  76381. * 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"
  76382. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76383. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76384. * @param value defines the current value
  76385. * @param min defines the lower range value
  76386. * @param max defines the upper range value
  76387. * @param result defines the Vector3 where to store the result
  76388. */
  76389. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  76390. /**
  76391. * Checks if a given vector is inside a specific range
  76392. * @param v defines the vector to test
  76393. * @param min defines the minimum range
  76394. * @param max defines the maximum range
  76395. */
  76396. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  76397. /**
  76398. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  76399. * @param value1 defines the first control point
  76400. * @param tangent1 defines the first tangent vector
  76401. * @param value2 defines the second control point
  76402. * @param tangent2 defines the second tangent vector
  76403. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  76404. * @returns the new Vector3
  76405. */
  76406. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  76407. /**
  76408. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  76409. * @param start defines the start value
  76410. * @param end defines the end value
  76411. * @param amount max defines amount between both (between 0 and 1)
  76412. * @returns the new Vector3
  76413. */
  76414. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  76415. /**
  76416. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  76417. * @param start defines the start value
  76418. * @param end defines the end value
  76419. * @param amount max defines amount between both (between 0 and 1)
  76420. * @param result defines the Vector3 where to store the result
  76421. */
  76422. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  76423. /**
  76424. * Returns the dot product (float) between the vectors "left" and "right"
  76425. * @param left defines the left operand
  76426. * @param right defines the right operand
  76427. * @returns the dot product
  76428. */
  76429. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  76430. /**
  76431. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  76432. * The cross product is then orthogonal to both "left" and "right"
  76433. * @param left defines the left operand
  76434. * @param right defines the right operand
  76435. * @returns the cross product
  76436. */
  76437. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76438. /**
  76439. * Sets the given vector "result" with the cross product of "left" and "right"
  76440. * The cross product is then orthogonal to both "left" and "right"
  76441. * @param left defines the left operand
  76442. * @param right defines the right operand
  76443. * @param result defines the Vector3 where to store the result
  76444. */
  76445. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  76446. /**
  76447. * Returns a new Vector3 as the normalization of the given vector
  76448. * @param vector defines the Vector3 to normalize
  76449. * @returns the new Vector3
  76450. */
  76451. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  76452. /**
  76453. * Sets the given vector "result" with the normalization of the given first vector
  76454. * @param vector defines the Vector3 to normalize
  76455. * @param result defines the Vector3 where to store the result
  76456. */
  76457. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  76458. /**
  76459. * Project a Vector3 onto screen space
  76460. * @param vector defines the Vector3 to project
  76461. * @param world defines the world matrix to use
  76462. * @param transform defines the transform (view x projection) matrix to use
  76463. * @param viewport defines the screen viewport to use
  76464. * @returns the new Vector3
  76465. */
  76466. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  76467. /** @hidden */
  76468. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  76469. /**
  76470. * Unproject from screen space to object space
  76471. * @param source defines the screen space Vector3 to use
  76472. * @param viewportWidth defines the current width of the viewport
  76473. * @param viewportHeight defines the current height of the viewport
  76474. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76475. * @param transform defines the transform (view x projection) matrix to use
  76476. * @returns the new Vector3
  76477. */
  76478. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  76479. /**
  76480. * Unproject from screen space to object space
  76481. * @param source defines the screen space Vector3 to use
  76482. * @param viewportWidth defines the current width of the viewport
  76483. * @param viewportHeight defines the current height of the viewport
  76484. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76485. * @param view defines the view matrix to use
  76486. * @param projection defines the projection matrix to use
  76487. * @returns the new Vector3
  76488. */
  76489. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  76490. /**
  76491. * Unproject from screen space to object space
  76492. * @param source defines the screen space Vector3 to use
  76493. * @param viewportWidth defines the current width of the viewport
  76494. * @param viewportHeight defines the current height of the viewport
  76495. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76496. * @param view defines the view matrix to use
  76497. * @param projection defines the projection matrix to use
  76498. * @param result defines the Vector3 where to store the result
  76499. */
  76500. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  76501. /**
  76502. * Unproject from screen space to object space
  76503. * @param sourceX defines the screen space x coordinate to use
  76504. * @param sourceY defines the screen space y coordinate to use
  76505. * @param sourceZ defines the screen space z coordinate to use
  76506. * @param viewportWidth defines the current width of the viewport
  76507. * @param viewportHeight defines the current height of the viewport
  76508. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76509. * @param view defines the view matrix to use
  76510. * @param projection defines the projection matrix to use
  76511. * @param result defines the Vector3 where to store the result
  76512. */
  76513. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  76514. /**
  76515. * Gets the minimal coordinate values between two Vector3
  76516. * @param left defines the first operand
  76517. * @param right defines the second operand
  76518. * @returns the new Vector3
  76519. */
  76520. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76521. /**
  76522. * Gets the maximal coordinate values between two Vector3
  76523. * @param left defines the first operand
  76524. * @param right defines the second operand
  76525. * @returns the new Vector3
  76526. */
  76527. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76528. /**
  76529. * Returns the distance between the vectors "value1" and "value2"
  76530. * @param value1 defines the first operand
  76531. * @param value2 defines the second operand
  76532. * @returns the distance
  76533. */
  76534. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  76535. /**
  76536. * Returns the squared distance between the vectors "value1" and "value2"
  76537. * @param value1 defines the first operand
  76538. * @param value2 defines the second operand
  76539. * @returns the squared distance
  76540. */
  76541. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  76542. /**
  76543. * Returns a new Vector3 located at the center between "value1" and "value2"
  76544. * @param value1 defines the first operand
  76545. * @param value2 defines the second operand
  76546. * @returns the new Vector3
  76547. */
  76548. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  76549. /**
  76550. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  76551. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  76552. * to something in order to rotate it from its local system to the given target system
  76553. * Note: axis1, axis2 and axis3 are normalized during this operation
  76554. * @param axis1 defines the first axis
  76555. * @param axis2 defines the second axis
  76556. * @param axis3 defines the third axis
  76557. * @returns a new Vector3
  76558. */
  76559. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  76560. /**
  76561. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  76562. * @param axis1 defines the first axis
  76563. * @param axis2 defines the second axis
  76564. * @param axis3 defines the third axis
  76565. * @param ref defines the Vector3 where to store the result
  76566. */
  76567. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  76568. }
  76569. /**
  76570. * Vector4 class created for EulerAngle class conversion to Quaternion
  76571. */
  76572. export class Vector4 {
  76573. /** x value of the vector */
  76574. x: number;
  76575. /** y value of the vector */
  76576. y: number;
  76577. /** z value of the vector */
  76578. z: number;
  76579. /** w value of the vector */
  76580. w: number;
  76581. /**
  76582. * Creates a Vector4 object from the given floats.
  76583. * @param x x value of the vector
  76584. * @param y y value of the vector
  76585. * @param z z value of the vector
  76586. * @param w w value of the vector
  76587. */
  76588. constructor(
  76589. /** x value of the vector */
  76590. x: number,
  76591. /** y value of the vector */
  76592. y: number,
  76593. /** z value of the vector */
  76594. z: number,
  76595. /** w value of the vector */
  76596. w: number);
  76597. /**
  76598. * Returns the string with the Vector4 coordinates.
  76599. * @returns a string containing all the vector values
  76600. */
  76601. toString(): string;
  76602. /**
  76603. * Returns the string "Vector4".
  76604. * @returns "Vector4"
  76605. */
  76606. getClassName(): string;
  76607. /**
  76608. * Returns the Vector4 hash code.
  76609. * @returns a unique hash code
  76610. */
  76611. getHashCode(): number;
  76612. /**
  76613. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  76614. * @returns the resulting array
  76615. */
  76616. asArray(): number[];
  76617. /**
  76618. * Populates the given array from the given index with the Vector4 coordinates.
  76619. * @param array array to populate
  76620. * @param index index of the array to start at (default: 0)
  76621. * @returns the Vector4.
  76622. */
  76623. toArray(array: FloatArray, index?: number): Vector4;
  76624. /**
  76625. * Adds the given vector to the current Vector4.
  76626. * @param otherVector the vector to add
  76627. * @returns the updated Vector4.
  76628. */
  76629. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76630. /**
  76631. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  76632. * @param otherVector the vector to add
  76633. * @returns the resulting vector
  76634. */
  76635. add(otherVector: DeepImmutable<Vector4>): Vector4;
  76636. /**
  76637. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  76638. * @param otherVector the vector to add
  76639. * @param result the vector to store the result
  76640. * @returns the current Vector4.
  76641. */
  76642. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76643. /**
  76644. * Subtract in place the given vector from the current Vector4.
  76645. * @param otherVector the vector to subtract
  76646. * @returns the updated Vector4.
  76647. */
  76648. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76649. /**
  76650. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  76651. * @param otherVector the vector to add
  76652. * @returns the new vector with the result
  76653. */
  76654. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  76655. /**
  76656. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  76657. * @param otherVector the vector to subtract
  76658. * @param result the vector to store the result
  76659. * @returns the current Vector4.
  76660. */
  76661. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76662. /**
  76663. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76664. */
  76665. /**
  76666. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76667. * @param x value to subtract
  76668. * @param y value to subtract
  76669. * @param z value to subtract
  76670. * @param w value to subtract
  76671. * @returns new vector containing the result
  76672. */
  76673. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76674. /**
  76675. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76676. * @param x value to subtract
  76677. * @param y value to subtract
  76678. * @param z value to subtract
  76679. * @param w value to subtract
  76680. * @param result the vector to store the result in
  76681. * @returns the current Vector4.
  76682. */
  76683. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  76684. /**
  76685. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  76686. * @returns a new vector with the negated values
  76687. */
  76688. negate(): Vector4;
  76689. /**
  76690. * Negate this vector in place
  76691. * @returns this
  76692. */
  76693. negateInPlace(): Vector4;
  76694. /**
  76695. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  76696. * @param result defines the Vector3 object where to store the result
  76697. * @returns the current Vector4
  76698. */
  76699. negateToRef(result: Vector4): Vector4;
  76700. /**
  76701. * Multiplies the current Vector4 coordinates by scale (float).
  76702. * @param scale the number to scale with
  76703. * @returns the updated Vector4.
  76704. */
  76705. scaleInPlace(scale: number): Vector4;
  76706. /**
  76707. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  76708. * @param scale the number to scale with
  76709. * @returns a new vector with the result
  76710. */
  76711. scale(scale: number): Vector4;
  76712. /**
  76713. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  76714. * @param scale the number to scale with
  76715. * @param result a vector to store the result in
  76716. * @returns the current Vector4.
  76717. */
  76718. scaleToRef(scale: number, result: Vector4): Vector4;
  76719. /**
  76720. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  76721. * @param scale defines the scale factor
  76722. * @param result defines the Vector4 object where to store the result
  76723. * @returns the unmodified current Vector4
  76724. */
  76725. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  76726. /**
  76727. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  76728. * @param otherVector the vector to compare against
  76729. * @returns true if they are equal
  76730. */
  76731. equals(otherVector: DeepImmutable<Vector4>): boolean;
  76732. /**
  76733. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  76734. * @param otherVector vector to compare against
  76735. * @param epsilon (Default: very small number)
  76736. * @returns true if they are equal
  76737. */
  76738. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  76739. /**
  76740. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  76741. * @param x x value to compare against
  76742. * @param y y value to compare against
  76743. * @param z z value to compare against
  76744. * @param w w value to compare against
  76745. * @returns true if equal
  76746. */
  76747. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  76748. /**
  76749. * Multiplies in place the current Vector4 by the given one.
  76750. * @param otherVector vector to multiple with
  76751. * @returns the updated Vector4.
  76752. */
  76753. multiplyInPlace(otherVector: Vector4): Vector4;
  76754. /**
  76755. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  76756. * @param otherVector vector to multiple with
  76757. * @returns resulting new vector
  76758. */
  76759. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  76760. /**
  76761. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  76762. * @param otherVector vector to multiple with
  76763. * @param result vector to store the result
  76764. * @returns the current Vector4.
  76765. */
  76766. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76767. /**
  76768. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  76769. * @param x x value multiply with
  76770. * @param y y value multiply with
  76771. * @param z z value multiply with
  76772. * @param w w value multiply with
  76773. * @returns resulting new vector
  76774. */
  76775. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  76776. /**
  76777. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  76778. * @param otherVector vector to devide with
  76779. * @returns resulting new vector
  76780. */
  76781. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  76782. /**
  76783. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  76784. * @param otherVector vector to devide with
  76785. * @param result vector to store the result
  76786. * @returns the current Vector4.
  76787. */
  76788. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76789. /**
  76790. * Divides the current Vector3 coordinates by the given ones.
  76791. * @param otherVector vector to devide with
  76792. * @returns the updated Vector3.
  76793. */
  76794. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76795. /**
  76796. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  76797. * @param other defines the second operand
  76798. * @returns the current updated Vector4
  76799. */
  76800. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76801. /**
  76802. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  76803. * @param other defines the second operand
  76804. * @returns the current updated Vector4
  76805. */
  76806. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76807. /**
  76808. * Gets a new Vector4 from current Vector4 floored values
  76809. * @returns a new Vector4
  76810. */
  76811. floor(): Vector4;
  76812. /**
  76813. * Gets a new Vector4 from current Vector3 floored values
  76814. * @returns a new Vector4
  76815. */
  76816. fract(): Vector4;
  76817. /**
  76818. * Returns the Vector4 length (float).
  76819. * @returns the length
  76820. */
  76821. length(): number;
  76822. /**
  76823. * Returns the Vector4 squared length (float).
  76824. * @returns the length squared
  76825. */
  76826. lengthSquared(): number;
  76827. /**
  76828. * Normalizes in place the Vector4.
  76829. * @returns the updated Vector4.
  76830. */
  76831. normalize(): Vector4;
  76832. /**
  76833. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  76834. * @returns this converted to a new vector3
  76835. */
  76836. toVector3(): Vector3;
  76837. /**
  76838. * Returns a new Vector4 copied from the current one.
  76839. * @returns the new cloned vector
  76840. */
  76841. clone(): Vector4;
  76842. /**
  76843. * Updates the current Vector4 with the given one coordinates.
  76844. * @param source the source vector to copy from
  76845. * @returns the updated Vector4.
  76846. */
  76847. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  76848. /**
  76849. * Updates the current Vector4 coordinates with the given floats.
  76850. * @param x float to copy from
  76851. * @param y float to copy from
  76852. * @param z float to copy from
  76853. * @param w float to copy from
  76854. * @returns the updated Vector4.
  76855. */
  76856. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76857. /**
  76858. * Updates the current Vector4 coordinates with the given floats.
  76859. * @param x float to set from
  76860. * @param y float to set from
  76861. * @param z float to set from
  76862. * @param w float to set from
  76863. * @returns the updated Vector4.
  76864. */
  76865. set(x: number, y: number, z: number, w: number): Vector4;
  76866. /**
  76867. * Copies the given float to the current Vector3 coordinates
  76868. * @param v defines the x, y, z and w coordinates of the operand
  76869. * @returns the current updated Vector3
  76870. */
  76871. setAll(v: number): Vector4;
  76872. /**
  76873. * Returns a new Vector4 set from the starting index of the given array.
  76874. * @param array the array to pull values from
  76875. * @param offset the offset into the array to start at
  76876. * @returns the new vector
  76877. */
  76878. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  76879. /**
  76880. * Updates the given vector "result" from the starting index of the given array.
  76881. * @param array the array to pull values from
  76882. * @param offset the offset into the array to start at
  76883. * @param result the vector to store the result in
  76884. */
  76885. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  76886. /**
  76887. * Updates the given vector "result" from the starting index of the given Float32Array.
  76888. * @param array the array to pull values from
  76889. * @param offset the offset into the array to start at
  76890. * @param result the vector to store the result in
  76891. */
  76892. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  76893. /**
  76894. * Updates the given vector "result" coordinates from the given floats.
  76895. * @param x float to set from
  76896. * @param y float to set from
  76897. * @param z float to set from
  76898. * @param w float to set from
  76899. * @param result the vector to the floats in
  76900. */
  76901. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  76902. /**
  76903. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  76904. * @returns the new vector
  76905. */
  76906. static Zero(): Vector4;
  76907. /**
  76908. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  76909. * @returns the new vector
  76910. */
  76911. static One(): Vector4;
  76912. /**
  76913. * Returns a new normalized Vector4 from the given one.
  76914. * @param vector the vector to normalize
  76915. * @returns the vector
  76916. */
  76917. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  76918. /**
  76919. * Updates the given vector "result" from the normalization of the given one.
  76920. * @param vector the vector to normalize
  76921. * @param result the vector to store the result in
  76922. */
  76923. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  76924. /**
  76925. * Returns a vector with the minimum values from the left and right vectors
  76926. * @param left left vector to minimize
  76927. * @param right right vector to minimize
  76928. * @returns a new vector with the minimum of the left and right vector values
  76929. */
  76930. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76931. /**
  76932. * Returns a vector with the maximum values from the left and right vectors
  76933. * @param left left vector to maximize
  76934. * @param right right vector to maximize
  76935. * @returns a new vector with the maximum of the left and right vector values
  76936. */
  76937. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76938. /**
  76939. * Returns the distance (float) between the vectors "value1" and "value2".
  76940. * @param value1 value to calulate the distance between
  76941. * @param value2 value to calulate the distance between
  76942. * @return the distance between the two vectors
  76943. */
  76944. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76945. /**
  76946. * Returns the squared distance (float) between the vectors "value1" and "value2".
  76947. * @param value1 value to calulate the distance between
  76948. * @param value2 value to calulate the distance between
  76949. * @return the distance between the two vectors squared
  76950. */
  76951. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76952. /**
  76953. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  76954. * @param value1 value to calulate the center between
  76955. * @param value2 value to calulate the center between
  76956. * @return the center between the two vectors
  76957. */
  76958. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  76959. /**
  76960. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  76961. * This methods computes transformed normalized direction vectors only.
  76962. * @param vector the vector to transform
  76963. * @param transformation the transformation matrix to apply
  76964. * @returns the new vector
  76965. */
  76966. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  76967. /**
  76968. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  76969. * This methods computes transformed normalized direction vectors only.
  76970. * @param vector the vector to transform
  76971. * @param transformation the transformation matrix to apply
  76972. * @param result the vector to store the result in
  76973. */
  76974. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76975. /**
  76976. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  76977. * This methods computes transformed normalized direction vectors only.
  76978. * @param x value to transform
  76979. * @param y value to transform
  76980. * @param z value to transform
  76981. * @param w value to transform
  76982. * @param transformation the transformation matrix to apply
  76983. * @param result the vector to store the results in
  76984. */
  76985. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76986. /**
  76987. * Creates a new Vector4 from a Vector3
  76988. * @param source defines the source data
  76989. * @param w defines the 4th component (default is 0)
  76990. * @returns a new Vector4
  76991. */
  76992. static FromVector3(source: Vector3, w?: number): Vector4;
  76993. }
  76994. /**
  76995. * Class used to store quaternion data
  76996. * @see https://en.wikipedia.org/wiki/Quaternion
  76997. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  76998. */
  76999. export class Quaternion {
  77000. /** defines the first component (0 by default) */
  77001. x: number;
  77002. /** defines the second component (0 by default) */
  77003. y: number;
  77004. /** defines the third component (0 by default) */
  77005. z: number;
  77006. /** defines the fourth component (1.0 by default) */
  77007. w: number;
  77008. /**
  77009. * Creates a new Quaternion from the given floats
  77010. * @param x defines the first component (0 by default)
  77011. * @param y defines the second component (0 by default)
  77012. * @param z defines the third component (0 by default)
  77013. * @param w defines the fourth component (1.0 by default)
  77014. */
  77015. constructor(
  77016. /** defines the first component (0 by default) */
  77017. x?: number,
  77018. /** defines the second component (0 by default) */
  77019. y?: number,
  77020. /** defines the third component (0 by default) */
  77021. z?: number,
  77022. /** defines the fourth component (1.0 by default) */
  77023. w?: number);
  77024. /**
  77025. * Gets a string representation for the current quaternion
  77026. * @returns a string with the Quaternion coordinates
  77027. */
  77028. toString(): string;
  77029. /**
  77030. * Gets the class name of the quaternion
  77031. * @returns the string "Quaternion"
  77032. */
  77033. getClassName(): string;
  77034. /**
  77035. * Gets a hash code for this quaternion
  77036. * @returns the quaternion hash code
  77037. */
  77038. getHashCode(): number;
  77039. /**
  77040. * Copy the quaternion to an array
  77041. * @returns a new array populated with 4 elements from the quaternion coordinates
  77042. */
  77043. asArray(): number[];
  77044. /**
  77045. * Check if two quaternions are equals
  77046. * @param otherQuaternion defines the second operand
  77047. * @return true if the current quaternion and the given one coordinates are strictly equals
  77048. */
  77049. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  77050. /**
  77051. * Gets a boolean if two quaternions are equals (using an epsilon value)
  77052. * @param otherQuaternion defines the other quaternion
  77053. * @param epsilon defines the minimal distance to consider equality
  77054. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  77055. */
  77056. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  77057. /**
  77058. * Clone the current quaternion
  77059. * @returns a new quaternion copied from the current one
  77060. */
  77061. clone(): Quaternion;
  77062. /**
  77063. * Copy a quaternion to the current one
  77064. * @param other defines the other quaternion
  77065. * @returns the updated current quaternion
  77066. */
  77067. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  77068. /**
  77069. * Updates the current quaternion with the given float coordinates
  77070. * @param x defines the x coordinate
  77071. * @param y defines the y coordinate
  77072. * @param z defines the z coordinate
  77073. * @param w defines the w coordinate
  77074. * @returns the updated current quaternion
  77075. */
  77076. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  77077. /**
  77078. * Updates the current quaternion from the given float coordinates
  77079. * @param x defines the x coordinate
  77080. * @param y defines the y coordinate
  77081. * @param z defines the z coordinate
  77082. * @param w defines the w coordinate
  77083. * @returns the updated current quaternion
  77084. */
  77085. set(x: number, y: number, z: number, w: number): Quaternion;
  77086. /**
  77087. * Adds two quaternions
  77088. * @param other defines the second operand
  77089. * @returns a new quaternion as the addition result of the given one and the current quaternion
  77090. */
  77091. add(other: DeepImmutable<Quaternion>): Quaternion;
  77092. /**
  77093. * Add a quaternion to the current one
  77094. * @param other defines the quaternion to add
  77095. * @returns the current quaternion
  77096. */
  77097. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  77098. /**
  77099. * Subtract two quaternions
  77100. * @param other defines the second operand
  77101. * @returns a new quaternion as the subtraction result of the given one from the current one
  77102. */
  77103. subtract(other: Quaternion): Quaternion;
  77104. /**
  77105. * Multiplies the current quaternion by a scale factor
  77106. * @param value defines the scale factor
  77107. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  77108. */
  77109. scale(value: number): Quaternion;
  77110. /**
  77111. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  77112. * @param scale defines the scale factor
  77113. * @param result defines the Quaternion object where to store the result
  77114. * @returns the unmodified current quaternion
  77115. */
  77116. scaleToRef(scale: number, result: Quaternion): Quaternion;
  77117. /**
  77118. * Multiplies in place the current quaternion by a scale factor
  77119. * @param value defines the scale factor
  77120. * @returns the current modified quaternion
  77121. */
  77122. scaleInPlace(value: number): Quaternion;
  77123. /**
  77124. * Scale the current quaternion values by a factor and add the result to a given quaternion
  77125. * @param scale defines the scale factor
  77126. * @param result defines the Quaternion object where to store the result
  77127. * @returns the unmodified current quaternion
  77128. */
  77129. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  77130. /**
  77131. * Multiplies two quaternions
  77132. * @param q1 defines the second operand
  77133. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  77134. */
  77135. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  77136. /**
  77137. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  77138. * @param q1 defines the second operand
  77139. * @param result defines the target quaternion
  77140. * @returns the current quaternion
  77141. */
  77142. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  77143. /**
  77144. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  77145. * @param q1 defines the second operand
  77146. * @returns the currentupdated quaternion
  77147. */
  77148. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  77149. /**
  77150. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  77151. * @param ref defines the target quaternion
  77152. * @returns the current quaternion
  77153. */
  77154. conjugateToRef(ref: Quaternion): Quaternion;
  77155. /**
  77156. * Conjugates in place (1-q) the current quaternion
  77157. * @returns the current updated quaternion
  77158. */
  77159. conjugateInPlace(): Quaternion;
  77160. /**
  77161. * Conjugates in place (1-q) the current quaternion
  77162. * @returns a new quaternion
  77163. */
  77164. conjugate(): Quaternion;
  77165. /**
  77166. * Gets length of current quaternion
  77167. * @returns the quaternion length (float)
  77168. */
  77169. length(): number;
  77170. /**
  77171. * Normalize in place the current quaternion
  77172. * @returns the current updated quaternion
  77173. */
  77174. normalize(): Quaternion;
  77175. /**
  77176. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  77177. * @param order is a reserved parameter and is ignore for now
  77178. * @returns a new Vector3 containing the Euler angles
  77179. */
  77180. toEulerAngles(order?: string): Vector3;
  77181. /**
  77182. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  77183. * @param result defines the vector which will be filled with the Euler angles
  77184. * @param order is a reserved parameter and is ignore for now
  77185. * @returns the current unchanged quaternion
  77186. */
  77187. toEulerAnglesToRef(result: Vector3): Quaternion;
  77188. /**
  77189. * Updates the given rotation matrix with the current quaternion values
  77190. * @param result defines the target matrix
  77191. * @returns the current unchanged quaternion
  77192. */
  77193. toRotationMatrix(result: Matrix): Quaternion;
  77194. /**
  77195. * Updates the current quaternion from the given rotation matrix values
  77196. * @param matrix defines the source matrix
  77197. * @returns the current updated quaternion
  77198. */
  77199. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  77200. /**
  77201. * Creates a new quaternion from a rotation matrix
  77202. * @param matrix defines the source matrix
  77203. * @returns a new quaternion created from the given rotation matrix values
  77204. */
  77205. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  77206. /**
  77207. * Updates the given quaternion with the given rotation matrix values
  77208. * @param matrix defines the source matrix
  77209. * @param result defines the target quaternion
  77210. */
  77211. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  77212. /**
  77213. * Returns the dot product (float) between the quaternions "left" and "right"
  77214. * @param left defines the left operand
  77215. * @param right defines the right operand
  77216. * @returns the dot product
  77217. */
  77218. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  77219. /**
  77220. * Checks if the two quaternions are close to each other
  77221. * @param quat0 defines the first quaternion to check
  77222. * @param quat1 defines the second quaternion to check
  77223. * @returns true if the two quaternions are close to each other
  77224. */
  77225. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  77226. /**
  77227. * Creates an empty quaternion
  77228. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  77229. */
  77230. static Zero(): Quaternion;
  77231. /**
  77232. * Inverse a given quaternion
  77233. * @param q defines the source quaternion
  77234. * @returns a new quaternion as the inverted current quaternion
  77235. */
  77236. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  77237. /**
  77238. * Inverse a given quaternion
  77239. * @param q defines the source quaternion
  77240. * @param result the quaternion the result will be stored in
  77241. * @returns the result quaternion
  77242. */
  77243. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  77244. /**
  77245. * Creates an identity quaternion
  77246. * @returns the identity quaternion
  77247. */
  77248. static Identity(): Quaternion;
  77249. /**
  77250. * Gets a boolean indicating if the given quaternion is identity
  77251. * @param quaternion defines the quaternion to check
  77252. * @returns true if the quaternion is identity
  77253. */
  77254. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  77255. /**
  77256. * Creates a quaternion from a rotation around an axis
  77257. * @param axis defines the axis to use
  77258. * @param angle defines the angle to use
  77259. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  77260. */
  77261. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  77262. /**
  77263. * Creates a rotation around an axis and stores it into the given quaternion
  77264. * @param axis defines the axis to use
  77265. * @param angle defines the angle to use
  77266. * @param result defines the target quaternion
  77267. * @returns the target quaternion
  77268. */
  77269. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  77270. /**
  77271. * Creates a new quaternion from data stored into an array
  77272. * @param array defines the data source
  77273. * @param offset defines the offset in the source array where the data starts
  77274. * @returns a new quaternion
  77275. */
  77276. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  77277. /**
  77278. * Updates the given quaternion "result" from the starting index of the given array.
  77279. * @param array the array to pull values from
  77280. * @param offset the offset into the array to start at
  77281. * @param result the quaternion to store the result in
  77282. */
  77283. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  77284. /**
  77285. * Create a quaternion from Euler rotation angles
  77286. * @param x Pitch
  77287. * @param y Yaw
  77288. * @param z Roll
  77289. * @returns the new Quaternion
  77290. */
  77291. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  77292. /**
  77293. * Updates a quaternion from Euler rotation angles
  77294. * @param x Pitch
  77295. * @param y Yaw
  77296. * @param z Roll
  77297. * @param result the quaternion to store the result
  77298. * @returns the updated quaternion
  77299. */
  77300. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  77301. /**
  77302. * Create a quaternion from Euler rotation vector
  77303. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  77304. * @returns the new Quaternion
  77305. */
  77306. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  77307. /**
  77308. * Updates a quaternion from Euler rotation vector
  77309. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  77310. * @param result the quaternion to store the result
  77311. * @returns the updated quaternion
  77312. */
  77313. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  77314. /**
  77315. * Creates a new quaternion from the given Euler float angles (y, x, z)
  77316. * @param yaw defines the rotation around Y axis
  77317. * @param pitch defines the rotation around X axis
  77318. * @param roll defines the rotation around Z axis
  77319. * @returns the new quaternion
  77320. */
  77321. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  77322. /**
  77323. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  77324. * @param yaw defines the rotation around Y axis
  77325. * @param pitch defines the rotation around X axis
  77326. * @param roll defines the rotation around Z axis
  77327. * @param result defines the target quaternion
  77328. */
  77329. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  77330. /**
  77331. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  77332. * @param alpha defines the rotation around first axis
  77333. * @param beta defines the rotation around second axis
  77334. * @param gamma defines the rotation around third axis
  77335. * @returns the new quaternion
  77336. */
  77337. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  77338. /**
  77339. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  77340. * @param alpha defines the rotation around first axis
  77341. * @param beta defines the rotation around second axis
  77342. * @param gamma defines the rotation around third axis
  77343. * @param result defines the target quaternion
  77344. */
  77345. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  77346. /**
  77347. * 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)
  77348. * @param axis1 defines the first axis
  77349. * @param axis2 defines the second axis
  77350. * @param axis3 defines the third axis
  77351. * @returns the new quaternion
  77352. */
  77353. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  77354. /**
  77355. * 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
  77356. * @param axis1 defines the first axis
  77357. * @param axis2 defines the second axis
  77358. * @param axis3 defines the third axis
  77359. * @param ref defines the target quaternion
  77360. */
  77361. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  77362. /**
  77363. * Interpolates between two quaternions
  77364. * @param left defines first quaternion
  77365. * @param right defines second quaternion
  77366. * @param amount defines the gradient to use
  77367. * @returns the new interpolated quaternion
  77368. */
  77369. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77370. /**
  77371. * Interpolates between two quaternions and stores it into a target quaternion
  77372. * @param left defines first quaternion
  77373. * @param right defines second quaternion
  77374. * @param amount defines the gradient to use
  77375. * @param result defines the target quaternion
  77376. */
  77377. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  77378. /**
  77379. * Interpolate between two quaternions using Hermite interpolation
  77380. * @param value1 defines first quaternion
  77381. * @param tangent1 defines the incoming tangent
  77382. * @param value2 defines second quaternion
  77383. * @param tangent2 defines the outgoing tangent
  77384. * @param amount defines the target quaternion
  77385. * @returns the new interpolated quaternion
  77386. */
  77387. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77388. }
  77389. /**
  77390. * Class used to store matrix data (4x4)
  77391. */
  77392. export class Matrix {
  77393. private static _updateFlagSeed;
  77394. private static _identityReadOnly;
  77395. private _isIdentity;
  77396. private _isIdentityDirty;
  77397. private _isIdentity3x2;
  77398. private _isIdentity3x2Dirty;
  77399. /**
  77400. * Gets the update flag of the matrix which is an unique number for the matrix.
  77401. * It will be incremented every time the matrix data change.
  77402. * You can use it to speed the comparison between two versions of the same matrix.
  77403. */
  77404. updateFlag: number;
  77405. private readonly _m;
  77406. /**
  77407. * Gets the internal data of the matrix
  77408. */
  77409. get m(): DeepImmutable<Float32Array>;
  77410. /** @hidden */
  77411. _markAsUpdated(): void;
  77412. /** @hidden */
  77413. private _updateIdentityStatus;
  77414. /**
  77415. * Creates an empty matrix (filled with zeros)
  77416. */
  77417. constructor();
  77418. /**
  77419. * Check if the current matrix is identity
  77420. * @returns true is the matrix is the identity matrix
  77421. */
  77422. isIdentity(): boolean;
  77423. /**
  77424. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  77425. * @returns true is the matrix is the identity matrix
  77426. */
  77427. isIdentityAs3x2(): boolean;
  77428. /**
  77429. * Gets the determinant of the matrix
  77430. * @returns the matrix determinant
  77431. */
  77432. determinant(): number;
  77433. /**
  77434. * Returns the matrix as a Float32Array
  77435. * @returns the matrix underlying array
  77436. */
  77437. toArray(): DeepImmutable<Float32Array>;
  77438. /**
  77439. * Returns the matrix as a Float32Array
  77440. * @returns the matrix underlying array.
  77441. */
  77442. asArray(): DeepImmutable<Float32Array>;
  77443. /**
  77444. * Inverts the current matrix in place
  77445. * @returns the current inverted matrix
  77446. */
  77447. invert(): Matrix;
  77448. /**
  77449. * Sets all the matrix elements to zero
  77450. * @returns the current matrix
  77451. */
  77452. reset(): Matrix;
  77453. /**
  77454. * Adds the current matrix with a second one
  77455. * @param other defines the matrix to add
  77456. * @returns a new matrix as the addition of the current matrix and the given one
  77457. */
  77458. add(other: DeepImmutable<Matrix>): Matrix;
  77459. /**
  77460. * Sets the given matrix "result" to the addition of the current matrix and the given one
  77461. * @param other defines the matrix to add
  77462. * @param result defines the target matrix
  77463. * @returns the current matrix
  77464. */
  77465. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  77466. /**
  77467. * Adds in place the given matrix to the current matrix
  77468. * @param other defines the second operand
  77469. * @returns the current updated matrix
  77470. */
  77471. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  77472. /**
  77473. * Sets the given matrix to the current inverted Matrix
  77474. * @param other defines the target matrix
  77475. * @returns the unmodified current matrix
  77476. */
  77477. invertToRef(other: Matrix): Matrix;
  77478. /**
  77479. * add a value at the specified position in the current Matrix
  77480. * @param index the index of the value within the matrix. between 0 and 15.
  77481. * @param value the value to be added
  77482. * @returns the current updated matrix
  77483. */
  77484. addAtIndex(index: number, value: number): Matrix;
  77485. /**
  77486. * mutiply the specified position in the current Matrix by a value
  77487. * @param index the index of the value within the matrix. between 0 and 15.
  77488. * @param value the value to be added
  77489. * @returns the current updated matrix
  77490. */
  77491. multiplyAtIndex(index: number, value: number): Matrix;
  77492. /**
  77493. * Inserts the translation vector (using 3 floats) in the current matrix
  77494. * @param x defines the 1st component of the translation
  77495. * @param y defines the 2nd component of the translation
  77496. * @param z defines the 3rd component of the translation
  77497. * @returns the current updated matrix
  77498. */
  77499. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  77500. /**
  77501. * Adds the translation vector (using 3 floats) in the current matrix
  77502. * @param x defines the 1st component of the translation
  77503. * @param y defines the 2nd component of the translation
  77504. * @param z defines the 3rd component of the translation
  77505. * @returns the current updated matrix
  77506. */
  77507. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  77508. /**
  77509. * Inserts the translation vector in the current matrix
  77510. * @param vector3 defines the translation to insert
  77511. * @returns the current updated matrix
  77512. */
  77513. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  77514. /**
  77515. * Gets the translation value of the current matrix
  77516. * @returns a new Vector3 as the extracted translation from the matrix
  77517. */
  77518. getTranslation(): Vector3;
  77519. /**
  77520. * Fill a Vector3 with the extracted translation from the matrix
  77521. * @param result defines the Vector3 where to store the translation
  77522. * @returns the current matrix
  77523. */
  77524. getTranslationToRef(result: Vector3): Matrix;
  77525. /**
  77526. * Remove rotation and scaling part from the matrix
  77527. * @returns the updated matrix
  77528. */
  77529. removeRotationAndScaling(): Matrix;
  77530. /**
  77531. * Multiply two matrices
  77532. * @param other defines the second operand
  77533. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  77534. */
  77535. multiply(other: DeepImmutable<Matrix>): Matrix;
  77536. /**
  77537. * Copy the current matrix from the given one
  77538. * @param other defines the source matrix
  77539. * @returns the current updated matrix
  77540. */
  77541. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  77542. /**
  77543. * Populates the given array from the starting index with the current matrix values
  77544. * @param array defines the target array
  77545. * @param offset defines the offset in the target array where to start storing values
  77546. * @returns the current matrix
  77547. */
  77548. copyToArray(array: Float32Array, offset?: number): Matrix;
  77549. /**
  77550. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  77551. * @param other defines the second operand
  77552. * @param result defines the matrix where to store the multiplication
  77553. * @returns the current matrix
  77554. */
  77555. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  77556. /**
  77557. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  77558. * @param other defines the second operand
  77559. * @param result defines the array where to store the multiplication
  77560. * @param offset defines the offset in the target array where to start storing values
  77561. * @returns the current matrix
  77562. */
  77563. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  77564. /**
  77565. * Check equality between this matrix and a second one
  77566. * @param value defines the second matrix to compare
  77567. * @returns true is the current matrix and the given one values are strictly equal
  77568. */
  77569. equals(value: DeepImmutable<Matrix>): boolean;
  77570. /**
  77571. * Clone the current matrix
  77572. * @returns a new matrix from the current matrix
  77573. */
  77574. clone(): Matrix;
  77575. /**
  77576. * Returns the name of the current matrix class
  77577. * @returns the string "Matrix"
  77578. */
  77579. getClassName(): string;
  77580. /**
  77581. * Gets the hash code of the current matrix
  77582. * @returns the hash code
  77583. */
  77584. getHashCode(): number;
  77585. /**
  77586. * Decomposes the current Matrix into a translation, rotation and scaling components
  77587. * @param scale defines the scale vector3 given as a reference to update
  77588. * @param rotation defines the rotation quaternion given as a reference to update
  77589. * @param translation defines the translation vector3 given as a reference to update
  77590. * @returns true if operation was successful
  77591. */
  77592. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  77593. /**
  77594. * Gets specific row of the matrix
  77595. * @param index defines the number of the row to get
  77596. * @returns the index-th row of the current matrix as a new Vector4
  77597. */
  77598. getRow(index: number): Nullable<Vector4>;
  77599. /**
  77600. * Sets the index-th row of the current matrix to the vector4 values
  77601. * @param index defines the number of the row to set
  77602. * @param row defines the target vector4
  77603. * @returns the updated current matrix
  77604. */
  77605. setRow(index: number, row: Vector4): Matrix;
  77606. /**
  77607. * Compute the transpose of the matrix
  77608. * @returns the new transposed matrix
  77609. */
  77610. transpose(): Matrix;
  77611. /**
  77612. * Compute the transpose of the matrix and store it in a given matrix
  77613. * @param result defines the target matrix
  77614. * @returns the current matrix
  77615. */
  77616. transposeToRef(result: Matrix): Matrix;
  77617. /**
  77618. * Sets the index-th row of the current matrix with the given 4 x float values
  77619. * @param index defines the row index
  77620. * @param x defines the x component to set
  77621. * @param y defines the y component to set
  77622. * @param z defines the z component to set
  77623. * @param w defines the w component to set
  77624. * @returns the updated current matrix
  77625. */
  77626. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  77627. /**
  77628. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  77629. * @param scale defines the scale factor
  77630. * @returns a new matrix
  77631. */
  77632. scale(scale: number): Matrix;
  77633. /**
  77634. * Scale the current matrix values by a factor to a given result matrix
  77635. * @param scale defines the scale factor
  77636. * @param result defines the matrix to store the result
  77637. * @returns the current matrix
  77638. */
  77639. scaleToRef(scale: number, result: Matrix): Matrix;
  77640. /**
  77641. * Scale the current matrix values by a factor and add the result to a given matrix
  77642. * @param scale defines the scale factor
  77643. * @param result defines the Matrix to store the result
  77644. * @returns the current matrix
  77645. */
  77646. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  77647. /**
  77648. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  77649. * @param ref matrix to store the result
  77650. */
  77651. toNormalMatrix(ref: Matrix): void;
  77652. /**
  77653. * Gets only rotation part of the current matrix
  77654. * @returns a new matrix sets to the extracted rotation matrix from the current one
  77655. */
  77656. getRotationMatrix(): Matrix;
  77657. /**
  77658. * Extracts the rotation matrix from the current one and sets it as the given "result"
  77659. * @param result defines the target matrix to store data to
  77660. * @returns the current matrix
  77661. */
  77662. getRotationMatrixToRef(result: Matrix): Matrix;
  77663. /**
  77664. * Toggles model matrix from being right handed to left handed in place and vice versa
  77665. */
  77666. toggleModelMatrixHandInPlace(): void;
  77667. /**
  77668. * Toggles projection matrix from being right handed to left handed in place and vice versa
  77669. */
  77670. toggleProjectionMatrixHandInPlace(): void;
  77671. /**
  77672. * Creates a matrix from an array
  77673. * @param array defines the source array
  77674. * @param offset defines an offset in the source array
  77675. * @returns a new Matrix set from the starting index of the given array
  77676. */
  77677. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  77678. /**
  77679. * Copy the content of an array into a given matrix
  77680. * @param array defines the source array
  77681. * @param offset defines an offset in the source array
  77682. * @param result defines the target matrix
  77683. */
  77684. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  77685. /**
  77686. * Stores an array into a matrix after having multiplied each component by a given factor
  77687. * @param array defines the source array
  77688. * @param offset defines the offset in the source array
  77689. * @param scale defines the scaling factor
  77690. * @param result defines the target matrix
  77691. */
  77692. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  77693. /**
  77694. * Gets an identity matrix that must not be updated
  77695. */
  77696. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  77697. /**
  77698. * Stores a list of values (16) inside a given matrix
  77699. * @param initialM11 defines 1st value of 1st row
  77700. * @param initialM12 defines 2nd value of 1st row
  77701. * @param initialM13 defines 3rd value of 1st row
  77702. * @param initialM14 defines 4th value of 1st row
  77703. * @param initialM21 defines 1st value of 2nd row
  77704. * @param initialM22 defines 2nd value of 2nd row
  77705. * @param initialM23 defines 3rd value of 2nd row
  77706. * @param initialM24 defines 4th value of 2nd row
  77707. * @param initialM31 defines 1st value of 3rd row
  77708. * @param initialM32 defines 2nd value of 3rd row
  77709. * @param initialM33 defines 3rd value of 3rd row
  77710. * @param initialM34 defines 4th value of 3rd row
  77711. * @param initialM41 defines 1st value of 4th row
  77712. * @param initialM42 defines 2nd value of 4th row
  77713. * @param initialM43 defines 3rd value of 4th row
  77714. * @param initialM44 defines 4th value of 4th row
  77715. * @param result defines the target matrix
  77716. */
  77717. 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;
  77718. /**
  77719. * Creates new matrix from a list of values (16)
  77720. * @param initialM11 defines 1st value of 1st row
  77721. * @param initialM12 defines 2nd value of 1st row
  77722. * @param initialM13 defines 3rd value of 1st row
  77723. * @param initialM14 defines 4th value of 1st row
  77724. * @param initialM21 defines 1st value of 2nd row
  77725. * @param initialM22 defines 2nd value of 2nd row
  77726. * @param initialM23 defines 3rd value of 2nd row
  77727. * @param initialM24 defines 4th value of 2nd row
  77728. * @param initialM31 defines 1st value of 3rd row
  77729. * @param initialM32 defines 2nd value of 3rd row
  77730. * @param initialM33 defines 3rd value of 3rd row
  77731. * @param initialM34 defines 4th value of 3rd row
  77732. * @param initialM41 defines 1st value of 4th row
  77733. * @param initialM42 defines 2nd value of 4th row
  77734. * @param initialM43 defines 3rd value of 4th row
  77735. * @param initialM44 defines 4th value of 4th row
  77736. * @returns the new matrix
  77737. */
  77738. 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;
  77739. /**
  77740. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77741. * @param scale defines the scale vector3
  77742. * @param rotation defines the rotation quaternion
  77743. * @param translation defines the translation vector3
  77744. * @returns a new matrix
  77745. */
  77746. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  77747. /**
  77748. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77749. * @param scale defines the scale vector3
  77750. * @param rotation defines the rotation quaternion
  77751. * @param translation defines the translation vector3
  77752. * @param result defines the target matrix
  77753. */
  77754. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  77755. /**
  77756. * Creates a new identity matrix
  77757. * @returns a new identity matrix
  77758. */
  77759. static Identity(): Matrix;
  77760. /**
  77761. * Creates a new identity matrix and stores the result in a given matrix
  77762. * @param result defines the target matrix
  77763. */
  77764. static IdentityToRef(result: Matrix): void;
  77765. /**
  77766. * Creates a new zero matrix
  77767. * @returns a new zero matrix
  77768. */
  77769. static Zero(): Matrix;
  77770. /**
  77771. * Creates a new rotation matrix for "angle" radians around the X axis
  77772. * @param angle defines the angle (in radians) to use
  77773. * @return the new matrix
  77774. */
  77775. static RotationX(angle: number): Matrix;
  77776. /**
  77777. * Creates a new matrix as the invert of a given matrix
  77778. * @param source defines the source matrix
  77779. * @returns the new matrix
  77780. */
  77781. static Invert(source: DeepImmutable<Matrix>): Matrix;
  77782. /**
  77783. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  77784. * @param angle defines the angle (in radians) to use
  77785. * @param result defines the target matrix
  77786. */
  77787. static RotationXToRef(angle: number, result: Matrix): void;
  77788. /**
  77789. * Creates a new rotation matrix for "angle" radians around the Y axis
  77790. * @param angle defines the angle (in radians) to use
  77791. * @return the new matrix
  77792. */
  77793. static RotationY(angle: number): Matrix;
  77794. /**
  77795. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  77796. * @param angle defines the angle (in radians) to use
  77797. * @param result defines the target matrix
  77798. */
  77799. static RotationYToRef(angle: number, result: Matrix): void;
  77800. /**
  77801. * Creates a new rotation matrix for "angle" radians around the Z axis
  77802. * @param angle defines the angle (in radians) to use
  77803. * @return the new matrix
  77804. */
  77805. static RotationZ(angle: number): Matrix;
  77806. /**
  77807. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  77808. * @param angle defines the angle (in radians) to use
  77809. * @param result defines the target matrix
  77810. */
  77811. static RotationZToRef(angle: number, result: Matrix): void;
  77812. /**
  77813. * Creates a new rotation matrix for "angle" radians around the given axis
  77814. * @param axis defines the axis to use
  77815. * @param angle defines the angle (in radians) to use
  77816. * @return the new matrix
  77817. */
  77818. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  77819. /**
  77820. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  77821. * @param axis defines the axis to use
  77822. * @param angle defines the angle (in radians) to use
  77823. * @param result defines the target matrix
  77824. */
  77825. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  77826. /**
  77827. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  77828. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  77829. * @param from defines the vector to align
  77830. * @param to defines the vector to align to
  77831. * @param result defines the target matrix
  77832. */
  77833. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  77834. /**
  77835. * Creates a rotation matrix
  77836. * @param yaw defines the yaw angle in radians (Y axis)
  77837. * @param pitch defines the pitch angle in radians (X axis)
  77838. * @param roll defines the roll angle in radians (X axis)
  77839. * @returns the new rotation matrix
  77840. */
  77841. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  77842. /**
  77843. * Creates a rotation matrix and stores it in a given matrix
  77844. * @param yaw defines the yaw angle in radians (Y axis)
  77845. * @param pitch defines the pitch angle in radians (X axis)
  77846. * @param roll defines the roll angle in radians (X axis)
  77847. * @param result defines the target matrix
  77848. */
  77849. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  77850. /**
  77851. * Creates a scaling matrix
  77852. * @param x defines the scale factor on X axis
  77853. * @param y defines the scale factor on Y axis
  77854. * @param z defines the scale factor on Z axis
  77855. * @returns the new matrix
  77856. */
  77857. static Scaling(x: number, y: number, z: number): Matrix;
  77858. /**
  77859. * Creates a scaling matrix and stores it in a given matrix
  77860. * @param x defines the scale factor on X axis
  77861. * @param y defines the scale factor on Y axis
  77862. * @param z defines the scale factor on Z axis
  77863. * @param result defines the target matrix
  77864. */
  77865. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  77866. /**
  77867. * Creates a translation matrix
  77868. * @param x defines the translation on X axis
  77869. * @param y defines the translation on Y axis
  77870. * @param z defines the translationon Z axis
  77871. * @returns the new matrix
  77872. */
  77873. static Translation(x: number, y: number, z: number): Matrix;
  77874. /**
  77875. * Creates a translation matrix and stores it in a given matrix
  77876. * @param x defines the translation on X axis
  77877. * @param y defines the translation on Y axis
  77878. * @param z defines the translationon Z axis
  77879. * @param result defines the target matrix
  77880. */
  77881. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  77882. /**
  77883. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77884. * @param startValue defines the start value
  77885. * @param endValue defines the end value
  77886. * @param gradient defines the gradient factor
  77887. * @returns the new matrix
  77888. */
  77889. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77890. /**
  77891. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77892. * @param startValue defines the start value
  77893. * @param endValue defines the end value
  77894. * @param gradient defines the gradient factor
  77895. * @param result defines the Matrix object where to store data
  77896. */
  77897. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77898. /**
  77899. * Builds a new matrix whose values are computed by:
  77900. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77901. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77902. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77903. * @param startValue defines the first matrix
  77904. * @param endValue defines the second matrix
  77905. * @param gradient defines the gradient between the two matrices
  77906. * @returns the new matrix
  77907. */
  77908. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77909. /**
  77910. * Update a matrix to values which are computed by:
  77911. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77912. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77913. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77914. * @param startValue defines the first matrix
  77915. * @param endValue defines the second matrix
  77916. * @param gradient defines the gradient between the two matrices
  77917. * @param result defines the target matrix
  77918. */
  77919. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77920. /**
  77921. * 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"
  77922. * This function works in left handed mode
  77923. * @param eye defines the final position of the entity
  77924. * @param target defines where the entity should look at
  77925. * @param up defines the up vector for the entity
  77926. * @returns the new matrix
  77927. */
  77928. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77929. /**
  77930. * 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".
  77931. * This function works in left handed mode
  77932. * @param eye defines the final position of the entity
  77933. * @param target defines where the entity should look at
  77934. * @param up defines the up vector for the entity
  77935. * @param result defines the target matrix
  77936. */
  77937. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77938. /**
  77939. * 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"
  77940. * This function works in right handed mode
  77941. * @param eye defines the final position of the entity
  77942. * @param target defines where the entity should look at
  77943. * @param up defines the up vector for the entity
  77944. * @returns the new matrix
  77945. */
  77946. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77947. /**
  77948. * 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".
  77949. * This function works in right handed mode
  77950. * @param eye defines the final position of the entity
  77951. * @param target defines where the entity should look at
  77952. * @param up defines the up vector for the entity
  77953. * @param result defines the target matrix
  77954. */
  77955. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77956. /**
  77957. * Create a left-handed orthographic projection matrix
  77958. * @param width defines the viewport width
  77959. * @param height defines the viewport height
  77960. * @param znear defines the near clip plane
  77961. * @param zfar defines the far clip plane
  77962. * @returns a new matrix as a left-handed orthographic projection matrix
  77963. */
  77964. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  77965. /**
  77966. * Store a left-handed orthographic projection to a given matrix
  77967. * @param width defines the viewport width
  77968. * @param height defines the viewport height
  77969. * @param znear defines the near clip plane
  77970. * @param zfar defines the far clip plane
  77971. * @param result defines the target matrix
  77972. */
  77973. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  77974. /**
  77975. * Create a left-handed orthographic projection matrix
  77976. * @param left defines the viewport left coordinate
  77977. * @param right defines the viewport right coordinate
  77978. * @param bottom defines the viewport bottom coordinate
  77979. * @param top defines the viewport top coordinate
  77980. * @param znear defines the near clip plane
  77981. * @param zfar defines the far clip plane
  77982. * @returns a new matrix as a left-handed orthographic projection matrix
  77983. */
  77984. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  77985. /**
  77986. * Stores a left-handed orthographic projection into a given matrix
  77987. * @param left defines the viewport left coordinate
  77988. * @param right defines the viewport right coordinate
  77989. * @param bottom defines the viewport bottom coordinate
  77990. * @param top defines the viewport top coordinate
  77991. * @param znear defines the near clip plane
  77992. * @param zfar defines the far clip plane
  77993. * @param result defines the target matrix
  77994. */
  77995. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  77996. /**
  77997. * Creates a right-handed orthographic projection matrix
  77998. * @param left defines the viewport left coordinate
  77999. * @param right defines the viewport right coordinate
  78000. * @param bottom defines the viewport bottom coordinate
  78001. * @param top defines the viewport top coordinate
  78002. * @param znear defines the near clip plane
  78003. * @param zfar defines the far clip plane
  78004. * @returns a new matrix as a right-handed orthographic projection matrix
  78005. */
  78006. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  78007. /**
  78008. * Stores a right-handed orthographic projection into a given matrix
  78009. * @param left defines the viewport left coordinate
  78010. * @param right defines the viewport right coordinate
  78011. * @param bottom defines the viewport bottom coordinate
  78012. * @param top defines the viewport top coordinate
  78013. * @param znear defines the near clip plane
  78014. * @param zfar defines the far clip plane
  78015. * @param result defines the target matrix
  78016. */
  78017. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  78018. /**
  78019. * Creates a left-handed perspective projection matrix
  78020. * @param width defines the viewport width
  78021. * @param height defines the viewport height
  78022. * @param znear defines the near clip plane
  78023. * @param zfar defines the far clip plane
  78024. * @returns a new matrix as a left-handed perspective projection matrix
  78025. */
  78026. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  78027. /**
  78028. * Creates a left-handed perspective projection matrix
  78029. * @param fov defines the horizontal field of view
  78030. * @param aspect defines the aspect ratio
  78031. * @param znear defines the near clip plane
  78032. * @param zfar defines the far clip plane
  78033. * @returns a new matrix as a left-handed perspective projection matrix
  78034. */
  78035. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  78036. /**
  78037. * Stores a left-handed perspective projection into a given matrix
  78038. * @param fov defines the horizontal field of view
  78039. * @param aspect defines the aspect ratio
  78040. * @param znear defines the near clip plane
  78041. * @param zfar defines the far clip plane
  78042. * @param result defines the target matrix
  78043. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  78044. */
  78045. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  78046. /**
  78047. * Stores a left-handed perspective projection into a given matrix with depth reversed
  78048. * @param fov defines the horizontal field of view
  78049. * @param aspect defines the aspect ratio
  78050. * @param znear defines the near clip plane
  78051. * @param zfar not used as infinity is used as far clip
  78052. * @param result defines the target matrix
  78053. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  78054. */
  78055. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  78056. /**
  78057. * Creates a right-handed perspective projection matrix
  78058. * @param fov defines the horizontal field of view
  78059. * @param aspect defines the aspect ratio
  78060. * @param znear defines the near clip plane
  78061. * @param zfar defines the far clip plane
  78062. * @returns a new matrix as a right-handed perspective projection matrix
  78063. */
  78064. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  78065. /**
  78066. * Stores a right-handed perspective projection into a given matrix
  78067. * @param fov defines the horizontal field of view
  78068. * @param aspect defines the aspect ratio
  78069. * @param znear defines the near clip plane
  78070. * @param zfar defines the far clip plane
  78071. * @param result defines the target matrix
  78072. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  78073. */
  78074. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  78075. /**
  78076. * Stores a right-handed perspective projection into a given matrix
  78077. * @param fov defines the horizontal field of view
  78078. * @param aspect defines the aspect ratio
  78079. * @param znear defines the near clip plane
  78080. * @param zfar not used as infinity is used as far clip
  78081. * @param result defines the target matrix
  78082. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  78083. */
  78084. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  78085. /**
  78086. * Stores a perspective projection for WebVR info a given matrix
  78087. * @param fov defines the field of view
  78088. * @param znear defines the near clip plane
  78089. * @param zfar defines the far clip plane
  78090. * @param result defines the target matrix
  78091. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  78092. */
  78093. static PerspectiveFovWebVRToRef(fov: {
  78094. upDegrees: number;
  78095. downDegrees: number;
  78096. leftDegrees: number;
  78097. rightDegrees: number;
  78098. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  78099. /**
  78100. * Computes a complete transformation matrix
  78101. * @param viewport defines the viewport to use
  78102. * @param world defines the world matrix
  78103. * @param view defines the view matrix
  78104. * @param projection defines the projection matrix
  78105. * @param zmin defines the near clip plane
  78106. * @param zmax defines the far clip plane
  78107. * @returns the transformation matrix
  78108. */
  78109. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  78110. /**
  78111. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  78112. * @param matrix defines the matrix to use
  78113. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  78114. */
  78115. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  78116. /**
  78117. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  78118. * @param matrix defines the matrix to use
  78119. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  78120. */
  78121. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  78122. /**
  78123. * Compute the transpose of a given matrix
  78124. * @param matrix defines the matrix to transpose
  78125. * @returns the new matrix
  78126. */
  78127. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  78128. /**
  78129. * Compute the transpose of a matrix and store it in a target matrix
  78130. * @param matrix defines the matrix to transpose
  78131. * @param result defines the target matrix
  78132. */
  78133. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  78134. /**
  78135. * Computes a reflection matrix from a plane
  78136. * @param plane defines the reflection plane
  78137. * @returns a new matrix
  78138. */
  78139. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  78140. /**
  78141. * Computes a reflection matrix from a plane
  78142. * @param plane defines the reflection plane
  78143. * @param result defines the target matrix
  78144. */
  78145. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  78146. /**
  78147. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  78148. * @param xaxis defines the value of the 1st axis
  78149. * @param yaxis defines the value of the 2nd axis
  78150. * @param zaxis defines the value of the 3rd axis
  78151. * @param result defines the target matrix
  78152. */
  78153. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  78154. /**
  78155. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  78156. * @param quat defines the quaternion to use
  78157. * @param result defines the target matrix
  78158. */
  78159. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  78160. }
  78161. /**
  78162. * @hidden
  78163. */
  78164. export class TmpVectors {
  78165. static Vector2: Vector2[];
  78166. static Vector3: Vector3[];
  78167. static Vector4: Vector4[];
  78168. static Quaternion: Quaternion[];
  78169. static Matrix: Matrix[];
  78170. }
  78171. }
  78172. declare module BABYLON {
  78173. /**
  78174. * Defines potential orientation for back face culling
  78175. */
  78176. export enum Orientation {
  78177. /**
  78178. * Clockwise
  78179. */
  78180. CW = 0,
  78181. /** Counter clockwise */
  78182. CCW = 1
  78183. }
  78184. /** Class used to represent a Bezier curve */
  78185. export class BezierCurve {
  78186. /**
  78187. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  78188. * @param t defines the time
  78189. * @param x1 defines the left coordinate on X axis
  78190. * @param y1 defines the left coordinate on Y axis
  78191. * @param x2 defines the right coordinate on X axis
  78192. * @param y2 defines the right coordinate on Y axis
  78193. * @returns the interpolated value
  78194. */
  78195. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  78196. }
  78197. /**
  78198. * Defines angle representation
  78199. */
  78200. export class Angle {
  78201. private _radians;
  78202. /**
  78203. * Creates an Angle object of "radians" radians (float).
  78204. * @param radians the angle in radians
  78205. */
  78206. constructor(radians: number);
  78207. /**
  78208. * Get value in degrees
  78209. * @returns the Angle value in degrees (float)
  78210. */
  78211. degrees(): number;
  78212. /**
  78213. * Get value in radians
  78214. * @returns the Angle value in radians (float)
  78215. */
  78216. radians(): number;
  78217. /**
  78218. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  78219. * @param a defines first vector
  78220. * @param b defines second vector
  78221. * @returns a new Angle
  78222. */
  78223. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  78224. /**
  78225. * Gets a new Angle object from the given float in radians
  78226. * @param radians defines the angle value in radians
  78227. * @returns a new Angle
  78228. */
  78229. static FromRadians(radians: number): Angle;
  78230. /**
  78231. * Gets a new Angle object from the given float in degrees
  78232. * @param degrees defines the angle value in degrees
  78233. * @returns a new Angle
  78234. */
  78235. static FromDegrees(degrees: number): Angle;
  78236. }
  78237. /**
  78238. * This represents an arc in a 2d space.
  78239. */
  78240. export class Arc2 {
  78241. /** Defines the start point of the arc */
  78242. startPoint: Vector2;
  78243. /** Defines the mid point of the arc */
  78244. midPoint: Vector2;
  78245. /** Defines the end point of the arc */
  78246. endPoint: Vector2;
  78247. /**
  78248. * Defines the center point of the arc.
  78249. */
  78250. centerPoint: Vector2;
  78251. /**
  78252. * Defines the radius of the arc.
  78253. */
  78254. radius: number;
  78255. /**
  78256. * Defines the angle of the arc (from mid point to end point).
  78257. */
  78258. angle: Angle;
  78259. /**
  78260. * Defines the start angle of the arc (from start point to middle point).
  78261. */
  78262. startAngle: Angle;
  78263. /**
  78264. * Defines the orientation of the arc (clock wise/counter clock wise).
  78265. */
  78266. orientation: Orientation;
  78267. /**
  78268. * Creates an Arc object from the three given points : start, middle and end.
  78269. * @param startPoint Defines the start point of the arc
  78270. * @param midPoint Defines the midlle point of the arc
  78271. * @param endPoint Defines the end point of the arc
  78272. */
  78273. constructor(
  78274. /** Defines the start point of the arc */
  78275. startPoint: Vector2,
  78276. /** Defines the mid point of the arc */
  78277. midPoint: Vector2,
  78278. /** Defines the end point of the arc */
  78279. endPoint: Vector2);
  78280. }
  78281. /**
  78282. * Represents a 2D path made up of multiple 2D points
  78283. */
  78284. export class Path2 {
  78285. private _points;
  78286. private _length;
  78287. /**
  78288. * If the path start and end point are the same
  78289. */
  78290. closed: boolean;
  78291. /**
  78292. * Creates a Path2 object from the starting 2D coordinates x and y.
  78293. * @param x the starting points x value
  78294. * @param y the starting points y value
  78295. */
  78296. constructor(x: number, y: number);
  78297. /**
  78298. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  78299. * @param x the added points x value
  78300. * @param y the added points y value
  78301. * @returns the updated Path2.
  78302. */
  78303. addLineTo(x: number, y: number): Path2;
  78304. /**
  78305. * 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.
  78306. * @param midX middle point x value
  78307. * @param midY middle point y value
  78308. * @param endX end point x value
  78309. * @param endY end point y value
  78310. * @param numberOfSegments (default: 36)
  78311. * @returns the updated Path2.
  78312. */
  78313. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  78314. /**
  78315. * Closes the Path2.
  78316. * @returns the Path2.
  78317. */
  78318. close(): Path2;
  78319. /**
  78320. * Gets the sum of the distance between each sequential point in the path
  78321. * @returns the Path2 total length (float).
  78322. */
  78323. length(): number;
  78324. /**
  78325. * Gets the points which construct the path
  78326. * @returns the Path2 internal array of points.
  78327. */
  78328. getPoints(): Vector2[];
  78329. /**
  78330. * Retreives the point at the distance aways from the starting point
  78331. * @param normalizedLengthPosition the length along the path to retreive the point from
  78332. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  78333. */
  78334. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  78335. /**
  78336. * Creates a new path starting from an x and y position
  78337. * @param x starting x value
  78338. * @param y starting y value
  78339. * @returns a new Path2 starting at the coordinates (x, y).
  78340. */
  78341. static StartingAt(x: number, y: number): Path2;
  78342. }
  78343. /**
  78344. * Represents a 3D path made up of multiple 3D points
  78345. */
  78346. export class Path3D {
  78347. /**
  78348. * an array of Vector3, the curve axis of the Path3D
  78349. */
  78350. path: Vector3[];
  78351. private _curve;
  78352. private _distances;
  78353. private _tangents;
  78354. private _normals;
  78355. private _binormals;
  78356. private _raw;
  78357. private _alignTangentsWithPath;
  78358. private readonly _pointAtData;
  78359. /**
  78360. * new Path3D(path, normal, raw)
  78361. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  78362. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  78363. * @param path an array of Vector3, the curve axis of the Path3D
  78364. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  78365. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  78366. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  78367. */
  78368. constructor(
  78369. /**
  78370. * an array of Vector3, the curve axis of the Path3D
  78371. */
  78372. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  78373. /**
  78374. * Returns the Path3D array of successive Vector3 designing its curve.
  78375. * @returns the Path3D array of successive Vector3 designing its curve.
  78376. */
  78377. getCurve(): Vector3[];
  78378. /**
  78379. * Returns the Path3D array of successive Vector3 designing its curve.
  78380. * @returns the Path3D array of successive Vector3 designing its curve.
  78381. */
  78382. getPoints(): Vector3[];
  78383. /**
  78384. * @returns the computed length (float) of the path.
  78385. */
  78386. length(): number;
  78387. /**
  78388. * Returns an array populated with tangent vectors on each Path3D curve point.
  78389. * @returns an array populated with tangent vectors on each Path3D curve point.
  78390. */
  78391. getTangents(): Vector3[];
  78392. /**
  78393. * Returns an array populated with normal vectors on each Path3D curve point.
  78394. * @returns an array populated with normal vectors on each Path3D curve point.
  78395. */
  78396. getNormals(): Vector3[];
  78397. /**
  78398. * Returns an array populated with binormal vectors on each Path3D curve point.
  78399. * @returns an array populated with binormal vectors on each Path3D curve point.
  78400. */
  78401. getBinormals(): Vector3[];
  78402. /**
  78403. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  78404. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  78405. */
  78406. getDistances(): number[];
  78407. /**
  78408. * Returns an interpolated point along this path
  78409. * @param position the position of the point along this path, from 0.0 to 1.0
  78410. * @returns a new Vector3 as the point
  78411. */
  78412. getPointAt(position: number): Vector3;
  78413. /**
  78414. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78415. * @param position the position of the point along this path, from 0.0 to 1.0
  78416. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  78417. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  78418. */
  78419. getTangentAt(position: number, interpolated?: boolean): Vector3;
  78420. /**
  78421. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78422. * @param position the position of the point along this path, from 0.0 to 1.0
  78423. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  78424. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  78425. */
  78426. getNormalAt(position: number, interpolated?: boolean): Vector3;
  78427. /**
  78428. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  78429. * @param position the position of the point along this path, from 0.0 to 1.0
  78430. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  78431. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  78432. */
  78433. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  78434. /**
  78435. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  78436. * @param position the position of the point along this path, from 0.0 to 1.0
  78437. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  78438. */
  78439. getDistanceAt(position: number): number;
  78440. /**
  78441. * Returns the array index of the previous point of an interpolated point along this path
  78442. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78443. * @returns the array index
  78444. */
  78445. getPreviousPointIndexAt(position: number): number;
  78446. /**
  78447. * 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)
  78448. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78449. * @returns the sub position
  78450. */
  78451. getSubPositionAt(position: number): number;
  78452. /**
  78453. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  78454. * @param target the vector of which to get the closest position to
  78455. * @returns the position of the closest virtual point on this path to the target vector
  78456. */
  78457. getClosestPositionTo(target: Vector3): number;
  78458. /**
  78459. * Returns a sub path (slice) of this path
  78460. * @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
  78461. * @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
  78462. * @returns a sub path (slice) of this path
  78463. */
  78464. slice(start?: number, end?: number): Path3D;
  78465. /**
  78466. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  78467. * @param path path which all values are copied into the curves points
  78468. * @param firstNormal which should be projected onto the curve
  78469. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  78470. * @returns the same object updated.
  78471. */
  78472. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  78473. private _compute;
  78474. private _getFirstNonNullVector;
  78475. private _getLastNonNullVector;
  78476. private _normalVector;
  78477. /**
  78478. * Updates the point at data for an interpolated point along this curve
  78479. * @param position the position of the point along this curve, from 0.0 to 1.0
  78480. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  78481. * @returns the (updated) point at data
  78482. */
  78483. private _updatePointAtData;
  78484. /**
  78485. * Updates the point at data from the specified parameters
  78486. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  78487. * @param point the interpolated point
  78488. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  78489. */
  78490. private _setPointAtData;
  78491. /**
  78492. * Updates the point at interpolation matrix for the tangents, normals and binormals
  78493. */
  78494. private _updateInterpolationMatrix;
  78495. }
  78496. /**
  78497. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  78498. * A Curve3 is designed from a series of successive Vector3.
  78499. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  78500. */
  78501. export class Curve3 {
  78502. private _points;
  78503. private _length;
  78504. /**
  78505. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  78506. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  78507. * @param v1 (Vector3) the control point
  78508. * @param v2 (Vector3) the end point of the Quadratic Bezier
  78509. * @param nbPoints (integer) the wanted number of points in the curve
  78510. * @returns the created Curve3
  78511. */
  78512. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78513. /**
  78514. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  78515. * @param v0 (Vector3) the origin point of the Cubic Bezier
  78516. * @param v1 (Vector3) the first control point
  78517. * @param v2 (Vector3) the second control point
  78518. * @param v3 (Vector3) the end point of the Cubic Bezier
  78519. * @param nbPoints (integer) the wanted number of points in the curve
  78520. * @returns the created Curve3
  78521. */
  78522. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78523. /**
  78524. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  78525. * @param p1 (Vector3) the origin point of the Hermite Spline
  78526. * @param t1 (Vector3) the tangent vector at the origin point
  78527. * @param p2 (Vector3) the end point of the Hermite Spline
  78528. * @param t2 (Vector3) the tangent vector at the end point
  78529. * @param nbPoints (integer) the wanted number of points in the curve
  78530. * @returns the created Curve3
  78531. */
  78532. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78533. /**
  78534. * Returns a Curve3 object along a CatmullRom Spline curve :
  78535. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  78536. * @param nbPoints (integer) the wanted number of points between each curve control points
  78537. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  78538. * @returns the created Curve3
  78539. */
  78540. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  78541. /**
  78542. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  78543. * A Curve3 is designed from a series of successive Vector3.
  78544. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  78545. * @param points points which make up the curve
  78546. */
  78547. constructor(points: Vector3[]);
  78548. /**
  78549. * @returns the Curve3 stored array of successive Vector3
  78550. */
  78551. getPoints(): Vector3[];
  78552. /**
  78553. * @returns the computed length (float) of the curve.
  78554. */
  78555. length(): number;
  78556. /**
  78557. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  78558. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  78559. * curveA and curveB keep unchanged.
  78560. * @param curve the curve to continue from this curve
  78561. * @returns the newly constructed curve
  78562. */
  78563. continue(curve: DeepImmutable<Curve3>): Curve3;
  78564. private _computeLength;
  78565. }
  78566. }
  78567. declare module BABYLON {
  78568. /**
  78569. * This represents the main contract an easing function should follow.
  78570. * Easing functions are used throughout the animation system.
  78571. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78572. */
  78573. export interface IEasingFunction {
  78574. /**
  78575. * Given an input gradient between 0 and 1, this returns the corrseponding value
  78576. * of the easing function.
  78577. * The link below provides some of the most common examples of easing functions.
  78578. * @see https://easings.net/
  78579. * @param gradient Defines the value between 0 and 1 we want the easing value for
  78580. * @returns the corresponding value on the curve defined by the easing function
  78581. */
  78582. ease(gradient: number): number;
  78583. }
  78584. /**
  78585. * Base class used for every default easing function.
  78586. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78587. */
  78588. export class EasingFunction implements IEasingFunction {
  78589. /**
  78590. * Interpolation follows the mathematical formula associated with the easing function.
  78591. */
  78592. static readonly EASINGMODE_EASEIN: number;
  78593. /**
  78594. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  78595. */
  78596. static readonly EASINGMODE_EASEOUT: number;
  78597. /**
  78598. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  78599. */
  78600. static readonly EASINGMODE_EASEINOUT: number;
  78601. private _easingMode;
  78602. /**
  78603. * Sets the easing mode of the current function.
  78604. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  78605. */
  78606. setEasingMode(easingMode: number): void;
  78607. /**
  78608. * Gets the current easing mode.
  78609. * @returns the easing mode
  78610. */
  78611. getEasingMode(): number;
  78612. /**
  78613. * @hidden
  78614. */
  78615. easeInCore(gradient: number): number;
  78616. /**
  78617. * Given an input gradient between 0 and 1, this returns the corresponding value
  78618. * of the easing function.
  78619. * @param gradient Defines the value between 0 and 1 we want the easing value for
  78620. * @returns the corresponding value on the curve defined by the easing function
  78621. */
  78622. ease(gradient: number): number;
  78623. }
  78624. /**
  78625. * Easing function with a circle shape (see link below).
  78626. * @see https://easings.net/#easeInCirc
  78627. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78628. */
  78629. export class CircleEase extends EasingFunction implements IEasingFunction {
  78630. /** @hidden */
  78631. easeInCore(gradient: number): number;
  78632. }
  78633. /**
  78634. * Easing function with a ease back shape (see link below).
  78635. * @see https://easings.net/#easeInBack
  78636. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78637. */
  78638. export class BackEase extends EasingFunction implements IEasingFunction {
  78639. /** Defines the amplitude of the function */
  78640. amplitude: number;
  78641. /**
  78642. * Instantiates a back ease easing
  78643. * @see https://easings.net/#easeInBack
  78644. * @param amplitude Defines the amplitude of the function
  78645. */
  78646. constructor(
  78647. /** Defines the amplitude of the function */
  78648. amplitude?: number);
  78649. /** @hidden */
  78650. easeInCore(gradient: number): number;
  78651. }
  78652. /**
  78653. * Easing function with a bouncing shape (see link below).
  78654. * @see https://easings.net/#easeInBounce
  78655. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78656. */
  78657. export class BounceEase extends EasingFunction implements IEasingFunction {
  78658. /** Defines the number of bounces */
  78659. bounces: number;
  78660. /** Defines the amplitude of the bounce */
  78661. bounciness: number;
  78662. /**
  78663. * Instantiates a bounce easing
  78664. * @see https://easings.net/#easeInBounce
  78665. * @param bounces Defines the number of bounces
  78666. * @param bounciness Defines the amplitude of the bounce
  78667. */
  78668. constructor(
  78669. /** Defines the number of bounces */
  78670. bounces?: number,
  78671. /** Defines the amplitude of the bounce */
  78672. bounciness?: number);
  78673. /** @hidden */
  78674. easeInCore(gradient: number): number;
  78675. }
  78676. /**
  78677. * Easing function with a power of 3 shape (see link below).
  78678. * @see https://easings.net/#easeInCubic
  78679. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78680. */
  78681. export class CubicEase extends EasingFunction implements IEasingFunction {
  78682. /** @hidden */
  78683. easeInCore(gradient: number): number;
  78684. }
  78685. /**
  78686. * Easing function with an elastic shape (see link below).
  78687. * @see https://easings.net/#easeInElastic
  78688. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78689. */
  78690. export class ElasticEase extends EasingFunction implements IEasingFunction {
  78691. /** Defines the number of oscillations*/
  78692. oscillations: number;
  78693. /** Defines the amplitude of the oscillations*/
  78694. springiness: number;
  78695. /**
  78696. * Instantiates an elastic easing function
  78697. * @see https://easings.net/#easeInElastic
  78698. * @param oscillations Defines the number of oscillations
  78699. * @param springiness Defines the amplitude of the oscillations
  78700. */
  78701. constructor(
  78702. /** Defines the number of oscillations*/
  78703. oscillations?: number,
  78704. /** Defines the amplitude of the oscillations*/
  78705. springiness?: number);
  78706. /** @hidden */
  78707. easeInCore(gradient: number): number;
  78708. }
  78709. /**
  78710. * Easing function with an exponential shape (see link below).
  78711. * @see https://easings.net/#easeInExpo
  78712. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78713. */
  78714. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  78715. /** Defines the exponent of the function */
  78716. exponent: number;
  78717. /**
  78718. * Instantiates an exponential easing function
  78719. * @see https://easings.net/#easeInExpo
  78720. * @param exponent Defines the exponent of the function
  78721. */
  78722. constructor(
  78723. /** Defines the exponent of the function */
  78724. exponent?: number);
  78725. /** @hidden */
  78726. easeInCore(gradient: number): number;
  78727. }
  78728. /**
  78729. * Easing function with a power shape (see link below).
  78730. * @see https://easings.net/#easeInQuad
  78731. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78732. */
  78733. export class PowerEase extends EasingFunction implements IEasingFunction {
  78734. /** Defines the power of the function */
  78735. power: number;
  78736. /**
  78737. * Instantiates an power base easing function
  78738. * @see https://easings.net/#easeInQuad
  78739. * @param power Defines the power of the function
  78740. */
  78741. constructor(
  78742. /** Defines the power of the function */
  78743. power?: number);
  78744. /** @hidden */
  78745. easeInCore(gradient: number): number;
  78746. }
  78747. /**
  78748. * Easing function with a power of 2 shape (see link below).
  78749. * @see https://easings.net/#easeInQuad
  78750. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78751. */
  78752. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  78753. /** @hidden */
  78754. easeInCore(gradient: number): number;
  78755. }
  78756. /**
  78757. * Easing function with a power of 4 shape (see link below).
  78758. * @see https://easings.net/#easeInQuart
  78759. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78760. */
  78761. export class QuarticEase extends EasingFunction implements IEasingFunction {
  78762. /** @hidden */
  78763. easeInCore(gradient: number): number;
  78764. }
  78765. /**
  78766. * Easing function with a power of 5 shape (see link below).
  78767. * @see https://easings.net/#easeInQuint
  78768. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78769. */
  78770. export class QuinticEase extends EasingFunction implements IEasingFunction {
  78771. /** @hidden */
  78772. easeInCore(gradient: number): number;
  78773. }
  78774. /**
  78775. * Easing function with a sin shape (see link below).
  78776. * @see https://easings.net/#easeInSine
  78777. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78778. */
  78779. export class SineEase extends EasingFunction implements IEasingFunction {
  78780. /** @hidden */
  78781. easeInCore(gradient: number): number;
  78782. }
  78783. /**
  78784. * Easing function with a bezier shape (see link below).
  78785. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78786. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78787. */
  78788. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  78789. /** Defines the x component of the start tangent in the bezier curve */
  78790. x1: number;
  78791. /** Defines the y component of the start tangent in the bezier curve */
  78792. y1: number;
  78793. /** Defines the x component of the end tangent in the bezier curve */
  78794. x2: number;
  78795. /** Defines the y component of the end tangent in the bezier curve */
  78796. y2: number;
  78797. /**
  78798. * Instantiates a bezier function
  78799. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78800. * @param x1 Defines the x component of the start tangent in the bezier curve
  78801. * @param y1 Defines the y component of the start tangent in the bezier curve
  78802. * @param x2 Defines the x component of the end tangent in the bezier curve
  78803. * @param y2 Defines the y component of the end tangent in the bezier curve
  78804. */
  78805. constructor(
  78806. /** Defines the x component of the start tangent in the bezier curve */
  78807. x1?: number,
  78808. /** Defines the y component of the start tangent in the bezier curve */
  78809. y1?: number,
  78810. /** Defines the x component of the end tangent in the bezier curve */
  78811. x2?: number,
  78812. /** Defines the y component of the end tangent in the bezier curve */
  78813. y2?: number);
  78814. /** @hidden */
  78815. easeInCore(gradient: number): number;
  78816. }
  78817. }
  78818. declare module BABYLON {
  78819. /**
  78820. * Class used to hold a RBG color
  78821. */
  78822. export class Color3 {
  78823. /**
  78824. * Defines the red component (between 0 and 1, default is 0)
  78825. */
  78826. r: number;
  78827. /**
  78828. * Defines the green component (between 0 and 1, default is 0)
  78829. */
  78830. g: number;
  78831. /**
  78832. * Defines the blue component (between 0 and 1, default is 0)
  78833. */
  78834. b: number;
  78835. /**
  78836. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  78837. * @param r defines the red component (between 0 and 1, default is 0)
  78838. * @param g defines the green component (between 0 and 1, default is 0)
  78839. * @param b defines the blue component (between 0 and 1, default is 0)
  78840. */
  78841. constructor(
  78842. /**
  78843. * Defines the red component (between 0 and 1, default is 0)
  78844. */
  78845. r?: number,
  78846. /**
  78847. * Defines the green component (between 0 and 1, default is 0)
  78848. */
  78849. g?: number,
  78850. /**
  78851. * Defines the blue component (between 0 and 1, default is 0)
  78852. */
  78853. b?: number);
  78854. /**
  78855. * Creates a string with the Color3 current values
  78856. * @returns the string representation of the Color3 object
  78857. */
  78858. toString(): string;
  78859. /**
  78860. * Returns the string "Color3"
  78861. * @returns "Color3"
  78862. */
  78863. getClassName(): string;
  78864. /**
  78865. * Compute the Color3 hash code
  78866. * @returns an unique number that can be used to hash Color3 objects
  78867. */
  78868. getHashCode(): number;
  78869. /**
  78870. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  78871. * @param array defines the array where to store the r,g,b components
  78872. * @param index defines an optional index in the target array to define where to start storing values
  78873. * @returns the current Color3 object
  78874. */
  78875. toArray(array: FloatArray, index?: number): Color3;
  78876. /**
  78877. * Returns a new Color4 object from the current Color3 and the given alpha
  78878. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  78879. * @returns a new Color4 object
  78880. */
  78881. toColor4(alpha?: number): Color4;
  78882. /**
  78883. * Returns a new array populated with 3 numeric elements : red, green and blue values
  78884. * @returns the new array
  78885. */
  78886. asArray(): number[];
  78887. /**
  78888. * Returns the luminance value
  78889. * @returns a float value
  78890. */
  78891. toLuminance(): number;
  78892. /**
  78893. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  78894. * @param otherColor defines the second operand
  78895. * @returns the new Color3 object
  78896. */
  78897. multiply(otherColor: DeepImmutable<Color3>): Color3;
  78898. /**
  78899. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  78900. * @param otherColor defines the second operand
  78901. * @param result defines the Color3 object where to store the result
  78902. * @returns the current Color3
  78903. */
  78904. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78905. /**
  78906. * Determines equality between Color3 objects
  78907. * @param otherColor defines the second operand
  78908. * @returns true if the rgb values are equal to the given ones
  78909. */
  78910. equals(otherColor: DeepImmutable<Color3>): boolean;
  78911. /**
  78912. * Determines equality between the current Color3 object and a set of r,b,g values
  78913. * @param r defines the red component to check
  78914. * @param g defines the green component to check
  78915. * @param b defines the blue component to check
  78916. * @returns true if the rgb values are equal to the given ones
  78917. */
  78918. equalsFloats(r: number, g: number, b: number): boolean;
  78919. /**
  78920. * Multiplies in place each rgb value by scale
  78921. * @param scale defines the scaling factor
  78922. * @returns the updated Color3
  78923. */
  78924. scale(scale: number): Color3;
  78925. /**
  78926. * Multiplies the rgb values by scale and stores the result into "result"
  78927. * @param scale defines the scaling factor
  78928. * @param result defines the Color3 object where to store the result
  78929. * @returns the unmodified current Color3
  78930. */
  78931. scaleToRef(scale: number, result: Color3): Color3;
  78932. /**
  78933. * Scale the current Color3 values by a factor and add the result to a given Color3
  78934. * @param scale defines the scale factor
  78935. * @param result defines color to store the result into
  78936. * @returns the unmodified current Color3
  78937. */
  78938. scaleAndAddToRef(scale: number, result: Color3): Color3;
  78939. /**
  78940. * Clamps the rgb values by the min and max values and stores the result into "result"
  78941. * @param min defines minimum clamping value (default is 0)
  78942. * @param max defines maximum clamping value (default is 1)
  78943. * @param result defines color to store the result into
  78944. * @returns the original Color3
  78945. */
  78946. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  78947. /**
  78948. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  78949. * @param otherColor defines the second operand
  78950. * @returns the new Color3
  78951. */
  78952. add(otherColor: DeepImmutable<Color3>): Color3;
  78953. /**
  78954. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  78955. * @param otherColor defines the second operand
  78956. * @param result defines Color3 object to store the result into
  78957. * @returns the unmodified current Color3
  78958. */
  78959. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78960. /**
  78961. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  78962. * @param otherColor defines the second operand
  78963. * @returns the new Color3
  78964. */
  78965. subtract(otherColor: DeepImmutable<Color3>): Color3;
  78966. /**
  78967. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  78968. * @param otherColor defines the second operand
  78969. * @param result defines Color3 object to store the result into
  78970. * @returns the unmodified current Color3
  78971. */
  78972. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78973. /**
  78974. * Copy the current object
  78975. * @returns a new Color3 copied the current one
  78976. */
  78977. clone(): Color3;
  78978. /**
  78979. * Copies the rgb values from the source in the current Color3
  78980. * @param source defines the source Color3 object
  78981. * @returns the updated Color3 object
  78982. */
  78983. copyFrom(source: DeepImmutable<Color3>): Color3;
  78984. /**
  78985. * Updates the Color3 rgb values from the given floats
  78986. * @param r defines the red component to read from
  78987. * @param g defines the green component to read from
  78988. * @param b defines the blue component to read from
  78989. * @returns the current Color3 object
  78990. */
  78991. copyFromFloats(r: number, g: number, b: number): Color3;
  78992. /**
  78993. * Updates the Color3 rgb values from the given floats
  78994. * @param r defines the red component to read from
  78995. * @param g defines the green component to read from
  78996. * @param b defines the blue component to read from
  78997. * @returns the current Color3 object
  78998. */
  78999. set(r: number, g: number, b: number): Color3;
  79000. /**
  79001. * Compute the Color3 hexadecimal code as a string
  79002. * @returns a string containing the hexadecimal representation of the Color3 object
  79003. */
  79004. toHexString(): string;
  79005. /**
  79006. * Computes a new Color3 converted from the current one to linear space
  79007. * @returns a new Color3 object
  79008. */
  79009. toLinearSpace(): Color3;
  79010. /**
  79011. * Converts current color in rgb space to HSV values
  79012. * @returns a new color3 representing the HSV values
  79013. */
  79014. toHSV(): Color3;
  79015. /**
  79016. * Converts current color in rgb space to HSV values
  79017. * @param result defines the Color3 where to store the HSV values
  79018. */
  79019. toHSVToRef(result: Color3): void;
  79020. /**
  79021. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  79022. * @param convertedColor defines the Color3 object where to store the linear space version
  79023. * @returns the unmodified Color3
  79024. */
  79025. toLinearSpaceToRef(convertedColor: Color3): Color3;
  79026. /**
  79027. * Computes a new Color3 converted from the current one to gamma space
  79028. * @returns a new Color3 object
  79029. */
  79030. toGammaSpace(): Color3;
  79031. /**
  79032. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  79033. * @param convertedColor defines the Color3 object where to store the gamma space version
  79034. * @returns the unmodified Color3
  79035. */
  79036. toGammaSpaceToRef(convertedColor: Color3): Color3;
  79037. private static _BlackReadOnly;
  79038. /**
  79039. * Convert Hue, saturation and value to a Color3 (RGB)
  79040. * @param hue defines the hue
  79041. * @param saturation defines the saturation
  79042. * @param value defines the value
  79043. * @param result defines the Color3 where to store the RGB values
  79044. */
  79045. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  79046. /**
  79047. * Creates a new Color3 from the string containing valid hexadecimal values
  79048. * @param hex defines a string containing valid hexadecimal values
  79049. * @returns a new Color3 object
  79050. */
  79051. static FromHexString(hex: string): Color3;
  79052. /**
  79053. * Creates a new Color3 from the starting index of the given array
  79054. * @param array defines the source array
  79055. * @param offset defines an offset in the source array
  79056. * @returns a new Color3 object
  79057. */
  79058. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  79059. /**
  79060. * Creates a new Color3 from integer values (< 256)
  79061. * @param r defines the red component to read from (value between 0 and 255)
  79062. * @param g defines the green component to read from (value between 0 and 255)
  79063. * @param b defines the blue component to read from (value between 0 and 255)
  79064. * @returns a new Color3 object
  79065. */
  79066. static FromInts(r: number, g: number, b: number): Color3;
  79067. /**
  79068. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  79069. * @param start defines the start Color3 value
  79070. * @param end defines the end Color3 value
  79071. * @param amount defines the gradient value between start and end
  79072. * @returns a new Color3 object
  79073. */
  79074. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  79075. /**
  79076. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  79077. * @param left defines the start value
  79078. * @param right defines the end value
  79079. * @param amount defines the gradient factor
  79080. * @param result defines the Color3 object where to store the result
  79081. */
  79082. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  79083. /**
  79084. * Returns a Color3 value containing a red color
  79085. * @returns a new Color3 object
  79086. */
  79087. static Red(): Color3;
  79088. /**
  79089. * Returns a Color3 value containing a green color
  79090. * @returns a new Color3 object
  79091. */
  79092. static Green(): Color3;
  79093. /**
  79094. * Returns a Color3 value containing a blue color
  79095. * @returns a new Color3 object
  79096. */
  79097. static Blue(): Color3;
  79098. /**
  79099. * Returns a Color3 value containing a black color
  79100. * @returns a new Color3 object
  79101. */
  79102. static Black(): Color3;
  79103. /**
  79104. * Gets a Color3 value containing a black color that must not be updated
  79105. */
  79106. static get BlackReadOnly(): DeepImmutable<Color3>;
  79107. /**
  79108. * Returns a Color3 value containing a white color
  79109. * @returns a new Color3 object
  79110. */
  79111. static White(): Color3;
  79112. /**
  79113. * Returns a Color3 value containing a purple color
  79114. * @returns a new Color3 object
  79115. */
  79116. static Purple(): Color3;
  79117. /**
  79118. * Returns a Color3 value containing a magenta color
  79119. * @returns a new Color3 object
  79120. */
  79121. static Magenta(): Color3;
  79122. /**
  79123. * Returns a Color3 value containing a yellow color
  79124. * @returns a new Color3 object
  79125. */
  79126. static Yellow(): Color3;
  79127. /**
  79128. * Returns a Color3 value containing a gray color
  79129. * @returns a new Color3 object
  79130. */
  79131. static Gray(): Color3;
  79132. /**
  79133. * Returns a Color3 value containing a teal color
  79134. * @returns a new Color3 object
  79135. */
  79136. static Teal(): Color3;
  79137. /**
  79138. * Returns a Color3 value containing a random color
  79139. * @returns a new Color3 object
  79140. */
  79141. static Random(): Color3;
  79142. }
  79143. /**
  79144. * Class used to hold a RBGA color
  79145. */
  79146. export class Color4 {
  79147. /**
  79148. * Defines the red component (between 0 and 1, default is 0)
  79149. */
  79150. r: number;
  79151. /**
  79152. * Defines the green component (between 0 and 1, default is 0)
  79153. */
  79154. g: number;
  79155. /**
  79156. * Defines the blue component (between 0 and 1, default is 0)
  79157. */
  79158. b: number;
  79159. /**
  79160. * Defines the alpha component (between 0 and 1, default is 1)
  79161. */
  79162. a: number;
  79163. /**
  79164. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  79165. * @param r defines the red component (between 0 and 1, default is 0)
  79166. * @param g defines the green component (between 0 and 1, default is 0)
  79167. * @param b defines the blue component (between 0 and 1, default is 0)
  79168. * @param a defines the alpha component (between 0 and 1, default is 1)
  79169. */
  79170. constructor(
  79171. /**
  79172. * Defines the red component (between 0 and 1, default is 0)
  79173. */
  79174. r?: number,
  79175. /**
  79176. * Defines the green component (between 0 and 1, default is 0)
  79177. */
  79178. g?: number,
  79179. /**
  79180. * Defines the blue component (between 0 and 1, default is 0)
  79181. */
  79182. b?: number,
  79183. /**
  79184. * Defines the alpha component (between 0 and 1, default is 1)
  79185. */
  79186. a?: number);
  79187. /**
  79188. * Adds in place the given Color4 values to the current Color4 object
  79189. * @param right defines the second operand
  79190. * @returns the current updated Color4 object
  79191. */
  79192. addInPlace(right: DeepImmutable<Color4>): Color4;
  79193. /**
  79194. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  79195. * @returns the new array
  79196. */
  79197. asArray(): number[];
  79198. /**
  79199. * Stores from the starting index in the given array the Color4 successive values
  79200. * @param array defines the array where to store the r,g,b components
  79201. * @param index defines an optional index in the target array to define where to start storing values
  79202. * @returns the current Color4 object
  79203. */
  79204. toArray(array: number[], index?: number): Color4;
  79205. /**
  79206. * Determines equality between Color4 objects
  79207. * @param otherColor defines the second operand
  79208. * @returns true if the rgba values are equal to the given ones
  79209. */
  79210. equals(otherColor: DeepImmutable<Color4>): boolean;
  79211. /**
  79212. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  79213. * @param right defines the second operand
  79214. * @returns a new Color4 object
  79215. */
  79216. add(right: DeepImmutable<Color4>): Color4;
  79217. /**
  79218. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  79219. * @param right defines the second operand
  79220. * @returns a new Color4 object
  79221. */
  79222. subtract(right: DeepImmutable<Color4>): Color4;
  79223. /**
  79224. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  79225. * @param right defines the second operand
  79226. * @param result defines the Color4 object where to store the result
  79227. * @returns the current Color4 object
  79228. */
  79229. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  79230. /**
  79231. * Creates a new Color4 with the current Color4 values multiplied by scale
  79232. * @param scale defines the scaling factor to apply
  79233. * @returns a new Color4 object
  79234. */
  79235. scale(scale: number): Color4;
  79236. /**
  79237. * Multiplies the current Color4 values by scale and stores the result in "result"
  79238. * @param scale defines the scaling factor to apply
  79239. * @param result defines the Color4 object where to store the result
  79240. * @returns the current unmodified Color4
  79241. */
  79242. scaleToRef(scale: number, result: Color4): Color4;
  79243. /**
  79244. * Scale the current Color4 values by a factor and add the result to a given Color4
  79245. * @param scale defines the scale factor
  79246. * @param result defines the Color4 object where to store the result
  79247. * @returns the unmodified current Color4
  79248. */
  79249. scaleAndAddToRef(scale: number, result: Color4): Color4;
  79250. /**
  79251. * Clamps the rgb values by the min and max values and stores the result into "result"
  79252. * @param min defines minimum clamping value (default is 0)
  79253. * @param max defines maximum clamping value (default is 1)
  79254. * @param result defines color to store the result into.
  79255. * @returns the cuurent Color4
  79256. */
  79257. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  79258. /**
  79259. * Multipy an Color4 value by another and return a new Color4 object
  79260. * @param color defines the Color4 value to multiply by
  79261. * @returns a new Color4 object
  79262. */
  79263. multiply(color: Color4): Color4;
  79264. /**
  79265. * Multipy a Color4 value by another and push the result in a reference value
  79266. * @param color defines the Color4 value to multiply by
  79267. * @param result defines the Color4 to fill the result in
  79268. * @returns the result Color4
  79269. */
  79270. multiplyToRef(color: Color4, result: Color4): Color4;
  79271. /**
  79272. * Creates a string with the Color4 current values
  79273. * @returns the string representation of the Color4 object
  79274. */
  79275. toString(): string;
  79276. /**
  79277. * Returns the string "Color4"
  79278. * @returns "Color4"
  79279. */
  79280. getClassName(): string;
  79281. /**
  79282. * Compute the Color4 hash code
  79283. * @returns an unique number that can be used to hash Color4 objects
  79284. */
  79285. getHashCode(): number;
  79286. /**
  79287. * Creates a new Color4 copied from the current one
  79288. * @returns a new Color4 object
  79289. */
  79290. clone(): Color4;
  79291. /**
  79292. * Copies the given Color4 values into the current one
  79293. * @param source defines the source Color4 object
  79294. * @returns the current updated Color4 object
  79295. */
  79296. copyFrom(source: Color4): Color4;
  79297. /**
  79298. * Copies the given float values into the current one
  79299. * @param r defines the red component to read from
  79300. * @param g defines the green component to read from
  79301. * @param b defines the blue component to read from
  79302. * @param a defines the alpha component to read from
  79303. * @returns the current updated Color4 object
  79304. */
  79305. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  79306. /**
  79307. * Copies the given float values into the current one
  79308. * @param r defines the red component to read from
  79309. * @param g defines the green component to read from
  79310. * @param b defines the blue component to read from
  79311. * @param a defines the alpha component to read from
  79312. * @returns the current updated Color4 object
  79313. */
  79314. set(r: number, g: number, b: number, a: number): Color4;
  79315. /**
  79316. * Compute the Color4 hexadecimal code as a string
  79317. * @returns a string containing the hexadecimal representation of the Color4 object
  79318. */
  79319. toHexString(): string;
  79320. /**
  79321. * Computes a new Color4 converted from the current one to linear space
  79322. * @returns a new Color4 object
  79323. */
  79324. toLinearSpace(): Color4;
  79325. /**
  79326. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  79327. * @param convertedColor defines the Color4 object where to store the linear space version
  79328. * @returns the unmodified Color4
  79329. */
  79330. toLinearSpaceToRef(convertedColor: Color4): Color4;
  79331. /**
  79332. * Computes a new Color4 converted from the current one to gamma space
  79333. * @returns a new Color4 object
  79334. */
  79335. toGammaSpace(): Color4;
  79336. /**
  79337. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  79338. * @param convertedColor defines the Color4 object where to store the gamma space version
  79339. * @returns the unmodified Color4
  79340. */
  79341. toGammaSpaceToRef(convertedColor: Color4): Color4;
  79342. /**
  79343. * Creates a new Color4 from the string containing valid hexadecimal values
  79344. * @param hex defines a string containing valid hexadecimal values
  79345. * @returns a new Color4 object
  79346. */
  79347. static FromHexString(hex: string): Color4;
  79348. /**
  79349. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79350. * @param left defines the start value
  79351. * @param right defines the end value
  79352. * @param amount defines the gradient factor
  79353. * @returns a new Color4 object
  79354. */
  79355. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  79356. /**
  79357. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79358. * @param left defines the start value
  79359. * @param right defines the end value
  79360. * @param amount defines the gradient factor
  79361. * @param result defines the Color4 object where to store data
  79362. */
  79363. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  79364. /**
  79365. * Creates a new Color4 from a Color3 and an alpha value
  79366. * @param color3 defines the source Color3 to read from
  79367. * @param alpha defines the alpha component (1.0 by default)
  79368. * @returns a new Color4 object
  79369. */
  79370. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  79371. /**
  79372. * Creates a new Color4 from the starting index element of the given array
  79373. * @param array defines the source array to read from
  79374. * @param offset defines the offset in the source array
  79375. * @returns a new Color4 object
  79376. */
  79377. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  79378. /**
  79379. * Creates a new Color3 from integer values (< 256)
  79380. * @param r defines the red component to read from (value between 0 and 255)
  79381. * @param g defines the green component to read from (value between 0 and 255)
  79382. * @param b defines the blue component to read from (value between 0 and 255)
  79383. * @param a defines the alpha component to read from (value between 0 and 255)
  79384. * @returns a new Color3 object
  79385. */
  79386. static FromInts(r: number, g: number, b: number, a: number): Color4;
  79387. /**
  79388. * Check the content of a given array and convert it to an array containing RGBA data
  79389. * If the original array was already containing count * 4 values then it is returned directly
  79390. * @param colors defines the array to check
  79391. * @param count defines the number of RGBA data to expect
  79392. * @returns an array containing count * 4 values (RGBA)
  79393. */
  79394. static CheckColors4(colors: number[], count: number): number[];
  79395. }
  79396. /**
  79397. * @hidden
  79398. */
  79399. export class TmpColors {
  79400. static Color3: Color3[];
  79401. static Color4: Color4[];
  79402. }
  79403. }
  79404. declare module BABYLON {
  79405. /**
  79406. * Defines an interface which represents an animation key frame
  79407. */
  79408. export interface IAnimationKey {
  79409. /**
  79410. * Frame of the key frame
  79411. */
  79412. frame: number;
  79413. /**
  79414. * Value at the specifies key frame
  79415. */
  79416. value: any;
  79417. /**
  79418. * The input tangent for the cubic hermite spline
  79419. */
  79420. inTangent?: any;
  79421. /**
  79422. * The output tangent for the cubic hermite spline
  79423. */
  79424. outTangent?: any;
  79425. /**
  79426. * The animation interpolation type
  79427. */
  79428. interpolation?: AnimationKeyInterpolation;
  79429. }
  79430. /**
  79431. * Enum for the animation key frame interpolation type
  79432. */
  79433. export enum AnimationKeyInterpolation {
  79434. /**
  79435. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  79436. */
  79437. STEP = 1
  79438. }
  79439. }
  79440. declare module BABYLON {
  79441. /**
  79442. * Represents the range of an animation
  79443. */
  79444. export class AnimationRange {
  79445. /**The name of the animation range**/
  79446. name: string;
  79447. /**The starting frame of the animation */
  79448. from: number;
  79449. /**The ending frame of the animation*/
  79450. to: number;
  79451. /**
  79452. * Initializes the range of an animation
  79453. * @param name The name of the animation range
  79454. * @param from The starting frame of the animation
  79455. * @param to The ending frame of the animation
  79456. */
  79457. constructor(
  79458. /**The name of the animation range**/
  79459. name: string,
  79460. /**The starting frame of the animation */
  79461. from: number,
  79462. /**The ending frame of the animation*/
  79463. to: number);
  79464. /**
  79465. * Makes a copy of the animation range
  79466. * @returns A copy of the animation range
  79467. */
  79468. clone(): AnimationRange;
  79469. }
  79470. }
  79471. declare module BABYLON {
  79472. /**
  79473. * Composed of a frame, and an action function
  79474. */
  79475. export class AnimationEvent {
  79476. /** The frame for which the event is triggered **/
  79477. frame: number;
  79478. /** The event to perform when triggered **/
  79479. action: (currentFrame: number) => void;
  79480. /** Specifies if the event should be triggered only once**/
  79481. onlyOnce?: boolean | undefined;
  79482. /**
  79483. * Specifies if the animation event is done
  79484. */
  79485. isDone: boolean;
  79486. /**
  79487. * Initializes the animation event
  79488. * @param frame The frame for which the event is triggered
  79489. * @param action The event to perform when triggered
  79490. * @param onlyOnce Specifies if the event should be triggered only once
  79491. */
  79492. constructor(
  79493. /** The frame for which the event is triggered **/
  79494. frame: number,
  79495. /** The event to perform when triggered **/
  79496. action: (currentFrame: number) => void,
  79497. /** Specifies if the event should be triggered only once**/
  79498. onlyOnce?: boolean | undefined);
  79499. /** @hidden */
  79500. _clone(): AnimationEvent;
  79501. }
  79502. }
  79503. declare module BABYLON {
  79504. /**
  79505. * Interface used to define a behavior
  79506. */
  79507. export interface Behavior<T> {
  79508. /** gets or sets behavior's name */
  79509. name: string;
  79510. /**
  79511. * Function called when the behavior needs to be initialized (after attaching it to a target)
  79512. */
  79513. init(): void;
  79514. /**
  79515. * Called when the behavior is attached to a target
  79516. * @param target defines the target where the behavior is attached to
  79517. */
  79518. attach(target: T): void;
  79519. /**
  79520. * Called when the behavior is detached from its target
  79521. */
  79522. detach(): void;
  79523. }
  79524. /**
  79525. * Interface implemented by classes supporting behaviors
  79526. */
  79527. export interface IBehaviorAware<T> {
  79528. /**
  79529. * Attach a behavior
  79530. * @param behavior defines the behavior to attach
  79531. * @returns the current host
  79532. */
  79533. addBehavior(behavior: Behavior<T>): T;
  79534. /**
  79535. * Remove a behavior from the current object
  79536. * @param behavior defines the behavior to detach
  79537. * @returns the current host
  79538. */
  79539. removeBehavior(behavior: Behavior<T>): T;
  79540. /**
  79541. * Gets a behavior using its name to search
  79542. * @param name defines the name to search
  79543. * @returns the behavior or null if not found
  79544. */
  79545. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  79546. }
  79547. }
  79548. declare module BABYLON {
  79549. /**
  79550. * Defines an array and its length.
  79551. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  79552. */
  79553. export interface ISmartArrayLike<T> {
  79554. /**
  79555. * The data of the array.
  79556. */
  79557. data: Array<T>;
  79558. /**
  79559. * The active length of the array.
  79560. */
  79561. length: number;
  79562. }
  79563. /**
  79564. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  79565. */
  79566. export class SmartArray<T> implements ISmartArrayLike<T> {
  79567. /**
  79568. * The full set of data from the array.
  79569. */
  79570. data: Array<T>;
  79571. /**
  79572. * The active length of the array.
  79573. */
  79574. length: number;
  79575. protected _id: number;
  79576. /**
  79577. * Instantiates a Smart Array.
  79578. * @param capacity defines the default capacity of the array.
  79579. */
  79580. constructor(capacity: number);
  79581. /**
  79582. * Pushes a value at the end of the active data.
  79583. * @param value defines the object to push in the array.
  79584. */
  79585. push(value: T): void;
  79586. /**
  79587. * Iterates over the active data and apply the lambda to them.
  79588. * @param func defines the action to apply on each value.
  79589. */
  79590. forEach(func: (content: T) => void): void;
  79591. /**
  79592. * Sorts the full sets of data.
  79593. * @param compareFn defines the comparison function to apply.
  79594. */
  79595. sort(compareFn: (a: T, b: T) => number): void;
  79596. /**
  79597. * Resets the active data to an empty array.
  79598. */
  79599. reset(): void;
  79600. /**
  79601. * Releases all the data from the array as well as the array.
  79602. */
  79603. dispose(): void;
  79604. /**
  79605. * Concats the active data with a given array.
  79606. * @param array defines the data to concatenate with.
  79607. */
  79608. concat(array: any): void;
  79609. /**
  79610. * Returns the position of a value in the active data.
  79611. * @param value defines the value to find the index for
  79612. * @returns the index if found in the active data otherwise -1
  79613. */
  79614. indexOf(value: T): number;
  79615. /**
  79616. * Returns whether an element is part of the active data.
  79617. * @param value defines the value to look for
  79618. * @returns true if found in the active data otherwise false
  79619. */
  79620. contains(value: T): boolean;
  79621. private static _GlobalId;
  79622. }
  79623. /**
  79624. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  79625. * The data in this array can only be present once
  79626. */
  79627. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  79628. private _duplicateId;
  79629. /**
  79630. * Pushes a value at the end of the active data.
  79631. * THIS DOES NOT PREVENT DUPPLICATE DATA
  79632. * @param value defines the object to push in the array.
  79633. */
  79634. push(value: T): void;
  79635. /**
  79636. * Pushes a value at the end of the active data.
  79637. * If the data is already present, it won t be added again
  79638. * @param value defines the object to push in the array.
  79639. * @returns true if added false if it was already present
  79640. */
  79641. pushNoDuplicate(value: T): boolean;
  79642. /**
  79643. * Resets the active data to an empty array.
  79644. */
  79645. reset(): void;
  79646. /**
  79647. * Concats the active data with a given array.
  79648. * This ensures no dupplicate will be present in the result.
  79649. * @param array defines the data to concatenate with.
  79650. */
  79651. concatWithNoDuplicate(array: any): void;
  79652. }
  79653. }
  79654. declare module BABYLON {
  79655. /**
  79656. * @ignore
  79657. * This is a list of all the different input types that are available in the application.
  79658. * Fo instance: ArcRotateCameraGamepadInput...
  79659. */
  79660. export var CameraInputTypes: {};
  79661. /**
  79662. * This is the contract to implement in order to create a new input class.
  79663. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  79664. */
  79665. export interface ICameraInput<TCamera extends Camera> {
  79666. /**
  79667. * Defines the camera the input is attached to.
  79668. */
  79669. camera: Nullable<TCamera>;
  79670. /**
  79671. * Gets the class name of the current intput.
  79672. * @returns the class name
  79673. */
  79674. getClassName(): string;
  79675. /**
  79676. * Get the friendly name associated with the input class.
  79677. * @returns the input friendly name
  79678. */
  79679. getSimpleName(): string;
  79680. /**
  79681. * Attach the input controls to a specific dom element to get the input from.
  79682. * @param element Defines the element the controls should be listened from
  79683. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79684. */
  79685. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79686. /**
  79687. * Detach the current controls from the specified dom element.
  79688. * @param element Defines the element to stop listening the inputs from
  79689. */
  79690. detachControl(element: Nullable<HTMLElement>): void;
  79691. /**
  79692. * Update the current camera state depending on the inputs that have been used this frame.
  79693. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79694. */
  79695. checkInputs?: () => void;
  79696. }
  79697. /**
  79698. * Represents a map of input types to input instance or input index to input instance.
  79699. */
  79700. export interface CameraInputsMap<TCamera extends Camera> {
  79701. /**
  79702. * Accessor to the input by input type.
  79703. */
  79704. [name: string]: ICameraInput<TCamera>;
  79705. /**
  79706. * Accessor to the input by input index.
  79707. */
  79708. [idx: number]: ICameraInput<TCamera>;
  79709. }
  79710. /**
  79711. * This represents the input manager used within a camera.
  79712. * It helps dealing with all the different kind of input attached to a camera.
  79713. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79714. */
  79715. export class CameraInputsManager<TCamera extends Camera> {
  79716. /**
  79717. * Defines the list of inputs attahed to the camera.
  79718. */
  79719. attached: CameraInputsMap<TCamera>;
  79720. /**
  79721. * Defines the dom element the camera is collecting inputs from.
  79722. * This is null if the controls have not been attached.
  79723. */
  79724. attachedElement: Nullable<HTMLElement>;
  79725. /**
  79726. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79727. */
  79728. noPreventDefault: boolean;
  79729. /**
  79730. * Defined the camera the input manager belongs to.
  79731. */
  79732. camera: TCamera;
  79733. /**
  79734. * Update the current camera state depending on the inputs that have been used this frame.
  79735. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79736. */
  79737. checkInputs: () => void;
  79738. /**
  79739. * Instantiate a new Camera Input Manager.
  79740. * @param camera Defines the camera the input manager blongs to
  79741. */
  79742. constructor(camera: TCamera);
  79743. /**
  79744. * Add an input method to a camera
  79745. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79746. * @param input camera input method
  79747. */
  79748. add(input: ICameraInput<TCamera>): void;
  79749. /**
  79750. * Remove a specific input method from a camera
  79751. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  79752. * @param inputToRemove camera input method
  79753. */
  79754. remove(inputToRemove: ICameraInput<TCamera>): void;
  79755. /**
  79756. * Remove a specific input type from a camera
  79757. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  79758. * @param inputType the type of the input to remove
  79759. */
  79760. removeByType(inputType: string): void;
  79761. private _addCheckInputs;
  79762. /**
  79763. * Attach the input controls to the currently attached dom element to listen the events from.
  79764. * @param input Defines the input to attach
  79765. */
  79766. attachInput(input: ICameraInput<TCamera>): void;
  79767. /**
  79768. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  79769. * @param element Defines the dom element to collect the events from
  79770. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79771. */
  79772. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  79773. /**
  79774. * Detach the current manager inputs controls from a specific dom element.
  79775. * @param element Defines the dom element to collect the events from
  79776. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  79777. */
  79778. detachElement(element: HTMLElement, disconnect?: boolean): void;
  79779. /**
  79780. * Rebuild the dynamic inputCheck function from the current list of
  79781. * defined inputs in the manager.
  79782. */
  79783. rebuildInputCheck(): void;
  79784. /**
  79785. * Remove all attached input methods from a camera
  79786. */
  79787. clear(): void;
  79788. /**
  79789. * Serialize the current input manager attached to a camera.
  79790. * This ensures than once parsed,
  79791. * the input associated to the camera will be identical to the current ones
  79792. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  79793. */
  79794. serialize(serializedCamera: any): void;
  79795. /**
  79796. * Parses an input manager serialized JSON to restore the previous list of inputs
  79797. * and states associated to a camera.
  79798. * @param parsedCamera Defines the JSON to parse
  79799. */
  79800. parse(parsedCamera: any): void;
  79801. }
  79802. }
  79803. declare module BABYLON {
  79804. /**
  79805. * Class used to store data that will be store in GPU memory
  79806. */
  79807. export class Buffer {
  79808. private _engine;
  79809. private _buffer;
  79810. /** @hidden */
  79811. _data: Nullable<DataArray>;
  79812. private _updatable;
  79813. private _instanced;
  79814. private _divisor;
  79815. /**
  79816. * Gets the byte stride.
  79817. */
  79818. readonly byteStride: number;
  79819. /**
  79820. * Constructor
  79821. * @param engine the engine
  79822. * @param data the data to use for this buffer
  79823. * @param updatable whether the data is updatable
  79824. * @param stride the stride (optional)
  79825. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79826. * @param instanced whether the buffer is instanced (optional)
  79827. * @param useBytes set to true if the stride in in bytes (optional)
  79828. * @param divisor sets an optional divisor for instances (1 by default)
  79829. */
  79830. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  79831. /**
  79832. * Create a new VertexBuffer based on the current buffer
  79833. * @param kind defines the vertex buffer kind (position, normal, etc.)
  79834. * @param offset defines offset in the buffer (0 by default)
  79835. * @param size defines the size in floats of attributes (position is 3 for instance)
  79836. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  79837. * @param instanced defines if the vertex buffer contains indexed data
  79838. * @param useBytes defines if the offset and stride are in bytes *
  79839. * @param divisor sets an optional divisor for instances (1 by default)
  79840. * @returns the new vertex buffer
  79841. */
  79842. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  79843. /**
  79844. * Gets a boolean indicating if the Buffer is updatable?
  79845. * @returns true if the buffer is updatable
  79846. */
  79847. isUpdatable(): boolean;
  79848. /**
  79849. * Gets current buffer's data
  79850. * @returns a DataArray or null
  79851. */
  79852. getData(): Nullable<DataArray>;
  79853. /**
  79854. * Gets underlying native buffer
  79855. * @returns underlying native buffer
  79856. */
  79857. getBuffer(): Nullable<DataBuffer>;
  79858. /**
  79859. * Gets the stride in float32 units (i.e. byte stride / 4).
  79860. * May not be an integer if the byte stride is not divisible by 4.
  79861. * @returns the stride in float32 units
  79862. * @deprecated Please use byteStride instead.
  79863. */
  79864. getStrideSize(): number;
  79865. /**
  79866. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  79867. * @param data defines the data to store
  79868. */
  79869. create(data?: Nullable<DataArray>): void;
  79870. /** @hidden */
  79871. _rebuild(): void;
  79872. /**
  79873. * Update current buffer data
  79874. * @param data defines the data to store
  79875. */
  79876. update(data: DataArray): void;
  79877. /**
  79878. * Updates the data directly.
  79879. * @param data the new data
  79880. * @param offset the new offset
  79881. * @param vertexCount the vertex count (optional)
  79882. * @param useBytes set to true if the offset is in bytes
  79883. */
  79884. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  79885. /**
  79886. * Release all resources
  79887. */
  79888. dispose(): void;
  79889. }
  79890. /**
  79891. * Specialized buffer used to store vertex data
  79892. */
  79893. export class VertexBuffer {
  79894. /** @hidden */
  79895. _buffer: Buffer;
  79896. private _kind;
  79897. private _size;
  79898. private _ownsBuffer;
  79899. private _instanced;
  79900. private _instanceDivisor;
  79901. /**
  79902. * The byte type.
  79903. */
  79904. static readonly BYTE: number;
  79905. /**
  79906. * The unsigned byte type.
  79907. */
  79908. static readonly UNSIGNED_BYTE: number;
  79909. /**
  79910. * The short type.
  79911. */
  79912. static readonly SHORT: number;
  79913. /**
  79914. * The unsigned short type.
  79915. */
  79916. static readonly UNSIGNED_SHORT: number;
  79917. /**
  79918. * The integer type.
  79919. */
  79920. static readonly INT: number;
  79921. /**
  79922. * The unsigned integer type.
  79923. */
  79924. static readonly UNSIGNED_INT: number;
  79925. /**
  79926. * The float type.
  79927. */
  79928. static readonly FLOAT: number;
  79929. /**
  79930. * Gets or sets the instance divisor when in instanced mode
  79931. */
  79932. get instanceDivisor(): number;
  79933. set instanceDivisor(value: number);
  79934. /**
  79935. * Gets the byte stride.
  79936. */
  79937. readonly byteStride: number;
  79938. /**
  79939. * Gets the byte offset.
  79940. */
  79941. readonly byteOffset: number;
  79942. /**
  79943. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  79944. */
  79945. readonly normalized: boolean;
  79946. /**
  79947. * Gets the data type of each component in the array.
  79948. */
  79949. readonly type: number;
  79950. /**
  79951. * Constructor
  79952. * @param engine the engine
  79953. * @param data the data to use for this vertex buffer
  79954. * @param kind the vertex buffer kind
  79955. * @param updatable whether the data is updatable
  79956. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79957. * @param stride the stride (optional)
  79958. * @param instanced whether the buffer is instanced (optional)
  79959. * @param offset the offset of the data (optional)
  79960. * @param size the number of components (optional)
  79961. * @param type the type of the component (optional)
  79962. * @param normalized whether the data contains normalized data (optional)
  79963. * @param useBytes set to true if stride and offset are in bytes (optional)
  79964. * @param divisor defines the instance divisor to use (1 by default)
  79965. */
  79966. 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);
  79967. /** @hidden */
  79968. _rebuild(): void;
  79969. /**
  79970. * Returns the kind of the VertexBuffer (string)
  79971. * @returns a string
  79972. */
  79973. getKind(): string;
  79974. /**
  79975. * Gets a boolean indicating if the VertexBuffer is updatable?
  79976. * @returns true if the buffer is updatable
  79977. */
  79978. isUpdatable(): boolean;
  79979. /**
  79980. * Gets current buffer's data
  79981. * @returns a DataArray or null
  79982. */
  79983. getData(): Nullable<DataArray>;
  79984. /**
  79985. * Gets underlying native buffer
  79986. * @returns underlying native buffer
  79987. */
  79988. getBuffer(): Nullable<DataBuffer>;
  79989. /**
  79990. * Gets the stride in float32 units (i.e. byte stride / 4).
  79991. * May not be an integer if the byte stride is not divisible by 4.
  79992. * @returns the stride in float32 units
  79993. * @deprecated Please use byteStride instead.
  79994. */
  79995. getStrideSize(): number;
  79996. /**
  79997. * Returns the offset as a multiple of the type byte length.
  79998. * @returns the offset in bytes
  79999. * @deprecated Please use byteOffset instead.
  80000. */
  80001. getOffset(): number;
  80002. /**
  80003. * Returns the number of components per vertex attribute (integer)
  80004. * @returns the size in float
  80005. */
  80006. getSize(): number;
  80007. /**
  80008. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  80009. * @returns true if this buffer is instanced
  80010. */
  80011. getIsInstanced(): boolean;
  80012. /**
  80013. * Returns the instancing divisor, zero for non-instanced (integer).
  80014. * @returns a number
  80015. */
  80016. getInstanceDivisor(): number;
  80017. /**
  80018. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  80019. * @param data defines the data to store
  80020. */
  80021. create(data?: DataArray): void;
  80022. /**
  80023. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  80024. * This function will create a new buffer if the current one is not updatable
  80025. * @param data defines the data to store
  80026. */
  80027. update(data: DataArray): void;
  80028. /**
  80029. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  80030. * Returns the directly updated WebGLBuffer.
  80031. * @param data the new data
  80032. * @param offset the new offset
  80033. * @param useBytes set to true if the offset is in bytes
  80034. */
  80035. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  80036. /**
  80037. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  80038. */
  80039. dispose(): void;
  80040. /**
  80041. * Enumerates each value of this vertex buffer as numbers.
  80042. * @param count the number of values to enumerate
  80043. * @param callback the callback function called for each value
  80044. */
  80045. forEach(count: number, callback: (value: number, index: number) => void): void;
  80046. /**
  80047. * Positions
  80048. */
  80049. static readonly PositionKind: string;
  80050. /**
  80051. * Normals
  80052. */
  80053. static readonly NormalKind: string;
  80054. /**
  80055. * Tangents
  80056. */
  80057. static readonly TangentKind: string;
  80058. /**
  80059. * Texture coordinates
  80060. */
  80061. static readonly UVKind: string;
  80062. /**
  80063. * Texture coordinates 2
  80064. */
  80065. static readonly UV2Kind: string;
  80066. /**
  80067. * Texture coordinates 3
  80068. */
  80069. static readonly UV3Kind: string;
  80070. /**
  80071. * Texture coordinates 4
  80072. */
  80073. static readonly UV4Kind: string;
  80074. /**
  80075. * Texture coordinates 5
  80076. */
  80077. static readonly UV5Kind: string;
  80078. /**
  80079. * Texture coordinates 6
  80080. */
  80081. static readonly UV6Kind: string;
  80082. /**
  80083. * Colors
  80084. */
  80085. static readonly ColorKind: string;
  80086. /**
  80087. * Matrix indices (for bones)
  80088. */
  80089. static readonly MatricesIndicesKind: string;
  80090. /**
  80091. * Matrix weights (for bones)
  80092. */
  80093. static readonly MatricesWeightsKind: string;
  80094. /**
  80095. * Additional matrix indices (for bones)
  80096. */
  80097. static readonly MatricesIndicesExtraKind: string;
  80098. /**
  80099. * Additional matrix weights (for bones)
  80100. */
  80101. static readonly MatricesWeightsExtraKind: string;
  80102. /**
  80103. * Deduces the stride given a kind.
  80104. * @param kind The kind string to deduce
  80105. * @returns The deduced stride
  80106. */
  80107. static DeduceStride(kind: string): number;
  80108. /**
  80109. * Gets the byte length of the given type.
  80110. * @param type the type
  80111. * @returns the number of bytes
  80112. */
  80113. static GetTypeByteLength(type: number): number;
  80114. /**
  80115. * Enumerates each value of the given parameters as numbers.
  80116. * @param data the data to enumerate
  80117. * @param byteOffset the byte offset of the data
  80118. * @param byteStride the byte stride of the data
  80119. * @param componentCount the number of components per element
  80120. * @param componentType the type of the component
  80121. * @param count the number of values to enumerate
  80122. * @param normalized whether the data is normalized
  80123. * @param callback the callback function called for each value
  80124. */
  80125. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  80126. private static _GetFloatValue;
  80127. }
  80128. }
  80129. declare module BABYLON {
  80130. /**
  80131. * @hidden
  80132. */
  80133. export class IntersectionInfo {
  80134. bu: Nullable<number>;
  80135. bv: Nullable<number>;
  80136. distance: number;
  80137. faceId: number;
  80138. subMeshId: number;
  80139. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  80140. }
  80141. }
  80142. declare module BABYLON {
  80143. /**
  80144. * Represens a plane by the equation ax + by + cz + d = 0
  80145. */
  80146. export class Plane {
  80147. private static _TmpMatrix;
  80148. /**
  80149. * Normal of the plane (a,b,c)
  80150. */
  80151. normal: Vector3;
  80152. /**
  80153. * d component of the plane
  80154. */
  80155. d: number;
  80156. /**
  80157. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  80158. * @param a a component of the plane
  80159. * @param b b component of the plane
  80160. * @param c c component of the plane
  80161. * @param d d component of the plane
  80162. */
  80163. constructor(a: number, b: number, c: number, d: number);
  80164. /**
  80165. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  80166. */
  80167. asArray(): number[];
  80168. /**
  80169. * @returns a new plane copied from the current Plane.
  80170. */
  80171. clone(): Plane;
  80172. /**
  80173. * @returns the string "Plane".
  80174. */
  80175. getClassName(): string;
  80176. /**
  80177. * @returns the Plane hash code.
  80178. */
  80179. getHashCode(): number;
  80180. /**
  80181. * Normalize the current Plane in place.
  80182. * @returns the updated Plane.
  80183. */
  80184. normalize(): Plane;
  80185. /**
  80186. * Applies a transformation the plane and returns the result
  80187. * @param transformation the transformation matrix to be applied to the plane
  80188. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  80189. */
  80190. transform(transformation: DeepImmutable<Matrix>): Plane;
  80191. /**
  80192. * Calcualtte the dot product between the point and the plane normal
  80193. * @param point point to calculate the dot product with
  80194. * @returns the dot product (float) of the point coordinates and the plane normal.
  80195. */
  80196. dotCoordinate(point: DeepImmutable<Vector3>): number;
  80197. /**
  80198. * Updates the current Plane from the plane defined by the three given points.
  80199. * @param point1 one of the points used to contruct the plane
  80200. * @param point2 one of the points used to contruct the plane
  80201. * @param point3 one of the points used to contruct the plane
  80202. * @returns the updated Plane.
  80203. */
  80204. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80205. /**
  80206. * Checks if the plane is facing a given direction
  80207. * @param direction the direction to check if the plane is facing
  80208. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  80209. * @returns True is the vector "direction" is the same side than the plane normal.
  80210. */
  80211. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  80212. /**
  80213. * Calculates the distance to a point
  80214. * @param point point to calculate distance to
  80215. * @returns the signed distance (float) from the given point to the Plane.
  80216. */
  80217. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  80218. /**
  80219. * Creates a plane from an array
  80220. * @param array the array to create a plane from
  80221. * @returns a new Plane from the given array.
  80222. */
  80223. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  80224. /**
  80225. * Creates a plane from three points
  80226. * @param point1 point used to create the plane
  80227. * @param point2 point used to create the plane
  80228. * @param point3 point used to create the plane
  80229. * @returns a new Plane defined by the three given points.
  80230. */
  80231. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80232. /**
  80233. * Creates a plane from an origin point and a normal
  80234. * @param origin origin of the plane to be constructed
  80235. * @param normal normal of the plane to be constructed
  80236. * @returns a new Plane the normal vector to this plane at the given origin point.
  80237. * Note : the vector "normal" is updated because normalized.
  80238. */
  80239. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  80240. /**
  80241. * Calculates the distance from a plane and a point
  80242. * @param origin origin of the plane to be constructed
  80243. * @param normal normal of the plane to be constructed
  80244. * @param point point to calculate distance to
  80245. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  80246. */
  80247. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  80248. }
  80249. }
  80250. declare module BABYLON {
  80251. /**
  80252. * Class used to store bounding sphere information
  80253. */
  80254. export class BoundingSphere {
  80255. /**
  80256. * Gets the center of the bounding sphere in local space
  80257. */
  80258. readonly center: Vector3;
  80259. /**
  80260. * Radius of the bounding sphere in local space
  80261. */
  80262. radius: number;
  80263. /**
  80264. * Gets the center of the bounding sphere in world space
  80265. */
  80266. readonly centerWorld: Vector3;
  80267. /**
  80268. * Radius of the bounding sphere in world space
  80269. */
  80270. radiusWorld: number;
  80271. /**
  80272. * Gets the minimum vector in local space
  80273. */
  80274. readonly minimum: Vector3;
  80275. /**
  80276. * Gets the maximum vector in local space
  80277. */
  80278. readonly maximum: Vector3;
  80279. private _worldMatrix;
  80280. private static readonly TmpVector3;
  80281. /**
  80282. * Creates a new bounding sphere
  80283. * @param min defines the minimum vector (in local space)
  80284. * @param max defines the maximum vector (in local space)
  80285. * @param worldMatrix defines the new world matrix
  80286. */
  80287. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80288. /**
  80289. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  80290. * @param min defines the new minimum vector (in local space)
  80291. * @param max defines the new maximum vector (in local space)
  80292. * @param worldMatrix defines the new world matrix
  80293. */
  80294. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80295. /**
  80296. * Scale the current bounding sphere by applying a scale factor
  80297. * @param factor defines the scale factor to apply
  80298. * @returns the current bounding box
  80299. */
  80300. scale(factor: number): BoundingSphere;
  80301. /**
  80302. * Gets the world matrix of the bounding box
  80303. * @returns a matrix
  80304. */
  80305. getWorldMatrix(): DeepImmutable<Matrix>;
  80306. /** @hidden */
  80307. _update(worldMatrix: DeepImmutable<Matrix>): void;
  80308. /**
  80309. * Tests if the bounding sphere is intersecting the frustum planes
  80310. * @param frustumPlanes defines the frustum planes to test
  80311. * @returns true if there is an intersection
  80312. */
  80313. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80314. /**
  80315. * Tests if the bounding sphere center is in between the frustum planes.
  80316. * Used for optimistic fast inclusion.
  80317. * @param frustumPlanes defines the frustum planes to test
  80318. * @returns true if the sphere center is in between the frustum planes
  80319. */
  80320. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80321. /**
  80322. * Tests if a point is inside the bounding sphere
  80323. * @param point defines the point to test
  80324. * @returns true if the point is inside the bounding sphere
  80325. */
  80326. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80327. /**
  80328. * Checks if two sphere intersct
  80329. * @param sphere0 sphere 0
  80330. * @param sphere1 sphere 1
  80331. * @returns true if the speres intersect
  80332. */
  80333. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  80334. }
  80335. }
  80336. declare module BABYLON {
  80337. /**
  80338. * Class used to store bounding box information
  80339. */
  80340. export class BoundingBox implements ICullable {
  80341. /**
  80342. * Gets the 8 vectors representing the bounding box in local space
  80343. */
  80344. readonly vectors: Vector3[];
  80345. /**
  80346. * Gets the center of the bounding box in local space
  80347. */
  80348. readonly center: Vector3;
  80349. /**
  80350. * Gets the center of the bounding box in world space
  80351. */
  80352. readonly centerWorld: Vector3;
  80353. /**
  80354. * Gets the extend size in local space
  80355. */
  80356. readonly extendSize: Vector3;
  80357. /**
  80358. * Gets the extend size in world space
  80359. */
  80360. readonly extendSizeWorld: Vector3;
  80361. /**
  80362. * Gets the OBB (object bounding box) directions
  80363. */
  80364. readonly directions: Vector3[];
  80365. /**
  80366. * Gets the 8 vectors representing the bounding box in world space
  80367. */
  80368. readonly vectorsWorld: Vector3[];
  80369. /**
  80370. * Gets the minimum vector in world space
  80371. */
  80372. readonly minimumWorld: Vector3;
  80373. /**
  80374. * Gets the maximum vector in world space
  80375. */
  80376. readonly maximumWorld: Vector3;
  80377. /**
  80378. * Gets the minimum vector in local space
  80379. */
  80380. readonly minimum: Vector3;
  80381. /**
  80382. * Gets the maximum vector in local space
  80383. */
  80384. readonly maximum: Vector3;
  80385. private _worldMatrix;
  80386. private static readonly TmpVector3;
  80387. /**
  80388. * @hidden
  80389. */
  80390. _tag: number;
  80391. /**
  80392. * Creates a new bounding box
  80393. * @param min defines the minimum vector (in local space)
  80394. * @param max defines the maximum vector (in local space)
  80395. * @param worldMatrix defines the new world matrix
  80396. */
  80397. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80398. /**
  80399. * Recreates the entire bounding box from scratch as if we call the constructor in place
  80400. * @param min defines the new minimum vector (in local space)
  80401. * @param max defines the new maximum vector (in local space)
  80402. * @param worldMatrix defines the new world matrix
  80403. */
  80404. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80405. /**
  80406. * Scale the current bounding box by applying a scale factor
  80407. * @param factor defines the scale factor to apply
  80408. * @returns the current bounding box
  80409. */
  80410. scale(factor: number): BoundingBox;
  80411. /**
  80412. * Gets the world matrix of the bounding box
  80413. * @returns a matrix
  80414. */
  80415. getWorldMatrix(): DeepImmutable<Matrix>;
  80416. /** @hidden */
  80417. _update(world: DeepImmutable<Matrix>): void;
  80418. /**
  80419. * Tests if the bounding box is intersecting the frustum planes
  80420. * @param frustumPlanes defines the frustum planes to test
  80421. * @returns true if there is an intersection
  80422. */
  80423. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80424. /**
  80425. * Tests if the bounding box is entirely inside the frustum planes
  80426. * @param frustumPlanes defines the frustum planes to test
  80427. * @returns true if there is an inclusion
  80428. */
  80429. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80430. /**
  80431. * Tests if a point is inside the bounding box
  80432. * @param point defines the point to test
  80433. * @returns true if the point is inside the bounding box
  80434. */
  80435. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80436. /**
  80437. * Tests if the bounding box intersects with a bounding sphere
  80438. * @param sphere defines the sphere to test
  80439. * @returns true if there is an intersection
  80440. */
  80441. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  80442. /**
  80443. * Tests if the bounding box intersects with a box defined by a min and max vectors
  80444. * @param min defines the min vector to use
  80445. * @param max defines the max vector to use
  80446. * @returns true if there is an intersection
  80447. */
  80448. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  80449. /**
  80450. * Tests if two bounding boxes are intersections
  80451. * @param box0 defines the first box to test
  80452. * @param box1 defines the second box to test
  80453. * @returns true if there is an intersection
  80454. */
  80455. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  80456. /**
  80457. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  80458. * @param minPoint defines the minimum vector of the bounding box
  80459. * @param maxPoint defines the maximum vector of the bounding box
  80460. * @param sphereCenter defines the sphere center
  80461. * @param sphereRadius defines the sphere radius
  80462. * @returns true if there is an intersection
  80463. */
  80464. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  80465. /**
  80466. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  80467. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  80468. * @param frustumPlanes defines the frustum planes to test
  80469. * @return true if there is an inclusion
  80470. */
  80471. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80472. /**
  80473. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  80474. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  80475. * @param frustumPlanes defines the frustum planes to test
  80476. * @return true if there is an intersection
  80477. */
  80478. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80479. }
  80480. }
  80481. declare module BABYLON {
  80482. /** @hidden */
  80483. export class Collider {
  80484. /** Define if a collision was found */
  80485. collisionFound: boolean;
  80486. /**
  80487. * Define last intersection point in local space
  80488. */
  80489. intersectionPoint: Vector3;
  80490. /**
  80491. * Define last collided mesh
  80492. */
  80493. collidedMesh: Nullable<AbstractMesh>;
  80494. private _collisionPoint;
  80495. private _planeIntersectionPoint;
  80496. private _tempVector;
  80497. private _tempVector2;
  80498. private _tempVector3;
  80499. private _tempVector4;
  80500. private _edge;
  80501. private _baseToVertex;
  80502. private _destinationPoint;
  80503. private _slidePlaneNormal;
  80504. private _displacementVector;
  80505. /** @hidden */
  80506. _radius: Vector3;
  80507. /** @hidden */
  80508. _retry: number;
  80509. private _velocity;
  80510. private _basePoint;
  80511. private _epsilon;
  80512. /** @hidden */
  80513. _velocityWorldLength: number;
  80514. /** @hidden */
  80515. _basePointWorld: Vector3;
  80516. private _velocityWorld;
  80517. private _normalizedVelocity;
  80518. /** @hidden */
  80519. _initialVelocity: Vector3;
  80520. /** @hidden */
  80521. _initialPosition: Vector3;
  80522. private _nearestDistance;
  80523. private _collisionMask;
  80524. get collisionMask(): number;
  80525. set collisionMask(mask: number);
  80526. /**
  80527. * Gets the plane normal used to compute the sliding response (in local space)
  80528. */
  80529. get slidePlaneNormal(): Vector3;
  80530. /** @hidden */
  80531. _initialize(source: Vector3, dir: Vector3, e: number): void;
  80532. /** @hidden */
  80533. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  80534. /** @hidden */
  80535. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  80536. /** @hidden */
  80537. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  80538. /** @hidden */
  80539. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  80540. /** @hidden */
  80541. _getResponse(pos: Vector3, vel: Vector3): void;
  80542. }
  80543. }
  80544. declare module BABYLON {
  80545. /**
  80546. * Interface for cullable objects
  80547. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  80548. */
  80549. export interface ICullable {
  80550. /**
  80551. * Checks if the object or part of the object is in the frustum
  80552. * @param frustumPlanes Camera near/planes
  80553. * @returns true if the object is in frustum otherwise false
  80554. */
  80555. isInFrustum(frustumPlanes: Plane[]): boolean;
  80556. /**
  80557. * Checks if a cullable object (mesh...) is in the camera frustum
  80558. * Unlike isInFrustum this cheks the full bounding box
  80559. * @param frustumPlanes Camera near/planes
  80560. * @returns true if the object is in frustum otherwise false
  80561. */
  80562. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  80563. }
  80564. /**
  80565. * Info for a bounding data of a mesh
  80566. */
  80567. export class BoundingInfo implements ICullable {
  80568. /**
  80569. * Bounding box for the mesh
  80570. */
  80571. readonly boundingBox: BoundingBox;
  80572. /**
  80573. * Bounding sphere for the mesh
  80574. */
  80575. readonly boundingSphere: BoundingSphere;
  80576. private _isLocked;
  80577. private static readonly TmpVector3;
  80578. /**
  80579. * Constructs bounding info
  80580. * @param minimum min vector of the bounding box/sphere
  80581. * @param maximum max vector of the bounding box/sphere
  80582. * @param worldMatrix defines the new world matrix
  80583. */
  80584. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80585. /**
  80586. * Recreates the entire bounding info from scratch as if we call the constructor in place
  80587. * @param min defines the new minimum vector (in local space)
  80588. * @param max defines the new maximum vector (in local space)
  80589. * @param worldMatrix defines the new world matrix
  80590. */
  80591. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80592. /**
  80593. * min vector of the bounding box/sphere
  80594. */
  80595. get minimum(): Vector3;
  80596. /**
  80597. * max vector of the bounding box/sphere
  80598. */
  80599. get maximum(): Vector3;
  80600. /**
  80601. * If the info is locked and won't be updated to avoid perf overhead
  80602. */
  80603. get isLocked(): boolean;
  80604. set isLocked(value: boolean);
  80605. /**
  80606. * Updates the bounding sphere and box
  80607. * @param world world matrix to be used to update
  80608. */
  80609. update(world: DeepImmutable<Matrix>): void;
  80610. /**
  80611. * Recreate the bounding info to be centered around a specific point given a specific extend.
  80612. * @param center New center of the bounding info
  80613. * @param extend New extend of the bounding info
  80614. * @returns the current bounding info
  80615. */
  80616. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  80617. /**
  80618. * Scale the current bounding info by applying a scale factor
  80619. * @param factor defines the scale factor to apply
  80620. * @returns the current bounding info
  80621. */
  80622. scale(factor: number): BoundingInfo;
  80623. /**
  80624. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  80625. * @param frustumPlanes defines the frustum to test
  80626. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  80627. * @returns true if the bounding info is in the frustum planes
  80628. */
  80629. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  80630. /**
  80631. * Gets the world distance between the min and max points of the bounding box
  80632. */
  80633. get diagonalLength(): number;
  80634. /**
  80635. * Checks if a cullable object (mesh...) is in the camera frustum
  80636. * Unlike isInFrustum this cheks the full bounding box
  80637. * @param frustumPlanes Camera near/planes
  80638. * @returns true if the object is in frustum otherwise false
  80639. */
  80640. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80641. /** @hidden */
  80642. _checkCollision(collider: Collider): boolean;
  80643. /**
  80644. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  80645. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80646. * @param point the point to check intersection with
  80647. * @returns if the point intersects
  80648. */
  80649. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80650. /**
  80651. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  80652. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80653. * @param boundingInfo the bounding info to check intersection with
  80654. * @param precise if the intersection should be done using OBB
  80655. * @returns if the bounding info intersects
  80656. */
  80657. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  80658. }
  80659. }
  80660. declare module BABYLON {
  80661. /**
  80662. * Extracts minimum and maximum values from a list of indexed positions
  80663. * @param positions defines the positions to use
  80664. * @param indices defines the indices to the positions
  80665. * @param indexStart defines the start index
  80666. * @param indexCount defines the end index
  80667. * @param bias defines bias value to add to the result
  80668. * @return minimum and maximum values
  80669. */
  80670. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  80671. minimum: Vector3;
  80672. maximum: Vector3;
  80673. };
  80674. /**
  80675. * Extracts minimum and maximum values from a list of positions
  80676. * @param positions defines the positions to use
  80677. * @param start defines the start index in the positions array
  80678. * @param count defines the number of positions to handle
  80679. * @param bias defines bias value to add to the result
  80680. * @param stride defines the stride size to use (distance between two positions in the positions array)
  80681. * @return minimum and maximum values
  80682. */
  80683. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  80684. minimum: Vector3;
  80685. maximum: Vector3;
  80686. };
  80687. }
  80688. declare module BABYLON {
  80689. /** @hidden */
  80690. export class WebGLDataBuffer extends DataBuffer {
  80691. private _buffer;
  80692. constructor(resource: WebGLBuffer);
  80693. get underlyingResource(): any;
  80694. }
  80695. }
  80696. declare module BABYLON {
  80697. /** @hidden */
  80698. export class WebGLPipelineContext implements IPipelineContext {
  80699. engine: ThinEngine;
  80700. program: Nullable<WebGLProgram>;
  80701. context?: WebGLRenderingContext;
  80702. vertexShader?: WebGLShader;
  80703. fragmentShader?: WebGLShader;
  80704. isParallelCompiled: boolean;
  80705. onCompiled?: () => void;
  80706. transformFeedback?: WebGLTransformFeedback | null;
  80707. vertexCompilationError: Nullable<string>;
  80708. fragmentCompilationError: Nullable<string>;
  80709. programLinkError: Nullable<string>;
  80710. programValidationError: Nullable<string>;
  80711. get isAsync(): boolean;
  80712. get isReady(): boolean;
  80713. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  80714. _getVertexShaderCode(): string | null;
  80715. _getFragmentShaderCode(): string | null;
  80716. }
  80717. }
  80718. declare module BABYLON {
  80719. interface ThinEngine {
  80720. /**
  80721. * Create an uniform buffer
  80722. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80723. * @param elements defines the content of the uniform buffer
  80724. * @returns the webGL uniform buffer
  80725. */
  80726. createUniformBuffer(elements: FloatArray): DataBuffer;
  80727. /**
  80728. * Create a dynamic uniform buffer
  80729. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80730. * @param elements defines the content of the uniform buffer
  80731. * @returns the webGL uniform buffer
  80732. */
  80733. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  80734. /**
  80735. * Update an existing uniform buffer
  80736. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80737. * @param uniformBuffer defines the target uniform buffer
  80738. * @param elements defines the content to update
  80739. * @param offset defines the offset in the uniform buffer where update should start
  80740. * @param count defines the size of the data to update
  80741. */
  80742. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  80743. /**
  80744. * Bind an uniform buffer to the current webGL context
  80745. * @param buffer defines the buffer to bind
  80746. */
  80747. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  80748. /**
  80749. * Bind a buffer to the current webGL context at a given location
  80750. * @param buffer defines the buffer to bind
  80751. * @param location defines the index where to bind the buffer
  80752. */
  80753. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  80754. /**
  80755. * Bind a specific block at a given index in a specific shader program
  80756. * @param pipelineContext defines the pipeline context to use
  80757. * @param blockName defines the block name
  80758. * @param index defines the index where to bind the block
  80759. */
  80760. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  80761. }
  80762. }
  80763. declare module BABYLON {
  80764. /**
  80765. * Uniform buffer objects.
  80766. *
  80767. * Handles blocks of uniform on the GPU.
  80768. *
  80769. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80770. *
  80771. * For more information, please refer to :
  80772. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80773. */
  80774. export class UniformBuffer {
  80775. private _engine;
  80776. private _buffer;
  80777. private _data;
  80778. private _bufferData;
  80779. private _dynamic?;
  80780. private _uniformLocations;
  80781. private _uniformSizes;
  80782. private _uniformLocationPointer;
  80783. private _needSync;
  80784. private _noUBO;
  80785. private _currentEffect;
  80786. /** @hidden */
  80787. _alreadyBound: boolean;
  80788. private static _MAX_UNIFORM_SIZE;
  80789. private static _tempBuffer;
  80790. /**
  80791. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  80792. * This is dynamic to allow compat with webgl 1 and 2.
  80793. * You will need to pass the name of the uniform as well as the value.
  80794. */
  80795. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  80796. /**
  80797. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  80798. * This is dynamic to allow compat with webgl 1 and 2.
  80799. * You will need to pass the name of the uniform as well as the value.
  80800. */
  80801. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  80802. /**
  80803. * Lambda to Update a single float in a uniform buffer.
  80804. * This is dynamic to allow compat with webgl 1 and 2.
  80805. * You will need to pass the name of the uniform as well as the value.
  80806. */
  80807. updateFloat: (name: string, x: number) => void;
  80808. /**
  80809. * Lambda to Update a vec2 of float in a uniform buffer.
  80810. * This is dynamic to allow compat with webgl 1 and 2.
  80811. * You will need to pass the name of the uniform as well as the value.
  80812. */
  80813. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  80814. /**
  80815. * Lambda to Update a vec3 of float in a uniform buffer.
  80816. * This is dynamic to allow compat with webgl 1 and 2.
  80817. * You will need to pass the name of the uniform as well as the value.
  80818. */
  80819. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  80820. /**
  80821. * Lambda to Update a vec4 of float in a uniform buffer.
  80822. * This is dynamic to allow compat with webgl 1 and 2.
  80823. * You will need to pass the name of the uniform as well as the value.
  80824. */
  80825. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  80826. /**
  80827. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  80828. * This is dynamic to allow compat with webgl 1 and 2.
  80829. * You will need to pass the name of the uniform as well as the value.
  80830. */
  80831. updateMatrix: (name: string, mat: Matrix) => void;
  80832. /**
  80833. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  80834. * This is dynamic to allow compat with webgl 1 and 2.
  80835. * You will need to pass the name of the uniform as well as the value.
  80836. */
  80837. updateVector3: (name: string, vector: Vector3) => void;
  80838. /**
  80839. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  80840. * This is dynamic to allow compat with webgl 1 and 2.
  80841. * You will need to pass the name of the uniform as well as the value.
  80842. */
  80843. updateVector4: (name: string, vector: Vector4) => void;
  80844. /**
  80845. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  80846. * This is dynamic to allow compat with webgl 1 and 2.
  80847. * You will need to pass the name of the uniform as well as the value.
  80848. */
  80849. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  80850. /**
  80851. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  80852. * This is dynamic to allow compat with webgl 1 and 2.
  80853. * You will need to pass the name of the uniform as well as the value.
  80854. */
  80855. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  80856. /**
  80857. * Instantiates a new Uniform buffer objects.
  80858. *
  80859. * Handles blocks of uniform on the GPU.
  80860. *
  80861. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80862. *
  80863. * For more information, please refer to :
  80864. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80865. * @param engine Define the engine the buffer is associated with
  80866. * @param data Define the data contained in the buffer
  80867. * @param dynamic Define if the buffer is updatable
  80868. */
  80869. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  80870. /**
  80871. * Indicates if the buffer is using the WebGL2 UBO implementation,
  80872. * or just falling back on setUniformXXX calls.
  80873. */
  80874. get useUbo(): boolean;
  80875. /**
  80876. * Indicates if the WebGL underlying uniform buffer is in sync
  80877. * with the javascript cache data.
  80878. */
  80879. get isSync(): boolean;
  80880. /**
  80881. * Indicates if the WebGL underlying uniform buffer is dynamic.
  80882. * Also, a dynamic UniformBuffer will disable cache verification and always
  80883. * update the underlying WebGL uniform buffer to the GPU.
  80884. * @returns if Dynamic, otherwise false
  80885. */
  80886. isDynamic(): boolean;
  80887. /**
  80888. * The data cache on JS side.
  80889. * @returns the underlying data as a float array
  80890. */
  80891. getData(): Float32Array;
  80892. /**
  80893. * The underlying WebGL Uniform buffer.
  80894. * @returns the webgl buffer
  80895. */
  80896. getBuffer(): Nullable<DataBuffer>;
  80897. /**
  80898. * std140 layout specifies how to align data within an UBO structure.
  80899. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  80900. * for specs.
  80901. */
  80902. private _fillAlignment;
  80903. /**
  80904. * Adds an uniform in the buffer.
  80905. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  80906. * for the layout to be correct !
  80907. * @param name Name of the uniform, as used in the uniform block in the shader.
  80908. * @param size Data size, or data directly.
  80909. */
  80910. addUniform(name: string, size: number | number[]): void;
  80911. /**
  80912. * Adds a Matrix 4x4 to the uniform buffer.
  80913. * @param name Name of the uniform, as used in the uniform block in the shader.
  80914. * @param mat A 4x4 matrix.
  80915. */
  80916. addMatrix(name: string, mat: Matrix): void;
  80917. /**
  80918. * Adds a vec2 to the uniform buffer.
  80919. * @param name Name of the uniform, as used in the uniform block in the shader.
  80920. * @param x Define the x component value of the vec2
  80921. * @param y Define the y component value of the vec2
  80922. */
  80923. addFloat2(name: string, x: number, y: number): void;
  80924. /**
  80925. * Adds a vec3 to the uniform buffer.
  80926. * @param name Name of the uniform, as used in the uniform block in the shader.
  80927. * @param x Define the x component value of the vec3
  80928. * @param y Define the y component value of the vec3
  80929. * @param z Define the z component value of the vec3
  80930. */
  80931. addFloat3(name: string, x: number, y: number, z: number): void;
  80932. /**
  80933. * Adds a vec3 to the uniform buffer.
  80934. * @param name Name of the uniform, as used in the uniform block in the shader.
  80935. * @param color Define the vec3 from a Color
  80936. */
  80937. addColor3(name: string, color: Color3): void;
  80938. /**
  80939. * Adds a vec4 to the uniform buffer.
  80940. * @param name Name of the uniform, as used in the uniform block in the shader.
  80941. * @param color Define the rgb components from a Color
  80942. * @param alpha Define the a component of the vec4
  80943. */
  80944. addColor4(name: string, color: Color3, alpha: number): void;
  80945. /**
  80946. * Adds a vec3 to the uniform buffer.
  80947. * @param name Name of the uniform, as used in the uniform block in the shader.
  80948. * @param vector Define the vec3 components from a Vector
  80949. */
  80950. addVector3(name: string, vector: Vector3): void;
  80951. /**
  80952. * Adds a Matrix 3x3 to the uniform buffer.
  80953. * @param name Name of the uniform, as used in the uniform block in the shader.
  80954. */
  80955. addMatrix3x3(name: string): void;
  80956. /**
  80957. * Adds a Matrix 2x2 to the uniform buffer.
  80958. * @param name Name of the uniform, as used in the uniform block in the shader.
  80959. */
  80960. addMatrix2x2(name: string): void;
  80961. /**
  80962. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  80963. */
  80964. create(): void;
  80965. /** @hidden */
  80966. _rebuild(): void;
  80967. /**
  80968. * Updates the WebGL Uniform Buffer on the GPU.
  80969. * If the `dynamic` flag is set to true, no cache comparison is done.
  80970. * Otherwise, the buffer will be updated only if the cache differs.
  80971. */
  80972. update(): void;
  80973. /**
  80974. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  80975. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80976. * @param data Define the flattened data
  80977. * @param size Define the size of the data.
  80978. */
  80979. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  80980. private _valueCache;
  80981. private _cacheMatrix;
  80982. private _updateMatrix3x3ForUniform;
  80983. private _updateMatrix3x3ForEffect;
  80984. private _updateMatrix2x2ForEffect;
  80985. private _updateMatrix2x2ForUniform;
  80986. private _updateFloatForEffect;
  80987. private _updateFloatForUniform;
  80988. private _updateFloat2ForEffect;
  80989. private _updateFloat2ForUniform;
  80990. private _updateFloat3ForEffect;
  80991. private _updateFloat3ForUniform;
  80992. private _updateFloat4ForEffect;
  80993. private _updateFloat4ForUniform;
  80994. private _updateMatrixForEffect;
  80995. private _updateMatrixForUniform;
  80996. private _updateVector3ForEffect;
  80997. private _updateVector3ForUniform;
  80998. private _updateVector4ForEffect;
  80999. private _updateVector4ForUniform;
  81000. private _updateColor3ForEffect;
  81001. private _updateColor3ForUniform;
  81002. private _updateColor4ForEffect;
  81003. private _updateColor4ForUniform;
  81004. /**
  81005. * Sets a sampler uniform on the effect.
  81006. * @param name Define the name of the sampler.
  81007. * @param texture Define the texture to set in the sampler
  81008. */
  81009. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  81010. /**
  81011. * Directly updates the value of the uniform in the cache AND on the GPU.
  81012. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  81013. * @param data Define the flattened data
  81014. */
  81015. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  81016. /**
  81017. * Binds this uniform buffer to an effect.
  81018. * @param effect Define the effect to bind the buffer to
  81019. * @param name Name of the uniform block in the shader.
  81020. */
  81021. bindToEffect(effect: Effect, name: string): void;
  81022. /**
  81023. * Disposes the uniform buffer.
  81024. */
  81025. dispose(): void;
  81026. }
  81027. }
  81028. declare module BABYLON {
  81029. /**
  81030. * Enum that determines the text-wrapping mode to use.
  81031. */
  81032. export enum InspectableType {
  81033. /**
  81034. * Checkbox for booleans
  81035. */
  81036. Checkbox = 0,
  81037. /**
  81038. * Sliders for numbers
  81039. */
  81040. Slider = 1,
  81041. /**
  81042. * Vector3
  81043. */
  81044. Vector3 = 2,
  81045. /**
  81046. * Quaternions
  81047. */
  81048. Quaternion = 3,
  81049. /**
  81050. * Color3
  81051. */
  81052. Color3 = 4,
  81053. /**
  81054. * String
  81055. */
  81056. String = 5
  81057. }
  81058. /**
  81059. * Interface used to define custom inspectable properties.
  81060. * This interface is used by the inspector to display custom property grids
  81061. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81062. */
  81063. export interface IInspectable {
  81064. /**
  81065. * Gets the label to display
  81066. */
  81067. label: string;
  81068. /**
  81069. * Gets the name of the property to edit
  81070. */
  81071. propertyName: string;
  81072. /**
  81073. * Gets the type of the editor to use
  81074. */
  81075. type: InspectableType;
  81076. /**
  81077. * Gets the minimum value of the property when using in "slider" mode
  81078. */
  81079. min?: number;
  81080. /**
  81081. * Gets the maximum value of the property when using in "slider" mode
  81082. */
  81083. max?: number;
  81084. /**
  81085. * Gets the setp to use when using in "slider" mode
  81086. */
  81087. step?: number;
  81088. }
  81089. }
  81090. declare module BABYLON {
  81091. /**
  81092. * Class used to provide helper for timing
  81093. */
  81094. export class TimingTools {
  81095. /**
  81096. * Polyfill for setImmediate
  81097. * @param action defines the action to execute after the current execution block
  81098. */
  81099. static SetImmediate(action: () => void): void;
  81100. }
  81101. }
  81102. declare module BABYLON {
  81103. /**
  81104. * Class used to enable instatition of objects by class name
  81105. */
  81106. export class InstantiationTools {
  81107. /**
  81108. * Use this object to register external classes like custom textures or material
  81109. * to allow the laoders to instantiate them
  81110. */
  81111. static RegisteredExternalClasses: {
  81112. [key: string]: Object;
  81113. };
  81114. /**
  81115. * Tries to instantiate a new object from a given class name
  81116. * @param className defines the class name to instantiate
  81117. * @returns the new object or null if the system was not able to do the instantiation
  81118. */
  81119. static Instantiate(className: string): any;
  81120. }
  81121. }
  81122. declare module BABYLON {
  81123. /**
  81124. * Define options used to create a depth texture
  81125. */
  81126. export class DepthTextureCreationOptions {
  81127. /** Specifies whether or not a stencil should be allocated in the texture */
  81128. generateStencil?: boolean;
  81129. /** Specifies whether or not bilinear filtering is enable on the texture */
  81130. bilinearFiltering?: boolean;
  81131. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  81132. comparisonFunction?: number;
  81133. /** Specifies if the created texture is a cube texture */
  81134. isCube?: boolean;
  81135. }
  81136. }
  81137. declare module BABYLON {
  81138. interface ThinEngine {
  81139. /**
  81140. * Creates a depth stencil cube texture.
  81141. * This is only available in WebGL 2.
  81142. * @param size The size of face edge in the cube texture.
  81143. * @param options The options defining the cube texture.
  81144. * @returns The cube texture
  81145. */
  81146. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  81147. /**
  81148. * Creates a cube texture
  81149. * @param rootUrl defines the url where the files to load is located
  81150. * @param scene defines the current scene
  81151. * @param files defines the list of files to load (1 per face)
  81152. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  81153. * @param onLoad defines an optional callback raised when the texture is loaded
  81154. * @param onError defines an optional callback raised if there is an issue to load the texture
  81155. * @param format defines the format of the data
  81156. * @param forcedExtension defines the extension to use to pick the right loader
  81157. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  81158. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81159. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81160. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  81161. * @returns the cube texture as an InternalTexture
  81162. */
  81163. 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;
  81164. /**
  81165. * Creates a cube texture
  81166. * @param rootUrl defines the url where the files to load is located
  81167. * @param scene defines the current scene
  81168. * @param files defines the list of files to load (1 per face)
  81169. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  81170. * @param onLoad defines an optional callback raised when the texture is loaded
  81171. * @param onError defines an optional callback raised if there is an issue to load the texture
  81172. * @param format defines the format of the data
  81173. * @param forcedExtension defines the extension to use to pick the right loader
  81174. * @returns the cube texture as an InternalTexture
  81175. */
  81176. 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;
  81177. /**
  81178. * Creates a cube texture
  81179. * @param rootUrl defines the url where the files to load is located
  81180. * @param scene defines the current scene
  81181. * @param files defines the list of files to load (1 per face)
  81182. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  81183. * @param onLoad defines an optional callback raised when the texture is loaded
  81184. * @param onError defines an optional callback raised if there is an issue to load the texture
  81185. * @param format defines the format of the data
  81186. * @param forcedExtension defines the extension to use to pick the right loader
  81187. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  81188. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81189. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81190. * @returns the cube texture as an InternalTexture
  81191. */
  81192. 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;
  81193. /** @hidden */
  81194. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  81195. /** @hidden */
  81196. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  81197. /** @hidden */
  81198. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  81199. /** @hidden */
  81200. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  81201. /**
  81202. * @hidden
  81203. */
  81204. _setCubeMapTextureParams(loadMipmap: boolean): void;
  81205. }
  81206. }
  81207. declare module BABYLON {
  81208. /**
  81209. * Class for creating a cube texture
  81210. */
  81211. export class CubeTexture extends BaseTexture {
  81212. private _delayedOnLoad;
  81213. /**
  81214. * Observable triggered once the texture has been loaded.
  81215. */
  81216. onLoadObservable: Observable<CubeTexture>;
  81217. /**
  81218. * The url of the texture
  81219. */
  81220. url: string;
  81221. /**
  81222. * Gets or sets the center of the bounding box associated with the cube texture.
  81223. * It must define where the camera used to render the texture was set
  81224. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  81225. */
  81226. boundingBoxPosition: Vector3;
  81227. private _boundingBoxSize;
  81228. /**
  81229. * Gets or sets the size of the bounding box associated with the cube texture
  81230. * When defined, the cubemap will switch to local mode
  81231. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  81232. * @example https://www.babylonjs-playground.com/#RNASML
  81233. */
  81234. set boundingBoxSize(value: Vector3);
  81235. /**
  81236. * Returns the bounding box size
  81237. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  81238. */
  81239. get boundingBoxSize(): Vector3;
  81240. protected _rotationY: number;
  81241. /**
  81242. * Sets texture matrix rotation angle around Y axis in radians.
  81243. */
  81244. set rotationY(value: number);
  81245. /**
  81246. * Gets texture matrix rotation angle around Y axis radians.
  81247. */
  81248. get rotationY(): number;
  81249. /**
  81250. * Are mip maps generated for this texture or not.
  81251. */
  81252. get noMipmap(): boolean;
  81253. private _noMipmap;
  81254. private _files;
  81255. protected _forcedExtension: Nullable<string>;
  81256. private _extensions;
  81257. private _textureMatrix;
  81258. private _format;
  81259. private _createPolynomials;
  81260. /** @hidden */
  81261. _prefiltered: boolean;
  81262. /**
  81263. * Creates a cube texture from an array of image urls
  81264. * @param files defines an array of image urls
  81265. * @param scene defines the hosting scene
  81266. * @param noMipmap specifies if mip maps are not used
  81267. * @returns a cube texture
  81268. */
  81269. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  81270. /**
  81271. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  81272. * @param url defines the url of the prefiltered texture
  81273. * @param scene defines the scene the texture is attached to
  81274. * @param forcedExtension defines the extension of the file if different from the url
  81275. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  81276. * @return the prefiltered texture
  81277. */
  81278. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  81279. /**
  81280. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  81281. * as prefiltered data.
  81282. * @param rootUrl defines the url of the texture or the root name of the six images
  81283. * @param scene defines the scene the texture is attached to
  81284. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  81285. * @param noMipmap defines if mipmaps should be created or not
  81286. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  81287. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  81288. * @param onError defines a callback triggered in case of error during load
  81289. * @param format defines the internal format to use for the texture once loaded
  81290. * @param prefiltered defines whether or not the texture is created from prefiltered data
  81291. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  81292. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  81293. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81294. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81295. * @return the cube texture
  81296. */
  81297. 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);
  81298. /**
  81299. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  81300. */
  81301. get isPrefiltered(): boolean;
  81302. /**
  81303. * Get the current class name of the texture useful for serialization or dynamic coding.
  81304. * @returns "CubeTexture"
  81305. */
  81306. getClassName(): string;
  81307. /**
  81308. * Update the url (and optional buffer) of this texture if url was null during construction.
  81309. * @param url the url of the texture
  81310. * @param forcedExtension defines the extension to use
  81311. * @param onLoad callback called when the texture is loaded (defaults to null)
  81312. * @param prefiltered Defines whether the updated texture is prefiltered or not
  81313. */
  81314. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  81315. /**
  81316. * Delays loading of the cube texture
  81317. * @param forcedExtension defines the extension to use
  81318. */
  81319. delayLoad(forcedExtension?: string): void;
  81320. /**
  81321. * Returns the reflection texture matrix
  81322. * @returns the reflection texture matrix
  81323. */
  81324. getReflectionTextureMatrix(): Matrix;
  81325. /**
  81326. * Sets the reflection texture matrix
  81327. * @param value Reflection texture matrix
  81328. */
  81329. setReflectionTextureMatrix(value: Matrix): void;
  81330. /**
  81331. * Parses text to create a cube texture
  81332. * @param parsedTexture define the serialized text to read from
  81333. * @param scene defines the hosting scene
  81334. * @param rootUrl defines the root url of the cube texture
  81335. * @returns a cube texture
  81336. */
  81337. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  81338. /**
  81339. * Makes a clone, or deep copy, of the cube texture
  81340. * @returns a new cube texture
  81341. */
  81342. clone(): CubeTexture;
  81343. }
  81344. }
  81345. declare module BABYLON {
  81346. /**
  81347. * Manages the defines for the Material
  81348. */
  81349. export class MaterialDefines {
  81350. /** @hidden */
  81351. protected _keys: string[];
  81352. private _isDirty;
  81353. /** @hidden */
  81354. _renderId: number;
  81355. /** @hidden */
  81356. _areLightsDirty: boolean;
  81357. /** @hidden */
  81358. _areLightsDisposed: boolean;
  81359. /** @hidden */
  81360. _areAttributesDirty: boolean;
  81361. /** @hidden */
  81362. _areTexturesDirty: boolean;
  81363. /** @hidden */
  81364. _areFresnelDirty: boolean;
  81365. /** @hidden */
  81366. _areMiscDirty: boolean;
  81367. /** @hidden */
  81368. _areImageProcessingDirty: boolean;
  81369. /** @hidden */
  81370. _normals: boolean;
  81371. /** @hidden */
  81372. _uvs: boolean;
  81373. /** @hidden */
  81374. _needNormals: boolean;
  81375. /** @hidden */
  81376. _needUVs: boolean;
  81377. [id: string]: any;
  81378. /**
  81379. * Specifies if the material needs to be re-calculated
  81380. */
  81381. get isDirty(): boolean;
  81382. /**
  81383. * Marks the material to indicate that it has been re-calculated
  81384. */
  81385. markAsProcessed(): void;
  81386. /**
  81387. * Marks the material to indicate that it needs to be re-calculated
  81388. */
  81389. markAsUnprocessed(): void;
  81390. /**
  81391. * Marks the material to indicate all of its defines need to be re-calculated
  81392. */
  81393. markAllAsDirty(): void;
  81394. /**
  81395. * Marks the material to indicate that image processing needs to be re-calculated
  81396. */
  81397. markAsImageProcessingDirty(): void;
  81398. /**
  81399. * Marks the material to indicate the lights need to be re-calculated
  81400. * @param disposed Defines whether the light is dirty due to dispose or not
  81401. */
  81402. markAsLightDirty(disposed?: boolean): void;
  81403. /**
  81404. * Marks the attribute state as changed
  81405. */
  81406. markAsAttributesDirty(): void;
  81407. /**
  81408. * Marks the texture state as changed
  81409. */
  81410. markAsTexturesDirty(): void;
  81411. /**
  81412. * Marks the fresnel state as changed
  81413. */
  81414. markAsFresnelDirty(): void;
  81415. /**
  81416. * Marks the misc state as changed
  81417. */
  81418. markAsMiscDirty(): void;
  81419. /**
  81420. * Rebuilds the material defines
  81421. */
  81422. rebuild(): void;
  81423. /**
  81424. * Specifies if two material defines are equal
  81425. * @param other - A material define instance to compare to
  81426. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  81427. */
  81428. isEqual(other: MaterialDefines): boolean;
  81429. /**
  81430. * Clones this instance's defines to another instance
  81431. * @param other - material defines to clone values to
  81432. */
  81433. cloneTo(other: MaterialDefines): void;
  81434. /**
  81435. * Resets the material define values
  81436. */
  81437. reset(): void;
  81438. /**
  81439. * Converts the material define values to a string
  81440. * @returns - String of material define information
  81441. */
  81442. toString(): string;
  81443. }
  81444. }
  81445. declare module BABYLON {
  81446. /**
  81447. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  81448. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  81449. * 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;
  81450. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  81451. */
  81452. export class ColorCurves {
  81453. private _dirty;
  81454. private _tempColor;
  81455. private _globalCurve;
  81456. private _highlightsCurve;
  81457. private _midtonesCurve;
  81458. private _shadowsCurve;
  81459. private _positiveCurve;
  81460. private _negativeCurve;
  81461. private _globalHue;
  81462. private _globalDensity;
  81463. private _globalSaturation;
  81464. private _globalExposure;
  81465. /**
  81466. * Gets the global Hue value.
  81467. * 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).
  81468. */
  81469. get globalHue(): number;
  81470. /**
  81471. * Sets the global Hue value.
  81472. * 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).
  81473. */
  81474. set globalHue(value: number);
  81475. /**
  81476. * Gets the global Density value.
  81477. * 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.
  81478. * Values less than zero provide a filter of opposite hue.
  81479. */
  81480. get globalDensity(): number;
  81481. /**
  81482. * Sets the global Density value.
  81483. * 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.
  81484. * Values less than zero provide a filter of opposite hue.
  81485. */
  81486. set globalDensity(value: number);
  81487. /**
  81488. * Gets the global Saturation value.
  81489. * 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.
  81490. */
  81491. get globalSaturation(): number;
  81492. /**
  81493. * Sets the global Saturation value.
  81494. * 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.
  81495. */
  81496. set globalSaturation(value: number);
  81497. /**
  81498. * Gets the global Exposure value.
  81499. * 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.
  81500. */
  81501. get globalExposure(): number;
  81502. /**
  81503. * Sets the global Exposure value.
  81504. * 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.
  81505. */
  81506. set globalExposure(value: number);
  81507. private _highlightsHue;
  81508. private _highlightsDensity;
  81509. private _highlightsSaturation;
  81510. private _highlightsExposure;
  81511. /**
  81512. * Gets the highlights Hue value.
  81513. * 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).
  81514. */
  81515. get highlightsHue(): number;
  81516. /**
  81517. * Sets the highlights Hue value.
  81518. * 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).
  81519. */
  81520. set highlightsHue(value: number);
  81521. /**
  81522. * Gets the highlights Density value.
  81523. * 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.
  81524. * Values less than zero provide a filter of opposite hue.
  81525. */
  81526. get highlightsDensity(): number;
  81527. /**
  81528. * Sets the highlights Density value.
  81529. * 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.
  81530. * Values less than zero provide a filter of opposite hue.
  81531. */
  81532. set highlightsDensity(value: number);
  81533. /**
  81534. * Gets the highlights Saturation value.
  81535. * 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.
  81536. */
  81537. get highlightsSaturation(): number;
  81538. /**
  81539. * Sets the highlights Saturation value.
  81540. * 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.
  81541. */
  81542. set highlightsSaturation(value: number);
  81543. /**
  81544. * Gets the highlights Exposure value.
  81545. * 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.
  81546. */
  81547. get highlightsExposure(): number;
  81548. /**
  81549. * Sets the highlights Exposure value.
  81550. * 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.
  81551. */
  81552. set highlightsExposure(value: number);
  81553. private _midtonesHue;
  81554. private _midtonesDensity;
  81555. private _midtonesSaturation;
  81556. private _midtonesExposure;
  81557. /**
  81558. * Gets the midtones Hue value.
  81559. * 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).
  81560. */
  81561. get midtonesHue(): number;
  81562. /**
  81563. * Sets the midtones Hue value.
  81564. * 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).
  81565. */
  81566. set midtonesHue(value: number);
  81567. /**
  81568. * Gets the midtones Density value.
  81569. * 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.
  81570. * Values less than zero provide a filter of opposite hue.
  81571. */
  81572. get midtonesDensity(): number;
  81573. /**
  81574. * Sets the midtones Density value.
  81575. * 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.
  81576. * Values less than zero provide a filter of opposite hue.
  81577. */
  81578. set midtonesDensity(value: number);
  81579. /**
  81580. * Gets the midtones Saturation value.
  81581. * 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.
  81582. */
  81583. get midtonesSaturation(): number;
  81584. /**
  81585. * Sets the midtones Saturation value.
  81586. * 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.
  81587. */
  81588. set midtonesSaturation(value: number);
  81589. /**
  81590. * Gets the midtones Exposure value.
  81591. * 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.
  81592. */
  81593. get midtonesExposure(): number;
  81594. /**
  81595. * Sets the midtones Exposure value.
  81596. * 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.
  81597. */
  81598. set midtonesExposure(value: number);
  81599. private _shadowsHue;
  81600. private _shadowsDensity;
  81601. private _shadowsSaturation;
  81602. private _shadowsExposure;
  81603. /**
  81604. * Gets the shadows Hue value.
  81605. * 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).
  81606. */
  81607. get shadowsHue(): number;
  81608. /**
  81609. * Sets the shadows Hue value.
  81610. * 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).
  81611. */
  81612. set shadowsHue(value: number);
  81613. /**
  81614. * Gets the shadows Density value.
  81615. * 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.
  81616. * Values less than zero provide a filter of opposite hue.
  81617. */
  81618. get shadowsDensity(): number;
  81619. /**
  81620. * Sets the shadows Density value.
  81621. * 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.
  81622. * Values less than zero provide a filter of opposite hue.
  81623. */
  81624. set shadowsDensity(value: number);
  81625. /**
  81626. * Gets the shadows Saturation value.
  81627. * 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.
  81628. */
  81629. get shadowsSaturation(): number;
  81630. /**
  81631. * Sets the shadows Saturation value.
  81632. * 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.
  81633. */
  81634. set shadowsSaturation(value: number);
  81635. /**
  81636. * Gets the shadows Exposure value.
  81637. * 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.
  81638. */
  81639. get shadowsExposure(): number;
  81640. /**
  81641. * Sets the shadows Exposure value.
  81642. * 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.
  81643. */
  81644. set shadowsExposure(value: number);
  81645. /**
  81646. * Returns the class name
  81647. * @returns The class name
  81648. */
  81649. getClassName(): string;
  81650. /**
  81651. * Binds the color curves to the shader.
  81652. * @param colorCurves The color curve to bind
  81653. * @param effect The effect to bind to
  81654. * @param positiveUniform The positive uniform shader parameter
  81655. * @param neutralUniform The neutral uniform shader parameter
  81656. * @param negativeUniform The negative uniform shader parameter
  81657. */
  81658. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  81659. /**
  81660. * Prepare the list of uniforms associated with the ColorCurves effects.
  81661. * @param uniformsList The list of uniforms used in the effect
  81662. */
  81663. static PrepareUniforms(uniformsList: string[]): void;
  81664. /**
  81665. * Returns color grading data based on a hue, density, saturation and exposure value.
  81666. * @param filterHue The hue of the color filter.
  81667. * @param filterDensity The density of the color filter.
  81668. * @param saturation The saturation.
  81669. * @param exposure The exposure.
  81670. * @param result The result data container.
  81671. */
  81672. private getColorGradingDataToRef;
  81673. /**
  81674. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  81675. * @param value The input slider value in range [-100,100].
  81676. * @returns Adjusted value.
  81677. */
  81678. private static applyColorGradingSliderNonlinear;
  81679. /**
  81680. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  81681. * @param hue The hue (H) input.
  81682. * @param saturation The saturation (S) input.
  81683. * @param brightness The brightness (B) input.
  81684. * @result An RGBA color represented as Vector4.
  81685. */
  81686. private static fromHSBToRef;
  81687. /**
  81688. * Returns a value clamped between min and max
  81689. * @param value The value to clamp
  81690. * @param min The minimum of value
  81691. * @param max The maximum of value
  81692. * @returns The clamped value.
  81693. */
  81694. private static clamp;
  81695. /**
  81696. * Clones the current color curve instance.
  81697. * @return The cloned curves
  81698. */
  81699. clone(): ColorCurves;
  81700. /**
  81701. * Serializes the current color curve instance to a json representation.
  81702. * @return a JSON representation
  81703. */
  81704. serialize(): any;
  81705. /**
  81706. * Parses the color curve from a json representation.
  81707. * @param source the JSON source to parse
  81708. * @return The parsed curves
  81709. */
  81710. static Parse(source: any): ColorCurves;
  81711. }
  81712. }
  81713. declare module BABYLON {
  81714. /**
  81715. * Interface to follow in your material defines to integrate easily the
  81716. * Image proccessing functions.
  81717. * @hidden
  81718. */
  81719. export interface IImageProcessingConfigurationDefines {
  81720. IMAGEPROCESSING: boolean;
  81721. VIGNETTE: boolean;
  81722. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81723. VIGNETTEBLENDMODEOPAQUE: boolean;
  81724. TONEMAPPING: boolean;
  81725. TONEMAPPING_ACES: boolean;
  81726. CONTRAST: boolean;
  81727. EXPOSURE: boolean;
  81728. COLORCURVES: boolean;
  81729. COLORGRADING: boolean;
  81730. COLORGRADING3D: boolean;
  81731. SAMPLER3DGREENDEPTH: boolean;
  81732. SAMPLER3DBGRMAP: boolean;
  81733. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81734. }
  81735. /**
  81736. * @hidden
  81737. */
  81738. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  81739. IMAGEPROCESSING: boolean;
  81740. VIGNETTE: boolean;
  81741. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81742. VIGNETTEBLENDMODEOPAQUE: boolean;
  81743. TONEMAPPING: boolean;
  81744. TONEMAPPING_ACES: boolean;
  81745. CONTRAST: boolean;
  81746. COLORCURVES: boolean;
  81747. COLORGRADING: boolean;
  81748. COLORGRADING3D: boolean;
  81749. SAMPLER3DGREENDEPTH: boolean;
  81750. SAMPLER3DBGRMAP: boolean;
  81751. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81752. EXPOSURE: boolean;
  81753. constructor();
  81754. }
  81755. /**
  81756. * This groups together the common properties used for image processing either in direct forward pass
  81757. * or through post processing effect depending on the use of the image processing pipeline in your scene
  81758. * or not.
  81759. */
  81760. export class ImageProcessingConfiguration {
  81761. /**
  81762. * Default tone mapping applied in BabylonJS.
  81763. */
  81764. static readonly TONEMAPPING_STANDARD: number;
  81765. /**
  81766. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  81767. * to other engines rendering to increase portability.
  81768. */
  81769. static readonly TONEMAPPING_ACES: number;
  81770. /**
  81771. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  81772. */
  81773. colorCurves: Nullable<ColorCurves>;
  81774. private _colorCurvesEnabled;
  81775. /**
  81776. * Gets wether the color curves effect is enabled.
  81777. */
  81778. get colorCurvesEnabled(): boolean;
  81779. /**
  81780. * Sets wether the color curves effect is enabled.
  81781. */
  81782. set colorCurvesEnabled(value: boolean);
  81783. private _colorGradingTexture;
  81784. /**
  81785. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81786. */
  81787. get colorGradingTexture(): Nullable<BaseTexture>;
  81788. /**
  81789. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81790. */
  81791. set colorGradingTexture(value: Nullable<BaseTexture>);
  81792. private _colorGradingEnabled;
  81793. /**
  81794. * Gets wether the color grading effect is enabled.
  81795. */
  81796. get colorGradingEnabled(): boolean;
  81797. /**
  81798. * Sets wether the color grading effect is enabled.
  81799. */
  81800. set colorGradingEnabled(value: boolean);
  81801. private _colorGradingWithGreenDepth;
  81802. /**
  81803. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  81804. */
  81805. get colorGradingWithGreenDepth(): boolean;
  81806. /**
  81807. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  81808. */
  81809. set colorGradingWithGreenDepth(value: boolean);
  81810. private _colorGradingBGR;
  81811. /**
  81812. * Gets wether the color grading texture contains BGR values.
  81813. */
  81814. get colorGradingBGR(): boolean;
  81815. /**
  81816. * Sets wether the color grading texture contains BGR values.
  81817. */
  81818. set colorGradingBGR(value: boolean);
  81819. /** @hidden */
  81820. _exposure: number;
  81821. /**
  81822. * Gets the Exposure used in the effect.
  81823. */
  81824. get exposure(): number;
  81825. /**
  81826. * Sets the Exposure used in the effect.
  81827. */
  81828. set exposure(value: number);
  81829. private _toneMappingEnabled;
  81830. /**
  81831. * Gets wether the tone mapping effect is enabled.
  81832. */
  81833. get toneMappingEnabled(): boolean;
  81834. /**
  81835. * Sets wether the tone mapping effect is enabled.
  81836. */
  81837. set toneMappingEnabled(value: boolean);
  81838. private _toneMappingType;
  81839. /**
  81840. * Gets the type of tone mapping effect.
  81841. */
  81842. get toneMappingType(): number;
  81843. /**
  81844. * Sets the type of tone mapping effect used in BabylonJS.
  81845. */
  81846. set toneMappingType(value: number);
  81847. protected _contrast: number;
  81848. /**
  81849. * Gets the contrast used in the effect.
  81850. */
  81851. get contrast(): number;
  81852. /**
  81853. * Sets the contrast used in the effect.
  81854. */
  81855. set contrast(value: number);
  81856. /**
  81857. * Vignette stretch size.
  81858. */
  81859. vignetteStretch: number;
  81860. /**
  81861. * Vignette centre X Offset.
  81862. */
  81863. vignetteCentreX: number;
  81864. /**
  81865. * Vignette centre Y Offset.
  81866. */
  81867. vignetteCentreY: number;
  81868. /**
  81869. * Vignette weight or intensity of the vignette effect.
  81870. */
  81871. vignetteWeight: number;
  81872. /**
  81873. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  81874. * if vignetteEnabled is set to true.
  81875. */
  81876. vignetteColor: Color4;
  81877. /**
  81878. * Camera field of view used by the Vignette effect.
  81879. */
  81880. vignetteCameraFov: number;
  81881. private _vignetteBlendMode;
  81882. /**
  81883. * Gets the vignette blend mode allowing different kind of effect.
  81884. */
  81885. get vignetteBlendMode(): number;
  81886. /**
  81887. * Sets the vignette blend mode allowing different kind of effect.
  81888. */
  81889. set vignetteBlendMode(value: number);
  81890. private _vignetteEnabled;
  81891. /**
  81892. * Gets wether the vignette effect is enabled.
  81893. */
  81894. get vignetteEnabled(): boolean;
  81895. /**
  81896. * Sets wether the vignette effect is enabled.
  81897. */
  81898. set vignetteEnabled(value: boolean);
  81899. private _applyByPostProcess;
  81900. /**
  81901. * Gets wether the image processing is applied through a post process or not.
  81902. */
  81903. get applyByPostProcess(): boolean;
  81904. /**
  81905. * Sets wether the image processing is applied through a post process or not.
  81906. */
  81907. set applyByPostProcess(value: boolean);
  81908. private _isEnabled;
  81909. /**
  81910. * Gets wether the image processing is enabled or not.
  81911. */
  81912. get isEnabled(): boolean;
  81913. /**
  81914. * Sets wether the image processing is enabled or not.
  81915. */
  81916. set isEnabled(value: boolean);
  81917. /**
  81918. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  81919. */
  81920. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  81921. /**
  81922. * Method called each time the image processing information changes requires to recompile the effect.
  81923. */
  81924. protected _updateParameters(): void;
  81925. /**
  81926. * Gets the current class name.
  81927. * @return "ImageProcessingConfiguration"
  81928. */
  81929. getClassName(): string;
  81930. /**
  81931. * Prepare the list of uniforms associated with the Image Processing effects.
  81932. * @param uniforms The list of uniforms used in the effect
  81933. * @param defines the list of defines currently in use
  81934. */
  81935. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  81936. /**
  81937. * Prepare the list of samplers associated with the Image Processing effects.
  81938. * @param samplersList The list of uniforms used in the effect
  81939. * @param defines the list of defines currently in use
  81940. */
  81941. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  81942. /**
  81943. * Prepare the list of defines associated to the shader.
  81944. * @param defines the list of defines to complete
  81945. * @param forPostProcess Define if we are currently in post process mode or not
  81946. */
  81947. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  81948. /**
  81949. * Returns true if all the image processing information are ready.
  81950. * @returns True if ready, otherwise, false
  81951. */
  81952. isReady(): boolean;
  81953. /**
  81954. * Binds the image processing to the shader.
  81955. * @param effect The effect to bind to
  81956. * @param overrideAspectRatio Override the aspect ratio of the effect
  81957. */
  81958. bind(effect: Effect, overrideAspectRatio?: number): void;
  81959. /**
  81960. * Clones the current image processing instance.
  81961. * @return The cloned image processing
  81962. */
  81963. clone(): ImageProcessingConfiguration;
  81964. /**
  81965. * Serializes the current image processing instance to a json representation.
  81966. * @return a JSON representation
  81967. */
  81968. serialize(): any;
  81969. /**
  81970. * Parses the image processing from a json representation.
  81971. * @param source the JSON source to parse
  81972. * @return The parsed image processing
  81973. */
  81974. static Parse(source: any): ImageProcessingConfiguration;
  81975. private static _VIGNETTEMODE_MULTIPLY;
  81976. private static _VIGNETTEMODE_OPAQUE;
  81977. /**
  81978. * Used to apply the vignette as a mix with the pixel color.
  81979. */
  81980. static get VIGNETTEMODE_MULTIPLY(): number;
  81981. /**
  81982. * Used to apply the vignette as a replacement of the pixel color.
  81983. */
  81984. static get VIGNETTEMODE_OPAQUE(): number;
  81985. }
  81986. }
  81987. declare module BABYLON {
  81988. /** @hidden */
  81989. export var postprocessVertexShader: {
  81990. name: string;
  81991. shader: string;
  81992. };
  81993. }
  81994. declare module BABYLON {
  81995. interface ThinEngine {
  81996. /**
  81997. * Creates a new render target texture
  81998. * @param size defines the size of the texture
  81999. * @param options defines the options used to create the texture
  82000. * @returns a new render target texture stored in an InternalTexture
  82001. */
  82002. createRenderTargetTexture(size: number | {
  82003. width: number;
  82004. height: number;
  82005. layers?: number;
  82006. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  82007. /**
  82008. * Creates a depth stencil texture.
  82009. * This is only available in WebGL 2 or with the depth texture extension available.
  82010. * @param size The size of face edge in the texture.
  82011. * @param options The options defining the texture.
  82012. * @returns The texture
  82013. */
  82014. createDepthStencilTexture(size: number | {
  82015. width: number;
  82016. height: number;
  82017. layers?: number;
  82018. }, options: DepthTextureCreationOptions): InternalTexture;
  82019. /** @hidden */
  82020. _createDepthStencilTexture(size: number | {
  82021. width: number;
  82022. height: number;
  82023. layers?: number;
  82024. }, options: DepthTextureCreationOptions): InternalTexture;
  82025. }
  82026. }
  82027. declare module BABYLON {
  82028. /** Defines supported spaces */
  82029. export enum Space {
  82030. /** Local (object) space */
  82031. LOCAL = 0,
  82032. /** World space */
  82033. WORLD = 1,
  82034. /** Bone space */
  82035. BONE = 2
  82036. }
  82037. /** Defines the 3 main axes */
  82038. export class Axis {
  82039. /** X axis */
  82040. static X: Vector3;
  82041. /** Y axis */
  82042. static Y: Vector3;
  82043. /** Z axis */
  82044. static Z: Vector3;
  82045. }
  82046. }
  82047. declare module BABYLON {
  82048. /**
  82049. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  82050. * This is the base of the follow, arc rotate cameras and Free camera
  82051. * @see http://doc.babylonjs.com/features/cameras
  82052. */
  82053. export class TargetCamera extends Camera {
  82054. private static _RigCamTransformMatrix;
  82055. private static _TargetTransformMatrix;
  82056. private static _TargetFocalPoint;
  82057. /**
  82058. * Define the current direction the camera is moving to
  82059. */
  82060. cameraDirection: Vector3;
  82061. /**
  82062. * Define the current rotation the camera is rotating to
  82063. */
  82064. cameraRotation: Vector2;
  82065. /**
  82066. * When set, the up vector of the camera will be updated by the rotation of the camera
  82067. */
  82068. updateUpVectorFromRotation: boolean;
  82069. private _tmpQuaternion;
  82070. /**
  82071. * Define the current rotation of the camera
  82072. */
  82073. rotation: Vector3;
  82074. /**
  82075. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  82076. */
  82077. rotationQuaternion: Quaternion;
  82078. /**
  82079. * Define the current speed of the camera
  82080. */
  82081. speed: number;
  82082. /**
  82083. * Add constraint to the camera to prevent it to move freely in all directions and
  82084. * around all axis.
  82085. */
  82086. noRotationConstraint: boolean;
  82087. /**
  82088. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  82089. * panning
  82090. */
  82091. invertRotation: boolean;
  82092. /**
  82093. * Speed multiplier for inverse camera panning
  82094. */
  82095. inverseRotationSpeed: number;
  82096. /**
  82097. * Define the current target of the camera as an object or a position.
  82098. */
  82099. lockedTarget: any;
  82100. /** @hidden */
  82101. _currentTarget: Vector3;
  82102. /** @hidden */
  82103. _initialFocalDistance: number;
  82104. /** @hidden */
  82105. _viewMatrix: Matrix;
  82106. /** @hidden */
  82107. _camMatrix: Matrix;
  82108. /** @hidden */
  82109. _cameraTransformMatrix: Matrix;
  82110. /** @hidden */
  82111. _cameraRotationMatrix: Matrix;
  82112. /** @hidden */
  82113. _referencePoint: Vector3;
  82114. /** @hidden */
  82115. _transformedReferencePoint: Vector3;
  82116. protected _globalCurrentTarget: Vector3;
  82117. protected _globalCurrentUpVector: Vector3;
  82118. /** @hidden */
  82119. _reset: () => void;
  82120. private _defaultUp;
  82121. /**
  82122. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  82123. * This is the base of the follow, arc rotate cameras and Free camera
  82124. * @see http://doc.babylonjs.com/features/cameras
  82125. * @param name Defines the name of the camera in the scene
  82126. * @param position Defines the start position of the camera in the scene
  82127. * @param scene Defines the scene the camera belongs to
  82128. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  82129. */
  82130. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  82131. /**
  82132. * Gets the position in front of the camera at a given distance.
  82133. * @param distance The distance from the camera we want the position to be
  82134. * @returns the position
  82135. */
  82136. getFrontPosition(distance: number): Vector3;
  82137. /** @hidden */
  82138. _getLockedTargetPosition(): Nullable<Vector3>;
  82139. private _storedPosition;
  82140. private _storedRotation;
  82141. private _storedRotationQuaternion;
  82142. /**
  82143. * Store current camera state of the camera (fov, position, rotation, etc..)
  82144. * @returns the camera
  82145. */
  82146. storeState(): Camera;
  82147. /**
  82148. * Restored camera state. You must call storeState() first
  82149. * @returns whether it was successful or not
  82150. * @hidden
  82151. */
  82152. _restoreStateValues(): boolean;
  82153. /** @hidden */
  82154. _initCache(): void;
  82155. /** @hidden */
  82156. _updateCache(ignoreParentClass?: boolean): void;
  82157. /** @hidden */
  82158. _isSynchronizedViewMatrix(): boolean;
  82159. /** @hidden */
  82160. _computeLocalCameraSpeed(): number;
  82161. /**
  82162. * Defines the target the camera should look at.
  82163. * @param target Defines the new target as a Vector or a mesh
  82164. */
  82165. setTarget(target: Vector3): void;
  82166. /**
  82167. * Return the current target position of the camera. This value is expressed in local space.
  82168. * @returns the target position
  82169. */
  82170. getTarget(): Vector3;
  82171. /** @hidden */
  82172. _decideIfNeedsToMove(): boolean;
  82173. /** @hidden */
  82174. _updatePosition(): void;
  82175. /** @hidden */
  82176. _checkInputs(): void;
  82177. protected _updateCameraRotationMatrix(): void;
  82178. /**
  82179. * 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)
  82180. * @returns the current camera
  82181. */
  82182. private _rotateUpVectorWithCameraRotationMatrix;
  82183. private _cachedRotationZ;
  82184. private _cachedQuaternionRotationZ;
  82185. /** @hidden */
  82186. _getViewMatrix(): Matrix;
  82187. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  82188. /**
  82189. * @hidden
  82190. */
  82191. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  82192. /**
  82193. * @hidden
  82194. */
  82195. _updateRigCameras(): void;
  82196. private _getRigCamPositionAndTarget;
  82197. /**
  82198. * Gets the current object class name.
  82199. * @return the class name
  82200. */
  82201. getClassName(): string;
  82202. }
  82203. }
  82204. declare module BABYLON {
  82205. /**
  82206. * Gather the list of keyboard event types as constants.
  82207. */
  82208. export class KeyboardEventTypes {
  82209. /**
  82210. * The keydown event is fired when a key becomes active (pressed).
  82211. */
  82212. static readonly KEYDOWN: number;
  82213. /**
  82214. * The keyup event is fired when a key has been released.
  82215. */
  82216. static readonly KEYUP: number;
  82217. }
  82218. /**
  82219. * This class is used to store keyboard related info for the onKeyboardObservable event.
  82220. */
  82221. export class KeyboardInfo {
  82222. /**
  82223. * Defines the type of event (KeyboardEventTypes)
  82224. */
  82225. type: number;
  82226. /**
  82227. * Defines the related dom event
  82228. */
  82229. event: KeyboardEvent;
  82230. /**
  82231. * Instantiates a new keyboard info.
  82232. * This class is used to store keyboard related info for the onKeyboardObservable event.
  82233. * @param type Defines the type of event (KeyboardEventTypes)
  82234. * @param event Defines the related dom event
  82235. */
  82236. constructor(
  82237. /**
  82238. * Defines the type of event (KeyboardEventTypes)
  82239. */
  82240. type: number,
  82241. /**
  82242. * Defines the related dom event
  82243. */
  82244. event: KeyboardEvent);
  82245. }
  82246. /**
  82247. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  82248. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  82249. */
  82250. export class KeyboardInfoPre extends KeyboardInfo {
  82251. /**
  82252. * Defines the type of event (KeyboardEventTypes)
  82253. */
  82254. type: number;
  82255. /**
  82256. * Defines the related dom event
  82257. */
  82258. event: KeyboardEvent;
  82259. /**
  82260. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  82261. */
  82262. skipOnPointerObservable: boolean;
  82263. /**
  82264. * Instantiates a new keyboard pre info.
  82265. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  82266. * @param type Defines the type of event (KeyboardEventTypes)
  82267. * @param event Defines the related dom event
  82268. */
  82269. constructor(
  82270. /**
  82271. * Defines the type of event (KeyboardEventTypes)
  82272. */
  82273. type: number,
  82274. /**
  82275. * Defines the related dom event
  82276. */
  82277. event: KeyboardEvent);
  82278. }
  82279. }
  82280. declare module BABYLON {
  82281. /**
  82282. * Manage the keyboard inputs to control the movement of a free camera.
  82283. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82284. */
  82285. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  82286. /**
  82287. * Defines the camera the input is attached to.
  82288. */
  82289. camera: FreeCamera;
  82290. /**
  82291. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  82292. */
  82293. keysUp: number[];
  82294. /**
  82295. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  82296. */
  82297. keysUpward: number[];
  82298. /**
  82299. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  82300. */
  82301. keysDown: number[];
  82302. /**
  82303. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  82304. */
  82305. keysDownward: number[];
  82306. /**
  82307. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  82308. */
  82309. keysLeft: number[];
  82310. /**
  82311. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  82312. */
  82313. keysRight: number[];
  82314. private _keys;
  82315. private _onCanvasBlurObserver;
  82316. private _onKeyboardObserver;
  82317. private _engine;
  82318. private _scene;
  82319. /**
  82320. * Attach the input controls to a specific dom element to get the input from.
  82321. * @param element Defines the element the controls should be listened from
  82322. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82323. */
  82324. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82325. /**
  82326. * Detach the current controls from the specified dom element.
  82327. * @param element Defines the element to stop listening the inputs from
  82328. */
  82329. detachControl(element: Nullable<HTMLElement>): void;
  82330. /**
  82331. * Update the current camera state depending on the inputs that have been used this frame.
  82332. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  82333. */
  82334. checkInputs(): void;
  82335. /**
  82336. * Gets the class name of the current intput.
  82337. * @returns the class name
  82338. */
  82339. getClassName(): string;
  82340. /** @hidden */
  82341. _onLostFocus(): void;
  82342. /**
  82343. * Get the friendly name associated with the input class.
  82344. * @returns the input friendly name
  82345. */
  82346. getSimpleName(): string;
  82347. }
  82348. }
  82349. declare module BABYLON {
  82350. /**
  82351. * Interface describing all the common properties and methods a shadow light needs to implement.
  82352. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  82353. * as well as binding the different shadow properties to the effects.
  82354. */
  82355. export interface IShadowLight extends Light {
  82356. /**
  82357. * The light id in the scene (used in scene.findLighById for instance)
  82358. */
  82359. id: string;
  82360. /**
  82361. * The position the shdow will be casted from.
  82362. */
  82363. position: Vector3;
  82364. /**
  82365. * In 2d mode (needCube being false), the direction used to cast the shadow.
  82366. */
  82367. direction: Vector3;
  82368. /**
  82369. * The transformed position. Position of the light in world space taking parenting in account.
  82370. */
  82371. transformedPosition: Vector3;
  82372. /**
  82373. * The transformed direction. Direction of the light in world space taking parenting in account.
  82374. */
  82375. transformedDirection: Vector3;
  82376. /**
  82377. * The friendly name of the light in the scene.
  82378. */
  82379. name: string;
  82380. /**
  82381. * Defines the shadow projection clipping minimum z value.
  82382. */
  82383. shadowMinZ: number;
  82384. /**
  82385. * Defines the shadow projection clipping maximum z value.
  82386. */
  82387. shadowMaxZ: number;
  82388. /**
  82389. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  82390. * @returns true if the information has been computed, false if it does not need to (no parenting)
  82391. */
  82392. computeTransformedInformation(): boolean;
  82393. /**
  82394. * Gets the scene the light belongs to.
  82395. * @returns The scene
  82396. */
  82397. getScene(): Scene;
  82398. /**
  82399. * Callback defining a custom Projection Matrix Builder.
  82400. * This can be used to override the default projection matrix computation.
  82401. */
  82402. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  82403. /**
  82404. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  82405. * @param matrix The materix to updated with the projection information
  82406. * @param viewMatrix The transform matrix of the light
  82407. * @param renderList The list of mesh to render in the map
  82408. * @returns The current light
  82409. */
  82410. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  82411. /**
  82412. * Gets the current depth scale used in ESM.
  82413. * @returns The scale
  82414. */
  82415. getDepthScale(): number;
  82416. /**
  82417. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  82418. * @returns true if a cube texture needs to be use
  82419. */
  82420. needCube(): boolean;
  82421. /**
  82422. * Detects if the projection matrix requires to be recomputed this frame.
  82423. * @returns true if it requires to be recomputed otherwise, false.
  82424. */
  82425. needProjectionMatrixCompute(): boolean;
  82426. /**
  82427. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  82428. */
  82429. forceProjectionMatrixCompute(): void;
  82430. /**
  82431. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  82432. * @param faceIndex The index of the face we are computed the direction to generate shadow
  82433. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  82434. */
  82435. getShadowDirection(faceIndex?: number): Vector3;
  82436. /**
  82437. * Gets the minZ used for shadow according to both the scene and the light.
  82438. * @param activeCamera The camera we are returning the min for
  82439. * @returns the depth min z
  82440. */
  82441. getDepthMinZ(activeCamera: Camera): number;
  82442. /**
  82443. * Gets the maxZ used for shadow according to both the scene and the light.
  82444. * @param activeCamera The camera we are returning the max for
  82445. * @returns the depth max z
  82446. */
  82447. getDepthMaxZ(activeCamera: Camera): number;
  82448. }
  82449. /**
  82450. * Base implementation IShadowLight
  82451. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  82452. */
  82453. export abstract class ShadowLight extends Light implements IShadowLight {
  82454. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  82455. protected _position: Vector3;
  82456. protected _setPosition(value: Vector3): void;
  82457. /**
  82458. * Sets the position the shadow will be casted from. Also use as the light position for both
  82459. * point and spot lights.
  82460. */
  82461. get position(): Vector3;
  82462. /**
  82463. * Sets the position the shadow will be casted from. Also use as the light position for both
  82464. * point and spot lights.
  82465. */
  82466. set position(value: Vector3);
  82467. protected _direction: Vector3;
  82468. protected _setDirection(value: Vector3): void;
  82469. /**
  82470. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  82471. * Also use as the light direction on spot and directional lights.
  82472. */
  82473. get direction(): Vector3;
  82474. /**
  82475. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  82476. * Also use as the light direction on spot and directional lights.
  82477. */
  82478. set direction(value: Vector3);
  82479. protected _shadowMinZ: number;
  82480. /**
  82481. * Gets the shadow projection clipping minimum z value.
  82482. */
  82483. get shadowMinZ(): number;
  82484. /**
  82485. * Sets the shadow projection clipping minimum z value.
  82486. */
  82487. set shadowMinZ(value: number);
  82488. protected _shadowMaxZ: number;
  82489. /**
  82490. * Sets the shadow projection clipping maximum z value.
  82491. */
  82492. get shadowMaxZ(): number;
  82493. /**
  82494. * Gets the shadow projection clipping maximum z value.
  82495. */
  82496. set shadowMaxZ(value: number);
  82497. /**
  82498. * Callback defining a custom Projection Matrix Builder.
  82499. * This can be used to override the default projection matrix computation.
  82500. */
  82501. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  82502. /**
  82503. * The transformed position. Position of the light in world space taking parenting in account.
  82504. */
  82505. transformedPosition: Vector3;
  82506. /**
  82507. * The transformed direction. Direction of the light in world space taking parenting in account.
  82508. */
  82509. transformedDirection: Vector3;
  82510. private _needProjectionMatrixCompute;
  82511. /**
  82512. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  82513. * @returns true if the information has been computed, false if it does not need to (no parenting)
  82514. */
  82515. computeTransformedInformation(): boolean;
  82516. /**
  82517. * Return the depth scale used for the shadow map.
  82518. * @returns the depth scale.
  82519. */
  82520. getDepthScale(): number;
  82521. /**
  82522. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  82523. * @param faceIndex The index of the face we are computed the direction to generate shadow
  82524. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  82525. */
  82526. getShadowDirection(faceIndex?: number): Vector3;
  82527. /**
  82528. * Returns the ShadowLight absolute position in the World.
  82529. * @returns the position vector in world space
  82530. */
  82531. getAbsolutePosition(): Vector3;
  82532. /**
  82533. * Sets the ShadowLight direction toward the passed target.
  82534. * @param target The point to target in local space
  82535. * @returns the updated ShadowLight direction
  82536. */
  82537. setDirectionToTarget(target: Vector3): Vector3;
  82538. /**
  82539. * Returns the light rotation in euler definition.
  82540. * @returns the x y z rotation in local space.
  82541. */
  82542. getRotation(): Vector3;
  82543. /**
  82544. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  82545. * @returns true if a cube texture needs to be use
  82546. */
  82547. needCube(): boolean;
  82548. /**
  82549. * Detects if the projection matrix requires to be recomputed this frame.
  82550. * @returns true if it requires to be recomputed otherwise, false.
  82551. */
  82552. needProjectionMatrixCompute(): boolean;
  82553. /**
  82554. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  82555. */
  82556. forceProjectionMatrixCompute(): void;
  82557. /** @hidden */
  82558. _initCache(): void;
  82559. /** @hidden */
  82560. _isSynchronized(): boolean;
  82561. /**
  82562. * Computes the world matrix of the node
  82563. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82564. * @returns the world matrix
  82565. */
  82566. computeWorldMatrix(force?: boolean): Matrix;
  82567. /**
  82568. * Gets the minZ used for shadow according to both the scene and the light.
  82569. * @param activeCamera The camera we are returning the min for
  82570. * @returns the depth min z
  82571. */
  82572. getDepthMinZ(activeCamera: Camera): number;
  82573. /**
  82574. * Gets the maxZ used for shadow according to both the scene and the light.
  82575. * @param activeCamera The camera we are returning the max for
  82576. * @returns the depth max z
  82577. */
  82578. getDepthMaxZ(activeCamera: Camera): number;
  82579. /**
  82580. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  82581. * @param matrix The materix to updated with the projection information
  82582. * @param viewMatrix The transform matrix of the light
  82583. * @param renderList The list of mesh to render in the map
  82584. * @returns The current light
  82585. */
  82586. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  82587. }
  82588. }
  82589. declare module BABYLON {
  82590. /**
  82591. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  82592. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  82593. */
  82594. export class EffectFallbacks implements IEffectFallbacks {
  82595. private _defines;
  82596. private _currentRank;
  82597. private _maxRank;
  82598. private _mesh;
  82599. /**
  82600. * Removes the fallback from the bound mesh.
  82601. */
  82602. unBindMesh(): void;
  82603. /**
  82604. * Adds a fallback on the specified property.
  82605. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  82606. * @param define The name of the define in the shader
  82607. */
  82608. addFallback(rank: number, define: string): void;
  82609. /**
  82610. * Sets the mesh to use CPU skinning when needing to fallback.
  82611. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  82612. * @param mesh The mesh to use the fallbacks.
  82613. */
  82614. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  82615. /**
  82616. * Checks to see if more fallbacks are still availible.
  82617. */
  82618. get hasMoreFallbacks(): boolean;
  82619. /**
  82620. * Removes the defines that should be removed when falling back.
  82621. * @param currentDefines defines the current define statements for the shader.
  82622. * @param effect defines the current effect we try to compile
  82623. * @returns The resulting defines with defines of the current rank removed.
  82624. */
  82625. reduce(currentDefines: string, effect: Effect): string;
  82626. }
  82627. }
  82628. declare module BABYLON {
  82629. /**
  82630. * "Static Class" containing the most commonly used helper while dealing with material for
  82631. * rendering purpose.
  82632. *
  82633. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  82634. *
  82635. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  82636. */
  82637. export class MaterialHelper {
  82638. /**
  82639. * Bind the current view position to an effect.
  82640. * @param effect The effect to be bound
  82641. * @param scene The scene the eyes position is used from
  82642. */
  82643. static BindEyePosition(effect: Effect, scene: Scene): void;
  82644. /**
  82645. * Helps preparing the defines values about the UVs in used in the effect.
  82646. * UVs are shared as much as we can accross channels in the shaders.
  82647. * @param texture The texture we are preparing the UVs for
  82648. * @param defines The defines to update
  82649. * @param key The channel key "diffuse", "specular"... used in the shader
  82650. */
  82651. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  82652. /**
  82653. * Binds a texture matrix value to its corrsponding uniform
  82654. * @param texture The texture to bind the matrix for
  82655. * @param uniformBuffer The uniform buffer receivin the data
  82656. * @param key The channel key "diffuse", "specular"... used in the shader
  82657. */
  82658. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  82659. /**
  82660. * Gets the current status of the fog (should it be enabled?)
  82661. * @param mesh defines the mesh to evaluate for fog support
  82662. * @param scene defines the hosting scene
  82663. * @returns true if fog must be enabled
  82664. */
  82665. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  82666. /**
  82667. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  82668. * @param mesh defines the current mesh
  82669. * @param scene defines the current scene
  82670. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  82671. * @param pointsCloud defines if point cloud rendering has to be turned on
  82672. * @param fogEnabled defines if fog has to be turned on
  82673. * @param alphaTest defines if alpha testing has to be turned on
  82674. * @param defines defines the current list of defines
  82675. */
  82676. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  82677. /**
  82678. * Helper used to prepare the list of defines associated with frame values for shader compilation
  82679. * @param scene defines the current scene
  82680. * @param engine defines the current engine
  82681. * @param defines specifies the list of active defines
  82682. * @param useInstances defines if instances have to be turned on
  82683. * @param useClipPlane defines if clip plane have to be turned on
  82684. */
  82685. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  82686. /**
  82687. * Prepares the defines for bones
  82688. * @param mesh The mesh containing the geometry data we will draw
  82689. * @param defines The defines to update
  82690. */
  82691. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  82692. /**
  82693. * Prepares the defines for morph targets
  82694. * @param mesh The mesh containing the geometry data we will draw
  82695. * @param defines The defines to update
  82696. */
  82697. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  82698. /**
  82699. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  82700. * @param mesh The mesh containing the geometry data we will draw
  82701. * @param defines The defines to update
  82702. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  82703. * @param useBones Precise whether bones should be used or not (override mesh info)
  82704. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  82705. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  82706. * @returns false if defines are considered not dirty and have not been checked
  82707. */
  82708. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  82709. /**
  82710. * Prepares the defines related to multiview
  82711. * @param scene The scene we are intending to draw
  82712. * @param defines The defines to update
  82713. */
  82714. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  82715. /**
  82716. * Prepares the defines related to the light information passed in parameter
  82717. * @param scene The scene we are intending to draw
  82718. * @param mesh The mesh the effect is compiling for
  82719. * @param light The light the effect is compiling for
  82720. * @param lightIndex The index of the light
  82721. * @param defines The defines to update
  82722. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82723. * @param state Defines the current state regarding what is needed (normals, etc...)
  82724. */
  82725. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  82726. needNormals: boolean;
  82727. needRebuild: boolean;
  82728. shadowEnabled: boolean;
  82729. specularEnabled: boolean;
  82730. lightmapMode: boolean;
  82731. }): void;
  82732. /**
  82733. * Prepares the defines related to the light information passed in parameter
  82734. * @param scene The scene we are intending to draw
  82735. * @param mesh The mesh the effect is compiling for
  82736. * @param defines The defines to update
  82737. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82738. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  82739. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  82740. * @returns true if normals will be required for the rest of the effect
  82741. */
  82742. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  82743. /**
  82744. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  82745. * @param lightIndex defines the light index
  82746. * @param uniformsList The uniform list
  82747. * @param samplersList The sampler list
  82748. * @param projectedLightTexture defines if projected texture must be used
  82749. * @param uniformBuffersList defines an optional list of uniform buffers
  82750. */
  82751. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  82752. /**
  82753. * Prepares the uniforms and samplers list to be used in the effect
  82754. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  82755. * @param samplersList The sampler list
  82756. * @param defines The defines helping in the list generation
  82757. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  82758. */
  82759. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  82760. /**
  82761. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  82762. * @param defines The defines to update while falling back
  82763. * @param fallbacks The authorized effect fallbacks
  82764. * @param maxSimultaneousLights The maximum number of lights allowed
  82765. * @param rank the current rank of the Effect
  82766. * @returns The newly affected rank
  82767. */
  82768. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  82769. private static _TmpMorphInfluencers;
  82770. /**
  82771. * Prepares the list of attributes required for morph targets according to the effect defines.
  82772. * @param attribs The current list of supported attribs
  82773. * @param mesh The mesh to prepare the morph targets attributes for
  82774. * @param influencers The number of influencers
  82775. */
  82776. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  82777. /**
  82778. * Prepares the list of attributes required for morph targets according to the effect defines.
  82779. * @param attribs The current list of supported attribs
  82780. * @param mesh The mesh to prepare the morph targets attributes for
  82781. * @param defines The current Defines of the effect
  82782. */
  82783. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  82784. /**
  82785. * Prepares the list of attributes required for bones according to the effect defines.
  82786. * @param attribs The current list of supported attribs
  82787. * @param mesh The mesh to prepare the bones attributes for
  82788. * @param defines The current Defines of the effect
  82789. * @param fallbacks The current efffect fallback strategy
  82790. */
  82791. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  82792. /**
  82793. * Check and prepare the list of attributes required for instances according to the effect defines.
  82794. * @param attribs The current list of supported attribs
  82795. * @param defines The current MaterialDefines of the effect
  82796. */
  82797. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  82798. /**
  82799. * Add the list of attributes required for instances to the attribs array.
  82800. * @param attribs The current list of supported attribs
  82801. */
  82802. static PushAttributesForInstances(attribs: string[]): void;
  82803. /**
  82804. * Binds the light information to the effect.
  82805. * @param light The light containing the generator
  82806. * @param effect The effect we are binding the data to
  82807. * @param lightIndex The light index in the effect used to render
  82808. */
  82809. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  82810. /**
  82811. * Binds the lights information from the scene to the effect for the given mesh.
  82812. * @param light Light to bind
  82813. * @param lightIndex Light index
  82814. * @param scene The scene where the light belongs to
  82815. * @param effect The effect we are binding the data to
  82816. * @param useSpecular Defines if specular is supported
  82817. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82818. */
  82819. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  82820. /**
  82821. * Binds the lights information from the scene to the effect for the given mesh.
  82822. * @param scene The scene the lights belongs to
  82823. * @param mesh The mesh we are binding the information to render
  82824. * @param effect The effect we are binding the data to
  82825. * @param defines The generated defines for the effect
  82826. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  82827. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82828. */
  82829. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  82830. private static _tempFogColor;
  82831. /**
  82832. * Binds the fog information from the scene to the effect for the given mesh.
  82833. * @param scene The scene the lights belongs to
  82834. * @param mesh The mesh we are binding the information to render
  82835. * @param effect The effect we are binding the data to
  82836. * @param linearSpace Defines if the fog effect is applied in linear space
  82837. */
  82838. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  82839. /**
  82840. * Binds the bones information from the mesh to the effect.
  82841. * @param mesh The mesh we are binding the information to render
  82842. * @param effect The effect we are binding the data to
  82843. */
  82844. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  82845. /**
  82846. * Binds the morph targets information from the mesh to the effect.
  82847. * @param abstractMesh The mesh we are binding the information to render
  82848. * @param effect The effect we are binding the data to
  82849. */
  82850. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  82851. /**
  82852. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  82853. * @param defines The generated defines used in the effect
  82854. * @param effect The effect we are binding the data to
  82855. * @param scene The scene we are willing to render with logarithmic scale for
  82856. */
  82857. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  82858. /**
  82859. * Binds the clip plane information from the scene to the effect.
  82860. * @param scene The scene the clip plane information are extracted from
  82861. * @param effect The effect we are binding the data to
  82862. */
  82863. static BindClipPlane(effect: Effect, scene: Scene): void;
  82864. }
  82865. }
  82866. declare module BABYLON {
  82867. /** @hidden */
  82868. export var packingFunctions: {
  82869. name: string;
  82870. shader: string;
  82871. };
  82872. }
  82873. declare module BABYLON {
  82874. /** @hidden */
  82875. export var clipPlaneFragmentDeclaration: {
  82876. name: string;
  82877. shader: string;
  82878. };
  82879. }
  82880. declare module BABYLON {
  82881. /** @hidden */
  82882. export var clipPlaneFragment: {
  82883. name: string;
  82884. shader: string;
  82885. };
  82886. }
  82887. declare module BABYLON {
  82888. /** @hidden */
  82889. export var shadowMapPixelShader: {
  82890. name: string;
  82891. shader: string;
  82892. };
  82893. }
  82894. declare module BABYLON {
  82895. /** @hidden */
  82896. export var bonesDeclaration: {
  82897. name: string;
  82898. shader: string;
  82899. };
  82900. }
  82901. declare module BABYLON {
  82902. /** @hidden */
  82903. export var morphTargetsVertexGlobalDeclaration: {
  82904. name: string;
  82905. shader: string;
  82906. };
  82907. }
  82908. declare module BABYLON {
  82909. /** @hidden */
  82910. export var morphTargetsVertexDeclaration: {
  82911. name: string;
  82912. shader: string;
  82913. };
  82914. }
  82915. declare module BABYLON {
  82916. /** @hidden */
  82917. export var instancesDeclaration: {
  82918. name: string;
  82919. shader: string;
  82920. };
  82921. }
  82922. declare module BABYLON {
  82923. /** @hidden */
  82924. export var helperFunctions: {
  82925. name: string;
  82926. shader: string;
  82927. };
  82928. }
  82929. declare module BABYLON {
  82930. /** @hidden */
  82931. export var clipPlaneVertexDeclaration: {
  82932. name: string;
  82933. shader: string;
  82934. };
  82935. }
  82936. declare module BABYLON {
  82937. /** @hidden */
  82938. export var morphTargetsVertex: {
  82939. name: string;
  82940. shader: string;
  82941. };
  82942. }
  82943. declare module BABYLON {
  82944. /** @hidden */
  82945. export var instancesVertex: {
  82946. name: string;
  82947. shader: string;
  82948. };
  82949. }
  82950. declare module BABYLON {
  82951. /** @hidden */
  82952. export var bonesVertex: {
  82953. name: string;
  82954. shader: string;
  82955. };
  82956. }
  82957. declare module BABYLON {
  82958. /** @hidden */
  82959. export var clipPlaneVertex: {
  82960. name: string;
  82961. shader: string;
  82962. };
  82963. }
  82964. declare module BABYLON {
  82965. /** @hidden */
  82966. export var shadowMapVertexShader: {
  82967. name: string;
  82968. shader: string;
  82969. };
  82970. }
  82971. declare module BABYLON {
  82972. /** @hidden */
  82973. export var depthBoxBlurPixelShader: {
  82974. name: string;
  82975. shader: string;
  82976. };
  82977. }
  82978. declare module BABYLON {
  82979. /**
  82980. * Class representing a ray with position and direction
  82981. */
  82982. export class Ray {
  82983. /** origin point */
  82984. origin: Vector3;
  82985. /** direction */
  82986. direction: Vector3;
  82987. /** length of the ray */
  82988. length: number;
  82989. private static readonly TmpVector3;
  82990. private _tmpRay;
  82991. /**
  82992. * Creates a new ray
  82993. * @param origin origin point
  82994. * @param direction direction
  82995. * @param length length of the ray
  82996. */
  82997. constructor(
  82998. /** origin point */
  82999. origin: Vector3,
  83000. /** direction */
  83001. direction: Vector3,
  83002. /** length of the ray */
  83003. length?: number);
  83004. /**
  83005. * Checks if the ray intersects a box
  83006. * @param minimum bound of the box
  83007. * @param maximum bound of the box
  83008. * @param intersectionTreshold extra extend to be added to the box in all direction
  83009. * @returns if the box was hit
  83010. */
  83011. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  83012. /**
  83013. * Checks if the ray intersects a box
  83014. * @param box the bounding box to check
  83015. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  83016. * @returns if the box was hit
  83017. */
  83018. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  83019. /**
  83020. * If the ray hits a sphere
  83021. * @param sphere the bounding sphere to check
  83022. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  83023. * @returns true if it hits the sphere
  83024. */
  83025. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  83026. /**
  83027. * If the ray hits a triange
  83028. * @param vertex0 triangle vertex
  83029. * @param vertex1 triangle vertex
  83030. * @param vertex2 triangle vertex
  83031. * @returns intersection information if hit
  83032. */
  83033. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  83034. /**
  83035. * Checks if ray intersects a plane
  83036. * @param plane the plane to check
  83037. * @returns the distance away it was hit
  83038. */
  83039. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  83040. /**
  83041. * Calculate the intercept of a ray on a given axis
  83042. * @param axis to check 'x' | 'y' | 'z'
  83043. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  83044. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  83045. */
  83046. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  83047. /**
  83048. * Checks if ray intersects a mesh
  83049. * @param mesh the mesh to check
  83050. * @param fastCheck if only the bounding box should checked
  83051. * @returns picking info of the intersecton
  83052. */
  83053. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  83054. /**
  83055. * Checks if ray intersects a mesh
  83056. * @param meshes the meshes to check
  83057. * @param fastCheck if only the bounding box should checked
  83058. * @param results array to store result in
  83059. * @returns Array of picking infos
  83060. */
  83061. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  83062. private _comparePickingInfo;
  83063. private static smallnum;
  83064. private static rayl;
  83065. /**
  83066. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  83067. * @param sega the first point of the segment to test the intersection against
  83068. * @param segb the second point of the segment to test the intersection against
  83069. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  83070. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  83071. */
  83072. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  83073. /**
  83074. * Update the ray from viewport position
  83075. * @param x position
  83076. * @param y y position
  83077. * @param viewportWidth viewport width
  83078. * @param viewportHeight viewport height
  83079. * @param world world matrix
  83080. * @param view view matrix
  83081. * @param projection projection matrix
  83082. * @returns this ray updated
  83083. */
  83084. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  83085. /**
  83086. * Creates a ray with origin and direction of 0,0,0
  83087. * @returns the new ray
  83088. */
  83089. static Zero(): Ray;
  83090. /**
  83091. * Creates a new ray from screen space and viewport
  83092. * @param x position
  83093. * @param y y position
  83094. * @param viewportWidth viewport width
  83095. * @param viewportHeight viewport height
  83096. * @param world world matrix
  83097. * @param view view matrix
  83098. * @param projection projection matrix
  83099. * @returns new ray
  83100. */
  83101. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  83102. /**
  83103. * 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
  83104. * transformed to the given world matrix.
  83105. * @param origin The origin point
  83106. * @param end The end point
  83107. * @param world a matrix to transform the ray to. Default is the identity matrix.
  83108. * @returns the new ray
  83109. */
  83110. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  83111. /**
  83112. * Transforms a ray by a matrix
  83113. * @param ray ray to transform
  83114. * @param matrix matrix to apply
  83115. * @returns the resulting new ray
  83116. */
  83117. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  83118. /**
  83119. * Transforms a ray by a matrix
  83120. * @param ray ray to transform
  83121. * @param matrix matrix to apply
  83122. * @param result ray to store result in
  83123. */
  83124. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  83125. /**
  83126. * Unproject a ray from screen space to object space
  83127. * @param sourceX defines the screen space x coordinate to use
  83128. * @param sourceY defines the screen space y coordinate to use
  83129. * @param viewportWidth defines the current width of the viewport
  83130. * @param viewportHeight defines the current height of the viewport
  83131. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83132. * @param view defines the view matrix to use
  83133. * @param projection defines the projection matrix to use
  83134. */
  83135. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  83136. }
  83137. /**
  83138. * Type used to define predicate used to select faces when a mesh intersection is detected
  83139. */
  83140. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  83141. interface Scene {
  83142. /** @hidden */
  83143. _tempPickingRay: Nullable<Ray>;
  83144. /** @hidden */
  83145. _cachedRayForTransform: Ray;
  83146. /** @hidden */
  83147. _pickWithRayInverseMatrix: Matrix;
  83148. /** @hidden */
  83149. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  83150. /** @hidden */
  83151. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  83152. }
  83153. }
  83154. declare module BABYLON {
  83155. /**
  83156. * Groups all the scene component constants in one place to ease maintenance.
  83157. * @hidden
  83158. */
  83159. export class SceneComponentConstants {
  83160. static readonly NAME_EFFECTLAYER: string;
  83161. static readonly NAME_LAYER: string;
  83162. static readonly NAME_LENSFLARESYSTEM: string;
  83163. static readonly NAME_BOUNDINGBOXRENDERER: string;
  83164. static readonly NAME_PARTICLESYSTEM: string;
  83165. static readonly NAME_GAMEPAD: string;
  83166. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  83167. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  83168. static readonly NAME_DEPTHRENDERER: string;
  83169. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  83170. static readonly NAME_SPRITE: string;
  83171. static readonly NAME_OUTLINERENDERER: string;
  83172. static readonly NAME_PROCEDURALTEXTURE: string;
  83173. static readonly NAME_SHADOWGENERATOR: string;
  83174. static readonly NAME_OCTREE: string;
  83175. static readonly NAME_PHYSICSENGINE: string;
  83176. static readonly NAME_AUDIO: string;
  83177. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  83178. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  83179. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  83180. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  83181. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  83182. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  83183. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  83184. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  83185. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  83186. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  83187. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  83188. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  83189. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  83190. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  83191. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  83192. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  83193. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  83194. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  83195. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  83196. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  83197. static readonly STEP_AFTERRENDER_AUDIO: number;
  83198. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  83199. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  83200. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  83201. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  83202. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  83203. static readonly STEP_POINTERMOVE_SPRITE: number;
  83204. static readonly STEP_POINTERDOWN_SPRITE: number;
  83205. static readonly STEP_POINTERUP_SPRITE: number;
  83206. }
  83207. /**
  83208. * This represents a scene component.
  83209. *
  83210. * This is used to decouple the dependency the scene is having on the different workloads like
  83211. * layers, post processes...
  83212. */
  83213. export interface ISceneComponent {
  83214. /**
  83215. * The name of the component. Each component must have a unique name.
  83216. */
  83217. name: string;
  83218. /**
  83219. * The scene the component belongs to.
  83220. */
  83221. scene: Scene;
  83222. /**
  83223. * Register the component to one instance of a scene.
  83224. */
  83225. register(): void;
  83226. /**
  83227. * Rebuilds the elements related to this component in case of
  83228. * context lost for instance.
  83229. */
  83230. rebuild(): void;
  83231. /**
  83232. * Disposes the component and the associated ressources.
  83233. */
  83234. dispose(): void;
  83235. }
  83236. /**
  83237. * This represents a SERIALIZABLE scene component.
  83238. *
  83239. * This extends Scene Component to add Serialization methods on top.
  83240. */
  83241. export interface ISceneSerializableComponent extends ISceneComponent {
  83242. /**
  83243. * Adds all the elements from the container to the scene
  83244. * @param container the container holding the elements
  83245. */
  83246. addFromContainer(container: AbstractScene): void;
  83247. /**
  83248. * Removes all the elements in the container from the scene
  83249. * @param container contains the elements to remove
  83250. * @param dispose if the removed element should be disposed (default: false)
  83251. */
  83252. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  83253. /**
  83254. * Serializes the component data to the specified json object
  83255. * @param serializationObject The object to serialize to
  83256. */
  83257. serialize(serializationObject: any): void;
  83258. }
  83259. /**
  83260. * Strong typing of a Mesh related stage step action
  83261. */
  83262. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  83263. /**
  83264. * Strong typing of a Evaluate Sub Mesh related stage step action
  83265. */
  83266. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  83267. /**
  83268. * Strong typing of a Active Mesh related stage step action
  83269. */
  83270. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  83271. /**
  83272. * Strong typing of a Camera related stage step action
  83273. */
  83274. export type CameraStageAction = (camera: Camera) => void;
  83275. /**
  83276. * Strong typing of a Camera Frame buffer related stage step action
  83277. */
  83278. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  83279. /**
  83280. * Strong typing of a Render Target related stage step action
  83281. */
  83282. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  83283. /**
  83284. * Strong typing of a RenderingGroup related stage step action
  83285. */
  83286. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  83287. /**
  83288. * Strong typing of a Mesh Render related stage step action
  83289. */
  83290. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  83291. /**
  83292. * Strong typing of a simple stage step action
  83293. */
  83294. export type SimpleStageAction = () => void;
  83295. /**
  83296. * Strong typing of a render target action.
  83297. */
  83298. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  83299. /**
  83300. * Strong typing of a pointer move action.
  83301. */
  83302. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  83303. /**
  83304. * Strong typing of a pointer up/down action.
  83305. */
  83306. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  83307. /**
  83308. * Representation of a stage in the scene (Basically a list of ordered steps)
  83309. * @hidden
  83310. */
  83311. export class Stage<T extends Function> extends Array<{
  83312. index: number;
  83313. component: ISceneComponent;
  83314. action: T;
  83315. }> {
  83316. /**
  83317. * Hide ctor from the rest of the world.
  83318. * @param items The items to add.
  83319. */
  83320. private constructor();
  83321. /**
  83322. * Creates a new Stage.
  83323. * @returns A new instance of a Stage
  83324. */
  83325. static Create<T extends Function>(): Stage<T>;
  83326. /**
  83327. * Registers a step in an ordered way in the targeted stage.
  83328. * @param index Defines the position to register the step in
  83329. * @param component Defines the component attached to the step
  83330. * @param action Defines the action to launch during the step
  83331. */
  83332. registerStep(index: number, component: ISceneComponent, action: T): void;
  83333. /**
  83334. * Clears all the steps from the stage.
  83335. */
  83336. clear(): void;
  83337. }
  83338. }
  83339. declare module BABYLON {
  83340. interface Scene {
  83341. /** @hidden */
  83342. _pointerOverSprite: Nullable<Sprite>;
  83343. /** @hidden */
  83344. _pickedDownSprite: Nullable<Sprite>;
  83345. /** @hidden */
  83346. _tempSpritePickingRay: Nullable<Ray>;
  83347. /**
  83348. * All of the sprite managers added to this scene
  83349. * @see http://doc.babylonjs.com/babylon101/sprites
  83350. */
  83351. spriteManagers: Array<ISpriteManager>;
  83352. /**
  83353. * An event triggered when sprites rendering is about to start
  83354. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83355. */
  83356. onBeforeSpritesRenderingObservable: Observable<Scene>;
  83357. /**
  83358. * An event triggered when sprites rendering is done
  83359. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83360. */
  83361. onAfterSpritesRenderingObservable: Observable<Scene>;
  83362. /** @hidden */
  83363. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83364. /** Launch a ray to try to pick a sprite in the scene
  83365. * @param x position on screen
  83366. * @param y position on screen
  83367. * @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
  83368. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83369. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83370. * @returns a PickingInfo
  83371. */
  83372. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83373. /** Use the given ray to pick a sprite in the scene
  83374. * @param ray The ray (in world space) to use to pick meshes
  83375. * @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
  83376. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83377. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  83378. * @returns a PickingInfo
  83379. */
  83380. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83381. /** @hidden */
  83382. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83383. /** Launch a ray to try to pick sprites in the scene
  83384. * @param x position on screen
  83385. * @param y position on screen
  83386. * @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
  83387. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83388. * @returns a PickingInfo array
  83389. */
  83390. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83391. /** Use the given ray to pick sprites in the scene
  83392. * @param ray The ray (in world space) to use to pick meshes
  83393. * @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
  83394. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  83395. * @returns a PickingInfo array
  83396. */
  83397. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83398. /**
  83399. * Force the sprite under the pointer
  83400. * @param sprite defines the sprite to use
  83401. */
  83402. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  83403. /**
  83404. * Gets the sprite under the pointer
  83405. * @returns a Sprite or null if no sprite is under the pointer
  83406. */
  83407. getPointerOverSprite(): Nullable<Sprite>;
  83408. }
  83409. /**
  83410. * Defines the sprite scene component responsible to manage sprites
  83411. * in a given scene.
  83412. */
  83413. export class SpriteSceneComponent implements ISceneComponent {
  83414. /**
  83415. * The component name helpfull to identify the component in the list of scene components.
  83416. */
  83417. readonly name: string;
  83418. /**
  83419. * The scene the component belongs to.
  83420. */
  83421. scene: Scene;
  83422. /** @hidden */
  83423. private _spritePredicate;
  83424. /**
  83425. * Creates a new instance of the component for the given scene
  83426. * @param scene Defines the scene to register the component in
  83427. */
  83428. constructor(scene: Scene);
  83429. /**
  83430. * Registers the component in a given scene
  83431. */
  83432. register(): void;
  83433. /**
  83434. * Rebuilds the elements related to this component in case of
  83435. * context lost for instance.
  83436. */
  83437. rebuild(): void;
  83438. /**
  83439. * Disposes the component and the associated ressources.
  83440. */
  83441. dispose(): void;
  83442. private _pickSpriteButKeepRay;
  83443. private _pointerMove;
  83444. private _pointerDown;
  83445. private _pointerUp;
  83446. }
  83447. }
  83448. declare module BABYLON {
  83449. /** @hidden */
  83450. export var fogFragmentDeclaration: {
  83451. name: string;
  83452. shader: string;
  83453. };
  83454. }
  83455. declare module BABYLON {
  83456. /** @hidden */
  83457. export var fogFragment: {
  83458. name: string;
  83459. shader: string;
  83460. };
  83461. }
  83462. declare module BABYLON {
  83463. /** @hidden */
  83464. export var spritesPixelShader: {
  83465. name: string;
  83466. shader: string;
  83467. };
  83468. }
  83469. declare module BABYLON {
  83470. /** @hidden */
  83471. export var fogVertexDeclaration: {
  83472. name: string;
  83473. shader: string;
  83474. };
  83475. }
  83476. declare module BABYLON {
  83477. /** @hidden */
  83478. export var spritesVertexShader: {
  83479. name: string;
  83480. shader: string;
  83481. };
  83482. }
  83483. declare module BABYLON {
  83484. /**
  83485. * Defines the minimum interface to fullfil in order to be a sprite manager.
  83486. */
  83487. export interface ISpriteManager extends IDisposable {
  83488. /**
  83489. * Restricts the camera to viewing objects with the same layerMask.
  83490. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  83491. */
  83492. layerMask: number;
  83493. /**
  83494. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  83495. */
  83496. isPickable: boolean;
  83497. /**
  83498. * Specifies the rendering group id for this mesh (0 by default)
  83499. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  83500. */
  83501. renderingGroupId: number;
  83502. /**
  83503. * Defines the list of sprites managed by the manager.
  83504. */
  83505. sprites: Array<Sprite>;
  83506. /**
  83507. * Tests the intersection of a sprite with a specific ray.
  83508. * @param ray The ray we are sending to test the collision
  83509. * @param camera The camera space we are sending rays in
  83510. * @param predicate A predicate allowing excluding sprites from the list of object to test
  83511. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  83512. * @returns picking info or null.
  83513. */
  83514. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83515. /**
  83516. * Intersects the sprites with a ray
  83517. * @param ray defines the ray to intersect with
  83518. * @param camera defines the current active camera
  83519. * @param predicate defines a predicate used to select candidate sprites
  83520. * @returns null if no hit or a PickingInfo array
  83521. */
  83522. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83523. /**
  83524. * Renders the list of sprites on screen.
  83525. */
  83526. render(): void;
  83527. }
  83528. /**
  83529. * Class used to manage multiple sprites on the same spritesheet
  83530. * @see http://doc.babylonjs.com/babylon101/sprites
  83531. */
  83532. export class SpriteManager implements ISpriteManager {
  83533. /** defines the manager's name */
  83534. name: string;
  83535. /** Gets the list of sprites */
  83536. sprites: Sprite[];
  83537. /** Gets or sets the rendering group id (0 by default) */
  83538. renderingGroupId: number;
  83539. /** Gets or sets camera layer mask */
  83540. layerMask: number;
  83541. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  83542. fogEnabled: boolean;
  83543. /** Gets or sets a boolean indicating if the sprites are pickable */
  83544. isPickable: boolean;
  83545. /** Defines the default width of a cell in the spritesheet */
  83546. cellWidth: number;
  83547. /** Defines the default height of a cell in the spritesheet */
  83548. cellHeight: number;
  83549. /** Associative array from JSON sprite data file */
  83550. private _cellData;
  83551. /** Array of sprite names from JSON sprite data file */
  83552. private _spriteMap;
  83553. /** True when packed cell data from JSON file is ready*/
  83554. private _packedAndReady;
  83555. /**
  83556. * An event triggered when the manager is disposed.
  83557. */
  83558. onDisposeObservable: Observable<SpriteManager>;
  83559. private _onDisposeObserver;
  83560. /**
  83561. * Callback called when the manager is disposed
  83562. */
  83563. set onDispose(callback: () => void);
  83564. private _capacity;
  83565. private _fromPacked;
  83566. private _spriteTexture;
  83567. private _epsilon;
  83568. private _scene;
  83569. private _vertexData;
  83570. private _buffer;
  83571. private _vertexBuffers;
  83572. private _indexBuffer;
  83573. private _effectBase;
  83574. private _effectFog;
  83575. /**
  83576. * Gets or sets the spritesheet texture
  83577. */
  83578. get texture(): Texture;
  83579. set texture(value: Texture);
  83580. private _blendMode;
  83581. /**
  83582. * Blend mode use to render the particle, it can be any of
  83583. * the static Constants.ALPHA_x properties provided in this class.
  83584. * Default value is Constants.ALPHA_COMBINE
  83585. */
  83586. get blendMode(): number;
  83587. set blendMode(blendMode: number);
  83588. /** Disables writing to the depth buffer when rendering the sprites.
  83589. * It can be handy to disable depth writing when using textures without alpha channel
  83590. * and setting some specific blend modes.
  83591. */
  83592. disableDepthWrite: boolean;
  83593. /**
  83594. * Creates a new sprite manager
  83595. * @param name defines the manager's name
  83596. * @param imgUrl defines the sprite sheet url
  83597. * @param capacity defines the maximum allowed number of sprites
  83598. * @param cellSize defines the size of a sprite cell
  83599. * @param scene defines the hosting scene
  83600. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  83601. * @param samplingMode defines the smapling mode to use with spritesheet
  83602. * @param fromPacked set to false; do not alter
  83603. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  83604. */
  83605. constructor(
  83606. /** defines the manager's name */
  83607. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  83608. private _makePacked;
  83609. private _appendSpriteVertex;
  83610. /**
  83611. * Intersects the sprites with a ray
  83612. * @param ray defines the ray to intersect with
  83613. * @param camera defines the current active camera
  83614. * @param predicate defines a predicate used to select candidate sprites
  83615. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  83616. * @returns null if no hit or a PickingInfo
  83617. */
  83618. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83619. /**
  83620. * Intersects the sprites with a ray
  83621. * @param ray defines the ray to intersect with
  83622. * @param camera defines the current active camera
  83623. * @param predicate defines a predicate used to select candidate sprites
  83624. * @returns null if no hit or a PickingInfo array
  83625. */
  83626. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83627. /**
  83628. * Render all child sprites
  83629. */
  83630. render(): void;
  83631. /**
  83632. * Release associated resources
  83633. */
  83634. dispose(): void;
  83635. }
  83636. }
  83637. declare module BABYLON {
  83638. /** Interface used by value gradients (color, factor, ...) */
  83639. export interface IValueGradient {
  83640. /**
  83641. * Gets or sets the gradient value (between 0 and 1)
  83642. */
  83643. gradient: number;
  83644. }
  83645. /** Class used to store color4 gradient */
  83646. export class ColorGradient implements IValueGradient {
  83647. /**
  83648. * Gets or sets the gradient value (between 0 and 1)
  83649. */
  83650. gradient: number;
  83651. /**
  83652. * Gets or sets first associated color
  83653. */
  83654. color1: Color4;
  83655. /**
  83656. * Gets or sets second associated color
  83657. */
  83658. color2?: Color4;
  83659. /**
  83660. * Will get a color picked randomly between color1 and color2.
  83661. * If color2 is undefined then color1 will be used
  83662. * @param result defines the target Color4 to store the result in
  83663. */
  83664. getColorToRef(result: Color4): void;
  83665. }
  83666. /** Class used to store color 3 gradient */
  83667. export class Color3Gradient implements IValueGradient {
  83668. /**
  83669. * Gets or sets the gradient value (between 0 and 1)
  83670. */
  83671. gradient: number;
  83672. /**
  83673. * Gets or sets the associated color
  83674. */
  83675. color: Color3;
  83676. }
  83677. /** Class used to store factor gradient */
  83678. export class FactorGradient implements IValueGradient {
  83679. /**
  83680. * Gets or sets the gradient value (between 0 and 1)
  83681. */
  83682. gradient: number;
  83683. /**
  83684. * Gets or sets first associated factor
  83685. */
  83686. factor1: number;
  83687. /**
  83688. * Gets or sets second associated factor
  83689. */
  83690. factor2?: number;
  83691. /**
  83692. * Will get a number picked randomly between factor1 and factor2.
  83693. * If factor2 is undefined then factor1 will be used
  83694. * @returns the picked number
  83695. */
  83696. getFactor(): number;
  83697. }
  83698. /**
  83699. * Helper used to simplify some generic gradient tasks
  83700. */
  83701. export class GradientHelper {
  83702. /**
  83703. * Gets the current gradient from an array of IValueGradient
  83704. * @param ratio defines the current ratio to get
  83705. * @param gradients defines the array of IValueGradient
  83706. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  83707. */
  83708. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  83709. }
  83710. }
  83711. declare module BABYLON {
  83712. /**
  83713. * Interface for the size containing width and height
  83714. */
  83715. export interface ISize {
  83716. /**
  83717. * Width
  83718. */
  83719. width: number;
  83720. /**
  83721. * Heighht
  83722. */
  83723. height: number;
  83724. }
  83725. /**
  83726. * Size containing widht and height
  83727. */
  83728. export class Size implements ISize {
  83729. /**
  83730. * Width
  83731. */
  83732. width: number;
  83733. /**
  83734. * Height
  83735. */
  83736. height: number;
  83737. /**
  83738. * Creates a Size object from the given width and height (floats).
  83739. * @param width width of the new size
  83740. * @param height height of the new size
  83741. */
  83742. constructor(width: number, height: number);
  83743. /**
  83744. * Returns a string with the Size width and height
  83745. * @returns a string with the Size width and height
  83746. */
  83747. toString(): string;
  83748. /**
  83749. * "Size"
  83750. * @returns the string "Size"
  83751. */
  83752. getClassName(): string;
  83753. /**
  83754. * Returns the Size hash code.
  83755. * @returns a hash code for a unique width and height
  83756. */
  83757. getHashCode(): number;
  83758. /**
  83759. * Updates the current size from the given one.
  83760. * @param src the given size
  83761. */
  83762. copyFrom(src: Size): void;
  83763. /**
  83764. * Updates in place the current Size from the given floats.
  83765. * @param width width of the new size
  83766. * @param height height of the new size
  83767. * @returns the updated Size.
  83768. */
  83769. copyFromFloats(width: number, height: number): Size;
  83770. /**
  83771. * Updates in place the current Size from the given floats.
  83772. * @param width width to set
  83773. * @param height height to set
  83774. * @returns the updated Size.
  83775. */
  83776. set(width: number, height: number): Size;
  83777. /**
  83778. * Multiplies the width and height by numbers
  83779. * @param w factor to multiple the width by
  83780. * @param h factor to multiple the height by
  83781. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  83782. */
  83783. multiplyByFloats(w: number, h: number): Size;
  83784. /**
  83785. * Clones the size
  83786. * @returns a new Size copied from the given one.
  83787. */
  83788. clone(): Size;
  83789. /**
  83790. * True if the current Size and the given one width and height are strictly equal.
  83791. * @param other the other size to compare against
  83792. * @returns True if the current Size and the given one width and height are strictly equal.
  83793. */
  83794. equals(other: Size): boolean;
  83795. /**
  83796. * The surface of the Size : width * height (float).
  83797. */
  83798. get surface(): number;
  83799. /**
  83800. * Create a new size of zero
  83801. * @returns a new Size set to (0.0, 0.0)
  83802. */
  83803. static Zero(): Size;
  83804. /**
  83805. * Sums the width and height of two sizes
  83806. * @param otherSize size to add to this size
  83807. * @returns a new Size set as the addition result of the current Size and the given one.
  83808. */
  83809. add(otherSize: Size): Size;
  83810. /**
  83811. * Subtracts the width and height of two
  83812. * @param otherSize size to subtract to this size
  83813. * @returns a new Size set as the subtraction result of the given one from the current Size.
  83814. */
  83815. subtract(otherSize: Size): Size;
  83816. /**
  83817. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  83818. * @param start starting size to lerp between
  83819. * @param end end size to lerp between
  83820. * @param amount amount to lerp between the start and end values
  83821. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  83822. */
  83823. static Lerp(start: Size, end: Size, amount: number): Size;
  83824. }
  83825. }
  83826. declare module BABYLON {
  83827. interface ThinEngine {
  83828. /**
  83829. * Creates a dynamic texture
  83830. * @param width defines the width of the texture
  83831. * @param height defines the height of the texture
  83832. * @param generateMipMaps defines if the engine should generate the mip levels
  83833. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83834. * @returns the dynamic texture inside an InternalTexture
  83835. */
  83836. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  83837. /**
  83838. * Update the content of a dynamic texture
  83839. * @param texture defines the texture to update
  83840. * @param canvas defines the canvas containing the source
  83841. * @param invertY defines if data must be stored with Y axis inverted
  83842. * @param premulAlpha defines if alpha is stored as premultiplied
  83843. * @param format defines the format of the data
  83844. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  83845. */
  83846. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  83847. }
  83848. }
  83849. declare module BABYLON {
  83850. /**
  83851. * Helper class used to generate a canvas to manipulate images
  83852. */
  83853. export class CanvasGenerator {
  83854. /**
  83855. * Create a new canvas (or offscreen canvas depending on the context)
  83856. * @param width defines the expected width
  83857. * @param height defines the expected height
  83858. * @return a new canvas or offscreen canvas
  83859. */
  83860. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  83861. }
  83862. }
  83863. declare module BABYLON {
  83864. /**
  83865. * A class extending Texture allowing drawing on a texture
  83866. * @see http://doc.babylonjs.com/how_to/dynamictexture
  83867. */
  83868. export class DynamicTexture extends Texture {
  83869. private _generateMipMaps;
  83870. private _canvas;
  83871. private _context;
  83872. private _engine;
  83873. /**
  83874. * Creates a DynamicTexture
  83875. * @param name defines the name of the texture
  83876. * @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
  83877. * @param scene defines the scene where you want the texture
  83878. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  83879. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  83880. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  83881. */
  83882. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  83883. /**
  83884. * Get the current class name of the texture useful for serialization or dynamic coding.
  83885. * @returns "DynamicTexture"
  83886. */
  83887. getClassName(): string;
  83888. /**
  83889. * Gets the current state of canRescale
  83890. */
  83891. get canRescale(): boolean;
  83892. private _recreate;
  83893. /**
  83894. * Scales the texture
  83895. * @param ratio the scale factor to apply to both width and height
  83896. */
  83897. scale(ratio: number): void;
  83898. /**
  83899. * Resizes the texture
  83900. * @param width the new width
  83901. * @param height the new height
  83902. */
  83903. scaleTo(width: number, height: number): void;
  83904. /**
  83905. * Gets the context of the canvas used by the texture
  83906. * @returns the canvas context of the dynamic texture
  83907. */
  83908. getContext(): CanvasRenderingContext2D;
  83909. /**
  83910. * Clears the texture
  83911. */
  83912. clear(): void;
  83913. /**
  83914. * Updates the texture
  83915. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83916. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  83917. */
  83918. update(invertY?: boolean, premulAlpha?: boolean): void;
  83919. /**
  83920. * Draws text onto the texture
  83921. * @param text defines the text to be drawn
  83922. * @param x defines the placement of the text from the left
  83923. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  83924. * @param font defines the font to be used with font-style, font-size, font-name
  83925. * @param color defines the color used for the text
  83926. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  83927. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83928. * @param update defines whether texture is immediately update (default is true)
  83929. */
  83930. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  83931. /**
  83932. * Clones the texture
  83933. * @returns the clone of the texture.
  83934. */
  83935. clone(): DynamicTexture;
  83936. /**
  83937. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  83938. * @returns a serialized dynamic texture object
  83939. */
  83940. serialize(): any;
  83941. /** @hidden */
  83942. _rebuild(): void;
  83943. }
  83944. }
  83945. declare module BABYLON {
  83946. interface Engine {
  83947. /**
  83948. * Creates a raw texture
  83949. * @param data defines the data to store in the texture
  83950. * @param width defines the width of the texture
  83951. * @param height defines the height of the texture
  83952. * @param format defines the format of the data
  83953. * @param generateMipMaps defines if the engine should generate the mip levels
  83954. * @param invertY defines if data must be stored with Y axis inverted
  83955. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83956. * @param compression defines the compression used (null by default)
  83957. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83958. * @returns the raw texture inside an InternalTexture
  83959. */
  83960. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  83961. /**
  83962. * Update a raw texture
  83963. * @param texture defines the texture to update
  83964. * @param data defines the data to store in the texture
  83965. * @param format defines the format of the data
  83966. * @param invertY defines if data must be stored with Y axis inverted
  83967. */
  83968. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83969. /**
  83970. * Update a raw texture
  83971. * @param texture defines the texture to update
  83972. * @param data defines the data to store in the texture
  83973. * @param format defines the format of the data
  83974. * @param invertY defines if data must be stored with Y axis inverted
  83975. * @param compression defines the compression used (null by default)
  83976. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83977. */
  83978. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  83979. /**
  83980. * Creates a new raw cube texture
  83981. * @param data defines the array of data to use to create each face
  83982. * @param size defines the size of the textures
  83983. * @param format defines the format of the data
  83984. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83985. * @param generateMipMaps defines if the engine should generate the mip levels
  83986. * @param invertY defines if data must be stored with Y axis inverted
  83987. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83988. * @param compression defines the compression used (null by default)
  83989. * @returns the cube texture as an InternalTexture
  83990. */
  83991. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  83992. /**
  83993. * Update a raw cube texture
  83994. * @param texture defines the texture to udpdate
  83995. * @param data defines the data to store
  83996. * @param format defines the data format
  83997. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83998. * @param invertY defines if data must be stored with Y axis inverted
  83999. */
  84000. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  84001. /**
  84002. * Update a raw cube texture
  84003. * @param texture defines the texture to udpdate
  84004. * @param data defines the data to store
  84005. * @param format defines the data format
  84006. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84007. * @param invertY defines if data must be stored with Y axis inverted
  84008. * @param compression defines the compression used (null by default)
  84009. */
  84010. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  84011. /**
  84012. * Update a raw cube texture
  84013. * @param texture defines the texture to udpdate
  84014. * @param data defines the data to store
  84015. * @param format defines the data format
  84016. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84017. * @param invertY defines if data must be stored with Y axis inverted
  84018. * @param compression defines the compression used (null by default)
  84019. * @param level defines which level of the texture to update
  84020. */
  84021. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  84022. /**
  84023. * Creates a new raw cube texture from a specified url
  84024. * @param url defines the url where the data is located
  84025. * @param scene defines the current scene
  84026. * @param size defines the size of the textures
  84027. * @param format defines the format of the data
  84028. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84029. * @param noMipmap defines if the engine should avoid generating the mip levels
  84030. * @param callback defines a callback used to extract texture data from loaded data
  84031. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  84032. * @param onLoad defines a callback called when texture is loaded
  84033. * @param onError defines a callback called if there is an error
  84034. * @returns the cube texture as an InternalTexture
  84035. */
  84036. 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;
  84037. /**
  84038. * Creates a new raw cube texture from a specified url
  84039. * @param url defines the url where the data is located
  84040. * @param scene defines the current scene
  84041. * @param size defines the size of the textures
  84042. * @param format defines the format of the data
  84043. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84044. * @param noMipmap defines if the engine should avoid generating the mip levels
  84045. * @param callback defines a callback used to extract texture data from loaded data
  84046. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  84047. * @param onLoad defines a callback called when texture is loaded
  84048. * @param onError defines a callback called if there is an error
  84049. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84050. * @param invertY defines if data must be stored with Y axis inverted
  84051. * @returns the cube texture as an InternalTexture
  84052. */
  84053. 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;
  84054. /**
  84055. * Creates a new raw 3D texture
  84056. * @param data defines the data used to create the texture
  84057. * @param width defines the width of the texture
  84058. * @param height defines the height of the texture
  84059. * @param depth defines the depth of the texture
  84060. * @param format defines the format of the texture
  84061. * @param generateMipMaps defines if the engine must generate mip levels
  84062. * @param invertY defines if data must be stored with Y axis inverted
  84063. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84064. * @param compression defines the compressed used (can be null)
  84065. * @param textureType defines the compressed used (can be null)
  84066. * @returns a new raw 3D texture (stored in an InternalTexture)
  84067. */
  84068. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  84069. /**
  84070. * Update a raw 3D texture
  84071. * @param texture defines the texture to update
  84072. * @param data defines the data to store
  84073. * @param format defines the data format
  84074. * @param invertY defines if data must be stored with Y axis inverted
  84075. */
  84076. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  84077. /**
  84078. * Update a raw 3D texture
  84079. * @param texture defines the texture to update
  84080. * @param data defines the data to store
  84081. * @param format defines the data format
  84082. * @param invertY defines if data must be stored with Y axis inverted
  84083. * @param compression defines the used compression (can be null)
  84084. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  84085. */
  84086. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  84087. /**
  84088. * Creates a new raw 2D array texture
  84089. * @param data defines the data used to create the texture
  84090. * @param width defines the width of the texture
  84091. * @param height defines the height of the texture
  84092. * @param depth defines the number of layers of the texture
  84093. * @param format defines the format of the texture
  84094. * @param generateMipMaps defines if the engine must generate mip levels
  84095. * @param invertY defines if data must be stored with Y axis inverted
  84096. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84097. * @param compression defines the compressed used (can be null)
  84098. * @param textureType defines the compressed used (can be null)
  84099. * @returns a new raw 2D array texture (stored in an InternalTexture)
  84100. */
  84101. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  84102. /**
  84103. * Update a raw 2D array texture
  84104. * @param texture defines the texture to update
  84105. * @param data defines the data to store
  84106. * @param format defines the data format
  84107. * @param invertY defines if data must be stored with Y axis inverted
  84108. */
  84109. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  84110. /**
  84111. * Update a raw 2D array texture
  84112. * @param texture defines the texture to update
  84113. * @param data defines the data to store
  84114. * @param format defines the data format
  84115. * @param invertY defines if data must be stored with Y axis inverted
  84116. * @param compression defines the used compression (can be null)
  84117. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  84118. */
  84119. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  84120. }
  84121. }
  84122. declare module BABYLON {
  84123. /**
  84124. * Raw texture can help creating a texture directly from an array of data.
  84125. * This can be super useful if you either get the data from an uncompressed source or
  84126. * if you wish to create your texture pixel by pixel.
  84127. */
  84128. export class RawTexture extends Texture {
  84129. /**
  84130. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84131. */
  84132. format: number;
  84133. private _engine;
  84134. /**
  84135. * Instantiates a new RawTexture.
  84136. * Raw texture can help creating a texture directly from an array of data.
  84137. * This can be super useful if you either get the data from an uncompressed source or
  84138. * if you wish to create your texture pixel by pixel.
  84139. * @param data define the array of data to use to create the texture
  84140. * @param width define the width of the texture
  84141. * @param height define the height of the texture
  84142. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84143. * @param scene define the scene the texture belongs to
  84144. * @param generateMipMaps define whether mip maps should be generated or not
  84145. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84146. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84147. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84148. */
  84149. constructor(data: ArrayBufferView, width: number, height: number,
  84150. /**
  84151. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84152. */
  84153. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  84154. /**
  84155. * Updates the texture underlying data.
  84156. * @param data Define the new data of the texture
  84157. */
  84158. update(data: ArrayBufferView): void;
  84159. /**
  84160. * Creates a luminance texture from some data.
  84161. * @param data Define the texture data
  84162. * @param width Define the width of the texture
  84163. * @param height Define the height of the texture
  84164. * @param scene Define the scene the texture belongs to
  84165. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84166. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84167. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84168. * @returns the luminance texture
  84169. */
  84170. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84171. /**
  84172. * Creates a luminance alpha texture from some data.
  84173. * @param data Define the texture data
  84174. * @param width Define the width of the texture
  84175. * @param height Define the height of the texture
  84176. * @param scene Define the scene the texture belongs to
  84177. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84178. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84179. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84180. * @returns the luminance alpha texture
  84181. */
  84182. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84183. /**
  84184. * Creates an alpha texture from some data.
  84185. * @param data Define the texture data
  84186. * @param width Define the width of the texture
  84187. * @param height Define the height of the texture
  84188. * @param scene Define the scene the texture belongs to
  84189. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84190. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84191. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84192. * @returns the alpha texture
  84193. */
  84194. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84195. /**
  84196. * Creates a RGB texture from some data.
  84197. * @param data Define the texture data
  84198. * @param width Define the width of the texture
  84199. * @param height Define the height of the texture
  84200. * @param scene Define the scene the texture belongs to
  84201. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84202. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84203. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84204. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84205. * @returns the RGB alpha texture
  84206. */
  84207. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  84208. /**
  84209. * Creates a RGBA texture from some data.
  84210. * @param data Define the texture data
  84211. * @param width Define the width of the texture
  84212. * @param height Define the height of the texture
  84213. * @param scene Define the scene the texture belongs to
  84214. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84215. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84216. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84217. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84218. * @returns the RGBA texture
  84219. */
  84220. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  84221. /**
  84222. * Creates a R texture from some data.
  84223. * @param data Define the texture data
  84224. * @param width Define the width of the texture
  84225. * @param height Define the height of the texture
  84226. * @param scene Define the scene the texture belongs to
  84227. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84228. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84229. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84230. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84231. * @returns the R texture
  84232. */
  84233. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  84234. }
  84235. }
  84236. declare module BABYLON {
  84237. interface AbstractScene {
  84238. /**
  84239. * The list of procedural textures added to the scene
  84240. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84241. */
  84242. proceduralTextures: Array<ProceduralTexture>;
  84243. }
  84244. /**
  84245. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  84246. * in a given scene.
  84247. */
  84248. export class ProceduralTextureSceneComponent implements ISceneComponent {
  84249. /**
  84250. * The component name helpfull to identify the component in the list of scene components.
  84251. */
  84252. readonly name: string;
  84253. /**
  84254. * The scene the component belongs to.
  84255. */
  84256. scene: Scene;
  84257. /**
  84258. * Creates a new instance of the component for the given scene
  84259. * @param scene Defines the scene to register the component in
  84260. */
  84261. constructor(scene: Scene);
  84262. /**
  84263. * Registers the component in a given scene
  84264. */
  84265. register(): void;
  84266. /**
  84267. * Rebuilds the elements related to this component in case of
  84268. * context lost for instance.
  84269. */
  84270. rebuild(): void;
  84271. /**
  84272. * Disposes the component and the associated ressources.
  84273. */
  84274. dispose(): void;
  84275. private _beforeClear;
  84276. }
  84277. }
  84278. declare module BABYLON {
  84279. interface ThinEngine {
  84280. /**
  84281. * Creates a new render target cube texture
  84282. * @param size defines the size of the texture
  84283. * @param options defines the options used to create the texture
  84284. * @returns a new render target cube texture stored in an InternalTexture
  84285. */
  84286. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  84287. }
  84288. }
  84289. declare module BABYLON {
  84290. /** @hidden */
  84291. export var proceduralVertexShader: {
  84292. name: string;
  84293. shader: string;
  84294. };
  84295. }
  84296. declare module BABYLON {
  84297. /**
  84298. * 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.
  84299. * This is the base class of any Procedural texture and contains most of the shareable code.
  84300. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84301. */
  84302. export class ProceduralTexture extends Texture {
  84303. isCube: boolean;
  84304. /**
  84305. * Define if the texture is enabled or not (disabled texture will not render)
  84306. */
  84307. isEnabled: boolean;
  84308. /**
  84309. * Define if the texture must be cleared before rendering (default is true)
  84310. */
  84311. autoClear: boolean;
  84312. /**
  84313. * Callback called when the texture is generated
  84314. */
  84315. onGenerated: () => void;
  84316. /**
  84317. * Event raised when the texture is generated
  84318. */
  84319. onGeneratedObservable: Observable<ProceduralTexture>;
  84320. /** @hidden */
  84321. _generateMipMaps: boolean;
  84322. /** @hidden **/
  84323. _effect: Effect;
  84324. /** @hidden */
  84325. _textures: {
  84326. [key: string]: Texture;
  84327. };
  84328. private _size;
  84329. private _currentRefreshId;
  84330. private _frameId;
  84331. private _refreshRate;
  84332. private _vertexBuffers;
  84333. private _indexBuffer;
  84334. private _uniforms;
  84335. private _samplers;
  84336. private _fragment;
  84337. private _floats;
  84338. private _ints;
  84339. private _floatsArrays;
  84340. private _colors3;
  84341. private _colors4;
  84342. private _vectors2;
  84343. private _vectors3;
  84344. private _matrices;
  84345. private _fallbackTexture;
  84346. private _fallbackTextureUsed;
  84347. private _engine;
  84348. private _cachedDefines;
  84349. private _contentUpdateId;
  84350. private _contentData;
  84351. /**
  84352. * Instantiates a new procedural texture.
  84353. * 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.
  84354. * This is the base class of any Procedural texture and contains most of the shareable code.
  84355. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84356. * @param name Define the name of the texture
  84357. * @param size Define the size of the texture to create
  84358. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  84359. * @param scene Define the scene the texture belongs to
  84360. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  84361. * @param generateMipMaps Define if the texture should creates mip maps or not
  84362. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  84363. */
  84364. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  84365. /**
  84366. * The effect that is created when initializing the post process.
  84367. * @returns The created effect corresponding the the postprocess.
  84368. */
  84369. getEffect(): Effect;
  84370. /**
  84371. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  84372. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  84373. */
  84374. getContent(): Nullable<ArrayBufferView>;
  84375. private _createIndexBuffer;
  84376. /** @hidden */
  84377. _rebuild(): void;
  84378. /**
  84379. * Resets the texture in order to recreate its associated resources.
  84380. * This can be called in case of context loss
  84381. */
  84382. reset(): void;
  84383. protected _getDefines(): string;
  84384. /**
  84385. * Is the texture ready to be used ? (rendered at least once)
  84386. * @returns true if ready, otherwise, false.
  84387. */
  84388. isReady(): boolean;
  84389. /**
  84390. * Resets the refresh counter of the texture and start bak from scratch.
  84391. * Could be useful to regenerate the texture if it is setup to render only once.
  84392. */
  84393. resetRefreshCounter(): void;
  84394. /**
  84395. * Set the fragment shader to use in order to render the texture.
  84396. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  84397. */
  84398. setFragment(fragment: any): void;
  84399. /**
  84400. * Define the refresh rate of the texture or the rendering frequency.
  84401. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84402. */
  84403. get refreshRate(): number;
  84404. set refreshRate(value: number);
  84405. /** @hidden */
  84406. _shouldRender(): boolean;
  84407. /**
  84408. * Get the size the texture is rendering at.
  84409. * @returns the size (texture is always squared)
  84410. */
  84411. getRenderSize(): number;
  84412. /**
  84413. * Resize the texture to new value.
  84414. * @param size Define the new size the texture should have
  84415. * @param generateMipMaps Define whether the new texture should create mip maps
  84416. */
  84417. resize(size: number, generateMipMaps: boolean): void;
  84418. private _checkUniform;
  84419. /**
  84420. * Set a texture in the shader program used to render.
  84421. * @param name Define the name of the uniform samplers as defined in the shader
  84422. * @param texture Define the texture to bind to this sampler
  84423. * @return the texture itself allowing "fluent" like uniform updates
  84424. */
  84425. setTexture(name: string, texture: Texture): ProceduralTexture;
  84426. /**
  84427. * Set a float in the shader.
  84428. * @param name Define the name of the uniform as defined in the shader
  84429. * @param value Define the value to give to the uniform
  84430. * @return the texture itself allowing "fluent" like uniform updates
  84431. */
  84432. setFloat(name: string, value: number): ProceduralTexture;
  84433. /**
  84434. * Set a int in the shader.
  84435. * @param name Define the name of the uniform as defined in the shader
  84436. * @param value Define the value to give to the uniform
  84437. * @return the texture itself allowing "fluent" like uniform updates
  84438. */
  84439. setInt(name: string, value: number): ProceduralTexture;
  84440. /**
  84441. * Set an array of floats in the shader.
  84442. * @param name Define the name of the uniform as defined in the shader
  84443. * @param value Define the value to give to the uniform
  84444. * @return the texture itself allowing "fluent" like uniform updates
  84445. */
  84446. setFloats(name: string, value: number[]): ProceduralTexture;
  84447. /**
  84448. * Set a vec3 in the shader from a Color3.
  84449. * @param name Define the name of the uniform as defined in the shader
  84450. * @param value Define the value to give to the uniform
  84451. * @return the texture itself allowing "fluent" like uniform updates
  84452. */
  84453. setColor3(name: string, value: Color3): ProceduralTexture;
  84454. /**
  84455. * Set a vec4 in the shader from a Color4.
  84456. * @param name Define the name of the uniform as defined in the shader
  84457. * @param value Define the value to give to the uniform
  84458. * @return the texture itself allowing "fluent" like uniform updates
  84459. */
  84460. setColor4(name: string, value: Color4): ProceduralTexture;
  84461. /**
  84462. * Set a vec2 in the shader from a Vector2.
  84463. * @param name Define the name of the uniform as defined in the shader
  84464. * @param value Define the value to give to the uniform
  84465. * @return the texture itself allowing "fluent" like uniform updates
  84466. */
  84467. setVector2(name: string, value: Vector2): ProceduralTexture;
  84468. /**
  84469. * Set a vec3 in the shader from a Vector3.
  84470. * @param name Define the name of the uniform as defined in the shader
  84471. * @param value Define the value to give to the uniform
  84472. * @return the texture itself allowing "fluent" like uniform updates
  84473. */
  84474. setVector3(name: string, value: Vector3): ProceduralTexture;
  84475. /**
  84476. * Set a mat4 in the shader from a MAtrix.
  84477. * @param name Define the name of the uniform as defined in the shader
  84478. * @param value Define the value to give to the uniform
  84479. * @return the texture itself allowing "fluent" like uniform updates
  84480. */
  84481. setMatrix(name: string, value: Matrix): ProceduralTexture;
  84482. /**
  84483. * Render the texture to its associated render target.
  84484. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  84485. */
  84486. render(useCameraPostProcess?: boolean): void;
  84487. /**
  84488. * Clone the texture.
  84489. * @returns the cloned texture
  84490. */
  84491. clone(): ProceduralTexture;
  84492. /**
  84493. * Dispose the texture and release its asoociated resources.
  84494. */
  84495. dispose(): void;
  84496. }
  84497. }
  84498. declare module BABYLON {
  84499. /**
  84500. * This represents the base class for particle system in Babylon.
  84501. * 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.
  84502. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84503. * @example https://doc.babylonjs.com/babylon101/particles
  84504. */
  84505. export class BaseParticleSystem {
  84506. /**
  84507. * Source color is added to the destination color without alpha affecting the result
  84508. */
  84509. static BLENDMODE_ONEONE: number;
  84510. /**
  84511. * Blend current color and particle color using particle’s alpha
  84512. */
  84513. static BLENDMODE_STANDARD: number;
  84514. /**
  84515. * Add current color and particle color multiplied by particle’s alpha
  84516. */
  84517. static BLENDMODE_ADD: number;
  84518. /**
  84519. * Multiply current color with particle color
  84520. */
  84521. static BLENDMODE_MULTIPLY: number;
  84522. /**
  84523. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  84524. */
  84525. static BLENDMODE_MULTIPLYADD: number;
  84526. /**
  84527. * List of animations used by the particle system.
  84528. */
  84529. animations: Animation[];
  84530. /**
  84531. * The id of the Particle system.
  84532. */
  84533. id: string;
  84534. /**
  84535. * The friendly name of the Particle system.
  84536. */
  84537. name: string;
  84538. /**
  84539. * The rendering group used by the Particle system to chose when to render.
  84540. */
  84541. renderingGroupId: number;
  84542. /**
  84543. * The emitter represents the Mesh or position we are attaching the particle system to.
  84544. */
  84545. emitter: Nullable<AbstractMesh | Vector3>;
  84546. /**
  84547. * The maximum number of particles to emit per frame
  84548. */
  84549. emitRate: number;
  84550. /**
  84551. * If you want to launch only a few particles at once, that can be done, as well.
  84552. */
  84553. manualEmitCount: number;
  84554. /**
  84555. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  84556. */
  84557. updateSpeed: number;
  84558. /**
  84559. * The amount of time the particle system is running (depends of the overall update speed).
  84560. */
  84561. targetStopDuration: number;
  84562. /**
  84563. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84564. */
  84565. disposeOnStop: boolean;
  84566. /**
  84567. * Minimum power of emitting particles.
  84568. */
  84569. minEmitPower: number;
  84570. /**
  84571. * Maximum power of emitting particles.
  84572. */
  84573. maxEmitPower: number;
  84574. /**
  84575. * Minimum life time of emitting particles.
  84576. */
  84577. minLifeTime: number;
  84578. /**
  84579. * Maximum life time of emitting particles.
  84580. */
  84581. maxLifeTime: number;
  84582. /**
  84583. * Minimum Size of emitting particles.
  84584. */
  84585. minSize: number;
  84586. /**
  84587. * Maximum Size of emitting particles.
  84588. */
  84589. maxSize: number;
  84590. /**
  84591. * Minimum scale of emitting particles on X axis.
  84592. */
  84593. minScaleX: number;
  84594. /**
  84595. * Maximum scale of emitting particles on X axis.
  84596. */
  84597. maxScaleX: number;
  84598. /**
  84599. * Minimum scale of emitting particles on Y axis.
  84600. */
  84601. minScaleY: number;
  84602. /**
  84603. * Maximum scale of emitting particles on Y axis.
  84604. */
  84605. maxScaleY: number;
  84606. /**
  84607. * Gets or sets the minimal initial rotation in radians.
  84608. */
  84609. minInitialRotation: number;
  84610. /**
  84611. * Gets or sets the maximal initial rotation in radians.
  84612. */
  84613. maxInitialRotation: number;
  84614. /**
  84615. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84616. */
  84617. minAngularSpeed: number;
  84618. /**
  84619. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84620. */
  84621. maxAngularSpeed: number;
  84622. /**
  84623. * The texture used to render each particle. (this can be a spritesheet)
  84624. */
  84625. particleTexture: Nullable<Texture>;
  84626. /**
  84627. * The layer mask we are rendering the particles through.
  84628. */
  84629. layerMask: number;
  84630. /**
  84631. * This can help using your own shader to render the particle system.
  84632. * The according effect will be created
  84633. */
  84634. customShader: any;
  84635. /**
  84636. * By default particle system starts as soon as they are created. This prevents the
  84637. * automatic start to happen and let you decide when to start emitting particles.
  84638. */
  84639. preventAutoStart: boolean;
  84640. private _noiseTexture;
  84641. /**
  84642. * Gets or sets a texture used to add random noise to particle positions
  84643. */
  84644. get noiseTexture(): Nullable<ProceduralTexture>;
  84645. set noiseTexture(value: Nullable<ProceduralTexture>);
  84646. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  84647. noiseStrength: Vector3;
  84648. /**
  84649. * Callback triggered when the particle animation is ending.
  84650. */
  84651. onAnimationEnd: Nullable<() => void>;
  84652. /**
  84653. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  84654. */
  84655. blendMode: number;
  84656. /**
  84657. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  84658. * to override the particles.
  84659. */
  84660. forceDepthWrite: boolean;
  84661. /** 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 */
  84662. preWarmCycles: number;
  84663. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  84664. preWarmStepOffset: number;
  84665. /**
  84666. * 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)
  84667. */
  84668. spriteCellChangeSpeed: number;
  84669. /**
  84670. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84671. */
  84672. startSpriteCellID: number;
  84673. /**
  84674. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84675. */
  84676. endSpriteCellID: number;
  84677. /**
  84678. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84679. */
  84680. spriteCellWidth: number;
  84681. /**
  84682. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84683. */
  84684. spriteCellHeight: number;
  84685. /**
  84686. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84687. */
  84688. spriteRandomStartCell: boolean;
  84689. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84690. translationPivot: Vector2;
  84691. /** @hidden */
  84692. protected _isAnimationSheetEnabled: boolean;
  84693. /**
  84694. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84695. */
  84696. beginAnimationOnStart: boolean;
  84697. /**
  84698. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84699. */
  84700. beginAnimationFrom: number;
  84701. /**
  84702. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84703. */
  84704. beginAnimationTo: number;
  84705. /**
  84706. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84707. */
  84708. beginAnimationLoop: boolean;
  84709. /**
  84710. * Gets or sets a world offset applied to all particles
  84711. */
  84712. worldOffset: Vector3;
  84713. /**
  84714. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  84715. */
  84716. get isAnimationSheetEnabled(): boolean;
  84717. set isAnimationSheetEnabled(value: boolean);
  84718. /**
  84719. * Get hosting scene
  84720. * @returns the scene
  84721. */
  84722. getScene(): Scene;
  84723. /**
  84724. * You can use gravity if you want to give an orientation to your particles.
  84725. */
  84726. gravity: Vector3;
  84727. protected _colorGradients: Nullable<Array<ColorGradient>>;
  84728. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  84729. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  84730. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  84731. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  84732. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  84733. protected _dragGradients: Nullable<Array<FactorGradient>>;
  84734. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  84735. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  84736. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  84737. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  84738. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  84739. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  84740. /**
  84741. * Defines the delay in milliseconds before starting the system (0 by default)
  84742. */
  84743. startDelay: number;
  84744. /**
  84745. * Gets the current list of drag gradients.
  84746. * You must use addDragGradient and removeDragGradient to udpate this list
  84747. * @returns the list of drag gradients
  84748. */
  84749. getDragGradients(): Nullable<Array<FactorGradient>>;
  84750. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84751. limitVelocityDamping: number;
  84752. /**
  84753. * Gets the current list of limit velocity gradients.
  84754. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84755. * @returns the list of limit velocity gradients
  84756. */
  84757. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84758. /**
  84759. * Gets the current list of color gradients.
  84760. * You must use addColorGradient and removeColorGradient to udpate this list
  84761. * @returns the list of color gradients
  84762. */
  84763. getColorGradients(): Nullable<Array<ColorGradient>>;
  84764. /**
  84765. * Gets the current list of size gradients.
  84766. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84767. * @returns the list of size gradients
  84768. */
  84769. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84770. /**
  84771. * Gets the current list of color remap gradients.
  84772. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84773. * @returns the list of color remap gradients
  84774. */
  84775. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84776. /**
  84777. * Gets the current list of alpha remap gradients.
  84778. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84779. * @returns the list of alpha remap gradients
  84780. */
  84781. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84782. /**
  84783. * Gets the current list of life time gradients.
  84784. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84785. * @returns the list of life time gradients
  84786. */
  84787. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84788. /**
  84789. * Gets the current list of angular speed gradients.
  84790. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84791. * @returns the list of angular speed gradients
  84792. */
  84793. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84794. /**
  84795. * Gets the current list of velocity gradients.
  84796. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84797. * @returns the list of velocity gradients
  84798. */
  84799. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84800. /**
  84801. * Gets the current list of start size gradients.
  84802. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84803. * @returns the list of start size gradients
  84804. */
  84805. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84806. /**
  84807. * Gets the current list of emit rate gradients.
  84808. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84809. * @returns the list of emit rate gradients
  84810. */
  84811. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84812. /**
  84813. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84814. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84815. */
  84816. get direction1(): Vector3;
  84817. set direction1(value: Vector3);
  84818. /**
  84819. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84820. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84821. */
  84822. get direction2(): Vector3;
  84823. set direction2(value: Vector3);
  84824. /**
  84825. * 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.
  84826. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84827. */
  84828. get minEmitBox(): Vector3;
  84829. set minEmitBox(value: Vector3);
  84830. /**
  84831. * 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.
  84832. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84833. */
  84834. get maxEmitBox(): Vector3;
  84835. set maxEmitBox(value: Vector3);
  84836. /**
  84837. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84838. */
  84839. color1: Color4;
  84840. /**
  84841. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84842. */
  84843. color2: Color4;
  84844. /**
  84845. * Color the particle will have at the end of its lifetime
  84846. */
  84847. colorDead: Color4;
  84848. /**
  84849. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  84850. */
  84851. textureMask: Color4;
  84852. /**
  84853. * The particle emitter type defines the emitter used by the particle system.
  84854. * It can be for example box, sphere, or cone...
  84855. */
  84856. particleEmitterType: IParticleEmitterType;
  84857. /** @hidden */
  84858. _isSubEmitter: boolean;
  84859. /**
  84860. * Gets or sets the billboard mode to use when isBillboardBased = true.
  84861. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  84862. */
  84863. billboardMode: number;
  84864. protected _isBillboardBased: boolean;
  84865. /**
  84866. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  84867. */
  84868. get isBillboardBased(): boolean;
  84869. set isBillboardBased(value: boolean);
  84870. /**
  84871. * The scene the particle system belongs to.
  84872. */
  84873. protected _scene: Scene;
  84874. /**
  84875. * Local cache of defines for image processing.
  84876. */
  84877. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  84878. /**
  84879. * Default configuration related to image processing available in the standard Material.
  84880. */
  84881. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  84882. /**
  84883. * Gets the image processing configuration used either in this material.
  84884. */
  84885. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  84886. /**
  84887. * Sets the Default image processing configuration used either in the this material.
  84888. *
  84889. * If sets to null, the scene one is in use.
  84890. */
  84891. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  84892. /**
  84893. * Attaches a new image processing configuration to the Standard Material.
  84894. * @param configuration
  84895. */
  84896. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  84897. /** @hidden */
  84898. protected _reset(): void;
  84899. /** @hidden */
  84900. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  84901. /**
  84902. * Instantiates a particle system.
  84903. * 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.
  84904. * @param name The name of the particle system
  84905. */
  84906. constructor(name: string);
  84907. /**
  84908. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84909. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84910. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84911. * @returns the emitter
  84912. */
  84913. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84914. /**
  84915. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84916. * @param radius The radius of the hemisphere to emit from
  84917. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84918. * @returns the emitter
  84919. */
  84920. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  84921. /**
  84922. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84923. * @param radius The radius of the sphere to emit from
  84924. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84925. * @returns the emitter
  84926. */
  84927. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  84928. /**
  84929. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84930. * @param radius The radius of the sphere to emit from
  84931. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84932. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84933. * @returns the emitter
  84934. */
  84935. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  84936. /**
  84937. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84938. * @param radius The radius of the emission cylinder
  84939. * @param height The height of the emission cylinder
  84940. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84941. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84942. * @returns the emitter
  84943. */
  84944. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  84945. /**
  84946. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84947. * @param radius The radius of the cylinder to emit from
  84948. * @param height The height of the emission cylinder
  84949. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84950. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84951. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84952. * @returns the emitter
  84953. */
  84954. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  84955. /**
  84956. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84957. * @param radius The radius of the cone to emit from
  84958. * @param angle The base angle of the cone
  84959. * @returns the emitter
  84960. */
  84961. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  84962. /**
  84963. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84964. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84965. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84966. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84967. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84968. * @returns the emitter
  84969. */
  84970. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84971. }
  84972. }
  84973. declare module BABYLON {
  84974. /**
  84975. * Type of sub emitter
  84976. */
  84977. export enum SubEmitterType {
  84978. /**
  84979. * Attached to the particle over it's lifetime
  84980. */
  84981. ATTACHED = 0,
  84982. /**
  84983. * Created when the particle dies
  84984. */
  84985. END = 1
  84986. }
  84987. /**
  84988. * Sub emitter class used to emit particles from an existing particle
  84989. */
  84990. export class SubEmitter {
  84991. /**
  84992. * the particle system to be used by the sub emitter
  84993. */
  84994. particleSystem: ParticleSystem;
  84995. /**
  84996. * Type of the submitter (Default: END)
  84997. */
  84998. type: SubEmitterType;
  84999. /**
  85000. * 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)
  85001. * Note: This only is supported when using an emitter of type Mesh
  85002. */
  85003. inheritDirection: boolean;
  85004. /**
  85005. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  85006. */
  85007. inheritedVelocityAmount: number;
  85008. /**
  85009. * Creates a sub emitter
  85010. * @param particleSystem the particle system to be used by the sub emitter
  85011. */
  85012. constructor(
  85013. /**
  85014. * the particle system to be used by the sub emitter
  85015. */
  85016. particleSystem: ParticleSystem);
  85017. /**
  85018. * Clones the sub emitter
  85019. * @returns the cloned sub emitter
  85020. */
  85021. clone(): SubEmitter;
  85022. /**
  85023. * Serialize current object to a JSON object
  85024. * @returns the serialized object
  85025. */
  85026. serialize(): any;
  85027. /** @hidden */
  85028. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  85029. /**
  85030. * Creates a new SubEmitter from a serialized JSON version
  85031. * @param serializationObject defines the JSON object to read from
  85032. * @param scene defines the hosting scene
  85033. * @param rootUrl defines the rootUrl for data loading
  85034. * @returns a new SubEmitter
  85035. */
  85036. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  85037. /** Release associated resources */
  85038. dispose(): void;
  85039. }
  85040. }
  85041. declare module BABYLON {
  85042. /** @hidden */
  85043. export var imageProcessingDeclaration: {
  85044. name: string;
  85045. shader: string;
  85046. };
  85047. }
  85048. declare module BABYLON {
  85049. /** @hidden */
  85050. export var imageProcessingFunctions: {
  85051. name: string;
  85052. shader: string;
  85053. };
  85054. }
  85055. declare module BABYLON {
  85056. /** @hidden */
  85057. export var particlesPixelShader: {
  85058. name: string;
  85059. shader: string;
  85060. };
  85061. }
  85062. declare module BABYLON {
  85063. /** @hidden */
  85064. export var particlesVertexShader: {
  85065. name: string;
  85066. shader: string;
  85067. };
  85068. }
  85069. declare module BABYLON {
  85070. /**
  85071. * This represents a particle system in Babylon.
  85072. * 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.
  85073. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  85074. * @example https://doc.babylonjs.com/babylon101/particles
  85075. */
  85076. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  85077. /**
  85078. * Billboard mode will only apply to Y axis
  85079. */
  85080. static readonly BILLBOARDMODE_Y: number;
  85081. /**
  85082. * Billboard mode will apply to all axes
  85083. */
  85084. static readonly BILLBOARDMODE_ALL: number;
  85085. /**
  85086. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  85087. */
  85088. static readonly BILLBOARDMODE_STRETCHED: number;
  85089. /**
  85090. * This function can be defined to provide custom update for active particles.
  85091. * This function will be called instead of regular update (age, position, color, etc.).
  85092. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  85093. */
  85094. updateFunction: (particles: Particle[]) => void;
  85095. private _emitterWorldMatrix;
  85096. /**
  85097. * This function can be defined to specify initial direction for every new particle.
  85098. * It by default use the emitterType defined function
  85099. */
  85100. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  85101. /**
  85102. * This function can be defined to specify initial position for every new particle.
  85103. * It by default use the emitterType defined function
  85104. */
  85105. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  85106. /**
  85107. * @hidden
  85108. */
  85109. _inheritedVelocityOffset: Vector3;
  85110. /**
  85111. * An event triggered when the system is disposed
  85112. */
  85113. onDisposeObservable: Observable<ParticleSystem>;
  85114. private _onDisposeObserver;
  85115. /**
  85116. * Sets a callback that will be triggered when the system is disposed
  85117. */
  85118. set onDispose(callback: () => void);
  85119. private _particles;
  85120. private _epsilon;
  85121. private _capacity;
  85122. private _stockParticles;
  85123. private _newPartsExcess;
  85124. private _vertexData;
  85125. private _vertexBuffer;
  85126. private _vertexBuffers;
  85127. private _spriteBuffer;
  85128. private _indexBuffer;
  85129. private _effect;
  85130. private _customEffect;
  85131. private _cachedDefines;
  85132. private _scaledColorStep;
  85133. private _colorDiff;
  85134. private _scaledDirection;
  85135. private _scaledGravity;
  85136. private _currentRenderId;
  85137. private _alive;
  85138. private _useInstancing;
  85139. private _started;
  85140. private _stopped;
  85141. private _actualFrame;
  85142. private _scaledUpdateSpeed;
  85143. private _vertexBufferSize;
  85144. /** @hidden */
  85145. _currentEmitRateGradient: Nullable<FactorGradient>;
  85146. /** @hidden */
  85147. _currentEmitRate1: number;
  85148. /** @hidden */
  85149. _currentEmitRate2: number;
  85150. /** @hidden */
  85151. _currentStartSizeGradient: Nullable<FactorGradient>;
  85152. /** @hidden */
  85153. _currentStartSize1: number;
  85154. /** @hidden */
  85155. _currentStartSize2: number;
  85156. private readonly _rawTextureWidth;
  85157. private _rampGradientsTexture;
  85158. private _useRampGradients;
  85159. /** Gets or sets a boolean indicating that ramp gradients must be used
  85160. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85161. */
  85162. get useRampGradients(): boolean;
  85163. set useRampGradients(value: boolean);
  85164. /**
  85165. * 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.
  85166. * 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: [])
  85167. */
  85168. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  85169. private _subEmitters;
  85170. /**
  85171. * @hidden
  85172. * If the particle systems emitter should be disposed when the particle system is disposed
  85173. */
  85174. _disposeEmitterOnDispose: boolean;
  85175. /**
  85176. * The current active Sub-systems, this property is used by the root particle system only.
  85177. */
  85178. activeSubSystems: Array<ParticleSystem>;
  85179. /**
  85180. * Specifies if the particles are updated in emitter local space or world space
  85181. */
  85182. isLocal: boolean;
  85183. private _rootParticleSystem;
  85184. /**
  85185. * Gets the current list of active particles
  85186. */
  85187. get particles(): Particle[];
  85188. /**
  85189. * Returns the string "ParticleSystem"
  85190. * @returns a string containing the class name
  85191. */
  85192. getClassName(): string;
  85193. /**
  85194. * Instantiates a particle system.
  85195. * 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.
  85196. * @param name The name of the particle system
  85197. * @param capacity The max number of particles alive at the same time
  85198. * @param scene The scene the particle system belongs to
  85199. * @param customEffect a custom effect used to change the way particles are rendered by default
  85200. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  85201. * @param epsilon Offset used to render the particles
  85202. */
  85203. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  85204. private _addFactorGradient;
  85205. private _removeFactorGradient;
  85206. /**
  85207. * Adds a new life time gradient
  85208. * @param gradient defines the gradient to use (between 0 and 1)
  85209. * @param factor defines the life time factor to affect to the specified gradient
  85210. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85211. * @returns the current particle system
  85212. */
  85213. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85214. /**
  85215. * Remove a specific life time gradient
  85216. * @param gradient defines the gradient to remove
  85217. * @returns the current particle system
  85218. */
  85219. removeLifeTimeGradient(gradient: number): IParticleSystem;
  85220. /**
  85221. * Adds a new size gradient
  85222. * @param gradient defines the gradient to use (between 0 and 1)
  85223. * @param factor defines the size factor to affect to the specified gradient
  85224. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85225. * @returns the current particle system
  85226. */
  85227. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85228. /**
  85229. * Remove a specific size gradient
  85230. * @param gradient defines the gradient to remove
  85231. * @returns the current particle system
  85232. */
  85233. removeSizeGradient(gradient: number): IParticleSystem;
  85234. /**
  85235. * Adds a new color remap gradient
  85236. * @param gradient defines the gradient to use (between 0 and 1)
  85237. * @param min defines the color remap minimal range
  85238. * @param max defines the color remap maximal range
  85239. * @returns the current particle system
  85240. */
  85241. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85242. /**
  85243. * Remove a specific color remap gradient
  85244. * @param gradient defines the gradient to remove
  85245. * @returns the current particle system
  85246. */
  85247. removeColorRemapGradient(gradient: number): IParticleSystem;
  85248. /**
  85249. * Adds a new alpha remap gradient
  85250. * @param gradient defines the gradient to use (between 0 and 1)
  85251. * @param min defines the alpha remap minimal range
  85252. * @param max defines the alpha remap maximal range
  85253. * @returns the current particle system
  85254. */
  85255. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85256. /**
  85257. * Remove a specific alpha remap gradient
  85258. * @param gradient defines the gradient to remove
  85259. * @returns the current particle system
  85260. */
  85261. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  85262. /**
  85263. * Adds a new angular speed gradient
  85264. * @param gradient defines the gradient to use (between 0 and 1)
  85265. * @param factor defines the angular speed to affect to the specified gradient
  85266. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85267. * @returns the current particle system
  85268. */
  85269. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85270. /**
  85271. * Remove a specific angular speed gradient
  85272. * @param gradient defines the gradient to remove
  85273. * @returns the current particle system
  85274. */
  85275. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85276. /**
  85277. * Adds a new velocity gradient
  85278. * @param gradient defines the gradient to use (between 0 and 1)
  85279. * @param factor defines the velocity to affect to the specified gradient
  85280. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85281. * @returns the current particle system
  85282. */
  85283. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85284. /**
  85285. * Remove a specific velocity gradient
  85286. * @param gradient defines the gradient to remove
  85287. * @returns the current particle system
  85288. */
  85289. removeVelocityGradient(gradient: number): IParticleSystem;
  85290. /**
  85291. * Adds a new limit velocity gradient
  85292. * @param gradient defines the gradient to use (between 0 and 1)
  85293. * @param factor defines the limit velocity value to affect to the specified gradient
  85294. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85295. * @returns the current particle system
  85296. */
  85297. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85298. /**
  85299. * Remove a specific limit velocity gradient
  85300. * @param gradient defines the gradient to remove
  85301. * @returns the current particle system
  85302. */
  85303. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85304. /**
  85305. * Adds a new drag gradient
  85306. * @param gradient defines the gradient to use (between 0 and 1)
  85307. * @param factor defines the drag value to affect to the specified gradient
  85308. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85309. * @returns the current particle system
  85310. */
  85311. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85312. /**
  85313. * Remove a specific drag gradient
  85314. * @param gradient defines the gradient to remove
  85315. * @returns the current particle system
  85316. */
  85317. removeDragGradient(gradient: number): IParticleSystem;
  85318. /**
  85319. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85320. * @param gradient defines the gradient to use (between 0 and 1)
  85321. * @param factor defines the emit rate value to affect to the specified gradient
  85322. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85323. * @returns the current particle system
  85324. */
  85325. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85326. /**
  85327. * Remove a specific emit rate gradient
  85328. * @param gradient defines the gradient to remove
  85329. * @returns the current particle system
  85330. */
  85331. removeEmitRateGradient(gradient: number): IParticleSystem;
  85332. /**
  85333. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85334. * @param gradient defines the gradient to use (between 0 and 1)
  85335. * @param factor defines the start size value to affect to the specified gradient
  85336. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85337. * @returns the current particle system
  85338. */
  85339. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85340. /**
  85341. * Remove a specific start size gradient
  85342. * @param gradient defines the gradient to remove
  85343. * @returns the current particle system
  85344. */
  85345. removeStartSizeGradient(gradient: number): IParticleSystem;
  85346. private _createRampGradientTexture;
  85347. /**
  85348. * Gets the current list of ramp gradients.
  85349. * You must use addRampGradient and removeRampGradient to udpate this list
  85350. * @returns the list of ramp gradients
  85351. */
  85352. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85353. /**
  85354. * Adds a new ramp gradient used to remap particle colors
  85355. * @param gradient defines the gradient to use (between 0 and 1)
  85356. * @param color defines the color to affect to the specified gradient
  85357. * @returns the current particle system
  85358. */
  85359. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  85360. /**
  85361. * Remove a specific ramp gradient
  85362. * @param gradient defines the gradient to remove
  85363. * @returns the current particle system
  85364. */
  85365. removeRampGradient(gradient: number): ParticleSystem;
  85366. /**
  85367. * Adds a new color gradient
  85368. * @param gradient defines the gradient to use (between 0 and 1)
  85369. * @param color1 defines the color to affect to the specified gradient
  85370. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85371. * @returns this particle system
  85372. */
  85373. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85374. /**
  85375. * Remove a specific color gradient
  85376. * @param gradient defines the gradient to remove
  85377. * @returns this particle system
  85378. */
  85379. removeColorGradient(gradient: number): IParticleSystem;
  85380. private _fetchR;
  85381. protected _reset(): void;
  85382. private _resetEffect;
  85383. private _createVertexBuffers;
  85384. private _createIndexBuffer;
  85385. /**
  85386. * Gets the maximum number of particles active at the same time.
  85387. * @returns The max number of active particles.
  85388. */
  85389. getCapacity(): number;
  85390. /**
  85391. * Gets whether there are still active particles in the system.
  85392. * @returns True if it is alive, otherwise false.
  85393. */
  85394. isAlive(): boolean;
  85395. /**
  85396. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85397. * @returns True if it has been started, otherwise false.
  85398. */
  85399. isStarted(): boolean;
  85400. private _prepareSubEmitterInternalArray;
  85401. /**
  85402. * Starts the particle system and begins to emit
  85403. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  85404. */
  85405. start(delay?: number): void;
  85406. /**
  85407. * Stops the particle system.
  85408. * @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.
  85409. */
  85410. stop(stopSubEmitters?: boolean): void;
  85411. /**
  85412. * Remove all active particles
  85413. */
  85414. reset(): void;
  85415. /**
  85416. * @hidden (for internal use only)
  85417. */
  85418. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  85419. /**
  85420. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  85421. * Its lifetime will start back at 0.
  85422. */
  85423. recycleParticle: (particle: Particle) => void;
  85424. private _stopSubEmitters;
  85425. private _createParticle;
  85426. private _removeFromRoot;
  85427. private _emitFromParticle;
  85428. private _update;
  85429. /** @hidden */
  85430. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  85431. /** @hidden */
  85432. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  85433. /** @hidden */
  85434. private _getEffect;
  85435. /**
  85436. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  85437. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  85438. */
  85439. animate(preWarmOnly?: boolean): void;
  85440. private _appendParticleVertices;
  85441. /**
  85442. * Rebuilds the particle system.
  85443. */
  85444. rebuild(): void;
  85445. /**
  85446. * Is this system ready to be used/rendered
  85447. * @return true if the system is ready
  85448. */
  85449. isReady(): boolean;
  85450. private _render;
  85451. /**
  85452. * Renders the particle system in its current state.
  85453. * @returns the current number of particles
  85454. */
  85455. render(): number;
  85456. /**
  85457. * Disposes the particle system and free the associated resources
  85458. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85459. */
  85460. dispose(disposeTexture?: boolean): void;
  85461. /**
  85462. * Clones the particle system.
  85463. * @param name The name of the cloned object
  85464. * @param newEmitter The new emitter to use
  85465. * @returns the cloned particle system
  85466. */
  85467. clone(name: string, newEmitter: any): ParticleSystem;
  85468. /**
  85469. * Serializes the particle system to a JSON object.
  85470. * @returns the JSON object
  85471. */
  85472. serialize(): any;
  85473. /** @hidden */
  85474. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  85475. /** @hidden */
  85476. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  85477. /**
  85478. * Parses a JSON object to create a particle system.
  85479. * @param parsedParticleSystem The JSON object to parse
  85480. * @param scene The scene to create the particle system in
  85481. * @param rootUrl The root url to use to load external dependencies like texture
  85482. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  85483. * @returns the Parsed particle system
  85484. */
  85485. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  85486. }
  85487. }
  85488. declare module BABYLON {
  85489. /**
  85490. * A particle represents one of the element emitted by a particle system.
  85491. * This is mainly define by its coordinates, direction, velocity and age.
  85492. */
  85493. export class Particle {
  85494. /**
  85495. * The particle system the particle belongs to.
  85496. */
  85497. particleSystem: ParticleSystem;
  85498. private static _Count;
  85499. /**
  85500. * Unique ID of the particle
  85501. */
  85502. id: number;
  85503. /**
  85504. * The world position of the particle in the scene.
  85505. */
  85506. position: Vector3;
  85507. /**
  85508. * The world direction of the particle in the scene.
  85509. */
  85510. direction: Vector3;
  85511. /**
  85512. * The color of the particle.
  85513. */
  85514. color: Color4;
  85515. /**
  85516. * The color change of the particle per step.
  85517. */
  85518. colorStep: Color4;
  85519. /**
  85520. * Defines how long will the life of the particle be.
  85521. */
  85522. lifeTime: number;
  85523. /**
  85524. * The current age of the particle.
  85525. */
  85526. age: number;
  85527. /**
  85528. * The current size of the particle.
  85529. */
  85530. size: number;
  85531. /**
  85532. * The current scale of the particle.
  85533. */
  85534. scale: Vector2;
  85535. /**
  85536. * The current angle of the particle.
  85537. */
  85538. angle: number;
  85539. /**
  85540. * Defines how fast is the angle changing.
  85541. */
  85542. angularSpeed: number;
  85543. /**
  85544. * Defines the cell index used by the particle to be rendered from a sprite.
  85545. */
  85546. cellIndex: number;
  85547. /**
  85548. * The information required to support color remapping
  85549. */
  85550. remapData: Vector4;
  85551. /** @hidden */
  85552. _randomCellOffset?: number;
  85553. /** @hidden */
  85554. _initialDirection: Nullable<Vector3>;
  85555. /** @hidden */
  85556. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  85557. /** @hidden */
  85558. _initialStartSpriteCellID: number;
  85559. /** @hidden */
  85560. _initialEndSpriteCellID: number;
  85561. /** @hidden */
  85562. _currentColorGradient: Nullable<ColorGradient>;
  85563. /** @hidden */
  85564. _currentColor1: Color4;
  85565. /** @hidden */
  85566. _currentColor2: Color4;
  85567. /** @hidden */
  85568. _currentSizeGradient: Nullable<FactorGradient>;
  85569. /** @hidden */
  85570. _currentSize1: number;
  85571. /** @hidden */
  85572. _currentSize2: number;
  85573. /** @hidden */
  85574. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  85575. /** @hidden */
  85576. _currentAngularSpeed1: number;
  85577. /** @hidden */
  85578. _currentAngularSpeed2: number;
  85579. /** @hidden */
  85580. _currentVelocityGradient: Nullable<FactorGradient>;
  85581. /** @hidden */
  85582. _currentVelocity1: number;
  85583. /** @hidden */
  85584. _currentVelocity2: number;
  85585. /** @hidden */
  85586. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  85587. /** @hidden */
  85588. _currentLimitVelocity1: number;
  85589. /** @hidden */
  85590. _currentLimitVelocity2: number;
  85591. /** @hidden */
  85592. _currentDragGradient: Nullable<FactorGradient>;
  85593. /** @hidden */
  85594. _currentDrag1: number;
  85595. /** @hidden */
  85596. _currentDrag2: number;
  85597. /** @hidden */
  85598. _randomNoiseCoordinates1: Vector3;
  85599. /** @hidden */
  85600. _randomNoiseCoordinates2: Vector3;
  85601. /** @hidden */
  85602. _localPosition?: Vector3;
  85603. /**
  85604. * Creates a new instance Particle
  85605. * @param particleSystem the particle system the particle belongs to
  85606. */
  85607. constructor(
  85608. /**
  85609. * The particle system the particle belongs to.
  85610. */
  85611. particleSystem: ParticleSystem);
  85612. private updateCellInfoFromSystem;
  85613. /**
  85614. * Defines how the sprite cell index is updated for the particle
  85615. */
  85616. updateCellIndex(): void;
  85617. /** @hidden */
  85618. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  85619. /** @hidden */
  85620. _inheritParticleInfoToSubEmitters(): void;
  85621. /** @hidden */
  85622. _reset(): void;
  85623. /**
  85624. * Copy the properties of particle to another one.
  85625. * @param other the particle to copy the information to.
  85626. */
  85627. copyTo(other: Particle): void;
  85628. }
  85629. }
  85630. declare module BABYLON {
  85631. /**
  85632. * Particle emitter represents a volume emitting particles.
  85633. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  85634. */
  85635. export interface IParticleEmitterType {
  85636. /**
  85637. * Called by the particle System when the direction is computed for the created particle.
  85638. * @param worldMatrix is the world matrix of the particle system
  85639. * @param directionToUpdate is the direction vector to update with the result
  85640. * @param particle is the particle we are computed the direction for
  85641. * @param isLocal defines if the direction should be set in local space
  85642. */
  85643. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85644. /**
  85645. * Called by the particle System when the position is computed for the created particle.
  85646. * @param worldMatrix is the world matrix of the particle system
  85647. * @param positionToUpdate is the position vector to update with the result
  85648. * @param particle is the particle we are computed the position for
  85649. * @param isLocal defines if the position should be set in local space
  85650. */
  85651. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85652. /**
  85653. * Clones the current emitter and returns a copy of it
  85654. * @returns the new emitter
  85655. */
  85656. clone(): IParticleEmitterType;
  85657. /**
  85658. * Called by the GPUParticleSystem to setup the update shader
  85659. * @param effect defines the update shader
  85660. */
  85661. applyToShader(effect: Effect): void;
  85662. /**
  85663. * Returns a string to use to update the GPU particles update shader
  85664. * @returns the effect defines string
  85665. */
  85666. getEffectDefines(): string;
  85667. /**
  85668. * Returns a string representing the class name
  85669. * @returns a string containing the class name
  85670. */
  85671. getClassName(): string;
  85672. /**
  85673. * Serializes the particle system to a JSON object.
  85674. * @returns the JSON object
  85675. */
  85676. serialize(): any;
  85677. /**
  85678. * Parse properties from a JSON object
  85679. * @param serializationObject defines the JSON object
  85680. * @param scene defines the hosting scene
  85681. */
  85682. parse(serializationObject: any, scene: Scene): void;
  85683. }
  85684. }
  85685. declare module BABYLON {
  85686. /**
  85687. * Particle emitter emitting particles from the inside of a box.
  85688. * It emits the particles randomly between 2 given directions.
  85689. */
  85690. export class BoxParticleEmitter implements IParticleEmitterType {
  85691. /**
  85692. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85693. */
  85694. direction1: Vector3;
  85695. /**
  85696. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85697. */
  85698. direction2: Vector3;
  85699. /**
  85700. * 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.
  85701. */
  85702. minEmitBox: Vector3;
  85703. /**
  85704. * 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.
  85705. */
  85706. maxEmitBox: Vector3;
  85707. /**
  85708. * Creates a new instance BoxParticleEmitter
  85709. */
  85710. constructor();
  85711. /**
  85712. * Called by the particle System when the direction is computed for the created particle.
  85713. * @param worldMatrix is the world matrix of the particle system
  85714. * @param directionToUpdate is the direction vector to update with the result
  85715. * @param particle is the particle we are computed the direction for
  85716. * @param isLocal defines if the direction should be set in local space
  85717. */
  85718. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85719. /**
  85720. * Called by the particle System when the position is computed for the created particle.
  85721. * @param worldMatrix is the world matrix of the particle system
  85722. * @param positionToUpdate is the position vector to update with the result
  85723. * @param particle is the particle we are computed the position for
  85724. * @param isLocal defines if the position should be set in local space
  85725. */
  85726. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85727. /**
  85728. * Clones the current emitter and returns a copy of it
  85729. * @returns the new emitter
  85730. */
  85731. clone(): BoxParticleEmitter;
  85732. /**
  85733. * Called by the GPUParticleSystem to setup the update shader
  85734. * @param effect defines the update shader
  85735. */
  85736. applyToShader(effect: Effect): void;
  85737. /**
  85738. * Returns a string to use to update the GPU particles update shader
  85739. * @returns a string containng the defines string
  85740. */
  85741. getEffectDefines(): string;
  85742. /**
  85743. * Returns the string "BoxParticleEmitter"
  85744. * @returns a string containing the class name
  85745. */
  85746. getClassName(): string;
  85747. /**
  85748. * Serializes the particle system to a JSON object.
  85749. * @returns the JSON object
  85750. */
  85751. serialize(): any;
  85752. /**
  85753. * Parse properties from a JSON object
  85754. * @param serializationObject defines the JSON object
  85755. */
  85756. parse(serializationObject: any): void;
  85757. }
  85758. }
  85759. declare module BABYLON {
  85760. /**
  85761. * Particle emitter emitting particles from the inside of a cone.
  85762. * It emits the particles alongside the cone volume from the base to the particle.
  85763. * The emission direction might be randomized.
  85764. */
  85765. export class ConeParticleEmitter implements IParticleEmitterType {
  85766. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85767. directionRandomizer: number;
  85768. private _radius;
  85769. private _angle;
  85770. private _height;
  85771. /**
  85772. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  85773. */
  85774. radiusRange: number;
  85775. /**
  85776. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  85777. */
  85778. heightRange: number;
  85779. /**
  85780. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  85781. */
  85782. emitFromSpawnPointOnly: boolean;
  85783. /**
  85784. * Gets or sets the radius of the emission cone
  85785. */
  85786. get radius(): number;
  85787. set radius(value: number);
  85788. /**
  85789. * Gets or sets the angle of the emission cone
  85790. */
  85791. get angle(): number;
  85792. set angle(value: number);
  85793. private _buildHeight;
  85794. /**
  85795. * Creates a new instance ConeParticleEmitter
  85796. * @param radius the radius of the emission cone (1 by default)
  85797. * @param angle the cone base angle (PI by default)
  85798. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  85799. */
  85800. constructor(radius?: number, angle?: number,
  85801. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85802. directionRandomizer?: number);
  85803. /**
  85804. * Called by the particle System when the direction is computed for the created particle.
  85805. * @param worldMatrix is the world matrix of the particle system
  85806. * @param directionToUpdate is the direction vector to update with the result
  85807. * @param particle is the particle we are computed the direction for
  85808. * @param isLocal defines if the direction should be set in local space
  85809. */
  85810. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85811. /**
  85812. * Called by the particle System when the position is computed for the created particle.
  85813. * @param worldMatrix is the world matrix of the particle system
  85814. * @param positionToUpdate is the position vector to update with the result
  85815. * @param particle is the particle we are computed the position for
  85816. * @param isLocal defines if the position should be set in local space
  85817. */
  85818. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85819. /**
  85820. * Clones the current emitter and returns a copy of it
  85821. * @returns the new emitter
  85822. */
  85823. clone(): ConeParticleEmitter;
  85824. /**
  85825. * Called by the GPUParticleSystem to setup the update shader
  85826. * @param effect defines the update shader
  85827. */
  85828. applyToShader(effect: Effect): void;
  85829. /**
  85830. * Returns a string to use to update the GPU particles update shader
  85831. * @returns a string containng the defines string
  85832. */
  85833. getEffectDefines(): string;
  85834. /**
  85835. * Returns the string "ConeParticleEmitter"
  85836. * @returns a string containing the class name
  85837. */
  85838. getClassName(): string;
  85839. /**
  85840. * Serializes the particle system to a JSON object.
  85841. * @returns the JSON object
  85842. */
  85843. serialize(): any;
  85844. /**
  85845. * Parse properties from a JSON object
  85846. * @param serializationObject defines the JSON object
  85847. */
  85848. parse(serializationObject: any): void;
  85849. }
  85850. }
  85851. declare module BABYLON {
  85852. /**
  85853. * Particle emitter emitting particles from the inside of a cylinder.
  85854. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  85855. */
  85856. export class CylinderParticleEmitter implements IParticleEmitterType {
  85857. /**
  85858. * The radius of the emission cylinder.
  85859. */
  85860. radius: number;
  85861. /**
  85862. * The height of the emission cylinder.
  85863. */
  85864. height: number;
  85865. /**
  85866. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85867. */
  85868. radiusRange: number;
  85869. /**
  85870. * How much to randomize the particle direction [0-1].
  85871. */
  85872. directionRandomizer: number;
  85873. /**
  85874. * Creates a new instance CylinderParticleEmitter
  85875. * @param radius the radius of the emission cylinder (1 by default)
  85876. * @param height the height of the emission cylinder (1 by default)
  85877. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85878. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85879. */
  85880. constructor(
  85881. /**
  85882. * The radius of the emission cylinder.
  85883. */
  85884. radius?: number,
  85885. /**
  85886. * The height of the emission cylinder.
  85887. */
  85888. height?: number,
  85889. /**
  85890. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85891. */
  85892. radiusRange?: number,
  85893. /**
  85894. * How much to randomize the particle direction [0-1].
  85895. */
  85896. directionRandomizer?: number);
  85897. /**
  85898. * Called by the particle System when the direction is computed for the created particle.
  85899. * @param worldMatrix is the world matrix of the particle system
  85900. * @param directionToUpdate is the direction vector to update with the result
  85901. * @param particle is the particle we are computed the direction for
  85902. * @param isLocal defines if the direction should be set in local space
  85903. */
  85904. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85905. /**
  85906. * Called by the particle System when the position is computed for the created particle.
  85907. * @param worldMatrix is the world matrix of the particle system
  85908. * @param positionToUpdate is the position vector to update with the result
  85909. * @param particle is the particle we are computed the position for
  85910. * @param isLocal defines if the position should be set in local space
  85911. */
  85912. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85913. /**
  85914. * Clones the current emitter and returns a copy of it
  85915. * @returns the new emitter
  85916. */
  85917. clone(): CylinderParticleEmitter;
  85918. /**
  85919. * Called by the GPUParticleSystem to setup the update shader
  85920. * @param effect defines the update shader
  85921. */
  85922. applyToShader(effect: Effect): void;
  85923. /**
  85924. * Returns a string to use to update the GPU particles update shader
  85925. * @returns a string containng the defines string
  85926. */
  85927. getEffectDefines(): string;
  85928. /**
  85929. * Returns the string "CylinderParticleEmitter"
  85930. * @returns a string containing the class name
  85931. */
  85932. getClassName(): string;
  85933. /**
  85934. * Serializes the particle system to a JSON object.
  85935. * @returns the JSON object
  85936. */
  85937. serialize(): any;
  85938. /**
  85939. * Parse properties from a JSON object
  85940. * @param serializationObject defines the JSON object
  85941. */
  85942. parse(serializationObject: any): void;
  85943. }
  85944. /**
  85945. * Particle emitter emitting particles from the inside of a cylinder.
  85946. * It emits the particles randomly between two vectors.
  85947. */
  85948. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  85949. /**
  85950. * The min limit of the emission direction.
  85951. */
  85952. direction1: Vector3;
  85953. /**
  85954. * The max limit of the emission direction.
  85955. */
  85956. direction2: Vector3;
  85957. /**
  85958. * Creates a new instance CylinderDirectedParticleEmitter
  85959. * @param radius the radius of the emission cylinder (1 by default)
  85960. * @param height the height of the emission cylinder (1 by default)
  85961. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85962. * @param direction1 the min limit of the emission direction (up vector by default)
  85963. * @param direction2 the max limit of the emission direction (up vector by default)
  85964. */
  85965. constructor(radius?: number, height?: number, radiusRange?: number,
  85966. /**
  85967. * The min limit of the emission direction.
  85968. */
  85969. direction1?: Vector3,
  85970. /**
  85971. * The max limit of the emission direction.
  85972. */
  85973. direction2?: Vector3);
  85974. /**
  85975. * Called by the particle System when the direction is computed for the created particle.
  85976. * @param worldMatrix is the world matrix of the particle system
  85977. * @param directionToUpdate is the direction vector to update with the result
  85978. * @param particle is the particle we are computed the direction for
  85979. */
  85980. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85981. /**
  85982. * Clones the current emitter and returns a copy of it
  85983. * @returns the new emitter
  85984. */
  85985. clone(): CylinderDirectedParticleEmitter;
  85986. /**
  85987. * Called by the GPUParticleSystem to setup the update shader
  85988. * @param effect defines the update shader
  85989. */
  85990. applyToShader(effect: Effect): void;
  85991. /**
  85992. * Returns a string to use to update the GPU particles update shader
  85993. * @returns a string containng the defines string
  85994. */
  85995. getEffectDefines(): string;
  85996. /**
  85997. * Returns the string "CylinderDirectedParticleEmitter"
  85998. * @returns a string containing the class name
  85999. */
  86000. getClassName(): string;
  86001. /**
  86002. * Serializes the particle system to a JSON object.
  86003. * @returns the JSON object
  86004. */
  86005. serialize(): any;
  86006. /**
  86007. * Parse properties from a JSON object
  86008. * @param serializationObject defines the JSON object
  86009. */
  86010. parse(serializationObject: any): void;
  86011. }
  86012. }
  86013. declare module BABYLON {
  86014. /**
  86015. * Particle emitter emitting particles from the inside of a hemisphere.
  86016. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  86017. */
  86018. export class HemisphericParticleEmitter implements IParticleEmitterType {
  86019. /**
  86020. * The radius of the emission hemisphere.
  86021. */
  86022. radius: number;
  86023. /**
  86024. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86025. */
  86026. radiusRange: number;
  86027. /**
  86028. * How much to randomize the particle direction [0-1].
  86029. */
  86030. directionRandomizer: number;
  86031. /**
  86032. * Creates a new instance HemisphericParticleEmitter
  86033. * @param radius the radius of the emission hemisphere (1 by default)
  86034. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86035. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86036. */
  86037. constructor(
  86038. /**
  86039. * The radius of the emission hemisphere.
  86040. */
  86041. radius?: number,
  86042. /**
  86043. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86044. */
  86045. radiusRange?: number,
  86046. /**
  86047. * How much to randomize the particle direction [0-1].
  86048. */
  86049. directionRandomizer?: number);
  86050. /**
  86051. * Called by the particle System when the direction is computed for the created particle.
  86052. * @param worldMatrix is the world matrix of the particle system
  86053. * @param directionToUpdate is the direction vector to update with the result
  86054. * @param particle is the particle we are computed the direction for
  86055. * @param isLocal defines if the direction should be set in local space
  86056. */
  86057. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86058. /**
  86059. * Called by the particle System when the position is computed for the created particle.
  86060. * @param worldMatrix is the world matrix of the particle system
  86061. * @param positionToUpdate is the position vector to update with the result
  86062. * @param particle is the particle we are computed the position for
  86063. * @param isLocal defines if the position should be set in local space
  86064. */
  86065. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86066. /**
  86067. * Clones the current emitter and returns a copy of it
  86068. * @returns the new emitter
  86069. */
  86070. clone(): HemisphericParticleEmitter;
  86071. /**
  86072. * Called by the GPUParticleSystem to setup the update shader
  86073. * @param effect defines the update shader
  86074. */
  86075. applyToShader(effect: Effect): void;
  86076. /**
  86077. * Returns a string to use to update the GPU particles update shader
  86078. * @returns a string containng the defines string
  86079. */
  86080. getEffectDefines(): string;
  86081. /**
  86082. * Returns the string "HemisphericParticleEmitter"
  86083. * @returns a string containing the class name
  86084. */
  86085. getClassName(): string;
  86086. /**
  86087. * Serializes the particle system to a JSON object.
  86088. * @returns the JSON object
  86089. */
  86090. serialize(): any;
  86091. /**
  86092. * Parse properties from a JSON object
  86093. * @param serializationObject defines the JSON object
  86094. */
  86095. parse(serializationObject: any): void;
  86096. }
  86097. }
  86098. declare module BABYLON {
  86099. /**
  86100. * Particle emitter emitting particles from a point.
  86101. * It emits the particles randomly between 2 given directions.
  86102. */
  86103. export class PointParticleEmitter implements IParticleEmitterType {
  86104. /**
  86105. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86106. */
  86107. direction1: Vector3;
  86108. /**
  86109. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86110. */
  86111. direction2: Vector3;
  86112. /**
  86113. * Creates a new instance PointParticleEmitter
  86114. */
  86115. constructor();
  86116. /**
  86117. * Called by the particle System when the direction is computed for the created particle.
  86118. * @param worldMatrix is the world matrix of the particle system
  86119. * @param directionToUpdate is the direction vector to update with the result
  86120. * @param particle is the particle we are computed the direction for
  86121. * @param isLocal defines if the direction should be set in local space
  86122. */
  86123. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86124. /**
  86125. * Called by the particle System when the position is computed for the created particle.
  86126. * @param worldMatrix is the world matrix of the particle system
  86127. * @param positionToUpdate is the position vector to update with the result
  86128. * @param particle is the particle we are computed the position for
  86129. * @param isLocal defines if the position should be set in local space
  86130. */
  86131. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86132. /**
  86133. * Clones the current emitter and returns a copy of it
  86134. * @returns the new emitter
  86135. */
  86136. clone(): PointParticleEmitter;
  86137. /**
  86138. * Called by the GPUParticleSystem to setup the update shader
  86139. * @param effect defines the update shader
  86140. */
  86141. applyToShader(effect: Effect): void;
  86142. /**
  86143. * Returns a string to use to update the GPU particles update shader
  86144. * @returns a string containng the defines string
  86145. */
  86146. getEffectDefines(): string;
  86147. /**
  86148. * Returns the string "PointParticleEmitter"
  86149. * @returns a string containing the class name
  86150. */
  86151. getClassName(): string;
  86152. /**
  86153. * Serializes the particle system to a JSON object.
  86154. * @returns the JSON object
  86155. */
  86156. serialize(): any;
  86157. /**
  86158. * Parse properties from a JSON object
  86159. * @param serializationObject defines the JSON object
  86160. */
  86161. parse(serializationObject: any): void;
  86162. }
  86163. }
  86164. declare module BABYLON {
  86165. /**
  86166. * Particle emitter emitting particles from the inside of a sphere.
  86167. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  86168. */
  86169. export class SphereParticleEmitter implements IParticleEmitterType {
  86170. /**
  86171. * The radius of the emission sphere.
  86172. */
  86173. radius: number;
  86174. /**
  86175. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86176. */
  86177. radiusRange: number;
  86178. /**
  86179. * How much to randomize the particle direction [0-1].
  86180. */
  86181. directionRandomizer: number;
  86182. /**
  86183. * Creates a new instance SphereParticleEmitter
  86184. * @param radius the radius of the emission sphere (1 by default)
  86185. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86186. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86187. */
  86188. constructor(
  86189. /**
  86190. * The radius of the emission sphere.
  86191. */
  86192. radius?: number,
  86193. /**
  86194. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86195. */
  86196. radiusRange?: number,
  86197. /**
  86198. * How much to randomize the particle direction [0-1].
  86199. */
  86200. directionRandomizer?: number);
  86201. /**
  86202. * Called by the particle System when the direction is computed for the created particle.
  86203. * @param worldMatrix is the world matrix of the particle system
  86204. * @param directionToUpdate is the direction vector to update with the result
  86205. * @param particle is the particle we are computed the direction for
  86206. * @param isLocal defines if the direction should be set in local space
  86207. */
  86208. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86209. /**
  86210. * Called by the particle System when the position is computed for the created particle.
  86211. * @param worldMatrix is the world matrix of the particle system
  86212. * @param positionToUpdate is the position vector to update with the result
  86213. * @param particle is the particle we are computed the position for
  86214. * @param isLocal defines if the position should be set in local space
  86215. */
  86216. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86217. /**
  86218. * Clones the current emitter and returns a copy of it
  86219. * @returns the new emitter
  86220. */
  86221. clone(): SphereParticleEmitter;
  86222. /**
  86223. * Called by the GPUParticleSystem to setup the update shader
  86224. * @param effect defines the update shader
  86225. */
  86226. applyToShader(effect: Effect): void;
  86227. /**
  86228. * Returns a string to use to update the GPU particles update shader
  86229. * @returns a string containng the defines string
  86230. */
  86231. getEffectDefines(): string;
  86232. /**
  86233. * Returns the string "SphereParticleEmitter"
  86234. * @returns a string containing the class name
  86235. */
  86236. getClassName(): string;
  86237. /**
  86238. * Serializes the particle system to a JSON object.
  86239. * @returns the JSON object
  86240. */
  86241. serialize(): any;
  86242. /**
  86243. * Parse properties from a JSON object
  86244. * @param serializationObject defines the JSON object
  86245. */
  86246. parse(serializationObject: any): void;
  86247. }
  86248. /**
  86249. * Particle emitter emitting particles from the inside of a sphere.
  86250. * It emits the particles randomly between two vectors.
  86251. */
  86252. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  86253. /**
  86254. * The min limit of the emission direction.
  86255. */
  86256. direction1: Vector3;
  86257. /**
  86258. * The max limit of the emission direction.
  86259. */
  86260. direction2: Vector3;
  86261. /**
  86262. * Creates a new instance SphereDirectedParticleEmitter
  86263. * @param radius the radius of the emission sphere (1 by default)
  86264. * @param direction1 the min limit of the emission direction (up vector by default)
  86265. * @param direction2 the max limit of the emission direction (up vector by default)
  86266. */
  86267. constructor(radius?: number,
  86268. /**
  86269. * The min limit of the emission direction.
  86270. */
  86271. direction1?: Vector3,
  86272. /**
  86273. * The max limit of the emission direction.
  86274. */
  86275. direction2?: Vector3);
  86276. /**
  86277. * Called by the particle System when the direction is computed for the created particle.
  86278. * @param worldMatrix is the world matrix of the particle system
  86279. * @param directionToUpdate is the direction vector to update with the result
  86280. * @param particle is the particle we are computed the direction for
  86281. */
  86282. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86283. /**
  86284. * Clones the current emitter and returns a copy of it
  86285. * @returns the new emitter
  86286. */
  86287. clone(): SphereDirectedParticleEmitter;
  86288. /**
  86289. * Called by the GPUParticleSystem to setup the update shader
  86290. * @param effect defines the update shader
  86291. */
  86292. applyToShader(effect: Effect): void;
  86293. /**
  86294. * Returns a string to use to update the GPU particles update shader
  86295. * @returns a string containng the defines string
  86296. */
  86297. getEffectDefines(): string;
  86298. /**
  86299. * Returns the string "SphereDirectedParticleEmitter"
  86300. * @returns a string containing the class name
  86301. */
  86302. getClassName(): string;
  86303. /**
  86304. * Serializes the particle system to a JSON object.
  86305. * @returns the JSON object
  86306. */
  86307. serialize(): any;
  86308. /**
  86309. * Parse properties from a JSON object
  86310. * @param serializationObject defines the JSON object
  86311. */
  86312. parse(serializationObject: any): void;
  86313. }
  86314. }
  86315. declare module BABYLON {
  86316. /**
  86317. * Particle emitter emitting particles from a custom list of positions.
  86318. */
  86319. export class CustomParticleEmitter implements IParticleEmitterType {
  86320. /**
  86321. * Gets or sets the position generator that will create the inital position of each particle.
  86322. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  86323. */
  86324. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  86325. /**
  86326. * Gets or sets the destination generator that will create the final destination of each particle.
  86327. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  86328. */
  86329. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  86330. /**
  86331. * Creates a new instance CustomParticleEmitter
  86332. */
  86333. constructor();
  86334. /**
  86335. * Called by the particle System when the direction is computed for the created particle.
  86336. * @param worldMatrix is the world matrix of the particle system
  86337. * @param directionToUpdate is the direction vector to update with the result
  86338. * @param particle is the particle we are computed the direction for
  86339. * @param isLocal defines if the direction should be set in local space
  86340. */
  86341. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86342. /**
  86343. * Called by the particle System when the position is computed for the created particle.
  86344. * @param worldMatrix is the world matrix of the particle system
  86345. * @param positionToUpdate is the position vector to update with the result
  86346. * @param particle is the particle we are computed the position for
  86347. * @param isLocal defines if the position should be set in local space
  86348. */
  86349. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86350. /**
  86351. * Clones the current emitter and returns a copy of it
  86352. * @returns the new emitter
  86353. */
  86354. clone(): CustomParticleEmitter;
  86355. /**
  86356. * Called by the GPUParticleSystem to setup the update shader
  86357. * @param effect defines the update shader
  86358. */
  86359. applyToShader(effect: Effect): void;
  86360. /**
  86361. * Returns a string to use to update the GPU particles update shader
  86362. * @returns a string containng the defines string
  86363. */
  86364. getEffectDefines(): string;
  86365. /**
  86366. * Returns the string "PointParticleEmitter"
  86367. * @returns a string containing the class name
  86368. */
  86369. getClassName(): string;
  86370. /**
  86371. * Serializes the particle system to a JSON object.
  86372. * @returns the JSON object
  86373. */
  86374. serialize(): any;
  86375. /**
  86376. * Parse properties from a JSON object
  86377. * @param serializationObject defines the JSON object
  86378. */
  86379. parse(serializationObject: any): void;
  86380. }
  86381. }
  86382. declare module BABYLON {
  86383. /**
  86384. * Particle emitter emitting particles from the inside of a box.
  86385. * It emits the particles randomly between 2 given directions.
  86386. */
  86387. export class MeshParticleEmitter implements IParticleEmitterType {
  86388. private _indices;
  86389. private _positions;
  86390. private _normals;
  86391. private _storedNormal;
  86392. private _mesh;
  86393. /**
  86394. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86395. */
  86396. direction1: Vector3;
  86397. /**
  86398. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86399. */
  86400. direction2: Vector3;
  86401. /**
  86402. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  86403. */
  86404. useMeshNormalsForDirection: boolean;
  86405. /** Defines the mesh to use as source */
  86406. get mesh(): Nullable<AbstractMesh>;
  86407. set mesh(value: Nullable<AbstractMesh>);
  86408. /**
  86409. * Creates a new instance MeshParticleEmitter
  86410. * @param mesh defines the mesh to use as source
  86411. */
  86412. constructor(mesh?: Nullable<AbstractMesh>);
  86413. /**
  86414. * Called by the particle System when the direction is computed for the created particle.
  86415. * @param worldMatrix is the world matrix of the particle system
  86416. * @param directionToUpdate is the direction vector to update with the result
  86417. * @param particle is the particle we are computed the direction for
  86418. * @param isLocal defines if the direction should be set in local space
  86419. */
  86420. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86421. /**
  86422. * Called by the particle System when the position is computed for the created particle.
  86423. * @param worldMatrix is the world matrix of the particle system
  86424. * @param positionToUpdate is the position vector to update with the result
  86425. * @param particle is the particle we are computed the position for
  86426. * @param isLocal defines if the position should be set in local space
  86427. */
  86428. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86429. /**
  86430. * Clones the current emitter and returns a copy of it
  86431. * @returns the new emitter
  86432. */
  86433. clone(): MeshParticleEmitter;
  86434. /**
  86435. * Called by the GPUParticleSystem to setup the update shader
  86436. * @param effect defines the update shader
  86437. */
  86438. applyToShader(effect: Effect): void;
  86439. /**
  86440. * Returns a string to use to update the GPU particles update shader
  86441. * @returns a string containng the defines string
  86442. */
  86443. getEffectDefines(): string;
  86444. /**
  86445. * Returns the string "BoxParticleEmitter"
  86446. * @returns a string containing the class name
  86447. */
  86448. getClassName(): string;
  86449. /**
  86450. * Serializes the particle system to a JSON object.
  86451. * @returns the JSON object
  86452. */
  86453. serialize(): any;
  86454. /**
  86455. * Parse properties from a JSON object
  86456. * @param serializationObject defines the JSON object
  86457. * @param scene defines the hosting scene
  86458. */
  86459. parse(serializationObject: any, scene: Scene): void;
  86460. }
  86461. }
  86462. declare module BABYLON {
  86463. /**
  86464. * Interface representing a particle system in Babylon.js.
  86465. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  86466. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  86467. */
  86468. export interface IParticleSystem {
  86469. /**
  86470. * List of animations used by the particle system.
  86471. */
  86472. animations: Animation[];
  86473. /**
  86474. * The id of the Particle system.
  86475. */
  86476. id: string;
  86477. /**
  86478. * The name of the Particle system.
  86479. */
  86480. name: string;
  86481. /**
  86482. * The emitter represents the Mesh or position we are attaching the particle system to.
  86483. */
  86484. emitter: Nullable<AbstractMesh | Vector3>;
  86485. /**
  86486. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  86487. */
  86488. isBillboardBased: boolean;
  86489. /**
  86490. * The rendering group used by the Particle system to chose when to render.
  86491. */
  86492. renderingGroupId: number;
  86493. /**
  86494. * The layer mask we are rendering the particles through.
  86495. */
  86496. layerMask: number;
  86497. /**
  86498. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  86499. */
  86500. updateSpeed: number;
  86501. /**
  86502. * The amount of time the particle system is running (depends of the overall update speed).
  86503. */
  86504. targetStopDuration: number;
  86505. /**
  86506. * The texture used to render each particle. (this can be a spritesheet)
  86507. */
  86508. particleTexture: Nullable<Texture>;
  86509. /**
  86510. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  86511. */
  86512. blendMode: number;
  86513. /**
  86514. * Minimum life time of emitting particles.
  86515. */
  86516. minLifeTime: number;
  86517. /**
  86518. * Maximum life time of emitting particles.
  86519. */
  86520. maxLifeTime: number;
  86521. /**
  86522. * Minimum Size of emitting particles.
  86523. */
  86524. minSize: number;
  86525. /**
  86526. * Maximum Size of emitting particles.
  86527. */
  86528. maxSize: number;
  86529. /**
  86530. * Minimum scale of emitting particles on X axis.
  86531. */
  86532. minScaleX: number;
  86533. /**
  86534. * Maximum scale of emitting particles on X axis.
  86535. */
  86536. maxScaleX: number;
  86537. /**
  86538. * Minimum scale of emitting particles on Y axis.
  86539. */
  86540. minScaleY: number;
  86541. /**
  86542. * Maximum scale of emitting particles on Y axis.
  86543. */
  86544. maxScaleY: number;
  86545. /**
  86546. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86547. */
  86548. color1: Color4;
  86549. /**
  86550. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86551. */
  86552. color2: Color4;
  86553. /**
  86554. * Color the particle will have at the end of its lifetime.
  86555. */
  86556. colorDead: Color4;
  86557. /**
  86558. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  86559. */
  86560. emitRate: number;
  86561. /**
  86562. * You can use gravity if you want to give an orientation to your particles.
  86563. */
  86564. gravity: Vector3;
  86565. /**
  86566. * Minimum power of emitting particles.
  86567. */
  86568. minEmitPower: number;
  86569. /**
  86570. * Maximum power of emitting particles.
  86571. */
  86572. maxEmitPower: number;
  86573. /**
  86574. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  86575. */
  86576. minAngularSpeed: number;
  86577. /**
  86578. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  86579. */
  86580. maxAngularSpeed: number;
  86581. /**
  86582. * Gets or sets the minimal initial rotation in radians.
  86583. */
  86584. minInitialRotation: number;
  86585. /**
  86586. * Gets or sets the maximal initial rotation in radians.
  86587. */
  86588. maxInitialRotation: number;
  86589. /**
  86590. * The particle emitter type defines the emitter used by the particle system.
  86591. * It can be for example box, sphere, or cone...
  86592. */
  86593. particleEmitterType: Nullable<IParticleEmitterType>;
  86594. /**
  86595. * Defines the delay in milliseconds before starting the system (0 by default)
  86596. */
  86597. startDelay: number;
  86598. /**
  86599. * 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
  86600. */
  86601. preWarmCycles: number;
  86602. /**
  86603. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  86604. */
  86605. preWarmStepOffset: number;
  86606. /**
  86607. * 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)
  86608. */
  86609. spriteCellChangeSpeed: number;
  86610. /**
  86611. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  86612. */
  86613. startSpriteCellID: number;
  86614. /**
  86615. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  86616. */
  86617. endSpriteCellID: number;
  86618. /**
  86619. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  86620. */
  86621. spriteCellWidth: number;
  86622. /**
  86623. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  86624. */
  86625. spriteCellHeight: number;
  86626. /**
  86627. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  86628. */
  86629. spriteRandomStartCell: boolean;
  86630. /**
  86631. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  86632. */
  86633. isAnimationSheetEnabled: boolean;
  86634. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  86635. translationPivot: Vector2;
  86636. /**
  86637. * Gets or sets a texture used to add random noise to particle positions
  86638. */
  86639. noiseTexture: Nullable<BaseTexture>;
  86640. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  86641. noiseStrength: Vector3;
  86642. /**
  86643. * Gets or sets the billboard mode to use when isBillboardBased = true.
  86644. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  86645. */
  86646. billboardMode: number;
  86647. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  86648. limitVelocityDamping: number;
  86649. /**
  86650. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  86651. */
  86652. beginAnimationOnStart: boolean;
  86653. /**
  86654. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  86655. */
  86656. beginAnimationFrom: number;
  86657. /**
  86658. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  86659. */
  86660. beginAnimationTo: number;
  86661. /**
  86662. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  86663. */
  86664. beginAnimationLoop: boolean;
  86665. /**
  86666. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  86667. */
  86668. disposeOnStop: boolean;
  86669. /**
  86670. * Specifies if the particles are updated in emitter local space or world space
  86671. */
  86672. isLocal: boolean;
  86673. /**
  86674. * Gets the maximum number of particles active at the same time.
  86675. * @returns The max number of active particles.
  86676. */
  86677. getCapacity(): number;
  86678. /**
  86679. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86680. * @returns True if it has been started, otherwise false.
  86681. */
  86682. isStarted(): boolean;
  86683. /**
  86684. * Animates the particle system for this frame.
  86685. */
  86686. animate(): void;
  86687. /**
  86688. * Renders the particle system in its current state.
  86689. * @returns the current number of particles
  86690. */
  86691. render(): number;
  86692. /**
  86693. * Dispose the particle system and frees its associated resources.
  86694. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86695. */
  86696. dispose(disposeTexture?: boolean): void;
  86697. /**
  86698. * Clones the particle system.
  86699. * @param name The name of the cloned object
  86700. * @param newEmitter The new emitter to use
  86701. * @returns the cloned particle system
  86702. */
  86703. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  86704. /**
  86705. * Serializes the particle system to a JSON object.
  86706. * @returns the JSON object
  86707. */
  86708. serialize(): any;
  86709. /**
  86710. * Rebuild the particle system
  86711. */
  86712. rebuild(): void;
  86713. /**
  86714. * Starts the particle system and begins to emit
  86715. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  86716. */
  86717. start(delay?: number): void;
  86718. /**
  86719. * Stops the particle system.
  86720. */
  86721. stop(): void;
  86722. /**
  86723. * Remove all active particles
  86724. */
  86725. reset(): void;
  86726. /**
  86727. * Is this system ready to be used/rendered
  86728. * @return true if the system is ready
  86729. */
  86730. isReady(): boolean;
  86731. /**
  86732. * Returns the string "ParticleSystem"
  86733. * @returns a string containing the class name
  86734. */
  86735. getClassName(): string;
  86736. /**
  86737. * Adds a new color gradient
  86738. * @param gradient defines the gradient to use (between 0 and 1)
  86739. * @param color1 defines the color to affect to the specified gradient
  86740. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86741. * @returns the current particle system
  86742. */
  86743. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86744. /**
  86745. * Remove a specific color gradient
  86746. * @param gradient defines the gradient to remove
  86747. * @returns the current particle system
  86748. */
  86749. removeColorGradient(gradient: number): IParticleSystem;
  86750. /**
  86751. * Adds a new size gradient
  86752. * @param gradient defines the gradient to use (between 0 and 1)
  86753. * @param factor defines the size factor to affect to the specified gradient
  86754. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86755. * @returns the current particle system
  86756. */
  86757. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86758. /**
  86759. * Remove a specific size gradient
  86760. * @param gradient defines the gradient to remove
  86761. * @returns the current particle system
  86762. */
  86763. removeSizeGradient(gradient: number): IParticleSystem;
  86764. /**
  86765. * Gets the current list of color gradients.
  86766. * You must use addColorGradient and removeColorGradient to udpate this list
  86767. * @returns the list of color gradients
  86768. */
  86769. getColorGradients(): Nullable<Array<ColorGradient>>;
  86770. /**
  86771. * Gets the current list of size gradients.
  86772. * You must use addSizeGradient and removeSizeGradient to udpate this list
  86773. * @returns the list of size gradients
  86774. */
  86775. getSizeGradients(): Nullable<Array<FactorGradient>>;
  86776. /**
  86777. * Gets the current list of angular speed gradients.
  86778. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  86779. * @returns the list of angular speed gradients
  86780. */
  86781. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  86782. /**
  86783. * Adds a new angular speed gradient
  86784. * @param gradient defines the gradient to use (between 0 and 1)
  86785. * @param factor defines the angular speed to affect to the specified gradient
  86786. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86787. * @returns the current particle system
  86788. */
  86789. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86790. /**
  86791. * Remove a specific angular speed gradient
  86792. * @param gradient defines the gradient to remove
  86793. * @returns the current particle system
  86794. */
  86795. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86796. /**
  86797. * Gets the current list of velocity gradients.
  86798. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  86799. * @returns the list of velocity gradients
  86800. */
  86801. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  86802. /**
  86803. * Adds a new velocity gradient
  86804. * @param gradient defines the gradient to use (between 0 and 1)
  86805. * @param factor defines the velocity to affect to the specified gradient
  86806. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86807. * @returns the current particle system
  86808. */
  86809. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86810. /**
  86811. * Remove a specific velocity gradient
  86812. * @param gradient defines the gradient to remove
  86813. * @returns the current particle system
  86814. */
  86815. removeVelocityGradient(gradient: number): IParticleSystem;
  86816. /**
  86817. * Gets the current list of limit velocity gradients.
  86818. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  86819. * @returns the list of limit velocity gradients
  86820. */
  86821. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  86822. /**
  86823. * Adds a new limit velocity gradient
  86824. * @param gradient defines the gradient to use (between 0 and 1)
  86825. * @param factor defines the limit velocity to affect to the specified gradient
  86826. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86827. * @returns the current particle system
  86828. */
  86829. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86830. /**
  86831. * Remove a specific limit velocity gradient
  86832. * @param gradient defines the gradient to remove
  86833. * @returns the current particle system
  86834. */
  86835. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86836. /**
  86837. * Adds a new drag gradient
  86838. * @param gradient defines the gradient to use (between 0 and 1)
  86839. * @param factor defines the drag to affect to the specified gradient
  86840. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86841. * @returns the current particle system
  86842. */
  86843. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86844. /**
  86845. * Remove a specific drag gradient
  86846. * @param gradient defines the gradient to remove
  86847. * @returns the current particle system
  86848. */
  86849. removeDragGradient(gradient: number): IParticleSystem;
  86850. /**
  86851. * Gets the current list of drag gradients.
  86852. * You must use addDragGradient and removeDragGradient to udpate this list
  86853. * @returns the list of drag gradients
  86854. */
  86855. getDragGradients(): Nullable<Array<FactorGradient>>;
  86856. /**
  86857. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86858. * @param gradient defines the gradient to use (between 0 and 1)
  86859. * @param factor defines the emit rate to affect to the specified gradient
  86860. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86861. * @returns the current particle system
  86862. */
  86863. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86864. /**
  86865. * Remove a specific emit rate gradient
  86866. * @param gradient defines the gradient to remove
  86867. * @returns the current particle system
  86868. */
  86869. removeEmitRateGradient(gradient: number): IParticleSystem;
  86870. /**
  86871. * Gets the current list of emit rate gradients.
  86872. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  86873. * @returns the list of emit rate gradients
  86874. */
  86875. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  86876. /**
  86877. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86878. * @param gradient defines the gradient to use (between 0 and 1)
  86879. * @param factor defines the start size to affect to the specified gradient
  86880. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86881. * @returns the current particle system
  86882. */
  86883. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86884. /**
  86885. * Remove a specific start size gradient
  86886. * @param gradient defines the gradient to remove
  86887. * @returns the current particle system
  86888. */
  86889. removeStartSizeGradient(gradient: number): IParticleSystem;
  86890. /**
  86891. * Gets the current list of start size gradients.
  86892. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  86893. * @returns the list of start size gradients
  86894. */
  86895. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  86896. /**
  86897. * Adds a new life time gradient
  86898. * @param gradient defines the gradient to use (between 0 and 1)
  86899. * @param factor defines the life time factor to affect to the specified gradient
  86900. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86901. * @returns the current particle system
  86902. */
  86903. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86904. /**
  86905. * Remove a specific life time gradient
  86906. * @param gradient defines the gradient to remove
  86907. * @returns the current particle system
  86908. */
  86909. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86910. /**
  86911. * Gets the current list of life time gradients.
  86912. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  86913. * @returns the list of life time gradients
  86914. */
  86915. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  86916. /**
  86917. * Gets the current list of color gradients.
  86918. * You must use addColorGradient and removeColorGradient to udpate this list
  86919. * @returns the list of color gradients
  86920. */
  86921. getColorGradients(): Nullable<Array<ColorGradient>>;
  86922. /**
  86923. * Adds a new ramp gradient used to remap particle colors
  86924. * @param gradient defines the gradient to use (between 0 and 1)
  86925. * @param color defines the color to affect to the specified gradient
  86926. * @returns the current particle system
  86927. */
  86928. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  86929. /**
  86930. * Gets the current list of ramp gradients.
  86931. * You must use addRampGradient and removeRampGradient to udpate this list
  86932. * @returns the list of ramp gradients
  86933. */
  86934. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86935. /** Gets or sets a boolean indicating that ramp gradients must be used
  86936. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  86937. */
  86938. useRampGradients: boolean;
  86939. /**
  86940. * Adds a new color remap gradient
  86941. * @param gradient defines the gradient to use (between 0 and 1)
  86942. * @param min defines the color remap minimal range
  86943. * @param max defines the color remap maximal range
  86944. * @returns the current particle system
  86945. */
  86946. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86947. /**
  86948. * Gets the current list of color remap gradients.
  86949. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  86950. * @returns the list of color remap gradients
  86951. */
  86952. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  86953. /**
  86954. * Adds a new alpha remap gradient
  86955. * @param gradient defines the gradient to use (between 0 and 1)
  86956. * @param min defines the alpha remap minimal range
  86957. * @param max defines the alpha remap maximal range
  86958. * @returns the current particle system
  86959. */
  86960. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86961. /**
  86962. * Gets the current list of alpha remap gradients.
  86963. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  86964. * @returns the list of alpha remap gradients
  86965. */
  86966. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  86967. /**
  86968. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  86969. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86970. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86971. * @returns the emitter
  86972. */
  86973. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  86974. /**
  86975. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  86976. * @param radius The radius of the hemisphere to emit from
  86977. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86978. * @returns the emitter
  86979. */
  86980. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  86981. /**
  86982. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  86983. * @param radius The radius of the sphere to emit from
  86984. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86985. * @returns the emitter
  86986. */
  86987. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  86988. /**
  86989. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  86990. * @param radius The radius of the sphere to emit from
  86991. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  86992. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  86993. * @returns the emitter
  86994. */
  86995. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86996. /**
  86997. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  86998. * @param radius The radius of the emission cylinder
  86999. * @param height The height of the emission cylinder
  87000. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  87001. * @param directionRandomizer How much to randomize the particle direction [0-1]
  87002. * @returns the emitter
  87003. */
  87004. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  87005. /**
  87006. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  87007. * @param radius The radius of the cylinder to emit from
  87008. * @param height The height of the emission cylinder
  87009. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87010. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  87011. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  87012. * @returns the emitter
  87013. */
  87014. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87015. /**
  87016. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  87017. * @param radius The radius of the cone to emit from
  87018. * @param angle The base angle of the cone
  87019. * @returns the emitter
  87020. */
  87021. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  87022. /**
  87023. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  87024. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87025. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87026. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87027. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87028. * @returns the emitter
  87029. */
  87030. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  87031. /**
  87032. * Get hosting scene
  87033. * @returns the scene
  87034. */
  87035. getScene(): Scene;
  87036. }
  87037. }
  87038. declare module BABYLON {
  87039. /**
  87040. * 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.
  87041. * @see https://doc.babylonjs.com/how_to/transformnode
  87042. */
  87043. export class TransformNode extends Node {
  87044. /**
  87045. * Object will not rotate to face the camera
  87046. */
  87047. static BILLBOARDMODE_NONE: number;
  87048. /**
  87049. * Object will rotate to face the camera but only on the x axis
  87050. */
  87051. static BILLBOARDMODE_X: number;
  87052. /**
  87053. * Object will rotate to face the camera but only on the y axis
  87054. */
  87055. static BILLBOARDMODE_Y: number;
  87056. /**
  87057. * Object will rotate to face the camera but only on the z axis
  87058. */
  87059. static BILLBOARDMODE_Z: number;
  87060. /**
  87061. * Object will rotate to face the camera
  87062. */
  87063. static BILLBOARDMODE_ALL: number;
  87064. /**
  87065. * Object will rotate to face the camera's position instead of orientation
  87066. */
  87067. static BILLBOARDMODE_USE_POSITION: number;
  87068. private _forward;
  87069. private _forwardInverted;
  87070. private _up;
  87071. private _right;
  87072. private _rightInverted;
  87073. private _position;
  87074. private _rotation;
  87075. private _rotationQuaternion;
  87076. protected _scaling: Vector3;
  87077. protected _isDirty: boolean;
  87078. private _transformToBoneReferal;
  87079. private _isAbsoluteSynced;
  87080. private _billboardMode;
  87081. /**
  87082. * Gets or sets the billboard mode. Default is 0.
  87083. *
  87084. * | Value | Type | Description |
  87085. * | --- | --- | --- |
  87086. * | 0 | BILLBOARDMODE_NONE | |
  87087. * | 1 | BILLBOARDMODE_X | |
  87088. * | 2 | BILLBOARDMODE_Y | |
  87089. * | 4 | BILLBOARDMODE_Z | |
  87090. * | 7 | BILLBOARDMODE_ALL | |
  87091. *
  87092. */
  87093. get billboardMode(): number;
  87094. set billboardMode(value: number);
  87095. private _preserveParentRotationForBillboard;
  87096. /**
  87097. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  87098. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  87099. */
  87100. get preserveParentRotationForBillboard(): boolean;
  87101. set preserveParentRotationForBillboard(value: boolean);
  87102. /**
  87103. * 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
  87104. */
  87105. scalingDeterminant: number;
  87106. private _infiniteDistance;
  87107. /**
  87108. * Gets or sets the distance of the object to max, often used by skybox
  87109. */
  87110. get infiniteDistance(): boolean;
  87111. set infiniteDistance(value: boolean);
  87112. /**
  87113. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  87114. * By default the system will update normals to compensate
  87115. */
  87116. ignoreNonUniformScaling: boolean;
  87117. /**
  87118. * 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
  87119. */
  87120. reIntegrateRotationIntoRotationQuaternion: boolean;
  87121. /** @hidden */
  87122. _poseMatrix: Nullable<Matrix>;
  87123. /** @hidden */
  87124. _localMatrix: Matrix;
  87125. private _usePivotMatrix;
  87126. private _absolutePosition;
  87127. private _absoluteScaling;
  87128. private _absoluteRotationQuaternion;
  87129. private _pivotMatrix;
  87130. private _pivotMatrixInverse;
  87131. protected _postMultiplyPivotMatrix: boolean;
  87132. protected _isWorldMatrixFrozen: boolean;
  87133. /** @hidden */
  87134. _indexInSceneTransformNodesArray: number;
  87135. /**
  87136. * An event triggered after the world matrix is updated
  87137. */
  87138. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  87139. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  87140. /**
  87141. * Gets a string identifying the name of the class
  87142. * @returns "TransformNode" string
  87143. */
  87144. getClassName(): string;
  87145. /**
  87146. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  87147. */
  87148. get position(): Vector3;
  87149. set position(newPosition: Vector3);
  87150. /**
  87151. * 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)).
  87152. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  87153. */
  87154. get rotation(): Vector3;
  87155. set rotation(newRotation: Vector3);
  87156. /**
  87157. * 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)).
  87158. */
  87159. get scaling(): Vector3;
  87160. set scaling(newScaling: Vector3);
  87161. /**
  87162. * 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).
  87163. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  87164. */
  87165. get rotationQuaternion(): Nullable<Quaternion>;
  87166. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  87167. /**
  87168. * The forward direction of that transform in world space.
  87169. */
  87170. get forward(): Vector3;
  87171. /**
  87172. * The up direction of that transform in world space.
  87173. */
  87174. get up(): Vector3;
  87175. /**
  87176. * The right direction of that transform in world space.
  87177. */
  87178. get right(): Vector3;
  87179. /**
  87180. * Copies the parameter passed Matrix into the mesh Pose matrix.
  87181. * @param matrix the matrix to copy the pose from
  87182. * @returns this TransformNode.
  87183. */
  87184. updatePoseMatrix(matrix: Matrix): TransformNode;
  87185. /**
  87186. * Returns the mesh Pose matrix.
  87187. * @returns the pose matrix
  87188. */
  87189. getPoseMatrix(): Matrix;
  87190. /** @hidden */
  87191. _isSynchronized(): boolean;
  87192. /** @hidden */
  87193. _initCache(): void;
  87194. /**
  87195. * Flag the transform node as dirty (Forcing it to update everything)
  87196. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  87197. * @returns this transform node
  87198. */
  87199. markAsDirty(property: string): TransformNode;
  87200. /**
  87201. * Returns the current mesh absolute position.
  87202. * Returns a Vector3.
  87203. */
  87204. get absolutePosition(): Vector3;
  87205. /**
  87206. * Returns the current mesh absolute scaling.
  87207. * Returns a Vector3.
  87208. */
  87209. get absoluteScaling(): Vector3;
  87210. /**
  87211. * Returns the current mesh absolute rotation.
  87212. * Returns a Quaternion.
  87213. */
  87214. get absoluteRotationQuaternion(): Quaternion;
  87215. /**
  87216. * Sets a new matrix to apply before all other transformation
  87217. * @param matrix defines the transform matrix
  87218. * @returns the current TransformNode
  87219. */
  87220. setPreTransformMatrix(matrix: Matrix): TransformNode;
  87221. /**
  87222. * Sets a new pivot matrix to the current node
  87223. * @param matrix defines the new pivot matrix to use
  87224. * @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
  87225. * @returns the current TransformNode
  87226. */
  87227. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  87228. /**
  87229. * Returns the mesh pivot matrix.
  87230. * Default : Identity.
  87231. * @returns the matrix
  87232. */
  87233. getPivotMatrix(): Matrix;
  87234. /**
  87235. * Instantiate (when possible) or clone that node with its hierarchy
  87236. * @param newParent defines the new parent to use for the instance (or clone)
  87237. * @param options defines options to configure how copy is done
  87238. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  87239. * @returns an instance (or a clone) of the current node with its hiearchy
  87240. */
  87241. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  87242. doNotInstantiate: boolean;
  87243. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  87244. /**
  87245. * Prevents the World matrix to be computed any longer
  87246. * @param newWorldMatrix defines an optional matrix to use as world matrix
  87247. * @returns the TransformNode.
  87248. */
  87249. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  87250. /**
  87251. * Allows back the World matrix computation.
  87252. * @returns the TransformNode.
  87253. */
  87254. unfreezeWorldMatrix(): this;
  87255. /**
  87256. * True if the World matrix has been frozen.
  87257. */
  87258. get isWorldMatrixFrozen(): boolean;
  87259. /**
  87260. * Retuns the mesh absolute position in the World.
  87261. * @returns a Vector3.
  87262. */
  87263. getAbsolutePosition(): Vector3;
  87264. /**
  87265. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  87266. * @param absolutePosition the absolute position to set
  87267. * @returns the TransformNode.
  87268. */
  87269. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  87270. /**
  87271. * Sets the mesh position in its local space.
  87272. * @param vector3 the position to set in localspace
  87273. * @returns the TransformNode.
  87274. */
  87275. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  87276. /**
  87277. * Returns the mesh position in the local space from the current World matrix values.
  87278. * @returns a new Vector3.
  87279. */
  87280. getPositionExpressedInLocalSpace(): Vector3;
  87281. /**
  87282. * Translates the mesh along the passed Vector3 in its local space.
  87283. * @param vector3 the distance to translate in localspace
  87284. * @returns the TransformNode.
  87285. */
  87286. locallyTranslate(vector3: Vector3): TransformNode;
  87287. private static _lookAtVectorCache;
  87288. /**
  87289. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  87290. * @param targetPoint the position (must be in same space as current mesh) to look at
  87291. * @param yawCor optional yaw (y-axis) correction in radians
  87292. * @param pitchCor optional pitch (x-axis) correction in radians
  87293. * @param rollCor optional roll (z-axis) correction in radians
  87294. * @param space the choosen space of the target
  87295. * @returns the TransformNode.
  87296. */
  87297. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  87298. /**
  87299. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  87300. * This Vector3 is expressed in the World space.
  87301. * @param localAxis axis to rotate
  87302. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  87303. */
  87304. getDirection(localAxis: Vector3): Vector3;
  87305. /**
  87306. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  87307. * localAxis is expressed in the mesh local space.
  87308. * result is computed in the Wordl space from the mesh World matrix.
  87309. * @param localAxis axis to rotate
  87310. * @param result the resulting transformnode
  87311. * @returns this TransformNode.
  87312. */
  87313. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  87314. /**
  87315. * Sets this transform node rotation to the given local axis.
  87316. * @param localAxis the axis in local space
  87317. * @param yawCor optional yaw (y-axis) correction in radians
  87318. * @param pitchCor optional pitch (x-axis) correction in radians
  87319. * @param rollCor optional roll (z-axis) correction in radians
  87320. * @returns this TransformNode
  87321. */
  87322. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  87323. /**
  87324. * Sets a new pivot point to the current node
  87325. * @param point defines the new pivot point to use
  87326. * @param space defines if the point is in world or local space (local by default)
  87327. * @returns the current TransformNode
  87328. */
  87329. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  87330. /**
  87331. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  87332. * @returns the pivot point
  87333. */
  87334. getPivotPoint(): Vector3;
  87335. /**
  87336. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  87337. * @param result the vector3 to store the result
  87338. * @returns this TransformNode.
  87339. */
  87340. getPivotPointToRef(result: Vector3): TransformNode;
  87341. /**
  87342. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  87343. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  87344. */
  87345. getAbsolutePivotPoint(): Vector3;
  87346. /**
  87347. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  87348. * @param result vector3 to store the result
  87349. * @returns this TransformNode.
  87350. */
  87351. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  87352. /**
  87353. * Defines the passed node as the parent of the current node.
  87354. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  87355. * @see https://doc.babylonjs.com/how_to/parenting
  87356. * @param node the node ot set as the parent
  87357. * @returns this TransformNode.
  87358. */
  87359. setParent(node: Nullable<Node>): TransformNode;
  87360. private _nonUniformScaling;
  87361. /**
  87362. * True if the scaling property of this object is non uniform eg. (1,2,1)
  87363. */
  87364. get nonUniformScaling(): boolean;
  87365. /** @hidden */
  87366. _updateNonUniformScalingState(value: boolean): boolean;
  87367. /**
  87368. * Attach the current TransformNode to another TransformNode associated with a bone
  87369. * @param bone Bone affecting the TransformNode
  87370. * @param affectedTransformNode TransformNode associated with the bone
  87371. * @returns this object
  87372. */
  87373. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  87374. /**
  87375. * Detach the transform node if its associated with a bone
  87376. * @returns this object
  87377. */
  87378. detachFromBone(): TransformNode;
  87379. private static _rotationAxisCache;
  87380. /**
  87381. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  87382. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87383. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87384. * The passed axis is also normalized.
  87385. * @param axis the axis to rotate around
  87386. * @param amount the amount to rotate in radians
  87387. * @param space Space to rotate in (Default: local)
  87388. * @returns the TransformNode.
  87389. */
  87390. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  87391. /**
  87392. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  87393. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87394. * The passed axis is also normalized. .
  87395. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  87396. * @param point the point to rotate around
  87397. * @param axis the axis to rotate around
  87398. * @param amount the amount to rotate in radians
  87399. * @returns the TransformNode
  87400. */
  87401. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  87402. /**
  87403. * Translates the mesh along the axis vector for the passed distance in the given space.
  87404. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87405. * @param axis the axis to translate in
  87406. * @param distance the distance to translate
  87407. * @param space Space to rotate in (Default: local)
  87408. * @returns the TransformNode.
  87409. */
  87410. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  87411. /**
  87412. * Adds a rotation step to the mesh current rotation.
  87413. * x, y, z are Euler angles expressed in radians.
  87414. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  87415. * This means this rotation is made in the mesh local space only.
  87416. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  87417. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  87418. * ```javascript
  87419. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  87420. * ```
  87421. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  87422. * 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.
  87423. * @param x Rotation to add
  87424. * @param y Rotation to add
  87425. * @param z Rotation to add
  87426. * @returns the TransformNode.
  87427. */
  87428. addRotation(x: number, y: number, z: number): TransformNode;
  87429. /**
  87430. * @hidden
  87431. */
  87432. protected _getEffectiveParent(): Nullable<Node>;
  87433. /**
  87434. * Computes the world matrix of the node
  87435. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  87436. * @returns the world matrix
  87437. */
  87438. computeWorldMatrix(force?: boolean): Matrix;
  87439. /**
  87440. * Resets this nodeTransform's local matrix to Matrix.Identity().
  87441. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  87442. */
  87443. resetLocalMatrix(independentOfChildren?: boolean): void;
  87444. protected _afterComputeWorldMatrix(): void;
  87445. /**
  87446. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  87447. * @param func callback function to add
  87448. *
  87449. * @returns the TransformNode.
  87450. */
  87451. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87452. /**
  87453. * Removes a registered callback function.
  87454. * @param func callback function to remove
  87455. * @returns the TransformNode.
  87456. */
  87457. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87458. /**
  87459. * Gets the position of the current mesh in camera space
  87460. * @param camera defines the camera to use
  87461. * @returns a position
  87462. */
  87463. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  87464. /**
  87465. * Returns the distance from the mesh to the active camera
  87466. * @param camera defines the camera to use
  87467. * @returns the distance
  87468. */
  87469. getDistanceToCamera(camera?: Nullable<Camera>): number;
  87470. /**
  87471. * Clone the current transform node
  87472. * @param name Name of the new clone
  87473. * @param newParent New parent for the clone
  87474. * @param doNotCloneChildren Do not clone children hierarchy
  87475. * @returns the new transform node
  87476. */
  87477. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  87478. /**
  87479. * Serializes the objects information.
  87480. * @param currentSerializationObject defines the object to serialize in
  87481. * @returns the serialized object
  87482. */
  87483. serialize(currentSerializationObject?: any): any;
  87484. /**
  87485. * Returns a new TransformNode object parsed from the source provided.
  87486. * @param parsedTransformNode is the source.
  87487. * @param scene the scne the object belongs to
  87488. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  87489. * @returns a new TransformNode object parsed from the source provided.
  87490. */
  87491. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  87492. /**
  87493. * Get all child-transformNodes of this node
  87494. * @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
  87495. * @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
  87496. * @returns an array of TransformNode
  87497. */
  87498. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  87499. /**
  87500. * Releases resources associated with this transform node.
  87501. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87502. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87503. */
  87504. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87505. /**
  87506. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  87507. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  87508. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  87509. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  87510. * @returns the current mesh
  87511. */
  87512. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  87513. private _syncAbsoluteScalingAndRotation;
  87514. }
  87515. }
  87516. declare module BABYLON {
  87517. /**
  87518. * Class used to override all child animations of a given target
  87519. */
  87520. export class AnimationPropertiesOverride {
  87521. /**
  87522. * Gets or sets a value indicating if animation blending must be used
  87523. */
  87524. enableBlending: boolean;
  87525. /**
  87526. * Gets or sets the blending speed to use when enableBlending is true
  87527. */
  87528. blendingSpeed: number;
  87529. /**
  87530. * Gets or sets the default loop mode to use
  87531. */
  87532. loopMode: number;
  87533. }
  87534. }
  87535. declare module BABYLON {
  87536. /**
  87537. * Class used to store bone information
  87538. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  87539. */
  87540. export class Bone extends Node {
  87541. /**
  87542. * defines the bone name
  87543. */
  87544. name: string;
  87545. private static _tmpVecs;
  87546. private static _tmpQuat;
  87547. private static _tmpMats;
  87548. /**
  87549. * Gets the list of child bones
  87550. */
  87551. children: Bone[];
  87552. /** Gets the animations associated with this bone */
  87553. animations: Animation[];
  87554. /**
  87555. * Gets or sets bone length
  87556. */
  87557. length: number;
  87558. /**
  87559. * @hidden Internal only
  87560. * Set this value to map this bone to a different index in the transform matrices
  87561. * Set this value to -1 to exclude the bone from the transform matrices
  87562. */
  87563. _index: Nullable<number>;
  87564. private _skeleton;
  87565. private _localMatrix;
  87566. private _restPose;
  87567. private _baseMatrix;
  87568. private _absoluteTransform;
  87569. private _invertedAbsoluteTransform;
  87570. private _parent;
  87571. private _scalingDeterminant;
  87572. private _worldTransform;
  87573. private _localScaling;
  87574. private _localRotation;
  87575. private _localPosition;
  87576. private _needToDecompose;
  87577. private _needToCompose;
  87578. /** @hidden */
  87579. _linkedTransformNode: Nullable<TransformNode>;
  87580. /** @hidden */
  87581. _waitingTransformNodeId: Nullable<string>;
  87582. /** @hidden */
  87583. get _matrix(): Matrix;
  87584. /** @hidden */
  87585. set _matrix(value: Matrix);
  87586. /**
  87587. * Create a new bone
  87588. * @param name defines the bone name
  87589. * @param skeleton defines the parent skeleton
  87590. * @param parentBone defines the parent (can be null if the bone is the root)
  87591. * @param localMatrix defines the local matrix
  87592. * @param restPose defines the rest pose matrix
  87593. * @param baseMatrix defines the base matrix
  87594. * @param index defines index of the bone in the hiearchy
  87595. */
  87596. constructor(
  87597. /**
  87598. * defines the bone name
  87599. */
  87600. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  87601. /**
  87602. * Gets the current object class name.
  87603. * @return the class name
  87604. */
  87605. getClassName(): string;
  87606. /**
  87607. * Gets the parent skeleton
  87608. * @returns a skeleton
  87609. */
  87610. getSkeleton(): Skeleton;
  87611. /**
  87612. * Gets parent bone
  87613. * @returns a bone or null if the bone is the root of the bone hierarchy
  87614. */
  87615. getParent(): Nullable<Bone>;
  87616. /**
  87617. * Returns an array containing the root bones
  87618. * @returns an array containing the root bones
  87619. */
  87620. getChildren(): Array<Bone>;
  87621. /**
  87622. * Gets the node index in matrix array generated for rendering
  87623. * @returns the node index
  87624. */
  87625. getIndex(): number;
  87626. /**
  87627. * Sets the parent bone
  87628. * @param parent defines the parent (can be null if the bone is the root)
  87629. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  87630. */
  87631. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  87632. /**
  87633. * Gets the local matrix
  87634. * @returns a matrix
  87635. */
  87636. getLocalMatrix(): Matrix;
  87637. /**
  87638. * Gets the base matrix (initial matrix which remains unchanged)
  87639. * @returns a matrix
  87640. */
  87641. getBaseMatrix(): Matrix;
  87642. /**
  87643. * Gets the rest pose matrix
  87644. * @returns a matrix
  87645. */
  87646. getRestPose(): Matrix;
  87647. /**
  87648. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  87649. */
  87650. getWorldMatrix(): Matrix;
  87651. /**
  87652. * Sets the local matrix to rest pose matrix
  87653. */
  87654. returnToRest(): void;
  87655. /**
  87656. * Gets the inverse of the absolute transform matrix.
  87657. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  87658. * @returns a matrix
  87659. */
  87660. getInvertedAbsoluteTransform(): Matrix;
  87661. /**
  87662. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  87663. * @returns a matrix
  87664. */
  87665. getAbsoluteTransform(): Matrix;
  87666. /**
  87667. * Links with the given transform node.
  87668. * The local matrix of this bone is copied from the transform node every frame.
  87669. * @param transformNode defines the transform node to link to
  87670. */
  87671. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  87672. /**
  87673. * Gets the node used to drive the bone's transformation
  87674. * @returns a transform node or null
  87675. */
  87676. getTransformNode(): Nullable<TransformNode>;
  87677. /** Gets or sets current position (in local space) */
  87678. get position(): Vector3;
  87679. set position(newPosition: Vector3);
  87680. /** Gets or sets current rotation (in local space) */
  87681. get rotation(): Vector3;
  87682. set rotation(newRotation: Vector3);
  87683. /** Gets or sets current rotation quaternion (in local space) */
  87684. get rotationQuaternion(): Quaternion;
  87685. set rotationQuaternion(newRotation: Quaternion);
  87686. /** Gets or sets current scaling (in local space) */
  87687. get scaling(): Vector3;
  87688. set scaling(newScaling: Vector3);
  87689. /**
  87690. * Gets the animation properties override
  87691. */
  87692. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  87693. private _decompose;
  87694. private _compose;
  87695. /**
  87696. * Update the base and local matrices
  87697. * @param matrix defines the new base or local matrix
  87698. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  87699. * @param updateLocalMatrix defines if the local matrix should be updated
  87700. */
  87701. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  87702. /** @hidden */
  87703. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  87704. /**
  87705. * Flag the bone as dirty (Forcing it to update everything)
  87706. */
  87707. markAsDirty(): void;
  87708. /** @hidden */
  87709. _markAsDirtyAndCompose(): void;
  87710. private _markAsDirtyAndDecompose;
  87711. /**
  87712. * Translate the bone in local or world space
  87713. * @param vec The amount to translate the bone
  87714. * @param space The space that the translation is in
  87715. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87716. */
  87717. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87718. /**
  87719. * Set the postion of the bone in local or world space
  87720. * @param position The position to set the bone
  87721. * @param space The space that the position is in
  87722. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87723. */
  87724. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87725. /**
  87726. * Set the absolute position of the bone (world space)
  87727. * @param position The position to set the bone
  87728. * @param mesh The mesh that this bone is attached to
  87729. */
  87730. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  87731. /**
  87732. * Scale the bone on the x, y and z axes (in local space)
  87733. * @param x The amount to scale the bone on the x axis
  87734. * @param y The amount to scale the bone on the y axis
  87735. * @param z The amount to scale the bone on the z axis
  87736. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  87737. */
  87738. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  87739. /**
  87740. * Set the bone scaling in local space
  87741. * @param scale defines the scaling vector
  87742. */
  87743. setScale(scale: Vector3): void;
  87744. /**
  87745. * Gets the current scaling in local space
  87746. * @returns the current scaling vector
  87747. */
  87748. getScale(): Vector3;
  87749. /**
  87750. * Gets the current scaling in local space and stores it in a target vector
  87751. * @param result defines the target vector
  87752. */
  87753. getScaleToRef(result: Vector3): void;
  87754. /**
  87755. * Set the yaw, pitch, and roll of the bone in local or world space
  87756. * @param yaw The rotation of the bone on the y axis
  87757. * @param pitch The rotation of the bone on the x axis
  87758. * @param roll The rotation of the bone on the z axis
  87759. * @param space The space that the axes of rotation are in
  87760. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87761. */
  87762. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  87763. /**
  87764. * Add a rotation to the bone on an axis in local or world space
  87765. * @param axis The axis to rotate the bone on
  87766. * @param amount The amount to rotate the bone
  87767. * @param space The space that the axis is in
  87768. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87769. */
  87770. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  87771. /**
  87772. * Set the rotation of the bone to a particular axis angle in local or world space
  87773. * @param axis The axis to rotate the bone on
  87774. * @param angle The angle that the bone should be rotated to
  87775. * @param space The space that the axis is in
  87776. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87777. */
  87778. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  87779. /**
  87780. * Set the euler rotation of the bone in local of world space
  87781. * @param rotation The euler rotation that the bone should be set to
  87782. * @param space The space that the rotation is in
  87783. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87784. */
  87785. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87786. /**
  87787. * Set the quaternion rotation of the bone in local of world space
  87788. * @param quat The quaternion rotation that the bone should be set to
  87789. * @param space The space that the rotation is in
  87790. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87791. */
  87792. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  87793. /**
  87794. * Set the rotation matrix of the bone in local of world space
  87795. * @param rotMat The rotation matrix that the bone should be set to
  87796. * @param space The space that the rotation is in
  87797. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87798. */
  87799. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  87800. private _rotateWithMatrix;
  87801. private _getNegativeRotationToRef;
  87802. /**
  87803. * Get the position of the bone in local or world space
  87804. * @param space The space that the returned position is in
  87805. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87806. * @returns The position of the bone
  87807. */
  87808. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  87809. /**
  87810. * Copy the position of the bone to a vector3 in local or world space
  87811. * @param space The space that the returned position is in
  87812. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87813. * @param result The vector3 to copy the position to
  87814. */
  87815. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  87816. /**
  87817. * Get the absolute position of the bone (world space)
  87818. * @param mesh The mesh that this bone is attached to
  87819. * @returns The absolute position of the bone
  87820. */
  87821. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  87822. /**
  87823. * Copy the absolute position of the bone (world space) to the result param
  87824. * @param mesh The mesh that this bone is attached to
  87825. * @param result The vector3 to copy the absolute position to
  87826. */
  87827. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  87828. /**
  87829. * Compute the absolute transforms of this bone and its children
  87830. */
  87831. computeAbsoluteTransforms(): void;
  87832. /**
  87833. * Get the world direction from an axis that is in the local space of the bone
  87834. * @param localAxis The local direction that is used to compute the world direction
  87835. * @param mesh The mesh that this bone is attached to
  87836. * @returns The world direction
  87837. */
  87838. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87839. /**
  87840. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  87841. * @param localAxis The local direction that is used to compute the world direction
  87842. * @param mesh The mesh that this bone is attached to
  87843. * @param result The vector3 that the world direction will be copied to
  87844. */
  87845. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87846. /**
  87847. * Get the euler rotation of the bone in local or world space
  87848. * @param space The space that the rotation should be in
  87849. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87850. * @returns The euler rotation
  87851. */
  87852. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  87853. /**
  87854. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  87855. * @param space The space that the rotation should be in
  87856. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87857. * @param result The vector3 that the rotation should be copied to
  87858. */
  87859. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87860. /**
  87861. * Get the quaternion rotation of the bone in either local or world space
  87862. * @param space The space that the rotation should be in
  87863. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87864. * @returns The quaternion rotation
  87865. */
  87866. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  87867. /**
  87868. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  87869. * @param space The space that the rotation should be in
  87870. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87871. * @param result The quaternion that the rotation should be copied to
  87872. */
  87873. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  87874. /**
  87875. * Get the rotation matrix of the bone in local or world space
  87876. * @param space The space that the rotation should be in
  87877. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87878. * @returns The rotation matrix
  87879. */
  87880. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  87881. /**
  87882. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  87883. * @param space The space that the rotation should be in
  87884. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87885. * @param result The quaternion that the rotation should be copied to
  87886. */
  87887. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  87888. /**
  87889. * Get the world position of a point that is in the local space of the bone
  87890. * @param position The local position
  87891. * @param mesh The mesh that this bone is attached to
  87892. * @returns The world position
  87893. */
  87894. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87895. /**
  87896. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  87897. * @param position The local position
  87898. * @param mesh The mesh that this bone is attached to
  87899. * @param result The vector3 that the world position should be copied to
  87900. */
  87901. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87902. /**
  87903. * Get the local position of a point that is in world space
  87904. * @param position The world position
  87905. * @param mesh The mesh that this bone is attached to
  87906. * @returns The local position
  87907. */
  87908. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87909. /**
  87910. * Get the local position of a point that is in world space and copy it to the result param
  87911. * @param position The world position
  87912. * @param mesh The mesh that this bone is attached to
  87913. * @param result The vector3 that the local position should be copied to
  87914. */
  87915. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87916. }
  87917. }
  87918. declare module BABYLON {
  87919. /**
  87920. * Defines a runtime animation
  87921. */
  87922. export class RuntimeAnimation {
  87923. private _events;
  87924. /**
  87925. * The current frame of the runtime animation
  87926. */
  87927. private _currentFrame;
  87928. /**
  87929. * The animation used by the runtime animation
  87930. */
  87931. private _animation;
  87932. /**
  87933. * The target of the runtime animation
  87934. */
  87935. private _target;
  87936. /**
  87937. * The initiating animatable
  87938. */
  87939. private _host;
  87940. /**
  87941. * The original value of the runtime animation
  87942. */
  87943. private _originalValue;
  87944. /**
  87945. * The original blend value of the runtime animation
  87946. */
  87947. private _originalBlendValue;
  87948. /**
  87949. * The offsets cache of the runtime animation
  87950. */
  87951. private _offsetsCache;
  87952. /**
  87953. * The high limits cache of the runtime animation
  87954. */
  87955. private _highLimitsCache;
  87956. /**
  87957. * Specifies if the runtime animation has been stopped
  87958. */
  87959. private _stopped;
  87960. /**
  87961. * The blending factor of the runtime animation
  87962. */
  87963. private _blendingFactor;
  87964. /**
  87965. * The BabylonJS scene
  87966. */
  87967. private _scene;
  87968. /**
  87969. * The current value of the runtime animation
  87970. */
  87971. private _currentValue;
  87972. /** @hidden */
  87973. _animationState: _IAnimationState;
  87974. /**
  87975. * The active target of the runtime animation
  87976. */
  87977. private _activeTargets;
  87978. private _currentActiveTarget;
  87979. private _directTarget;
  87980. /**
  87981. * The target path of the runtime animation
  87982. */
  87983. private _targetPath;
  87984. /**
  87985. * The weight of the runtime animation
  87986. */
  87987. private _weight;
  87988. /**
  87989. * The ratio offset of the runtime animation
  87990. */
  87991. private _ratioOffset;
  87992. /**
  87993. * The previous delay of the runtime animation
  87994. */
  87995. private _previousDelay;
  87996. /**
  87997. * The previous ratio of the runtime animation
  87998. */
  87999. private _previousRatio;
  88000. private _enableBlending;
  88001. private _keys;
  88002. private _minFrame;
  88003. private _maxFrame;
  88004. private _minValue;
  88005. private _maxValue;
  88006. private _targetIsArray;
  88007. /**
  88008. * Gets the current frame of the runtime animation
  88009. */
  88010. get currentFrame(): number;
  88011. /**
  88012. * Gets the weight of the runtime animation
  88013. */
  88014. get weight(): number;
  88015. /**
  88016. * Gets the current value of the runtime animation
  88017. */
  88018. get currentValue(): any;
  88019. /**
  88020. * Gets the target path of the runtime animation
  88021. */
  88022. get targetPath(): string;
  88023. /**
  88024. * Gets the actual target of the runtime animation
  88025. */
  88026. get target(): any;
  88027. /** @hidden */
  88028. _onLoop: () => void;
  88029. /**
  88030. * Create a new RuntimeAnimation object
  88031. * @param target defines the target of the animation
  88032. * @param animation defines the source animation object
  88033. * @param scene defines the hosting scene
  88034. * @param host defines the initiating Animatable
  88035. */
  88036. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  88037. private _preparePath;
  88038. /**
  88039. * Gets the animation from the runtime animation
  88040. */
  88041. get animation(): Animation;
  88042. /**
  88043. * Resets the runtime animation to the beginning
  88044. * @param restoreOriginal defines whether to restore the target property to the original value
  88045. */
  88046. reset(restoreOriginal?: boolean): void;
  88047. /**
  88048. * Specifies if the runtime animation is stopped
  88049. * @returns Boolean specifying if the runtime animation is stopped
  88050. */
  88051. isStopped(): boolean;
  88052. /**
  88053. * Disposes of the runtime animation
  88054. */
  88055. dispose(): void;
  88056. /**
  88057. * Apply the interpolated value to the target
  88058. * @param currentValue defines the value computed by the animation
  88059. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  88060. */
  88061. setValue(currentValue: any, weight: number): void;
  88062. private _getOriginalValues;
  88063. private _setValue;
  88064. /**
  88065. * Gets the loop pmode of the runtime animation
  88066. * @returns Loop Mode
  88067. */
  88068. private _getCorrectLoopMode;
  88069. /**
  88070. * Move the current animation to a given frame
  88071. * @param frame defines the frame to move to
  88072. */
  88073. goToFrame(frame: number): void;
  88074. /**
  88075. * @hidden Internal use only
  88076. */
  88077. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  88078. /**
  88079. * Execute the current animation
  88080. * @param delay defines the delay to add to the current frame
  88081. * @param from defines the lower bound of the animation range
  88082. * @param to defines the upper bound of the animation range
  88083. * @param loop defines if the current animation must loop
  88084. * @param speedRatio defines the current speed ratio
  88085. * @param weight defines the weight of the animation (default is -1 so no weight)
  88086. * @param onLoop optional callback called when animation loops
  88087. * @returns a boolean indicating if the animation is running
  88088. */
  88089. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  88090. }
  88091. }
  88092. declare module BABYLON {
  88093. /**
  88094. * Class used to store an actual running animation
  88095. */
  88096. export class Animatable {
  88097. /** defines the target object */
  88098. target: any;
  88099. /** defines the starting frame number (default is 0) */
  88100. fromFrame: number;
  88101. /** defines the ending frame number (default is 100) */
  88102. toFrame: number;
  88103. /** defines if the animation must loop (default is false) */
  88104. loopAnimation: boolean;
  88105. /** defines a callback to call when animation ends if it is not looping */
  88106. onAnimationEnd?: (() => void) | null | undefined;
  88107. /** defines a callback to call when animation loops */
  88108. onAnimationLoop?: (() => void) | null | undefined;
  88109. private _localDelayOffset;
  88110. private _pausedDelay;
  88111. private _runtimeAnimations;
  88112. private _paused;
  88113. private _scene;
  88114. private _speedRatio;
  88115. private _weight;
  88116. private _syncRoot;
  88117. /**
  88118. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  88119. * This will only apply for non looping animation (default is true)
  88120. */
  88121. disposeOnEnd: boolean;
  88122. /**
  88123. * Gets a boolean indicating if the animation has started
  88124. */
  88125. animationStarted: boolean;
  88126. /**
  88127. * Observer raised when the animation ends
  88128. */
  88129. onAnimationEndObservable: Observable<Animatable>;
  88130. /**
  88131. * Observer raised when the animation loops
  88132. */
  88133. onAnimationLoopObservable: Observable<Animatable>;
  88134. /**
  88135. * Gets the root Animatable used to synchronize and normalize animations
  88136. */
  88137. get syncRoot(): Nullable<Animatable>;
  88138. /**
  88139. * Gets the current frame of the first RuntimeAnimation
  88140. * Used to synchronize Animatables
  88141. */
  88142. get masterFrame(): number;
  88143. /**
  88144. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  88145. */
  88146. get weight(): number;
  88147. set weight(value: number);
  88148. /**
  88149. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  88150. */
  88151. get speedRatio(): number;
  88152. set speedRatio(value: number);
  88153. /**
  88154. * Creates a new Animatable
  88155. * @param scene defines the hosting scene
  88156. * @param target defines the target object
  88157. * @param fromFrame defines the starting frame number (default is 0)
  88158. * @param toFrame defines the ending frame number (default is 100)
  88159. * @param loopAnimation defines if the animation must loop (default is false)
  88160. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  88161. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  88162. * @param animations defines a group of animation to add to the new Animatable
  88163. * @param onAnimationLoop defines a callback to call when animation loops
  88164. */
  88165. constructor(scene: Scene,
  88166. /** defines the target object */
  88167. target: any,
  88168. /** defines the starting frame number (default is 0) */
  88169. fromFrame?: number,
  88170. /** defines the ending frame number (default is 100) */
  88171. toFrame?: number,
  88172. /** defines if the animation must loop (default is false) */
  88173. loopAnimation?: boolean, speedRatio?: number,
  88174. /** defines a callback to call when animation ends if it is not looping */
  88175. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  88176. /** defines a callback to call when animation loops */
  88177. onAnimationLoop?: (() => void) | null | undefined);
  88178. /**
  88179. * Synchronize and normalize current Animatable with a source Animatable
  88180. * This is useful when using animation weights and when animations are not of the same length
  88181. * @param root defines the root Animatable to synchronize with
  88182. * @returns the current Animatable
  88183. */
  88184. syncWith(root: Animatable): Animatable;
  88185. /**
  88186. * Gets the list of runtime animations
  88187. * @returns an array of RuntimeAnimation
  88188. */
  88189. getAnimations(): RuntimeAnimation[];
  88190. /**
  88191. * Adds more animations to the current animatable
  88192. * @param target defines the target of the animations
  88193. * @param animations defines the new animations to add
  88194. */
  88195. appendAnimations(target: any, animations: Animation[]): void;
  88196. /**
  88197. * Gets the source animation for a specific property
  88198. * @param property defines the propertyu to look for
  88199. * @returns null or the source animation for the given property
  88200. */
  88201. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  88202. /**
  88203. * Gets the runtime animation for a specific property
  88204. * @param property defines the propertyu to look for
  88205. * @returns null or the runtime animation for the given property
  88206. */
  88207. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  88208. /**
  88209. * Resets the animatable to its original state
  88210. */
  88211. reset(): void;
  88212. /**
  88213. * Allows the animatable to blend with current running animations
  88214. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  88215. * @param blendingSpeed defines the blending speed to use
  88216. */
  88217. enableBlending(blendingSpeed: number): void;
  88218. /**
  88219. * Disable animation blending
  88220. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  88221. */
  88222. disableBlending(): void;
  88223. /**
  88224. * Jump directly to a given frame
  88225. * @param frame defines the frame to jump to
  88226. */
  88227. goToFrame(frame: number): void;
  88228. /**
  88229. * Pause the animation
  88230. */
  88231. pause(): void;
  88232. /**
  88233. * Restart the animation
  88234. */
  88235. restart(): void;
  88236. private _raiseOnAnimationEnd;
  88237. /**
  88238. * Stop and delete the current animation
  88239. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  88240. * @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)
  88241. */
  88242. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  88243. /**
  88244. * Wait asynchronously for the animation to end
  88245. * @returns a promise which will be fullfilled when the animation ends
  88246. */
  88247. waitAsync(): Promise<Animatable>;
  88248. /** @hidden */
  88249. _animate(delay: number): boolean;
  88250. }
  88251. interface Scene {
  88252. /** @hidden */
  88253. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  88254. /** @hidden */
  88255. _processLateAnimationBindingsForMatrices(holder: {
  88256. totalWeight: number;
  88257. animations: RuntimeAnimation[];
  88258. originalValue: Matrix;
  88259. }): any;
  88260. /** @hidden */
  88261. _processLateAnimationBindingsForQuaternions(holder: {
  88262. totalWeight: number;
  88263. animations: RuntimeAnimation[];
  88264. originalValue: Quaternion;
  88265. }, refQuaternion: Quaternion): Quaternion;
  88266. /** @hidden */
  88267. _processLateAnimationBindings(): void;
  88268. /**
  88269. * Will start the animation sequence of a given target
  88270. * @param target defines the target
  88271. * @param from defines from which frame should animation start
  88272. * @param to defines until which frame should animation run.
  88273. * @param weight defines the weight to apply to the animation (1.0 by default)
  88274. * @param loop defines if the animation loops
  88275. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  88276. * @param onAnimationEnd defines the function to be executed when the animation ends
  88277. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  88278. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  88279. * @param onAnimationLoop defines the callback to call when an animation loops
  88280. * @returns the animatable object created for this animation
  88281. */
  88282. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  88283. /**
  88284. * Will start the animation sequence of a given target
  88285. * @param target defines the target
  88286. * @param from defines from which frame should animation start
  88287. * @param to defines until which frame should animation run.
  88288. * @param loop defines if the animation loops
  88289. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  88290. * @param onAnimationEnd defines the function to be executed when the animation ends
  88291. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  88292. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  88293. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  88294. * @param onAnimationLoop defines the callback to call when an animation loops
  88295. * @returns the animatable object created for this animation
  88296. */
  88297. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  88298. /**
  88299. * Will start the animation sequence of a given target and its hierarchy
  88300. * @param target defines the target
  88301. * @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.
  88302. * @param from defines from which frame should animation start
  88303. * @param to defines until which frame should animation run.
  88304. * @param loop defines if the animation loops
  88305. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  88306. * @param onAnimationEnd defines the function to be executed when the animation ends
  88307. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  88308. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  88309. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  88310. * @param onAnimationLoop defines the callback to call when an animation loops
  88311. * @returns the list of created animatables
  88312. */
  88313. 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[];
  88314. /**
  88315. * Begin a new animation on a given node
  88316. * @param target defines the target where the animation will take place
  88317. * @param animations defines the list of animations to start
  88318. * @param from defines the initial value
  88319. * @param to defines the final value
  88320. * @param loop defines if you want animation to loop (off by default)
  88321. * @param speedRatio defines the speed ratio to apply to all animations
  88322. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88323. * @param onAnimationLoop defines the callback to call when an animation loops
  88324. * @returns the list of created animatables
  88325. */
  88326. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  88327. /**
  88328. * Begin a new animation on a given node and its hierarchy
  88329. * @param target defines the root node where the animation will take place
  88330. * @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.
  88331. * @param animations defines the list of animations to start
  88332. * @param from defines the initial value
  88333. * @param to defines the final value
  88334. * @param loop defines if you want animation to loop (off by default)
  88335. * @param speedRatio defines the speed ratio to apply to all animations
  88336. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88337. * @param onAnimationLoop defines the callback to call when an animation loops
  88338. * @returns the list of animatables created for all nodes
  88339. */
  88340. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  88341. /**
  88342. * Gets the animatable associated with a specific target
  88343. * @param target defines the target of the animatable
  88344. * @returns the required animatable if found
  88345. */
  88346. getAnimatableByTarget(target: any): Nullable<Animatable>;
  88347. /**
  88348. * Gets all animatables associated with a given target
  88349. * @param target defines the target to look animatables for
  88350. * @returns an array of Animatables
  88351. */
  88352. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  88353. /**
  88354. * Stops and removes all animations that have been applied to the scene
  88355. */
  88356. stopAllAnimations(): void;
  88357. /**
  88358. * Gets the current delta time used by animation engine
  88359. */
  88360. deltaTime: number;
  88361. }
  88362. interface Bone {
  88363. /**
  88364. * Copy an animation range from another bone
  88365. * @param source defines the source bone
  88366. * @param rangeName defines the range name to copy
  88367. * @param frameOffset defines the frame offset
  88368. * @param rescaleAsRequired defines if rescaling must be applied if required
  88369. * @param skelDimensionsRatio defines the scaling ratio
  88370. * @returns true if operation was successful
  88371. */
  88372. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  88373. }
  88374. }
  88375. declare module BABYLON {
  88376. /**
  88377. * Class used to handle skinning animations
  88378. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  88379. */
  88380. export class Skeleton implements IAnimatable {
  88381. /** defines the skeleton name */
  88382. name: string;
  88383. /** defines the skeleton Id */
  88384. id: string;
  88385. /**
  88386. * Defines the list of child bones
  88387. */
  88388. bones: Bone[];
  88389. /**
  88390. * Defines an estimate of the dimension of the skeleton at rest
  88391. */
  88392. dimensionsAtRest: Vector3;
  88393. /**
  88394. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  88395. */
  88396. needInitialSkinMatrix: boolean;
  88397. /**
  88398. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  88399. */
  88400. overrideMesh: Nullable<AbstractMesh>;
  88401. /**
  88402. * Gets the list of animations attached to this skeleton
  88403. */
  88404. animations: Array<Animation>;
  88405. private _scene;
  88406. private _isDirty;
  88407. private _transformMatrices;
  88408. private _transformMatrixTexture;
  88409. private _meshesWithPoseMatrix;
  88410. private _animatables;
  88411. private _identity;
  88412. private _synchronizedWithMesh;
  88413. private _ranges;
  88414. private _lastAbsoluteTransformsUpdateId;
  88415. private _canUseTextureForBones;
  88416. private _uniqueId;
  88417. /** @hidden */
  88418. _numBonesWithLinkedTransformNode: number;
  88419. /** @hidden */
  88420. _hasWaitingData: Nullable<boolean>;
  88421. /**
  88422. * Specifies if the skeleton should be serialized
  88423. */
  88424. doNotSerialize: boolean;
  88425. private _useTextureToStoreBoneMatrices;
  88426. /**
  88427. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  88428. * Please note that this option is not available if the hardware does not support it
  88429. */
  88430. get useTextureToStoreBoneMatrices(): boolean;
  88431. set useTextureToStoreBoneMatrices(value: boolean);
  88432. private _animationPropertiesOverride;
  88433. /**
  88434. * Gets or sets the animation properties override
  88435. */
  88436. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  88437. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  88438. /**
  88439. * List of inspectable custom properties (used by the Inspector)
  88440. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88441. */
  88442. inspectableCustomProperties: IInspectable[];
  88443. /**
  88444. * An observable triggered before computing the skeleton's matrices
  88445. */
  88446. onBeforeComputeObservable: Observable<Skeleton>;
  88447. /**
  88448. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  88449. */
  88450. get isUsingTextureForMatrices(): boolean;
  88451. /**
  88452. * Gets the unique ID of this skeleton
  88453. */
  88454. get uniqueId(): number;
  88455. /**
  88456. * Creates a new skeleton
  88457. * @param name defines the skeleton name
  88458. * @param id defines the skeleton Id
  88459. * @param scene defines the hosting scene
  88460. */
  88461. constructor(
  88462. /** defines the skeleton name */
  88463. name: string,
  88464. /** defines the skeleton Id */
  88465. id: string, scene: Scene);
  88466. /**
  88467. * Gets the current object class name.
  88468. * @return the class name
  88469. */
  88470. getClassName(): string;
  88471. /**
  88472. * Returns an array containing the root bones
  88473. * @returns an array containing the root bones
  88474. */
  88475. getChildren(): Array<Bone>;
  88476. /**
  88477. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  88478. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  88479. * @returns a Float32Array containing matrices data
  88480. */
  88481. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  88482. /**
  88483. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  88484. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  88485. * @returns a raw texture containing the data
  88486. */
  88487. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  88488. /**
  88489. * Gets the current hosting scene
  88490. * @returns a scene object
  88491. */
  88492. getScene(): Scene;
  88493. /**
  88494. * Gets a string representing the current skeleton data
  88495. * @param fullDetails defines a boolean indicating if we want a verbose version
  88496. * @returns a string representing the current skeleton data
  88497. */
  88498. toString(fullDetails?: boolean): string;
  88499. /**
  88500. * Get bone's index searching by name
  88501. * @param name defines bone's name to search for
  88502. * @return the indice of the bone. Returns -1 if not found
  88503. */
  88504. getBoneIndexByName(name: string): number;
  88505. /**
  88506. * Creater a new animation range
  88507. * @param name defines the name of the range
  88508. * @param from defines the start key
  88509. * @param to defines the end key
  88510. */
  88511. createAnimationRange(name: string, from: number, to: number): void;
  88512. /**
  88513. * Delete a specific animation range
  88514. * @param name defines the name of the range
  88515. * @param deleteFrames defines if frames must be removed as well
  88516. */
  88517. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  88518. /**
  88519. * Gets a specific animation range
  88520. * @param name defines the name of the range to look for
  88521. * @returns the requested animation range or null if not found
  88522. */
  88523. getAnimationRange(name: string): Nullable<AnimationRange>;
  88524. /**
  88525. * Gets the list of all animation ranges defined on this skeleton
  88526. * @returns an array
  88527. */
  88528. getAnimationRanges(): Nullable<AnimationRange>[];
  88529. /**
  88530. * Copy animation range from a source skeleton.
  88531. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  88532. * @param source defines the source skeleton
  88533. * @param name defines the name of the range to copy
  88534. * @param rescaleAsRequired defines if rescaling must be applied if required
  88535. * @returns true if operation was successful
  88536. */
  88537. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  88538. /**
  88539. * Forces the skeleton to go to rest pose
  88540. */
  88541. returnToRest(): void;
  88542. private _getHighestAnimationFrame;
  88543. /**
  88544. * Begin a specific animation range
  88545. * @param name defines the name of the range to start
  88546. * @param loop defines if looping must be turned on (false by default)
  88547. * @param speedRatio defines the speed ratio to apply (1 by default)
  88548. * @param onAnimationEnd defines a callback which will be called when animation will end
  88549. * @returns a new animatable
  88550. */
  88551. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  88552. /** @hidden */
  88553. _markAsDirty(): void;
  88554. /** @hidden */
  88555. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  88556. /** @hidden */
  88557. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  88558. private _computeTransformMatrices;
  88559. /**
  88560. * Build all resources required to render a skeleton
  88561. */
  88562. prepare(): void;
  88563. /**
  88564. * Gets the list of animatables currently running for this skeleton
  88565. * @returns an array of animatables
  88566. */
  88567. getAnimatables(): IAnimatable[];
  88568. /**
  88569. * Clone the current skeleton
  88570. * @param name defines the name of the new skeleton
  88571. * @param id defines the id of the new skeleton
  88572. * @returns the new skeleton
  88573. */
  88574. clone(name: string, id?: string): Skeleton;
  88575. /**
  88576. * Enable animation blending for this skeleton
  88577. * @param blendingSpeed defines the blending speed to apply
  88578. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  88579. */
  88580. enableBlending(blendingSpeed?: number): void;
  88581. /**
  88582. * Releases all resources associated with the current skeleton
  88583. */
  88584. dispose(): void;
  88585. /**
  88586. * Serialize the skeleton in a JSON object
  88587. * @returns a JSON object
  88588. */
  88589. serialize(): any;
  88590. /**
  88591. * Creates a new skeleton from serialized data
  88592. * @param parsedSkeleton defines the serialized data
  88593. * @param scene defines the hosting scene
  88594. * @returns a new skeleton
  88595. */
  88596. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  88597. /**
  88598. * Compute all node absolute transforms
  88599. * @param forceUpdate defines if computation must be done even if cache is up to date
  88600. */
  88601. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  88602. /**
  88603. * Gets the root pose matrix
  88604. * @returns a matrix
  88605. */
  88606. getPoseMatrix(): Nullable<Matrix>;
  88607. /**
  88608. * Sorts bones per internal index
  88609. */
  88610. sortBones(): void;
  88611. private _sortBones;
  88612. }
  88613. }
  88614. declare module BABYLON {
  88615. /**
  88616. * Creates an instance based on a source mesh.
  88617. */
  88618. export class InstancedMesh extends AbstractMesh {
  88619. private _sourceMesh;
  88620. private _currentLOD;
  88621. /** @hidden */
  88622. _indexInSourceMeshInstanceArray: number;
  88623. constructor(name: string, source: Mesh);
  88624. /**
  88625. * Returns the string "InstancedMesh".
  88626. */
  88627. getClassName(): string;
  88628. /** Gets the list of lights affecting that mesh */
  88629. get lightSources(): Light[];
  88630. _resyncLightSources(): void;
  88631. _resyncLightSource(light: Light): void;
  88632. _removeLightSource(light: Light, dispose: boolean): void;
  88633. /**
  88634. * If the source mesh receives shadows
  88635. */
  88636. get receiveShadows(): boolean;
  88637. /**
  88638. * The material of the source mesh
  88639. */
  88640. get material(): Nullable<Material>;
  88641. /**
  88642. * Visibility of the source mesh
  88643. */
  88644. get visibility(): number;
  88645. /**
  88646. * Skeleton of the source mesh
  88647. */
  88648. get skeleton(): Nullable<Skeleton>;
  88649. /**
  88650. * Rendering ground id of the source mesh
  88651. */
  88652. get renderingGroupId(): number;
  88653. set renderingGroupId(value: number);
  88654. /**
  88655. * Returns the total number of vertices (integer).
  88656. */
  88657. getTotalVertices(): number;
  88658. /**
  88659. * Returns a positive integer : the total number of indices in this mesh geometry.
  88660. * @returns the numner of indices or zero if the mesh has no geometry.
  88661. */
  88662. getTotalIndices(): number;
  88663. /**
  88664. * The source mesh of the instance
  88665. */
  88666. get sourceMesh(): Mesh;
  88667. /**
  88668. * Is this node ready to be used/rendered
  88669. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88670. * @return {boolean} is it ready
  88671. */
  88672. isReady(completeCheck?: boolean): boolean;
  88673. /**
  88674. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88675. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  88676. * @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.
  88677. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  88678. */
  88679. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  88680. /**
  88681. * Sets the vertex data of the mesh geometry for the requested `kind`.
  88682. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  88683. * The `data` are either a numeric array either a Float32Array.
  88684. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  88685. * 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).
  88686. * Note that a new underlying VertexBuffer object is created each call.
  88687. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  88688. *
  88689. * Possible `kind` values :
  88690. * - VertexBuffer.PositionKind
  88691. * - VertexBuffer.UVKind
  88692. * - VertexBuffer.UV2Kind
  88693. * - VertexBuffer.UV3Kind
  88694. * - VertexBuffer.UV4Kind
  88695. * - VertexBuffer.UV5Kind
  88696. * - VertexBuffer.UV6Kind
  88697. * - VertexBuffer.ColorKind
  88698. * - VertexBuffer.MatricesIndicesKind
  88699. * - VertexBuffer.MatricesIndicesExtraKind
  88700. * - VertexBuffer.MatricesWeightsKind
  88701. * - VertexBuffer.MatricesWeightsExtraKind
  88702. *
  88703. * Returns the Mesh.
  88704. */
  88705. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  88706. /**
  88707. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  88708. * If the mesh has no geometry, it is simply returned as it is.
  88709. * The `data` are either a numeric array either a Float32Array.
  88710. * No new underlying VertexBuffer object is created.
  88711. * 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.
  88712. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  88713. *
  88714. * Possible `kind` values :
  88715. * - VertexBuffer.PositionKind
  88716. * - VertexBuffer.UVKind
  88717. * - VertexBuffer.UV2Kind
  88718. * - VertexBuffer.UV3Kind
  88719. * - VertexBuffer.UV4Kind
  88720. * - VertexBuffer.UV5Kind
  88721. * - VertexBuffer.UV6Kind
  88722. * - VertexBuffer.ColorKind
  88723. * - VertexBuffer.MatricesIndicesKind
  88724. * - VertexBuffer.MatricesIndicesExtraKind
  88725. * - VertexBuffer.MatricesWeightsKind
  88726. * - VertexBuffer.MatricesWeightsExtraKind
  88727. *
  88728. * Returns the Mesh.
  88729. */
  88730. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  88731. /**
  88732. * Sets the mesh indices.
  88733. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  88734. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  88735. * This method creates a new index buffer each call.
  88736. * Returns the Mesh.
  88737. */
  88738. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  88739. /**
  88740. * Boolean : True if the mesh owns the requested kind of data.
  88741. */
  88742. isVerticesDataPresent(kind: string): boolean;
  88743. /**
  88744. * Returns an array of indices (IndicesArray).
  88745. */
  88746. getIndices(): Nullable<IndicesArray>;
  88747. get _positions(): Nullable<Vector3[]>;
  88748. /**
  88749. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  88750. * This means the mesh underlying bounding box and sphere are recomputed.
  88751. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  88752. * @returns the current mesh
  88753. */
  88754. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  88755. /** @hidden */
  88756. _preActivate(): InstancedMesh;
  88757. /** @hidden */
  88758. _activate(renderId: number, intermediateRendering: boolean): boolean;
  88759. /** @hidden */
  88760. _postActivate(): void;
  88761. getWorldMatrix(): Matrix;
  88762. get isAnInstance(): boolean;
  88763. /**
  88764. * Returns the current associated LOD AbstractMesh.
  88765. */
  88766. getLOD(camera: Camera): AbstractMesh;
  88767. /** @hidden */
  88768. _preActivateForIntermediateRendering(renderId: number): Mesh;
  88769. /** @hidden */
  88770. _syncSubMeshes(): InstancedMesh;
  88771. /** @hidden */
  88772. _generatePointsArray(): boolean;
  88773. /**
  88774. * Creates a new InstancedMesh from the current mesh.
  88775. * - name (string) : the cloned mesh name
  88776. * - newParent (optional Node) : the optional Node to parent the clone to.
  88777. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  88778. *
  88779. * Returns the clone.
  88780. */
  88781. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  88782. /**
  88783. * Disposes the InstancedMesh.
  88784. * Returns nothing.
  88785. */
  88786. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88787. }
  88788. interface Mesh {
  88789. /**
  88790. * Register a custom buffer that will be instanced
  88791. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88792. * @param kind defines the buffer kind
  88793. * @param stride defines the stride in floats
  88794. */
  88795. registerInstancedBuffer(kind: string, stride: number): void;
  88796. /** @hidden */
  88797. _userInstancedBuffersStorage: {
  88798. data: {
  88799. [key: string]: Float32Array;
  88800. };
  88801. sizes: {
  88802. [key: string]: number;
  88803. };
  88804. vertexBuffers: {
  88805. [key: string]: Nullable<VertexBuffer>;
  88806. };
  88807. strides: {
  88808. [key: string]: number;
  88809. };
  88810. };
  88811. }
  88812. interface AbstractMesh {
  88813. /**
  88814. * Object used to store instanced buffers defined by user
  88815. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88816. */
  88817. instancedBuffers: {
  88818. [key: string]: any;
  88819. };
  88820. }
  88821. }
  88822. declare module BABYLON {
  88823. /**
  88824. * Defines the options associated with the creation of a shader material.
  88825. */
  88826. export interface IShaderMaterialOptions {
  88827. /**
  88828. * Does the material work in alpha blend mode
  88829. */
  88830. needAlphaBlending: boolean;
  88831. /**
  88832. * Does the material work in alpha test mode
  88833. */
  88834. needAlphaTesting: boolean;
  88835. /**
  88836. * The list of attribute names used in the shader
  88837. */
  88838. attributes: string[];
  88839. /**
  88840. * The list of unifrom names used in the shader
  88841. */
  88842. uniforms: string[];
  88843. /**
  88844. * The list of UBO names used in the shader
  88845. */
  88846. uniformBuffers: string[];
  88847. /**
  88848. * The list of sampler names used in the shader
  88849. */
  88850. samplers: string[];
  88851. /**
  88852. * The list of defines used in the shader
  88853. */
  88854. defines: string[];
  88855. }
  88856. /**
  88857. * 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.
  88858. *
  88859. * This returned material effects how the mesh will look based on the code in the shaders.
  88860. *
  88861. * @see http://doc.babylonjs.com/how_to/shader_material
  88862. */
  88863. export class ShaderMaterial extends Material {
  88864. private _shaderPath;
  88865. private _options;
  88866. private _textures;
  88867. private _textureArrays;
  88868. private _floats;
  88869. private _ints;
  88870. private _floatsArrays;
  88871. private _colors3;
  88872. private _colors3Arrays;
  88873. private _colors4;
  88874. private _colors4Arrays;
  88875. private _vectors2;
  88876. private _vectors3;
  88877. private _vectors4;
  88878. private _matrices;
  88879. private _matrixArrays;
  88880. private _matrices3x3;
  88881. private _matrices2x2;
  88882. private _vectors2Arrays;
  88883. private _vectors3Arrays;
  88884. private _vectors4Arrays;
  88885. private _cachedWorldViewMatrix;
  88886. private _cachedWorldViewProjectionMatrix;
  88887. private _renderId;
  88888. private _multiview;
  88889. /**
  88890. * Instantiate a new shader material.
  88891. * 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.
  88892. * This returned material effects how the mesh will look based on the code in the shaders.
  88893. * @see http://doc.babylonjs.com/how_to/shader_material
  88894. * @param name Define the name of the material in the scene
  88895. * @param scene Define the scene the material belongs to
  88896. * @param shaderPath Defines the route to the shader code in one of three ways:
  88897. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  88898. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  88899. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  88900. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  88901. * @param options Define the options used to create the shader
  88902. */
  88903. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  88904. /**
  88905. * Gets the shader path used to define the shader code
  88906. * It can be modified to trigger a new compilation
  88907. */
  88908. get shaderPath(): any;
  88909. /**
  88910. * Sets the shader path used to define the shader code
  88911. * It can be modified to trigger a new compilation
  88912. */
  88913. set shaderPath(shaderPath: any);
  88914. /**
  88915. * Gets the options used to compile the shader.
  88916. * They can be modified to trigger a new compilation
  88917. */
  88918. get options(): IShaderMaterialOptions;
  88919. /**
  88920. * Gets the current class name of the material e.g. "ShaderMaterial"
  88921. * Mainly use in serialization.
  88922. * @returns the class name
  88923. */
  88924. getClassName(): string;
  88925. /**
  88926. * Specifies if the material will require alpha blending
  88927. * @returns a boolean specifying if alpha blending is needed
  88928. */
  88929. needAlphaBlending(): boolean;
  88930. /**
  88931. * Specifies if this material should be rendered in alpha test mode
  88932. * @returns a boolean specifying if an alpha test is needed.
  88933. */
  88934. needAlphaTesting(): boolean;
  88935. private _checkUniform;
  88936. /**
  88937. * Set a texture in the shader.
  88938. * @param name Define the name of the uniform samplers as defined in the shader
  88939. * @param texture Define the texture to bind to this sampler
  88940. * @return the material itself allowing "fluent" like uniform updates
  88941. */
  88942. setTexture(name: string, texture: Texture): ShaderMaterial;
  88943. /**
  88944. * Set a texture array in the shader.
  88945. * @param name Define the name of the uniform sampler array as defined in the shader
  88946. * @param textures Define the list of textures to bind to this sampler
  88947. * @return the material itself allowing "fluent" like uniform updates
  88948. */
  88949. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  88950. /**
  88951. * Set a float in the shader.
  88952. * @param name Define the name of the uniform as defined in the shader
  88953. * @param value Define the value to give to the uniform
  88954. * @return the material itself allowing "fluent" like uniform updates
  88955. */
  88956. setFloat(name: string, value: number): ShaderMaterial;
  88957. /**
  88958. * Set a int in the shader.
  88959. * @param name Define the name of the uniform as defined in the shader
  88960. * @param value Define the value to give to the uniform
  88961. * @return the material itself allowing "fluent" like uniform updates
  88962. */
  88963. setInt(name: string, value: number): ShaderMaterial;
  88964. /**
  88965. * Set an array of floats in the shader.
  88966. * @param name Define the name of the uniform as defined in the shader
  88967. * @param value Define the value to give to the uniform
  88968. * @return the material itself allowing "fluent" like uniform updates
  88969. */
  88970. setFloats(name: string, value: number[]): ShaderMaterial;
  88971. /**
  88972. * Set a vec3 in the shader from a Color3.
  88973. * @param name Define the name of the uniform as defined in the shader
  88974. * @param value Define the value to give to the uniform
  88975. * @return the material itself allowing "fluent" like uniform updates
  88976. */
  88977. setColor3(name: string, value: Color3): ShaderMaterial;
  88978. /**
  88979. * Set a vec3 array in the shader from a Color3 array.
  88980. * @param name Define the name of the uniform as defined in the shader
  88981. * @param value Define the value to give to the uniform
  88982. * @return the material itself allowing "fluent" like uniform updates
  88983. */
  88984. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  88985. /**
  88986. * Set a vec4 in the shader from a Color4.
  88987. * @param name Define the name of the uniform as defined in the shader
  88988. * @param value Define the value to give to the uniform
  88989. * @return the material itself allowing "fluent" like uniform updates
  88990. */
  88991. setColor4(name: string, value: Color4): ShaderMaterial;
  88992. /**
  88993. * Set a vec4 array in the shader from a Color4 array.
  88994. * @param name Define the name of the uniform as defined in the shader
  88995. * @param value Define the value to give to the uniform
  88996. * @return the material itself allowing "fluent" like uniform updates
  88997. */
  88998. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  88999. /**
  89000. * Set a vec2 in the shader from a Vector2.
  89001. * @param name Define the name of the uniform as defined in the shader
  89002. * @param value Define the value to give to the uniform
  89003. * @return the material itself allowing "fluent" like uniform updates
  89004. */
  89005. setVector2(name: string, value: Vector2): ShaderMaterial;
  89006. /**
  89007. * Set a vec3 in the shader from a Vector3.
  89008. * @param name Define the name of the uniform as defined in the shader
  89009. * @param value Define the value to give to the uniform
  89010. * @return the material itself allowing "fluent" like uniform updates
  89011. */
  89012. setVector3(name: string, value: Vector3): ShaderMaterial;
  89013. /**
  89014. * Set a vec4 in the shader from a Vector4.
  89015. * @param name Define the name of the uniform as defined in the shader
  89016. * @param value Define the value to give to the uniform
  89017. * @return the material itself allowing "fluent" like uniform updates
  89018. */
  89019. setVector4(name: string, value: Vector4): ShaderMaterial;
  89020. /**
  89021. * Set a mat4 in the shader from a Matrix.
  89022. * @param name Define the name of the uniform as defined in the shader
  89023. * @param value Define the value to give to the uniform
  89024. * @return the material itself allowing "fluent" like uniform updates
  89025. */
  89026. setMatrix(name: string, value: Matrix): ShaderMaterial;
  89027. /**
  89028. * Set a float32Array in the shader from a matrix array.
  89029. * @param name Define the name of the uniform as defined in the shader
  89030. * @param value Define the value to give to the uniform
  89031. * @return the material itself allowing "fluent" like uniform updates
  89032. */
  89033. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  89034. /**
  89035. * Set a mat3 in the shader from a Float32Array.
  89036. * @param name Define the name of the uniform as defined in the shader
  89037. * @param value Define the value to give to the uniform
  89038. * @return the material itself allowing "fluent" like uniform updates
  89039. */
  89040. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  89041. /**
  89042. * Set a mat2 in the shader from a Float32Array.
  89043. * @param name Define the name of the uniform as defined in the shader
  89044. * @param value Define the value to give to the uniform
  89045. * @return the material itself allowing "fluent" like uniform updates
  89046. */
  89047. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  89048. /**
  89049. * Set a vec2 array in the shader from a number array.
  89050. * @param name Define the name of the uniform as defined in the shader
  89051. * @param value Define the value to give to the uniform
  89052. * @return the material itself allowing "fluent" like uniform updates
  89053. */
  89054. setArray2(name: string, value: number[]): ShaderMaterial;
  89055. /**
  89056. * Set a vec3 array in the shader from a number array.
  89057. * @param name Define the name of the uniform as defined in the shader
  89058. * @param value Define the value to give to the uniform
  89059. * @return the material itself allowing "fluent" like uniform updates
  89060. */
  89061. setArray3(name: string, value: number[]): ShaderMaterial;
  89062. /**
  89063. * Set a vec4 array in the shader from a number array.
  89064. * @param name Define the name of the uniform as defined in the shader
  89065. * @param value Define the value to give to the uniform
  89066. * @return the material itself allowing "fluent" like uniform updates
  89067. */
  89068. setArray4(name: string, value: number[]): ShaderMaterial;
  89069. private _checkCache;
  89070. /**
  89071. * Specifies that the submesh is ready to be used
  89072. * @param mesh defines the mesh to check
  89073. * @param subMesh defines which submesh to check
  89074. * @param useInstances specifies that instances should be used
  89075. * @returns a boolean indicating that the submesh is ready or not
  89076. */
  89077. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  89078. /**
  89079. * Checks if the material is ready to render the requested mesh
  89080. * @param mesh Define the mesh to render
  89081. * @param useInstances Define whether or not the material is used with instances
  89082. * @returns true if ready, otherwise false
  89083. */
  89084. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  89085. /**
  89086. * Binds the world matrix to the material
  89087. * @param world defines the world transformation matrix
  89088. */
  89089. bindOnlyWorldMatrix(world: Matrix): void;
  89090. /**
  89091. * Binds the material to the mesh
  89092. * @param world defines the world transformation matrix
  89093. * @param mesh defines the mesh to bind the material to
  89094. */
  89095. bind(world: Matrix, mesh?: Mesh): void;
  89096. /**
  89097. * Gets the active textures from the material
  89098. * @returns an array of textures
  89099. */
  89100. getActiveTextures(): BaseTexture[];
  89101. /**
  89102. * Specifies if the material uses a texture
  89103. * @param texture defines the texture to check against the material
  89104. * @returns a boolean specifying if the material uses the texture
  89105. */
  89106. hasTexture(texture: BaseTexture): boolean;
  89107. /**
  89108. * Makes a duplicate of the material, and gives it a new name
  89109. * @param name defines the new name for the duplicated material
  89110. * @returns the cloned material
  89111. */
  89112. clone(name: string): ShaderMaterial;
  89113. /**
  89114. * Disposes the material
  89115. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  89116. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  89117. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  89118. */
  89119. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  89120. /**
  89121. * Serializes this material in a JSON representation
  89122. * @returns the serialized material object
  89123. */
  89124. serialize(): any;
  89125. /**
  89126. * Creates a shader material from parsed shader material data
  89127. * @param source defines the JSON represnetation of the material
  89128. * @param scene defines the hosting scene
  89129. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  89130. * @returns a new material
  89131. */
  89132. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  89133. }
  89134. }
  89135. declare module BABYLON {
  89136. /** @hidden */
  89137. export var colorPixelShader: {
  89138. name: string;
  89139. shader: string;
  89140. };
  89141. }
  89142. declare module BABYLON {
  89143. /** @hidden */
  89144. export var colorVertexShader: {
  89145. name: string;
  89146. shader: string;
  89147. };
  89148. }
  89149. declare module BABYLON {
  89150. /**
  89151. * Line mesh
  89152. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  89153. */
  89154. export class LinesMesh extends Mesh {
  89155. /**
  89156. * If vertex color should be applied to the mesh
  89157. */
  89158. readonly useVertexColor?: boolean | undefined;
  89159. /**
  89160. * If vertex alpha should be applied to the mesh
  89161. */
  89162. readonly useVertexAlpha?: boolean | undefined;
  89163. /**
  89164. * Color of the line (Default: White)
  89165. */
  89166. color: Color3;
  89167. /**
  89168. * Alpha of the line (Default: 1)
  89169. */
  89170. alpha: number;
  89171. /**
  89172. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  89173. * This margin is expressed in world space coordinates, so its value may vary.
  89174. * Default value is 0.1
  89175. */
  89176. intersectionThreshold: number;
  89177. private _colorShader;
  89178. private color4;
  89179. /**
  89180. * Creates a new LinesMesh
  89181. * @param name defines the name
  89182. * @param scene defines the hosting scene
  89183. * @param parent defines the parent mesh if any
  89184. * @param source defines the optional source LinesMesh used to clone data from
  89185. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  89186. * When false, achieved by calling a clone(), also passing False.
  89187. * This will make creation of children, recursive.
  89188. * @param useVertexColor defines if this LinesMesh supports vertex color
  89189. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  89190. */
  89191. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  89192. /**
  89193. * If vertex color should be applied to the mesh
  89194. */
  89195. useVertexColor?: boolean | undefined,
  89196. /**
  89197. * If vertex alpha should be applied to the mesh
  89198. */
  89199. useVertexAlpha?: boolean | undefined);
  89200. private _addClipPlaneDefine;
  89201. private _removeClipPlaneDefine;
  89202. isReady(): boolean;
  89203. /**
  89204. * Returns the string "LineMesh"
  89205. */
  89206. getClassName(): string;
  89207. /**
  89208. * @hidden
  89209. */
  89210. get material(): Material;
  89211. /**
  89212. * @hidden
  89213. */
  89214. set material(value: Material);
  89215. /**
  89216. * @hidden
  89217. */
  89218. get checkCollisions(): boolean;
  89219. /** @hidden */
  89220. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  89221. /** @hidden */
  89222. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  89223. /**
  89224. * Disposes of the line mesh
  89225. * @param doNotRecurse If children should be disposed
  89226. */
  89227. dispose(doNotRecurse?: boolean): void;
  89228. /**
  89229. * Returns a new LineMesh object cloned from the current one.
  89230. */
  89231. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  89232. /**
  89233. * Creates a new InstancedLinesMesh object from the mesh model.
  89234. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  89235. * @param name defines the name of the new instance
  89236. * @returns a new InstancedLinesMesh
  89237. */
  89238. createInstance(name: string): InstancedLinesMesh;
  89239. }
  89240. /**
  89241. * Creates an instance based on a source LinesMesh
  89242. */
  89243. export class InstancedLinesMesh extends InstancedMesh {
  89244. /**
  89245. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  89246. * This margin is expressed in world space coordinates, so its value may vary.
  89247. * Initilized with the intersectionThreshold value of the source LinesMesh
  89248. */
  89249. intersectionThreshold: number;
  89250. constructor(name: string, source: LinesMesh);
  89251. /**
  89252. * Returns the string "InstancedLinesMesh".
  89253. */
  89254. getClassName(): string;
  89255. }
  89256. }
  89257. declare module BABYLON {
  89258. /** @hidden */
  89259. export var linePixelShader: {
  89260. name: string;
  89261. shader: string;
  89262. };
  89263. }
  89264. declare module BABYLON {
  89265. /** @hidden */
  89266. export var lineVertexShader: {
  89267. name: string;
  89268. shader: string;
  89269. };
  89270. }
  89271. declare module BABYLON {
  89272. interface AbstractMesh {
  89273. /**
  89274. * Gets the edgesRenderer associated with the mesh
  89275. */
  89276. edgesRenderer: Nullable<EdgesRenderer>;
  89277. }
  89278. interface LinesMesh {
  89279. /**
  89280. * Enables the edge rendering mode on the mesh.
  89281. * This mode makes the mesh edges visible
  89282. * @param epsilon defines the maximal distance between two angles to detect a face
  89283. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  89284. * @returns the currentAbstractMesh
  89285. * @see https://www.babylonjs-playground.com/#19O9TU#0
  89286. */
  89287. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  89288. }
  89289. interface InstancedLinesMesh {
  89290. /**
  89291. * Enables the edge rendering mode on the mesh.
  89292. * This mode makes the mesh edges visible
  89293. * @param epsilon defines the maximal distance between two angles to detect a face
  89294. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  89295. * @returns the current InstancedLinesMesh
  89296. * @see https://www.babylonjs-playground.com/#19O9TU#0
  89297. */
  89298. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  89299. }
  89300. /**
  89301. * Defines the minimum contract an Edges renderer should follow.
  89302. */
  89303. export interface IEdgesRenderer extends IDisposable {
  89304. /**
  89305. * Gets or sets a boolean indicating if the edgesRenderer is active
  89306. */
  89307. isEnabled: boolean;
  89308. /**
  89309. * Renders the edges of the attached mesh,
  89310. */
  89311. render(): void;
  89312. /**
  89313. * Checks wether or not the edges renderer is ready to render.
  89314. * @return true if ready, otherwise false.
  89315. */
  89316. isReady(): boolean;
  89317. }
  89318. /**
  89319. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  89320. */
  89321. export class EdgesRenderer implements IEdgesRenderer {
  89322. /**
  89323. * Define the size of the edges with an orthographic camera
  89324. */
  89325. edgesWidthScalerForOrthographic: number;
  89326. /**
  89327. * Define the size of the edges with a perspective camera
  89328. */
  89329. edgesWidthScalerForPerspective: number;
  89330. protected _source: AbstractMesh;
  89331. protected _linesPositions: number[];
  89332. protected _linesNormals: number[];
  89333. protected _linesIndices: number[];
  89334. protected _epsilon: number;
  89335. protected _indicesCount: number;
  89336. protected _lineShader: ShaderMaterial;
  89337. protected _ib: DataBuffer;
  89338. protected _buffers: {
  89339. [key: string]: Nullable<VertexBuffer>;
  89340. };
  89341. protected _checkVerticesInsteadOfIndices: boolean;
  89342. private _meshRebuildObserver;
  89343. private _meshDisposeObserver;
  89344. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  89345. isEnabled: boolean;
  89346. /**
  89347. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  89348. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  89349. * @param source Mesh used to create edges
  89350. * @param epsilon sum of angles in adjacency to check for edge
  89351. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  89352. * @param generateEdgesLines - should generate Lines or only prepare resources.
  89353. */
  89354. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  89355. protected _prepareRessources(): void;
  89356. /** @hidden */
  89357. _rebuild(): void;
  89358. /**
  89359. * Releases the required resources for the edges renderer
  89360. */
  89361. dispose(): void;
  89362. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  89363. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  89364. /**
  89365. * Checks if the pair of p0 and p1 is en edge
  89366. * @param faceIndex
  89367. * @param edge
  89368. * @param faceNormals
  89369. * @param p0
  89370. * @param p1
  89371. * @private
  89372. */
  89373. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  89374. /**
  89375. * push line into the position, normal and index buffer
  89376. * @protected
  89377. */
  89378. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  89379. /**
  89380. * Generates lines edges from adjacencjes
  89381. * @private
  89382. */
  89383. _generateEdgesLines(): void;
  89384. /**
  89385. * Checks wether or not the edges renderer is ready to render.
  89386. * @return true if ready, otherwise false.
  89387. */
  89388. isReady(): boolean;
  89389. /**
  89390. * Renders the edges of the attached mesh,
  89391. */
  89392. render(): void;
  89393. }
  89394. /**
  89395. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  89396. */
  89397. export class LineEdgesRenderer extends EdgesRenderer {
  89398. /**
  89399. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  89400. * @param source LineMesh used to generate edges
  89401. * @param epsilon not important (specified angle for edge detection)
  89402. * @param checkVerticesInsteadOfIndices not important for LineMesh
  89403. */
  89404. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  89405. /**
  89406. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  89407. */
  89408. _generateEdgesLines(): void;
  89409. }
  89410. }
  89411. declare module BABYLON {
  89412. /**
  89413. * This represents the object necessary to create a rendering group.
  89414. * This is exclusively used and created by the rendering manager.
  89415. * To modify the behavior, you use the available helpers in your scene or meshes.
  89416. * @hidden
  89417. */
  89418. export class RenderingGroup {
  89419. index: number;
  89420. private static _zeroVector;
  89421. private _scene;
  89422. private _opaqueSubMeshes;
  89423. private _transparentSubMeshes;
  89424. private _alphaTestSubMeshes;
  89425. private _depthOnlySubMeshes;
  89426. private _particleSystems;
  89427. private _spriteManagers;
  89428. private _opaqueSortCompareFn;
  89429. private _alphaTestSortCompareFn;
  89430. private _transparentSortCompareFn;
  89431. private _renderOpaque;
  89432. private _renderAlphaTest;
  89433. private _renderTransparent;
  89434. /** @hidden */
  89435. _edgesRenderers: SmartArray<IEdgesRenderer>;
  89436. onBeforeTransparentRendering: () => void;
  89437. /**
  89438. * Set the opaque sort comparison function.
  89439. * If null the sub meshes will be render in the order they were created
  89440. */
  89441. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89442. /**
  89443. * Set the alpha test sort comparison function.
  89444. * If null the sub meshes will be render in the order they were created
  89445. */
  89446. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89447. /**
  89448. * Set the transparent sort comparison function.
  89449. * If null the sub meshes will be render in the order they were created
  89450. */
  89451. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89452. /**
  89453. * Creates a new rendering group.
  89454. * @param index The rendering group index
  89455. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  89456. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  89457. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  89458. */
  89459. 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>);
  89460. /**
  89461. * Render all the sub meshes contained in the group.
  89462. * @param customRenderFunction Used to override the default render behaviour of the group.
  89463. * @returns true if rendered some submeshes.
  89464. */
  89465. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  89466. /**
  89467. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  89468. * @param subMeshes The submeshes to render
  89469. */
  89470. private renderOpaqueSorted;
  89471. /**
  89472. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  89473. * @param subMeshes The submeshes to render
  89474. */
  89475. private renderAlphaTestSorted;
  89476. /**
  89477. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  89478. * @param subMeshes The submeshes to render
  89479. */
  89480. private renderTransparentSorted;
  89481. /**
  89482. * Renders the submeshes in a specified order.
  89483. * @param subMeshes The submeshes to sort before render
  89484. * @param sortCompareFn The comparison function use to sort
  89485. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  89486. * @param transparent Specifies to activate blending if true
  89487. */
  89488. private static renderSorted;
  89489. /**
  89490. * Renders the submeshes in the order they were dispatched (no sort applied).
  89491. * @param subMeshes The submeshes to render
  89492. */
  89493. private static renderUnsorted;
  89494. /**
  89495. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89496. * are rendered back to front if in the same alpha index.
  89497. *
  89498. * @param a The first submesh
  89499. * @param b The second submesh
  89500. * @returns The result of the comparison
  89501. */
  89502. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  89503. /**
  89504. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89505. * are rendered back to front.
  89506. *
  89507. * @param a The first submesh
  89508. * @param b The second submesh
  89509. * @returns The result of the comparison
  89510. */
  89511. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  89512. /**
  89513. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89514. * are rendered front to back (prevent overdraw).
  89515. *
  89516. * @param a The first submesh
  89517. * @param b The second submesh
  89518. * @returns The result of the comparison
  89519. */
  89520. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  89521. /**
  89522. * Resets the different lists of submeshes to prepare a new frame.
  89523. */
  89524. prepare(): void;
  89525. dispose(): void;
  89526. /**
  89527. * Inserts the submesh in its correct queue depending on its material.
  89528. * @param subMesh The submesh to dispatch
  89529. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89530. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89531. */
  89532. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89533. dispatchSprites(spriteManager: ISpriteManager): void;
  89534. dispatchParticles(particleSystem: IParticleSystem): void;
  89535. private _renderParticles;
  89536. private _renderSprites;
  89537. }
  89538. }
  89539. declare module BABYLON {
  89540. /**
  89541. * Interface describing the different options available in the rendering manager
  89542. * regarding Auto Clear between groups.
  89543. */
  89544. export interface IRenderingManagerAutoClearSetup {
  89545. /**
  89546. * Defines whether or not autoclear is enable.
  89547. */
  89548. autoClear: boolean;
  89549. /**
  89550. * Defines whether or not to autoclear the depth buffer.
  89551. */
  89552. depth: boolean;
  89553. /**
  89554. * Defines whether or not to autoclear the stencil buffer.
  89555. */
  89556. stencil: boolean;
  89557. }
  89558. /**
  89559. * This class is used by the onRenderingGroupObservable
  89560. */
  89561. export class RenderingGroupInfo {
  89562. /**
  89563. * The Scene that being rendered
  89564. */
  89565. scene: Scene;
  89566. /**
  89567. * The camera currently used for the rendering pass
  89568. */
  89569. camera: Nullable<Camera>;
  89570. /**
  89571. * The ID of the renderingGroup being processed
  89572. */
  89573. renderingGroupId: number;
  89574. }
  89575. /**
  89576. * This is the manager responsible of all the rendering for meshes sprites and particles.
  89577. * It is enable to manage the different groups as well as the different necessary sort functions.
  89578. * This should not be used directly aside of the few static configurations
  89579. */
  89580. export class RenderingManager {
  89581. /**
  89582. * The max id used for rendering groups (not included)
  89583. */
  89584. static MAX_RENDERINGGROUPS: number;
  89585. /**
  89586. * The min id used for rendering groups (included)
  89587. */
  89588. static MIN_RENDERINGGROUPS: number;
  89589. /**
  89590. * Used to globally prevent autoclearing scenes.
  89591. */
  89592. static AUTOCLEAR: boolean;
  89593. /**
  89594. * @hidden
  89595. */
  89596. _useSceneAutoClearSetup: boolean;
  89597. private _scene;
  89598. private _renderingGroups;
  89599. private _depthStencilBufferAlreadyCleaned;
  89600. private _autoClearDepthStencil;
  89601. private _customOpaqueSortCompareFn;
  89602. private _customAlphaTestSortCompareFn;
  89603. private _customTransparentSortCompareFn;
  89604. private _renderingGroupInfo;
  89605. /**
  89606. * Instantiates a new rendering group for a particular scene
  89607. * @param scene Defines the scene the groups belongs to
  89608. */
  89609. constructor(scene: Scene);
  89610. private _clearDepthStencilBuffer;
  89611. /**
  89612. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  89613. * @hidden
  89614. */
  89615. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  89616. /**
  89617. * Resets the different information of the group to prepare a new frame
  89618. * @hidden
  89619. */
  89620. reset(): void;
  89621. /**
  89622. * Dispose and release the group and its associated resources.
  89623. * @hidden
  89624. */
  89625. dispose(): void;
  89626. /**
  89627. * Clear the info related to rendering groups preventing retention points during dispose.
  89628. */
  89629. freeRenderingGroups(): void;
  89630. private _prepareRenderingGroup;
  89631. /**
  89632. * Add a sprite manager to the rendering manager in order to render it this frame.
  89633. * @param spriteManager Define the sprite manager to render
  89634. */
  89635. dispatchSprites(spriteManager: ISpriteManager): void;
  89636. /**
  89637. * Add a particle system to the rendering manager in order to render it this frame.
  89638. * @param particleSystem Define the particle system to render
  89639. */
  89640. dispatchParticles(particleSystem: IParticleSystem): void;
  89641. /**
  89642. * Add a submesh to the manager in order to render it this frame
  89643. * @param subMesh The submesh to dispatch
  89644. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89645. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89646. */
  89647. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89648. /**
  89649. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  89650. * This allowed control for front to back rendering or reversly depending of the special needs.
  89651. *
  89652. * @param renderingGroupId The rendering group id corresponding to its index
  89653. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  89654. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  89655. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  89656. */
  89657. 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;
  89658. /**
  89659. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  89660. *
  89661. * @param renderingGroupId The rendering group id corresponding to its index
  89662. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  89663. * @param depth Automatically clears depth between groups if true and autoClear is true.
  89664. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  89665. */
  89666. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  89667. /**
  89668. * Gets the current auto clear configuration for one rendering group of the rendering
  89669. * manager.
  89670. * @param index the rendering group index to get the information for
  89671. * @returns The auto clear setup for the requested rendering group
  89672. */
  89673. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  89674. }
  89675. }
  89676. declare module BABYLON {
  89677. /**
  89678. * Defines the options associated with the creation of a custom shader for a shadow generator.
  89679. */
  89680. export interface ICustomShaderOptions {
  89681. /**
  89682. * Gets or sets the custom shader name to use
  89683. */
  89684. shaderName: string;
  89685. /**
  89686. * The list of attribute names used in the shader
  89687. */
  89688. attributes?: string[];
  89689. /**
  89690. * The list of unifrom names used in the shader
  89691. */
  89692. uniforms?: string[];
  89693. /**
  89694. * The list of sampler names used in the shader
  89695. */
  89696. samplers?: string[];
  89697. /**
  89698. * The list of defines used in the shader
  89699. */
  89700. defines?: string[];
  89701. }
  89702. /**
  89703. * Interface to implement to create a shadow generator compatible with BJS.
  89704. */
  89705. export interface IShadowGenerator {
  89706. /**
  89707. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  89708. * @returns The render target texture if present otherwise, null
  89709. */
  89710. getShadowMap(): Nullable<RenderTargetTexture>;
  89711. /**
  89712. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  89713. * @param subMesh The submesh we want to render in the shadow map
  89714. * @param useInstances Defines wether will draw in the map using instances
  89715. * @returns true if ready otherwise, false
  89716. */
  89717. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  89718. /**
  89719. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  89720. * @param defines Defines of the material we want to update
  89721. * @param lightIndex Index of the light in the enabled light list of the material
  89722. */
  89723. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  89724. /**
  89725. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  89726. * defined in the generator but impacting the effect).
  89727. * It implies the unifroms available on the materials are the standard BJS ones.
  89728. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  89729. * @param effect The effect we are binfing the information for
  89730. */
  89731. bindShadowLight(lightIndex: string, effect: Effect): void;
  89732. /**
  89733. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  89734. * (eq to shadow prjection matrix * light transform matrix)
  89735. * @returns The transform matrix used to create the shadow map
  89736. */
  89737. getTransformMatrix(): Matrix;
  89738. /**
  89739. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  89740. * Cube and 2D textures for instance.
  89741. */
  89742. recreateShadowMap(): void;
  89743. /**
  89744. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89745. * @param onCompiled Callback triggered at the and of the effects compilation
  89746. * @param options Sets of optional options forcing the compilation with different modes
  89747. */
  89748. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  89749. useInstances: boolean;
  89750. }>): void;
  89751. /**
  89752. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89753. * @param options Sets of optional options forcing the compilation with different modes
  89754. * @returns A promise that resolves when the compilation completes
  89755. */
  89756. forceCompilationAsync(options?: Partial<{
  89757. useInstances: boolean;
  89758. }>): Promise<void>;
  89759. /**
  89760. * Serializes the shadow generator setup to a json object.
  89761. * @returns The serialized JSON object
  89762. */
  89763. serialize(): any;
  89764. /**
  89765. * Disposes the Shadow map and related Textures and effects.
  89766. */
  89767. dispose(): void;
  89768. }
  89769. /**
  89770. * Default implementation IShadowGenerator.
  89771. * This is the main object responsible of generating shadows in the framework.
  89772. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  89773. */
  89774. export class ShadowGenerator implements IShadowGenerator {
  89775. /**
  89776. * Name of the shadow generator class
  89777. */
  89778. static CLASSNAME: string;
  89779. /**
  89780. * Shadow generator mode None: no filtering applied.
  89781. */
  89782. static readonly FILTER_NONE: number;
  89783. /**
  89784. * Shadow generator mode ESM: Exponential Shadow Mapping.
  89785. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89786. */
  89787. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  89788. /**
  89789. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  89790. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  89791. */
  89792. static readonly FILTER_POISSONSAMPLING: number;
  89793. /**
  89794. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  89795. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89796. */
  89797. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  89798. /**
  89799. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  89800. * edge artifacts on steep falloff.
  89801. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89802. */
  89803. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  89804. /**
  89805. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  89806. * edge artifacts on steep falloff.
  89807. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89808. */
  89809. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  89810. /**
  89811. * Shadow generator mode PCF: Percentage Closer Filtering
  89812. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  89813. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  89814. */
  89815. static readonly FILTER_PCF: number;
  89816. /**
  89817. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  89818. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  89819. * Contact Hardening
  89820. */
  89821. static readonly FILTER_PCSS: number;
  89822. /**
  89823. * Reserved for PCF and PCSS
  89824. * Highest Quality.
  89825. *
  89826. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  89827. *
  89828. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  89829. */
  89830. static readonly QUALITY_HIGH: number;
  89831. /**
  89832. * Reserved for PCF and PCSS
  89833. * Good tradeoff for quality/perf cross devices
  89834. *
  89835. * Execute PCF on a 3*3 kernel.
  89836. *
  89837. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  89838. */
  89839. static readonly QUALITY_MEDIUM: number;
  89840. /**
  89841. * Reserved for PCF and PCSS
  89842. * The lowest quality but the fastest.
  89843. *
  89844. * Execute PCF on a 1*1 kernel.
  89845. *
  89846. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  89847. */
  89848. static readonly QUALITY_LOW: number;
  89849. /** Gets or sets the custom shader name to use */
  89850. customShaderOptions: ICustomShaderOptions;
  89851. /**
  89852. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  89853. */
  89854. onBeforeShadowMapRenderObservable: Observable<Effect>;
  89855. /**
  89856. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  89857. */
  89858. onAfterShadowMapRenderObservable: Observable<Effect>;
  89859. /**
  89860. * Observable triggered before a mesh is rendered in the shadow map.
  89861. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  89862. */
  89863. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  89864. /**
  89865. * Observable triggered after a mesh is rendered in the shadow map.
  89866. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  89867. */
  89868. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  89869. protected _bias: number;
  89870. /**
  89871. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  89872. */
  89873. get bias(): number;
  89874. /**
  89875. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  89876. */
  89877. set bias(bias: number);
  89878. protected _normalBias: number;
  89879. /**
  89880. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  89881. */
  89882. get normalBias(): number;
  89883. /**
  89884. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  89885. */
  89886. set normalBias(normalBias: number);
  89887. protected _blurBoxOffset: number;
  89888. /**
  89889. * Gets the blur box offset: offset applied during the blur pass.
  89890. * Only useful if useKernelBlur = false
  89891. */
  89892. get blurBoxOffset(): number;
  89893. /**
  89894. * Sets the blur box offset: offset applied during the blur pass.
  89895. * Only useful if useKernelBlur = false
  89896. */
  89897. set blurBoxOffset(value: number);
  89898. protected _blurScale: number;
  89899. /**
  89900. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  89901. * 2 means half of the size.
  89902. */
  89903. get blurScale(): number;
  89904. /**
  89905. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  89906. * 2 means half of the size.
  89907. */
  89908. set blurScale(value: number);
  89909. protected _blurKernel: number;
  89910. /**
  89911. * Gets the blur kernel: kernel size of the blur pass.
  89912. * Only useful if useKernelBlur = true
  89913. */
  89914. get blurKernel(): number;
  89915. /**
  89916. * Sets the blur kernel: kernel size of the blur pass.
  89917. * Only useful if useKernelBlur = true
  89918. */
  89919. set blurKernel(value: number);
  89920. protected _useKernelBlur: boolean;
  89921. /**
  89922. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  89923. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  89924. */
  89925. get useKernelBlur(): boolean;
  89926. /**
  89927. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  89928. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  89929. */
  89930. set useKernelBlur(value: boolean);
  89931. protected _depthScale: number;
  89932. /**
  89933. * Gets the depth scale used in ESM mode.
  89934. */
  89935. get depthScale(): number;
  89936. /**
  89937. * Sets the depth scale used in ESM mode.
  89938. * This can override the scale stored on the light.
  89939. */
  89940. set depthScale(value: number);
  89941. protected _validateFilter(filter: number): number;
  89942. protected _filter: number;
  89943. /**
  89944. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  89945. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  89946. */
  89947. get filter(): number;
  89948. /**
  89949. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  89950. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  89951. */
  89952. set filter(value: number);
  89953. /**
  89954. * Gets if the current filter is set to Poisson Sampling.
  89955. */
  89956. get usePoissonSampling(): boolean;
  89957. /**
  89958. * Sets the current filter to Poisson Sampling.
  89959. */
  89960. set usePoissonSampling(value: boolean);
  89961. /**
  89962. * Gets if the current filter is set to ESM.
  89963. */
  89964. get useExponentialShadowMap(): boolean;
  89965. /**
  89966. * Sets the current filter is to ESM.
  89967. */
  89968. set useExponentialShadowMap(value: boolean);
  89969. /**
  89970. * Gets if the current filter is set to filtered ESM.
  89971. */
  89972. get useBlurExponentialShadowMap(): boolean;
  89973. /**
  89974. * Gets if the current filter is set to filtered ESM.
  89975. */
  89976. set useBlurExponentialShadowMap(value: boolean);
  89977. /**
  89978. * Gets if the current filter is set to "close ESM" (using the inverse of the
  89979. * exponential to prevent steep falloff artifacts).
  89980. */
  89981. get useCloseExponentialShadowMap(): boolean;
  89982. /**
  89983. * Sets the current filter to "close ESM" (using the inverse of the
  89984. * exponential to prevent steep falloff artifacts).
  89985. */
  89986. set useCloseExponentialShadowMap(value: boolean);
  89987. /**
  89988. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  89989. * exponential to prevent steep falloff artifacts).
  89990. */
  89991. get useBlurCloseExponentialShadowMap(): boolean;
  89992. /**
  89993. * Sets the current filter to filtered "close ESM" (using the inverse of the
  89994. * exponential to prevent steep falloff artifacts).
  89995. */
  89996. set useBlurCloseExponentialShadowMap(value: boolean);
  89997. /**
  89998. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  89999. */
  90000. get usePercentageCloserFiltering(): boolean;
  90001. /**
  90002. * Sets the current filter to "PCF" (percentage closer filtering).
  90003. */
  90004. set usePercentageCloserFiltering(value: boolean);
  90005. protected _filteringQuality: number;
  90006. /**
  90007. * Gets the PCF or PCSS Quality.
  90008. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  90009. */
  90010. get filteringQuality(): number;
  90011. /**
  90012. * Sets the PCF or PCSS Quality.
  90013. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  90014. */
  90015. set filteringQuality(filteringQuality: number);
  90016. /**
  90017. * Gets if the current filter is set to "PCSS" (contact hardening).
  90018. */
  90019. get useContactHardeningShadow(): boolean;
  90020. /**
  90021. * Sets the current filter to "PCSS" (contact hardening).
  90022. */
  90023. set useContactHardeningShadow(value: boolean);
  90024. protected _contactHardeningLightSizeUVRatio: number;
  90025. /**
  90026. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  90027. * Using a ratio helps keeping shape stability independently of the map size.
  90028. *
  90029. * It does not account for the light projection as it was having too much
  90030. * instability during the light setup or during light position changes.
  90031. *
  90032. * Only valid if useContactHardeningShadow is true.
  90033. */
  90034. get contactHardeningLightSizeUVRatio(): number;
  90035. /**
  90036. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  90037. * Using a ratio helps keeping shape stability independently of the map size.
  90038. *
  90039. * It does not account for the light projection as it was having too much
  90040. * instability during the light setup or during light position changes.
  90041. *
  90042. * Only valid if useContactHardeningShadow is true.
  90043. */
  90044. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  90045. protected _darkness: number;
  90046. /** Gets or sets the actual darkness of a shadow */
  90047. get darkness(): number;
  90048. set darkness(value: number);
  90049. /**
  90050. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  90051. * 0 means strongest and 1 would means no shadow.
  90052. * @returns the darkness.
  90053. */
  90054. getDarkness(): number;
  90055. /**
  90056. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  90057. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  90058. * @returns the shadow generator allowing fluent coding.
  90059. */
  90060. setDarkness(darkness: number): ShadowGenerator;
  90061. protected _transparencyShadow: boolean;
  90062. /** Gets or sets the ability to have transparent shadow */
  90063. get transparencyShadow(): boolean;
  90064. set transparencyShadow(value: boolean);
  90065. /**
  90066. * Sets the ability to have transparent shadow (boolean).
  90067. * @param transparent True if transparent else False
  90068. * @returns the shadow generator allowing fluent coding
  90069. */
  90070. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  90071. protected _shadowMap: Nullable<RenderTargetTexture>;
  90072. protected _shadowMap2: Nullable<RenderTargetTexture>;
  90073. /**
  90074. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  90075. * @returns The render target texture if present otherwise, null
  90076. */
  90077. getShadowMap(): Nullable<RenderTargetTexture>;
  90078. /**
  90079. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  90080. * @returns The render target texture if the shadow map is present otherwise, null
  90081. */
  90082. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  90083. /**
  90084. * Gets the class name of that object
  90085. * @returns "ShadowGenerator"
  90086. */
  90087. getClassName(): string;
  90088. /**
  90089. * Helper function to add a mesh and its descendants to the list of shadow casters.
  90090. * @param mesh Mesh to add
  90091. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  90092. * @returns the Shadow Generator itself
  90093. */
  90094. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  90095. /**
  90096. * Helper function to remove a mesh and its descendants from the list of shadow casters
  90097. * @param mesh Mesh to remove
  90098. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  90099. * @returns the Shadow Generator itself
  90100. */
  90101. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  90102. /**
  90103. * Controls the extent to which the shadows fade out at the edge of the frustum
  90104. */
  90105. frustumEdgeFalloff: number;
  90106. protected _light: IShadowLight;
  90107. /**
  90108. * Returns the associated light object.
  90109. * @returns the light generating the shadow
  90110. */
  90111. getLight(): IShadowLight;
  90112. /**
  90113. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  90114. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  90115. * It might on the other hand introduce peter panning.
  90116. */
  90117. forceBackFacesOnly: boolean;
  90118. protected _scene: Scene;
  90119. protected _lightDirection: Vector3;
  90120. protected _effect: Effect;
  90121. protected _viewMatrix: Matrix;
  90122. protected _projectionMatrix: Matrix;
  90123. protected _transformMatrix: Matrix;
  90124. protected _cachedPosition: Vector3;
  90125. protected _cachedDirection: Vector3;
  90126. protected _cachedDefines: string;
  90127. protected _currentRenderID: number;
  90128. protected _boxBlurPostprocess: Nullable<PostProcess>;
  90129. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  90130. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  90131. protected _blurPostProcesses: PostProcess[];
  90132. protected _mapSize: number;
  90133. protected _currentFaceIndex: number;
  90134. protected _currentFaceIndexCache: number;
  90135. protected _textureType: number;
  90136. protected _defaultTextureMatrix: Matrix;
  90137. protected _storedUniqueId: Nullable<number>;
  90138. /** @hidden */
  90139. static _SceneComponentInitialization: (scene: Scene) => void;
  90140. /**
  90141. * Creates a ShadowGenerator object.
  90142. * A ShadowGenerator is the required tool to use the shadows.
  90143. * Each light casting shadows needs to use its own ShadowGenerator.
  90144. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  90145. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  90146. * @param light The light object generating the shadows.
  90147. * @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.
  90148. */
  90149. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  90150. protected _initializeGenerator(): void;
  90151. protected _createTargetRenderTexture(): void;
  90152. protected _initializeShadowMap(): void;
  90153. protected _initializeBlurRTTAndPostProcesses(): void;
  90154. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  90155. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  90156. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  90157. protected _applyFilterValues(): void;
  90158. /**
  90159. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  90160. * @param onCompiled Callback triggered at the and of the effects compilation
  90161. * @param options Sets of optional options forcing the compilation with different modes
  90162. */
  90163. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  90164. useInstances: boolean;
  90165. }>): void;
  90166. /**
  90167. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  90168. * @param options Sets of optional options forcing the compilation with different modes
  90169. * @returns A promise that resolves when the compilation completes
  90170. */
  90171. forceCompilationAsync(options?: Partial<{
  90172. useInstances: boolean;
  90173. }>): Promise<void>;
  90174. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  90175. /**
  90176. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  90177. * @param subMesh The submesh we want to render in the shadow map
  90178. * @param useInstances Defines wether will draw in the map using instances
  90179. * @returns true if ready otherwise, false
  90180. */
  90181. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  90182. /**
  90183. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  90184. * @param defines Defines of the material we want to update
  90185. * @param lightIndex Index of the light in the enabled light list of the material
  90186. */
  90187. prepareDefines(defines: any, lightIndex: number): void;
  90188. /**
  90189. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  90190. * defined in the generator but impacting the effect).
  90191. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  90192. * @param effect The effect we are binfing the information for
  90193. */
  90194. bindShadowLight(lightIndex: string, effect: Effect): void;
  90195. /**
  90196. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  90197. * (eq to shadow prjection matrix * light transform matrix)
  90198. * @returns The transform matrix used to create the shadow map
  90199. */
  90200. getTransformMatrix(): Matrix;
  90201. /**
  90202. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  90203. * Cube and 2D textures for instance.
  90204. */
  90205. recreateShadowMap(): void;
  90206. protected _disposeBlurPostProcesses(): void;
  90207. protected _disposeRTTandPostProcesses(): void;
  90208. /**
  90209. * Disposes the ShadowGenerator.
  90210. * Returns nothing.
  90211. */
  90212. dispose(): void;
  90213. /**
  90214. * Serializes the shadow generator setup to a json object.
  90215. * @returns The serialized JSON object
  90216. */
  90217. serialize(): any;
  90218. /**
  90219. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  90220. * @param parsedShadowGenerator The JSON object to parse
  90221. * @param scene The scene to create the shadow map for
  90222. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  90223. * @returns The parsed shadow generator
  90224. */
  90225. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  90226. }
  90227. }
  90228. declare module BABYLON {
  90229. /**
  90230. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  90231. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  90232. * 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.
  90233. */
  90234. export abstract class Light extends Node {
  90235. /**
  90236. * Falloff Default: light is falling off following the material specification:
  90237. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  90238. */
  90239. static readonly FALLOFF_DEFAULT: number;
  90240. /**
  90241. * Falloff Physical: light is falling off following the inverse squared distance law.
  90242. */
  90243. static readonly FALLOFF_PHYSICAL: number;
  90244. /**
  90245. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  90246. * to enhance interoperability with other engines.
  90247. */
  90248. static readonly FALLOFF_GLTF: number;
  90249. /**
  90250. * Falloff Standard: light is falling off like in the standard material
  90251. * to enhance interoperability with other materials.
  90252. */
  90253. static readonly FALLOFF_STANDARD: number;
  90254. /**
  90255. * If every light affecting the material is in this lightmapMode,
  90256. * material.lightmapTexture adds or multiplies
  90257. * (depends on material.useLightmapAsShadowmap)
  90258. * after every other light calculations.
  90259. */
  90260. static readonly LIGHTMAP_DEFAULT: number;
  90261. /**
  90262. * material.lightmapTexture as only diffuse lighting from this light
  90263. * adds only specular lighting from this light
  90264. * adds dynamic shadows
  90265. */
  90266. static readonly LIGHTMAP_SPECULAR: number;
  90267. /**
  90268. * material.lightmapTexture as only lighting
  90269. * no light calculation from this light
  90270. * only adds dynamic shadows from this light
  90271. */
  90272. static readonly LIGHTMAP_SHADOWSONLY: number;
  90273. /**
  90274. * Each light type uses the default quantity according to its type:
  90275. * point/spot lights use luminous intensity
  90276. * directional lights use illuminance
  90277. */
  90278. static readonly INTENSITYMODE_AUTOMATIC: number;
  90279. /**
  90280. * lumen (lm)
  90281. */
  90282. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  90283. /**
  90284. * candela (lm/sr)
  90285. */
  90286. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  90287. /**
  90288. * lux (lm/m^2)
  90289. */
  90290. static readonly INTENSITYMODE_ILLUMINANCE: number;
  90291. /**
  90292. * nit (cd/m^2)
  90293. */
  90294. static readonly INTENSITYMODE_LUMINANCE: number;
  90295. /**
  90296. * Light type const id of the point light.
  90297. */
  90298. static readonly LIGHTTYPEID_POINTLIGHT: number;
  90299. /**
  90300. * Light type const id of the directional light.
  90301. */
  90302. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  90303. /**
  90304. * Light type const id of the spot light.
  90305. */
  90306. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  90307. /**
  90308. * Light type const id of the hemispheric light.
  90309. */
  90310. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  90311. /**
  90312. * Diffuse gives the basic color to an object.
  90313. */
  90314. diffuse: Color3;
  90315. /**
  90316. * Specular produces a highlight color on an object.
  90317. * Note: This is note affecting PBR materials.
  90318. */
  90319. specular: Color3;
  90320. /**
  90321. * Defines the falloff type for this light. This lets overrriding how punctual light are
  90322. * falling off base on range or angle.
  90323. * This can be set to any values in Light.FALLOFF_x.
  90324. *
  90325. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  90326. * other types of materials.
  90327. */
  90328. falloffType: number;
  90329. /**
  90330. * Strength of the light.
  90331. * Note: By default it is define in the framework own unit.
  90332. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  90333. */
  90334. intensity: number;
  90335. private _range;
  90336. protected _inverseSquaredRange: number;
  90337. /**
  90338. * Defines how far from the source the light is impacting in scene units.
  90339. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  90340. */
  90341. get range(): number;
  90342. /**
  90343. * Defines how far from the source the light is impacting in scene units.
  90344. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  90345. */
  90346. set range(value: number);
  90347. /**
  90348. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  90349. * of light.
  90350. */
  90351. private _photometricScale;
  90352. private _intensityMode;
  90353. /**
  90354. * Gets the photometric scale used to interpret the intensity.
  90355. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  90356. */
  90357. get intensityMode(): number;
  90358. /**
  90359. * Sets the photometric scale used to interpret the intensity.
  90360. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  90361. */
  90362. set intensityMode(value: number);
  90363. private _radius;
  90364. /**
  90365. * Gets the light radius used by PBR Materials to simulate soft area lights.
  90366. */
  90367. get radius(): number;
  90368. /**
  90369. * sets the light radius used by PBR Materials to simulate soft area lights.
  90370. */
  90371. set radius(value: number);
  90372. private _renderPriority;
  90373. /**
  90374. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  90375. * exceeding the number allowed of the materials.
  90376. */
  90377. renderPriority: number;
  90378. private _shadowEnabled;
  90379. /**
  90380. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90381. * the current shadow generator.
  90382. */
  90383. get shadowEnabled(): boolean;
  90384. /**
  90385. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90386. * the current shadow generator.
  90387. */
  90388. set shadowEnabled(value: boolean);
  90389. private _includedOnlyMeshes;
  90390. /**
  90391. * Gets the only meshes impacted by this light.
  90392. */
  90393. get includedOnlyMeshes(): AbstractMesh[];
  90394. /**
  90395. * Sets the only meshes impacted by this light.
  90396. */
  90397. set includedOnlyMeshes(value: AbstractMesh[]);
  90398. private _excludedMeshes;
  90399. /**
  90400. * Gets the meshes not impacted by this light.
  90401. */
  90402. get excludedMeshes(): AbstractMesh[];
  90403. /**
  90404. * Sets the meshes not impacted by this light.
  90405. */
  90406. set excludedMeshes(value: AbstractMesh[]);
  90407. private _excludeWithLayerMask;
  90408. /**
  90409. * Gets the layer id use to find what meshes are not impacted by the light.
  90410. * Inactive if 0
  90411. */
  90412. get excludeWithLayerMask(): number;
  90413. /**
  90414. * Sets the layer id use to find what meshes are not impacted by the light.
  90415. * Inactive if 0
  90416. */
  90417. set excludeWithLayerMask(value: number);
  90418. private _includeOnlyWithLayerMask;
  90419. /**
  90420. * Gets the layer id use to find what meshes are impacted by the light.
  90421. * Inactive if 0
  90422. */
  90423. get includeOnlyWithLayerMask(): number;
  90424. /**
  90425. * Sets the layer id use to find what meshes are impacted by the light.
  90426. * Inactive if 0
  90427. */
  90428. set includeOnlyWithLayerMask(value: number);
  90429. private _lightmapMode;
  90430. /**
  90431. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90432. */
  90433. get lightmapMode(): number;
  90434. /**
  90435. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90436. */
  90437. set lightmapMode(value: number);
  90438. /**
  90439. * Shadow generator associted to the light.
  90440. * @hidden Internal use only.
  90441. */
  90442. _shadowGenerator: Nullable<IShadowGenerator>;
  90443. /**
  90444. * @hidden Internal use only.
  90445. */
  90446. _excludedMeshesIds: string[];
  90447. /**
  90448. * @hidden Internal use only.
  90449. */
  90450. _includedOnlyMeshesIds: string[];
  90451. /**
  90452. * The current light unifom buffer.
  90453. * @hidden Internal use only.
  90454. */
  90455. _uniformBuffer: UniformBuffer;
  90456. /** @hidden */
  90457. _renderId: number;
  90458. /**
  90459. * Creates a Light object in the scene.
  90460. * Documentation : https://doc.babylonjs.com/babylon101/lights
  90461. * @param name The firendly name of the light
  90462. * @param scene The scene the light belongs too
  90463. */
  90464. constructor(name: string, scene: Scene);
  90465. protected abstract _buildUniformLayout(): void;
  90466. /**
  90467. * Sets the passed Effect "effect" with the Light information.
  90468. * @param effect The effect to update
  90469. * @param lightIndex The index of the light in the effect to update
  90470. * @returns The light
  90471. */
  90472. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  90473. /**
  90474. * Sets the passed Effect "effect" with the Light textures.
  90475. * @param effect The effect to update
  90476. * @param lightIndex The index of the light in the effect to update
  90477. * @returns The light
  90478. */
  90479. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  90480. /**
  90481. * Binds the lights information from the scene to the effect for the given mesh.
  90482. * @param lightIndex Light index
  90483. * @param scene The scene where the light belongs to
  90484. * @param effect The effect we are binding the data to
  90485. * @param useSpecular Defines if specular is supported
  90486. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  90487. */
  90488. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  90489. /**
  90490. * Sets the passed Effect "effect" with the Light information.
  90491. * @param effect The effect to update
  90492. * @param lightDataUniformName The uniform used to store light data (position or direction)
  90493. * @returns The light
  90494. */
  90495. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  90496. /**
  90497. * Returns the string "Light".
  90498. * @returns the class name
  90499. */
  90500. getClassName(): string;
  90501. /** @hidden */
  90502. readonly _isLight: boolean;
  90503. /**
  90504. * Converts the light information to a readable string for debug purpose.
  90505. * @param fullDetails Supports for multiple levels of logging within scene loading
  90506. * @returns the human readable light info
  90507. */
  90508. toString(fullDetails?: boolean): string;
  90509. /** @hidden */
  90510. protected _syncParentEnabledState(): void;
  90511. /**
  90512. * Set the enabled state of this node.
  90513. * @param value - the new enabled state
  90514. */
  90515. setEnabled(value: boolean): void;
  90516. /**
  90517. * Returns the Light associated shadow generator if any.
  90518. * @return the associated shadow generator.
  90519. */
  90520. getShadowGenerator(): Nullable<IShadowGenerator>;
  90521. /**
  90522. * Returns a Vector3, the absolute light position in the World.
  90523. * @returns the world space position of the light
  90524. */
  90525. getAbsolutePosition(): Vector3;
  90526. /**
  90527. * Specifies if the light will affect the passed mesh.
  90528. * @param mesh The mesh to test against the light
  90529. * @return true the mesh is affected otherwise, false.
  90530. */
  90531. canAffectMesh(mesh: AbstractMesh): boolean;
  90532. /**
  90533. * Sort function to order lights for rendering.
  90534. * @param a First Light object to compare to second.
  90535. * @param b Second Light object to compare first.
  90536. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  90537. */
  90538. static CompareLightsPriority(a: Light, b: Light): number;
  90539. /**
  90540. * Releases resources associated with this node.
  90541. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90542. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90543. */
  90544. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90545. /**
  90546. * Returns the light type ID (integer).
  90547. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  90548. */
  90549. getTypeID(): number;
  90550. /**
  90551. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  90552. * @returns the scaled intensity in intensity mode unit
  90553. */
  90554. getScaledIntensity(): number;
  90555. /**
  90556. * Returns a new Light object, named "name", from the current one.
  90557. * @param name The name of the cloned light
  90558. * @returns the new created light
  90559. */
  90560. clone(name: string): Nullable<Light>;
  90561. /**
  90562. * Serializes the current light into a Serialization object.
  90563. * @returns the serialized object.
  90564. */
  90565. serialize(): any;
  90566. /**
  90567. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  90568. * This new light is named "name" and added to the passed scene.
  90569. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  90570. * @param name The friendly name of the light
  90571. * @param scene The scene the new light will belong to
  90572. * @returns the constructor function
  90573. */
  90574. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  90575. /**
  90576. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  90577. * @param parsedLight The JSON representation of the light
  90578. * @param scene The scene to create the parsed light in
  90579. * @returns the created light after parsing
  90580. */
  90581. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  90582. private _hookArrayForExcluded;
  90583. private _hookArrayForIncludedOnly;
  90584. private _resyncMeshes;
  90585. /**
  90586. * Forces the meshes to update their light related information in their rendering used effects
  90587. * @hidden Internal Use Only
  90588. */
  90589. _markMeshesAsLightDirty(): void;
  90590. /**
  90591. * Recomputes the cached photometric scale if needed.
  90592. */
  90593. private _computePhotometricScale;
  90594. /**
  90595. * Returns the Photometric Scale according to the light type and intensity mode.
  90596. */
  90597. private _getPhotometricScale;
  90598. /**
  90599. * Reorder the light in the scene according to their defined priority.
  90600. * @hidden Internal Use Only
  90601. */
  90602. _reorderLightsInScene(): void;
  90603. /**
  90604. * Prepares the list of defines specific to the light type.
  90605. * @param defines the list of defines
  90606. * @param lightIndex defines the index of the light for the effect
  90607. */
  90608. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  90609. }
  90610. }
  90611. declare module BABYLON {
  90612. /**
  90613. * Interface used to define Action
  90614. */
  90615. export interface IAction {
  90616. /**
  90617. * Trigger for the action
  90618. */
  90619. trigger: number;
  90620. /** Options of the trigger */
  90621. triggerOptions: any;
  90622. /**
  90623. * Gets the trigger parameters
  90624. * @returns the trigger parameters
  90625. */
  90626. getTriggerParameter(): any;
  90627. /**
  90628. * Internal only - executes current action event
  90629. * @hidden
  90630. */
  90631. _executeCurrent(evt?: ActionEvent): void;
  90632. /**
  90633. * Serialize placeholder for child classes
  90634. * @param parent of child
  90635. * @returns the serialized object
  90636. */
  90637. serialize(parent: any): any;
  90638. /**
  90639. * Internal only
  90640. * @hidden
  90641. */
  90642. _prepare(): void;
  90643. /**
  90644. * Internal only - manager for action
  90645. * @hidden
  90646. */
  90647. _actionManager: AbstractActionManager;
  90648. /**
  90649. * Adds action to chain of actions, may be a DoNothingAction
  90650. * @param action defines the next action to execute
  90651. * @returns The action passed in
  90652. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90653. */
  90654. then(action: IAction): IAction;
  90655. }
  90656. /**
  90657. * The action to be carried out following a trigger
  90658. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  90659. */
  90660. export class Action implements IAction {
  90661. /** the trigger, with or without parameters, for the action */
  90662. triggerOptions: any;
  90663. /**
  90664. * Trigger for the action
  90665. */
  90666. trigger: number;
  90667. /**
  90668. * Internal only - manager for action
  90669. * @hidden
  90670. */
  90671. _actionManager: ActionManager;
  90672. private _nextActiveAction;
  90673. private _child;
  90674. private _condition?;
  90675. private _triggerParameter;
  90676. /**
  90677. * An event triggered prior to action being executed.
  90678. */
  90679. onBeforeExecuteObservable: Observable<Action>;
  90680. /**
  90681. * Creates a new Action
  90682. * @param triggerOptions the trigger, with or without parameters, for the action
  90683. * @param condition an optional determinant of action
  90684. */
  90685. constructor(
  90686. /** the trigger, with or without parameters, for the action */
  90687. triggerOptions: any, condition?: Condition);
  90688. /**
  90689. * Internal only
  90690. * @hidden
  90691. */
  90692. _prepare(): void;
  90693. /**
  90694. * Gets the trigger parameters
  90695. * @returns the trigger parameters
  90696. */
  90697. getTriggerParameter(): any;
  90698. /**
  90699. * Internal only - executes current action event
  90700. * @hidden
  90701. */
  90702. _executeCurrent(evt?: ActionEvent): void;
  90703. /**
  90704. * Execute placeholder for child classes
  90705. * @param evt optional action event
  90706. */
  90707. execute(evt?: ActionEvent): void;
  90708. /**
  90709. * Skips to next active action
  90710. */
  90711. skipToNextActiveAction(): void;
  90712. /**
  90713. * Adds action to chain of actions, may be a DoNothingAction
  90714. * @param action defines the next action to execute
  90715. * @returns The action passed in
  90716. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90717. */
  90718. then(action: Action): Action;
  90719. /**
  90720. * Internal only
  90721. * @hidden
  90722. */
  90723. _getProperty(propertyPath: string): string;
  90724. /**
  90725. * Internal only
  90726. * @hidden
  90727. */
  90728. _getEffectiveTarget(target: any, propertyPath: string): any;
  90729. /**
  90730. * Serialize placeholder for child classes
  90731. * @param parent of child
  90732. * @returns the serialized object
  90733. */
  90734. serialize(parent: any): any;
  90735. /**
  90736. * Internal only called by serialize
  90737. * @hidden
  90738. */
  90739. protected _serialize(serializedAction: any, parent?: any): any;
  90740. /**
  90741. * Internal only
  90742. * @hidden
  90743. */
  90744. static _SerializeValueAsString: (value: any) => string;
  90745. /**
  90746. * Internal only
  90747. * @hidden
  90748. */
  90749. static _GetTargetProperty: (target: Node | Scene) => {
  90750. name: string;
  90751. targetType: string;
  90752. value: string;
  90753. };
  90754. }
  90755. }
  90756. declare module BABYLON {
  90757. /**
  90758. * A Condition applied to an Action
  90759. */
  90760. export class Condition {
  90761. /**
  90762. * Internal only - manager for action
  90763. * @hidden
  90764. */
  90765. _actionManager: ActionManager;
  90766. /**
  90767. * Internal only
  90768. * @hidden
  90769. */
  90770. _evaluationId: number;
  90771. /**
  90772. * Internal only
  90773. * @hidden
  90774. */
  90775. _currentResult: boolean;
  90776. /**
  90777. * Creates a new Condition
  90778. * @param actionManager the manager of the action the condition is applied to
  90779. */
  90780. constructor(actionManager: ActionManager);
  90781. /**
  90782. * Check if the current condition is valid
  90783. * @returns a boolean
  90784. */
  90785. isValid(): boolean;
  90786. /**
  90787. * Internal only
  90788. * @hidden
  90789. */
  90790. _getProperty(propertyPath: string): string;
  90791. /**
  90792. * Internal only
  90793. * @hidden
  90794. */
  90795. _getEffectiveTarget(target: any, propertyPath: string): any;
  90796. /**
  90797. * Serialize placeholder for child classes
  90798. * @returns the serialized object
  90799. */
  90800. serialize(): any;
  90801. /**
  90802. * Internal only
  90803. * @hidden
  90804. */
  90805. protected _serialize(serializedCondition: any): any;
  90806. }
  90807. /**
  90808. * Defines specific conditional operators as extensions of Condition
  90809. */
  90810. export class ValueCondition extends Condition {
  90811. /** path to specify the property of the target the conditional operator uses */
  90812. propertyPath: string;
  90813. /** the value compared by the conditional operator against the current value of the property */
  90814. value: any;
  90815. /** the conditional operator, default ValueCondition.IsEqual */
  90816. operator: number;
  90817. /**
  90818. * Internal only
  90819. * @hidden
  90820. */
  90821. private static _IsEqual;
  90822. /**
  90823. * Internal only
  90824. * @hidden
  90825. */
  90826. private static _IsDifferent;
  90827. /**
  90828. * Internal only
  90829. * @hidden
  90830. */
  90831. private static _IsGreater;
  90832. /**
  90833. * Internal only
  90834. * @hidden
  90835. */
  90836. private static _IsLesser;
  90837. /**
  90838. * returns the number for IsEqual
  90839. */
  90840. static get IsEqual(): number;
  90841. /**
  90842. * Returns the number for IsDifferent
  90843. */
  90844. static get IsDifferent(): number;
  90845. /**
  90846. * Returns the number for IsGreater
  90847. */
  90848. static get IsGreater(): number;
  90849. /**
  90850. * Returns the number for IsLesser
  90851. */
  90852. static get IsLesser(): number;
  90853. /**
  90854. * Internal only The action manager for the condition
  90855. * @hidden
  90856. */
  90857. _actionManager: ActionManager;
  90858. /**
  90859. * Internal only
  90860. * @hidden
  90861. */
  90862. private _target;
  90863. /**
  90864. * Internal only
  90865. * @hidden
  90866. */
  90867. private _effectiveTarget;
  90868. /**
  90869. * Internal only
  90870. * @hidden
  90871. */
  90872. private _property;
  90873. /**
  90874. * Creates a new ValueCondition
  90875. * @param actionManager manager for the action the condition applies to
  90876. * @param target for the action
  90877. * @param propertyPath path to specify the property of the target the conditional operator uses
  90878. * @param value the value compared by the conditional operator against the current value of the property
  90879. * @param operator the conditional operator, default ValueCondition.IsEqual
  90880. */
  90881. constructor(actionManager: ActionManager, target: any,
  90882. /** path to specify the property of the target the conditional operator uses */
  90883. propertyPath: string,
  90884. /** the value compared by the conditional operator against the current value of the property */
  90885. value: any,
  90886. /** the conditional operator, default ValueCondition.IsEqual */
  90887. operator?: number);
  90888. /**
  90889. * Compares the given value with the property value for the specified conditional operator
  90890. * @returns the result of the comparison
  90891. */
  90892. isValid(): boolean;
  90893. /**
  90894. * Serialize the ValueCondition into a JSON compatible object
  90895. * @returns serialization object
  90896. */
  90897. serialize(): any;
  90898. /**
  90899. * Gets the name of the conditional operator for the ValueCondition
  90900. * @param operator the conditional operator
  90901. * @returns the name
  90902. */
  90903. static GetOperatorName(operator: number): string;
  90904. }
  90905. /**
  90906. * Defines a predicate condition as an extension of Condition
  90907. */
  90908. export class PredicateCondition extends Condition {
  90909. /** defines the predicate function used to validate the condition */
  90910. predicate: () => boolean;
  90911. /**
  90912. * Internal only - manager for action
  90913. * @hidden
  90914. */
  90915. _actionManager: ActionManager;
  90916. /**
  90917. * Creates a new PredicateCondition
  90918. * @param actionManager manager for the action the condition applies to
  90919. * @param predicate defines the predicate function used to validate the condition
  90920. */
  90921. constructor(actionManager: ActionManager,
  90922. /** defines the predicate function used to validate the condition */
  90923. predicate: () => boolean);
  90924. /**
  90925. * @returns the validity of the predicate condition
  90926. */
  90927. isValid(): boolean;
  90928. }
  90929. /**
  90930. * Defines a state condition as an extension of Condition
  90931. */
  90932. export class StateCondition extends Condition {
  90933. /** Value to compare with target state */
  90934. value: string;
  90935. /**
  90936. * Internal only - manager for action
  90937. * @hidden
  90938. */
  90939. _actionManager: ActionManager;
  90940. /**
  90941. * Internal only
  90942. * @hidden
  90943. */
  90944. private _target;
  90945. /**
  90946. * Creates a new StateCondition
  90947. * @param actionManager manager for the action the condition applies to
  90948. * @param target of the condition
  90949. * @param value to compare with target state
  90950. */
  90951. constructor(actionManager: ActionManager, target: any,
  90952. /** Value to compare with target state */
  90953. value: string);
  90954. /**
  90955. * Gets a boolean indicating if the current condition is met
  90956. * @returns the validity of the state
  90957. */
  90958. isValid(): boolean;
  90959. /**
  90960. * Serialize the StateCondition into a JSON compatible object
  90961. * @returns serialization object
  90962. */
  90963. serialize(): any;
  90964. }
  90965. }
  90966. declare module BABYLON {
  90967. /**
  90968. * This defines an action responsible to toggle a boolean once triggered.
  90969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90970. */
  90971. export class SwitchBooleanAction extends Action {
  90972. /**
  90973. * The path to the boolean property in the target object
  90974. */
  90975. propertyPath: string;
  90976. private _target;
  90977. private _effectiveTarget;
  90978. private _property;
  90979. /**
  90980. * Instantiate the action
  90981. * @param triggerOptions defines the trigger options
  90982. * @param target defines the object containing the boolean
  90983. * @param propertyPath defines the path to the boolean property in the target object
  90984. * @param condition defines the trigger related conditions
  90985. */
  90986. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  90987. /** @hidden */
  90988. _prepare(): void;
  90989. /**
  90990. * Execute the action toggle the boolean value.
  90991. */
  90992. execute(): void;
  90993. /**
  90994. * Serializes the actions and its related information.
  90995. * @param parent defines the object to serialize in
  90996. * @returns the serialized object
  90997. */
  90998. serialize(parent: any): any;
  90999. }
  91000. /**
  91001. * This defines an action responsible to set a the state field of the target
  91002. * to a desired value once triggered.
  91003. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91004. */
  91005. export class SetStateAction extends Action {
  91006. /**
  91007. * The value to store in the state field.
  91008. */
  91009. value: string;
  91010. private _target;
  91011. /**
  91012. * Instantiate the action
  91013. * @param triggerOptions defines the trigger options
  91014. * @param target defines the object containing the state property
  91015. * @param value defines the value to store in the state field
  91016. * @param condition defines the trigger related conditions
  91017. */
  91018. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  91019. /**
  91020. * Execute the action and store the value on the target state property.
  91021. */
  91022. execute(): void;
  91023. /**
  91024. * Serializes the actions and its related information.
  91025. * @param parent defines the object to serialize in
  91026. * @returns the serialized object
  91027. */
  91028. serialize(parent: any): any;
  91029. }
  91030. /**
  91031. * This defines an action responsible to set a property of the target
  91032. * to a desired value once triggered.
  91033. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91034. */
  91035. export class SetValueAction extends Action {
  91036. /**
  91037. * The path of the property to set in the target.
  91038. */
  91039. propertyPath: string;
  91040. /**
  91041. * The value to set in the property
  91042. */
  91043. value: any;
  91044. private _target;
  91045. private _effectiveTarget;
  91046. private _property;
  91047. /**
  91048. * Instantiate the action
  91049. * @param triggerOptions defines the trigger options
  91050. * @param target defines the object containing the property
  91051. * @param propertyPath defines the path of the property to set in the target
  91052. * @param value defines the value to set in the property
  91053. * @param condition defines the trigger related conditions
  91054. */
  91055. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  91056. /** @hidden */
  91057. _prepare(): void;
  91058. /**
  91059. * Execute the action and set the targetted property to the desired value.
  91060. */
  91061. execute(): void;
  91062. /**
  91063. * Serializes the actions and its related information.
  91064. * @param parent defines the object to serialize in
  91065. * @returns the serialized object
  91066. */
  91067. serialize(parent: any): any;
  91068. }
  91069. /**
  91070. * This defines an action responsible to increment the target value
  91071. * to a desired value once triggered.
  91072. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91073. */
  91074. export class IncrementValueAction extends Action {
  91075. /**
  91076. * The path of the property to increment in the target.
  91077. */
  91078. propertyPath: string;
  91079. /**
  91080. * The value we should increment the property by.
  91081. */
  91082. value: any;
  91083. private _target;
  91084. private _effectiveTarget;
  91085. private _property;
  91086. /**
  91087. * Instantiate the action
  91088. * @param triggerOptions defines the trigger options
  91089. * @param target defines the object containing the property
  91090. * @param propertyPath defines the path of the property to increment in the target
  91091. * @param value defines the value value we should increment the property by
  91092. * @param condition defines the trigger related conditions
  91093. */
  91094. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  91095. /** @hidden */
  91096. _prepare(): void;
  91097. /**
  91098. * Execute the action and increment the target of the value amount.
  91099. */
  91100. execute(): void;
  91101. /**
  91102. * Serializes the actions and its related information.
  91103. * @param parent defines the object to serialize in
  91104. * @returns the serialized object
  91105. */
  91106. serialize(parent: any): any;
  91107. }
  91108. /**
  91109. * This defines an action responsible to start an animation once triggered.
  91110. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91111. */
  91112. export class PlayAnimationAction extends Action {
  91113. /**
  91114. * Where the animation should start (animation frame)
  91115. */
  91116. from: number;
  91117. /**
  91118. * Where the animation should stop (animation frame)
  91119. */
  91120. to: number;
  91121. /**
  91122. * Define if the animation should loop or stop after the first play.
  91123. */
  91124. loop?: boolean;
  91125. private _target;
  91126. /**
  91127. * Instantiate the action
  91128. * @param triggerOptions defines the trigger options
  91129. * @param target defines the target animation or animation name
  91130. * @param from defines from where the animation should start (animation frame)
  91131. * @param end defines where the animation should stop (animation frame)
  91132. * @param loop defines if the animation should loop or stop after the first play
  91133. * @param condition defines the trigger related conditions
  91134. */
  91135. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  91136. /** @hidden */
  91137. _prepare(): void;
  91138. /**
  91139. * Execute the action and play the animation.
  91140. */
  91141. execute(): void;
  91142. /**
  91143. * Serializes the actions and its related information.
  91144. * @param parent defines the object to serialize in
  91145. * @returns the serialized object
  91146. */
  91147. serialize(parent: any): any;
  91148. }
  91149. /**
  91150. * This defines an action responsible to stop an animation once triggered.
  91151. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91152. */
  91153. export class StopAnimationAction extends Action {
  91154. private _target;
  91155. /**
  91156. * Instantiate the action
  91157. * @param triggerOptions defines the trigger options
  91158. * @param target defines the target animation or animation name
  91159. * @param condition defines the trigger related conditions
  91160. */
  91161. constructor(triggerOptions: any, target: any, condition?: Condition);
  91162. /** @hidden */
  91163. _prepare(): void;
  91164. /**
  91165. * Execute the action and stop the animation.
  91166. */
  91167. execute(): void;
  91168. /**
  91169. * Serializes the actions and its related information.
  91170. * @param parent defines the object to serialize in
  91171. * @returns the serialized object
  91172. */
  91173. serialize(parent: any): any;
  91174. }
  91175. /**
  91176. * This defines an action responsible that does nothing once triggered.
  91177. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91178. */
  91179. export class DoNothingAction extends Action {
  91180. /**
  91181. * Instantiate the action
  91182. * @param triggerOptions defines the trigger options
  91183. * @param condition defines the trigger related conditions
  91184. */
  91185. constructor(triggerOptions?: any, condition?: Condition);
  91186. /**
  91187. * Execute the action and do nothing.
  91188. */
  91189. execute(): void;
  91190. /**
  91191. * Serializes the actions and its related information.
  91192. * @param parent defines the object to serialize in
  91193. * @returns the serialized object
  91194. */
  91195. serialize(parent: any): any;
  91196. }
  91197. /**
  91198. * This defines an action responsible to trigger several actions once triggered.
  91199. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91200. */
  91201. export class CombineAction extends Action {
  91202. /**
  91203. * The list of aggregated animations to run.
  91204. */
  91205. children: Action[];
  91206. /**
  91207. * Instantiate the action
  91208. * @param triggerOptions defines the trigger options
  91209. * @param children defines the list of aggregated animations to run
  91210. * @param condition defines the trigger related conditions
  91211. */
  91212. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  91213. /** @hidden */
  91214. _prepare(): void;
  91215. /**
  91216. * Execute the action and executes all the aggregated actions.
  91217. */
  91218. execute(evt: ActionEvent): void;
  91219. /**
  91220. * Serializes the actions and its related information.
  91221. * @param parent defines the object to serialize in
  91222. * @returns the serialized object
  91223. */
  91224. serialize(parent: any): any;
  91225. }
  91226. /**
  91227. * This defines an action responsible to run code (external event) once triggered.
  91228. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91229. */
  91230. export class ExecuteCodeAction extends Action {
  91231. /**
  91232. * The callback function to run.
  91233. */
  91234. func: (evt: ActionEvent) => void;
  91235. /**
  91236. * Instantiate the action
  91237. * @param triggerOptions defines the trigger options
  91238. * @param func defines the callback function to run
  91239. * @param condition defines the trigger related conditions
  91240. */
  91241. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  91242. /**
  91243. * Execute the action and run the attached code.
  91244. */
  91245. execute(evt: ActionEvent): void;
  91246. }
  91247. /**
  91248. * This defines an action responsible to set the parent property of the target once triggered.
  91249. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91250. */
  91251. export class SetParentAction extends Action {
  91252. private _parent;
  91253. private _target;
  91254. /**
  91255. * Instantiate the action
  91256. * @param triggerOptions defines the trigger options
  91257. * @param target defines the target containing the parent property
  91258. * @param parent defines from where the animation should start (animation frame)
  91259. * @param condition defines the trigger related conditions
  91260. */
  91261. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  91262. /** @hidden */
  91263. _prepare(): void;
  91264. /**
  91265. * Execute the action and set the parent property.
  91266. */
  91267. execute(): void;
  91268. /**
  91269. * Serializes the actions and its related information.
  91270. * @param parent defines the object to serialize in
  91271. * @returns the serialized object
  91272. */
  91273. serialize(parent: any): any;
  91274. }
  91275. }
  91276. declare module BABYLON {
  91277. /**
  91278. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  91279. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  91280. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91281. */
  91282. export class ActionManager extends AbstractActionManager {
  91283. /**
  91284. * Nothing
  91285. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91286. */
  91287. static readonly NothingTrigger: number;
  91288. /**
  91289. * On pick
  91290. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91291. */
  91292. static readonly OnPickTrigger: number;
  91293. /**
  91294. * On left pick
  91295. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91296. */
  91297. static readonly OnLeftPickTrigger: number;
  91298. /**
  91299. * On right pick
  91300. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91301. */
  91302. static readonly OnRightPickTrigger: number;
  91303. /**
  91304. * On center pick
  91305. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91306. */
  91307. static readonly OnCenterPickTrigger: number;
  91308. /**
  91309. * On pick down
  91310. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91311. */
  91312. static readonly OnPickDownTrigger: number;
  91313. /**
  91314. * On double pick
  91315. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91316. */
  91317. static readonly OnDoublePickTrigger: number;
  91318. /**
  91319. * On pick up
  91320. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91321. */
  91322. static readonly OnPickUpTrigger: number;
  91323. /**
  91324. * On pick out.
  91325. * This trigger will only be raised if you also declared a OnPickDown
  91326. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91327. */
  91328. static readonly OnPickOutTrigger: number;
  91329. /**
  91330. * On long press
  91331. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91332. */
  91333. static readonly OnLongPressTrigger: number;
  91334. /**
  91335. * On pointer over
  91336. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91337. */
  91338. static readonly OnPointerOverTrigger: number;
  91339. /**
  91340. * On pointer out
  91341. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91342. */
  91343. static readonly OnPointerOutTrigger: number;
  91344. /**
  91345. * On every frame
  91346. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91347. */
  91348. static readonly OnEveryFrameTrigger: number;
  91349. /**
  91350. * On intersection enter
  91351. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91352. */
  91353. static readonly OnIntersectionEnterTrigger: number;
  91354. /**
  91355. * On intersection exit
  91356. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91357. */
  91358. static readonly OnIntersectionExitTrigger: number;
  91359. /**
  91360. * On key down
  91361. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91362. */
  91363. static readonly OnKeyDownTrigger: number;
  91364. /**
  91365. * On key up
  91366. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91367. */
  91368. static readonly OnKeyUpTrigger: number;
  91369. private _scene;
  91370. /**
  91371. * Creates a new action manager
  91372. * @param scene defines the hosting scene
  91373. */
  91374. constructor(scene: Scene);
  91375. /**
  91376. * Releases all associated resources
  91377. */
  91378. dispose(): void;
  91379. /**
  91380. * Gets hosting scene
  91381. * @returns the hosting scene
  91382. */
  91383. getScene(): Scene;
  91384. /**
  91385. * Does this action manager handles actions of any of the given triggers
  91386. * @param triggers defines the triggers to be tested
  91387. * @return a boolean indicating whether one (or more) of the triggers is handled
  91388. */
  91389. hasSpecificTriggers(triggers: number[]): boolean;
  91390. /**
  91391. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  91392. * speed.
  91393. * @param triggerA defines the trigger to be tested
  91394. * @param triggerB defines the trigger to be tested
  91395. * @return a boolean indicating whether one (or more) of the triggers is handled
  91396. */
  91397. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  91398. /**
  91399. * Does this action manager handles actions of a given trigger
  91400. * @param trigger defines the trigger to be tested
  91401. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  91402. * @return whether the trigger is handled
  91403. */
  91404. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  91405. /**
  91406. * Does this action manager has pointer triggers
  91407. */
  91408. get hasPointerTriggers(): boolean;
  91409. /**
  91410. * Does this action manager has pick triggers
  91411. */
  91412. get hasPickTriggers(): boolean;
  91413. /**
  91414. * Registers an action to this action manager
  91415. * @param action defines the action to be registered
  91416. * @return the action amended (prepared) after registration
  91417. */
  91418. registerAction(action: IAction): Nullable<IAction>;
  91419. /**
  91420. * Unregisters an action to this action manager
  91421. * @param action defines the action to be unregistered
  91422. * @return a boolean indicating whether the action has been unregistered
  91423. */
  91424. unregisterAction(action: IAction): Boolean;
  91425. /**
  91426. * Process a specific trigger
  91427. * @param trigger defines the trigger to process
  91428. * @param evt defines the event details to be processed
  91429. */
  91430. processTrigger(trigger: number, evt?: IActionEvent): void;
  91431. /** @hidden */
  91432. _getEffectiveTarget(target: any, propertyPath: string): any;
  91433. /** @hidden */
  91434. _getProperty(propertyPath: string): string;
  91435. /**
  91436. * Serialize this manager to a JSON object
  91437. * @param name defines the property name to store this manager
  91438. * @returns a JSON representation of this manager
  91439. */
  91440. serialize(name: string): any;
  91441. /**
  91442. * Creates a new ActionManager from a JSON data
  91443. * @param parsedActions defines the JSON data to read from
  91444. * @param object defines the hosting mesh
  91445. * @param scene defines the hosting scene
  91446. */
  91447. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  91448. /**
  91449. * Get a trigger name by index
  91450. * @param trigger defines the trigger index
  91451. * @returns a trigger name
  91452. */
  91453. static GetTriggerName(trigger: number): string;
  91454. }
  91455. }
  91456. declare module BABYLON {
  91457. /**
  91458. * Class used to represent a sprite
  91459. * @see http://doc.babylonjs.com/babylon101/sprites
  91460. */
  91461. export class Sprite {
  91462. /** defines the name */
  91463. name: string;
  91464. /** Gets or sets the current world position */
  91465. position: Vector3;
  91466. /** Gets or sets the main color */
  91467. color: Color4;
  91468. /** Gets or sets the width */
  91469. width: number;
  91470. /** Gets or sets the height */
  91471. height: number;
  91472. /** Gets or sets rotation angle */
  91473. angle: number;
  91474. /** Gets or sets the cell index in the sprite sheet */
  91475. cellIndex: number;
  91476. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  91477. cellRef: string;
  91478. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  91479. invertU: number;
  91480. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  91481. invertV: number;
  91482. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  91483. disposeWhenFinishedAnimating: boolean;
  91484. /** Gets the list of attached animations */
  91485. animations: Animation[];
  91486. /** Gets or sets a boolean indicating if the sprite can be picked */
  91487. isPickable: boolean;
  91488. /**
  91489. * Gets or sets the associated action manager
  91490. */
  91491. actionManager: Nullable<ActionManager>;
  91492. private _animationStarted;
  91493. private _loopAnimation;
  91494. private _fromIndex;
  91495. private _toIndex;
  91496. private _delay;
  91497. private _direction;
  91498. private _manager;
  91499. private _time;
  91500. private _onAnimationEnd;
  91501. /**
  91502. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  91503. */
  91504. isVisible: boolean;
  91505. /**
  91506. * Gets or sets the sprite size
  91507. */
  91508. get size(): number;
  91509. set size(value: number);
  91510. /**
  91511. * Creates a new Sprite
  91512. * @param name defines the name
  91513. * @param manager defines the manager
  91514. */
  91515. constructor(
  91516. /** defines the name */
  91517. name: string, manager: ISpriteManager);
  91518. /**
  91519. * Starts an animation
  91520. * @param from defines the initial key
  91521. * @param to defines the end key
  91522. * @param loop defines if the animation must loop
  91523. * @param delay defines the start delay (in ms)
  91524. * @param onAnimationEnd defines a callback to call when animation ends
  91525. */
  91526. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  91527. /** Stops current animation (if any) */
  91528. stopAnimation(): void;
  91529. /** @hidden */
  91530. _animate(deltaTime: number): void;
  91531. /** Release associated resources */
  91532. dispose(): void;
  91533. }
  91534. }
  91535. declare module BABYLON {
  91536. /**
  91537. * Information about the result of picking within a scene
  91538. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  91539. */
  91540. export class PickingInfo {
  91541. /** @hidden */
  91542. _pickingUnavailable: boolean;
  91543. /**
  91544. * If the pick collided with an object
  91545. */
  91546. hit: boolean;
  91547. /**
  91548. * Distance away where the pick collided
  91549. */
  91550. distance: number;
  91551. /**
  91552. * The location of pick collision
  91553. */
  91554. pickedPoint: Nullable<Vector3>;
  91555. /**
  91556. * The mesh corresponding the the pick collision
  91557. */
  91558. pickedMesh: Nullable<AbstractMesh>;
  91559. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  91560. bu: number;
  91561. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  91562. bv: number;
  91563. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91564. faceId: number;
  91565. /** Id of the the submesh that was picked */
  91566. subMeshId: number;
  91567. /** If a sprite was picked, this will be the sprite the pick collided with */
  91568. pickedSprite: Nullable<Sprite>;
  91569. /**
  91570. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  91571. */
  91572. originMesh: Nullable<AbstractMesh>;
  91573. /**
  91574. * The ray that was used to perform the picking.
  91575. */
  91576. ray: Nullable<Ray>;
  91577. /**
  91578. * Gets the normal correspodning to the face the pick collided with
  91579. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  91580. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  91581. * @returns The normal correspodning to the face the pick collided with
  91582. */
  91583. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  91584. /**
  91585. * Gets the texture coordinates of where the pick occured
  91586. * @returns the vector containing the coordnates of the texture
  91587. */
  91588. getTextureCoordinates(): Nullable<Vector2>;
  91589. }
  91590. }
  91591. declare module BABYLON {
  91592. /**
  91593. * Gather the list of pointer event types as constants.
  91594. */
  91595. export class PointerEventTypes {
  91596. /**
  91597. * 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.
  91598. */
  91599. static readonly POINTERDOWN: number;
  91600. /**
  91601. * The pointerup event is fired when a pointer is no longer active.
  91602. */
  91603. static readonly POINTERUP: number;
  91604. /**
  91605. * The pointermove event is fired when a pointer changes coordinates.
  91606. */
  91607. static readonly POINTERMOVE: number;
  91608. /**
  91609. * The pointerwheel event is fired when a mouse wheel has been rotated.
  91610. */
  91611. static readonly POINTERWHEEL: number;
  91612. /**
  91613. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  91614. */
  91615. static readonly POINTERPICK: number;
  91616. /**
  91617. * The pointertap event is fired when a the object has been touched and released without drag.
  91618. */
  91619. static readonly POINTERTAP: number;
  91620. /**
  91621. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  91622. */
  91623. static readonly POINTERDOUBLETAP: number;
  91624. }
  91625. /**
  91626. * Base class of pointer info types.
  91627. */
  91628. export class PointerInfoBase {
  91629. /**
  91630. * Defines the type of event (PointerEventTypes)
  91631. */
  91632. type: number;
  91633. /**
  91634. * Defines the related dom event
  91635. */
  91636. event: PointerEvent | MouseWheelEvent;
  91637. /**
  91638. * Instantiates the base class of pointers info.
  91639. * @param type Defines the type of event (PointerEventTypes)
  91640. * @param event Defines the related dom event
  91641. */
  91642. constructor(
  91643. /**
  91644. * Defines the type of event (PointerEventTypes)
  91645. */
  91646. type: number,
  91647. /**
  91648. * Defines the related dom event
  91649. */
  91650. event: PointerEvent | MouseWheelEvent);
  91651. }
  91652. /**
  91653. * This class is used to store pointer related info for the onPrePointerObservable event.
  91654. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  91655. */
  91656. export class PointerInfoPre extends PointerInfoBase {
  91657. /**
  91658. * Ray from a pointer if availible (eg. 6dof controller)
  91659. */
  91660. ray: Nullable<Ray>;
  91661. /**
  91662. * Defines the local position of the pointer on the canvas.
  91663. */
  91664. localPosition: Vector2;
  91665. /**
  91666. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  91667. */
  91668. skipOnPointerObservable: boolean;
  91669. /**
  91670. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  91671. * @param type Defines the type of event (PointerEventTypes)
  91672. * @param event Defines the related dom event
  91673. * @param localX Defines the local x coordinates of the pointer when the event occured
  91674. * @param localY Defines the local y coordinates of the pointer when the event occured
  91675. */
  91676. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  91677. }
  91678. /**
  91679. * This type contains all the data related to a pointer event in Babylon.js.
  91680. * 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.
  91681. */
  91682. export class PointerInfo extends PointerInfoBase {
  91683. /**
  91684. * Defines the picking info associated to the info (if any)\
  91685. */
  91686. pickInfo: Nullable<PickingInfo>;
  91687. /**
  91688. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  91689. * @param type Defines the type of event (PointerEventTypes)
  91690. * @param event Defines the related dom event
  91691. * @param pickInfo Defines the picking info associated to the info (if any)\
  91692. */
  91693. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  91694. /**
  91695. * Defines the picking info associated to the info (if any)\
  91696. */
  91697. pickInfo: Nullable<PickingInfo>);
  91698. }
  91699. /**
  91700. * Data relating to a touch event on the screen.
  91701. */
  91702. export interface PointerTouch {
  91703. /**
  91704. * X coordinate of touch.
  91705. */
  91706. x: number;
  91707. /**
  91708. * Y coordinate of touch.
  91709. */
  91710. y: number;
  91711. /**
  91712. * Id of touch. Unique for each finger.
  91713. */
  91714. pointerId: number;
  91715. /**
  91716. * Event type passed from DOM.
  91717. */
  91718. type: any;
  91719. }
  91720. }
  91721. declare module BABYLON {
  91722. /**
  91723. * Manage the mouse inputs to control the movement of a free camera.
  91724. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91725. */
  91726. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  91727. /**
  91728. * Define if touch is enabled in the mouse input
  91729. */
  91730. touchEnabled: boolean;
  91731. /**
  91732. * Defines the camera the input is attached to.
  91733. */
  91734. camera: FreeCamera;
  91735. /**
  91736. * Defines the buttons associated with the input to handle camera move.
  91737. */
  91738. buttons: number[];
  91739. /**
  91740. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  91741. */
  91742. angularSensibility: number;
  91743. private _pointerInput;
  91744. private _onMouseMove;
  91745. private _observer;
  91746. private previousPosition;
  91747. /**
  91748. * Observable for when a pointer move event occurs containing the move offset
  91749. */
  91750. onPointerMovedObservable: Observable<{
  91751. offsetX: number;
  91752. offsetY: number;
  91753. }>;
  91754. /**
  91755. * @hidden
  91756. * If the camera should be rotated automatically based on pointer movement
  91757. */
  91758. _allowCameraRotation: boolean;
  91759. /**
  91760. * Manage the mouse inputs to control the movement of a free camera.
  91761. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91762. * @param touchEnabled Defines if touch is enabled or not
  91763. */
  91764. constructor(
  91765. /**
  91766. * Define if touch is enabled in the mouse input
  91767. */
  91768. touchEnabled?: boolean);
  91769. /**
  91770. * Attach the input controls to a specific dom element to get the input from.
  91771. * @param element Defines the element the controls should be listened from
  91772. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91773. */
  91774. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91775. /**
  91776. * Called on JS contextmenu event.
  91777. * Override this method to provide functionality.
  91778. */
  91779. protected onContextMenu(evt: PointerEvent): void;
  91780. /**
  91781. * Detach the current controls from the specified dom element.
  91782. * @param element Defines the element to stop listening the inputs from
  91783. */
  91784. detachControl(element: Nullable<HTMLElement>): void;
  91785. /**
  91786. * Gets the class name of the current intput.
  91787. * @returns the class name
  91788. */
  91789. getClassName(): string;
  91790. /**
  91791. * Get the friendly name associated with the input class.
  91792. * @returns the input friendly name
  91793. */
  91794. getSimpleName(): string;
  91795. }
  91796. }
  91797. declare module BABYLON {
  91798. /**
  91799. * Manage the touch inputs to control the movement of a free camera.
  91800. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91801. */
  91802. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  91803. /**
  91804. * Defines the camera the input is attached to.
  91805. */
  91806. camera: FreeCamera;
  91807. /**
  91808. * Defines the touch sensibility for rotation.
  91809. * The higher the faster.
  91810. */
  91811. touchAngularSensibility: number;
  91812. /**
  91813. * Defines the touch sensibility for move.
  91814. * The higher the faster.
  91815. */
  91816. touchMoveSensibility: number;
  91817. private _offsetX;
  91818. private _offsetY;
  91819. private _pointerPressed;
  91820. private _pointerInput;
  91821. private _observer;
  91822. private _onLostFocus;
  91823. /**
  91824. * Attach the input controls to a specific dom element to get the input from.
  91825. * @param element Defines the element the controls should be listened from
  91826. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91827. */
  91828. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91829. /**
  91830. * Detach the current controls from the specified dom element.
  91831. * @param element Defines the element to stop listening the inputs from
  91832. */
  91833. detachControl(element: Nullable<HTMLElement>): void;
  91834. /**
  91835. * Update the current camera state depending on the inputs that have been used this frame.
  91836. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91837. */
  91838. checkInputs(): void;
  91839. /**
  91840. * Gets the class name of the current intput.
  91841. * @returns the class name
  91842. */
  91843. getClassName(): string;
  91844. /**
  91845. * Get the friendly name associated with the input class.
  91846. * @returns the input friendly name
  91847. */
  91848. getSimpleName(): string;
  91849. }
  91850. }
  91851. declare module BABYLON {
  91852. /**
  91853. * Default Inputs manager for the FreeCamera.
  91854. * It groups all the default supported inputs for ease of use.
  91855. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91856. */
  91857. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  91858. /**
  91859. * @hidden
  91860. */
  91861. _mouseInput: Nullable<FreeCameraMouseInput>;
  91862. /**
  91863. * Instantiates a new FreeCameraInputsManager.
  91864. * @param camera Defines the camera the inputs belong to
  91865. */
  91866. constructor(camera: FreeCamera);
  91867. /**
  91868. * Add keyboard input support to the input manager.
  91869. * @returns the current input manager
  91870. */
  91871. addKeyboard(): FreeCameraInputsManager;
  91872. /**
  91873. * Add mouse input support to the input manager.
  91874. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  91875. * @returns the current input manager
  91876. */
  91877. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  91878. /**
  91879. * Removes the mouse input support from the manager
  91880. * @returns the current input manager
  91881. */
  91882. removeMouse(): FreeCameraInputsManager;
  91883. /**
  91884. * Add touch input support to the input manager.
  91885. * @returns the current input manager
  91886. */
  91887. addTouch(): FreeCameraInputsManager;
  91888. /**
  91889. * Remove all attached input methods from a camera
  91890. */
  91891. clear(): void;
  91892. }
  91893. }
  91894. declare module BABYLON {
  91895. /**
  91896. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  91897. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  91898. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  91899. */
  91900. export class FreeCamera extends TargetCamera {
  91901. /**
  91902. * Define the collision ellipsoid of the camera.
  91903. * This is helpful to simulate a camera body like the player body around the camera
  91904. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  91905. */
  91906. ellipsoid: Vector3;
  91907. /**
  91908. * Define an offset for the position of the ellipsoid around the camera.
  91909. * This can be helpful to determine the center of the body near the gravity center of the body
  91910. * instead of its head.
  91911. */
  91912. ellipsoidOffset: Vector3;
  91913. /**
  91914. * Enable or disable collisions of the camera with the rest of the scene objects.
  91915. */
  91916. checkCollisions: boolean;
  91917. /**
  91918. * Enable or disable gravity on the camera.
  91919. */
  91920. applyGravity: boolean;
  91921. /**
  91922. * Define the input manager associated to the camera.
  91923. */
  91924. inputs: FreeCameraInputsManager;
  91925. /**
  91926. * Gets the input sensibility for a mouse input. (default is 2000.0)
  91927. * Higher values reduce sensitivity.
  91928. */
  91929. get angularSensibility(): number;
  91930. /**
  91931. * Sets the input sensibility for a mouse input. (default is 2000.0)
  91932. * Higher values reduce sensitivity.
  91933. */
  91934. set angularSensibility(value: number);
  91935. /**
  91936. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  91937. */
  91938. get keysUp(): number[];
  91939. set keysUp(value: number[]);
  91940. /**
  91941. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  91942. */
  91943. get keysUpward(): number[];
  91944. set keysUpward(value: number[]);
  91945. /**
  91946. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  91947. */
  91948. get keysDown(): number[];
  91949. set keysDown(value: number[]);
  91950. /**
  91951. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  91952. */
  91953. get keysDownward(): number[];
  91954. set keysDownward(value: number[]);
  91955. /**
  91956. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  91957. */
  91958. get keysLeft(): number[];
  91959. set keysLeft(value: number[]);
  91960. /**
  91961. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  91962. */
  91963. get keysRight(): number[];
  91964. set keysRight(value: number[]);
  91965. /**
  91966. * Event raised when the camera collide with a mesh in the scene.
  91967. */
  91968. onCollide: (collidedMesh: AbstractMesh) => void;
  91969. private _collider;
  91970. private _needMoveForGravity;
  91971. private _oldPosition;
  91972. private _diffPosition;
  91973. private _newPosition;
  91974. /** @hidden */
  91975. _localDirection: Vector3;
  91976. /** @hidden */
  91977. _transformedDirection: Vector3;
  91978. /**
  91979. * Instantiates a Free Camera.
  91980. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  91981. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  91982. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  91983. * @param name Define the name of the camera in the scene
  91984. * @param position Define the start position of the camera in the scene
  91985. * @param scene Define the scene the camera belongs to
  91986. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  91987. */
  91988. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91989. /**
  91990. * Attached controls to the current camera.
  91991. * @param element Defines the element the controls should be listened from
  91992. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91993. */
  91994. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91995. /**
  91996. * Detach the current controls from the camera.
  91997. * The camera will stop reacting to inputs.
  91998. * @param element Defines the element to stop listening the inputs from
  91999. */
  92000. detachControl(element: HTMLElement): void;
  92001. private _collisionMask;
  92002. /**
  92003. * Define a collision mask to limit the list of object the camera can collide with
  92004. */
  92005. get collisionMask(): number;
  92006. set collisionMask(mask: number);
  92007. /** @hidden */
  92008. _collideWithWorld(displacement: Vector3): void;
  92009. private _onCollisionPositionChange;
  92010. /** @hidden */
  92011. _checkInputs(): void;
  92012. /** @hidden */
  92013. _decideIfNeedsToMove(): boolean;
  92014. /** @hidden */
  92015. _updatePosition(): void;
  92016. /**
  92017. * Destroy the camera and release the current resources hold by it.
  92018. */
  92019. dispose(): void;
  92020. /**
  92021. * Gets the current object class name.
  92022. * @return the class name
  92023. */
  92024. getClassName(): string;
  92025. }
  92026. }
  92027. declare module BABYLON {
  92028. /**
  92029. * Represents a gamepad control stick position
  92030. */
  92031. export class StickValues {
  92032. /**
  92033. * The x component of the control stick
  92034. */
  92035. x: number;
  92036. /**
  92037. * The y component of the control stick
  92038. */
  92039. y: number;
  92040. /**
  92041. * Initializes the gamepad x and y control stick values
  92042. * @param x The x component of the gamepad control stick value
  92043. * @param y The y component of the gamepad control stick value
  92044. */
  92045. constructor(
  92046. /**
  92047. * The x component of the control stick
  92048. */
  92049. x: number,
  92050. /**
  92051. * The y component of the control stick
  92052. */
  92053. y: number);
  92054. }
  92055. /**
  92056. * An interface which manages callbacks for gamepad button changes
  92057. */
  92058. export interface GamepadButtonChanges {
  92059. /**
  92060. * Called when a gamepad has been changed
  92061. */
  92062. changed: boolean;
  92063. /**
  92064. * Called when a gamepad press event has been triggered
  92065. */
  92066. pressChanged: boolean;
  92067. /**
  92068. * Called when a touch event has been triggered
  92069. */
  92070. touchChanged: boolean;
  92071. /**
  92072. * Called when a value has changed
  92073. */
  92074. valueChanged: boolean;
  92075. }
  92076. /**
  92077. * Represents a gamepad
  92078. */
  92079. export class Gamepad {
  92080. /**
  92081. * The id of the gamepad
  92082. */
  92083. id: string;
  92084. /**
  92085. * The index of the gamepad
  92086. */
  92087. index: number;
  92088. /**
  92089. * The browser gamepad
  92090. */
  92091. browserGamepad: any;
  92092. /**
  92093. * Specifies what type of gamepad this represents
  92094. */
  92095. type: number;
  92096. private _leftStick;
  92097. private _rightStick;
  92098. /** @hidden */
  92099. _isConnected: boolean;
  92100. private _leftStickAxisX;
  92101. private _leftStickAxisY;
  92102. private _rightStickAxisX;
  92103. private _rightStickAxisY;
  92104. /**
  92105. * Triggered when the left control stick has been changed
  92106. */
  92107. private _onleftstickchanged;
  92108. /**
  92109. * Triggered when the right control stick has been changed
  92110. */
  92111. private _onrightstickchanged;
  92112. /**
  92113. * Represents a gamepad controller
  92114. */
  92115. static GAMEPAD: number;
  92116. /**
  92117. * Represents a generic controller
  92118. */
  92119. static GENERIC: number;
  92120. /**
  92121. * Represents an XBox controller
  92122. */
  92123. static XBOX: number;
  92124. /**
  92125. * Represents a pose-enabled controller
  92126. */
  92127. static POSE_ENABLED: number;
  92128. /**
  92129. * Represents an Dual Shock controller
  92130. */
  92131. static DUALSHOCK: number;
  92132. /**
  92133. * Specifies whether the left control stick should be Y-inverted
  92134. */
  92135. protected _invertLeftStickY: boolean;
  92136. /**
  92137. * Specifies if the gamepad has been connected
  92138. */
  92139. get isConnected(): boolean;
  92140. /**
  92141. * Initializes the gamepad
  92142. * @param id The id of the gamepad
  92143. * @param index The index of the gamepad
  92144. * @param browserGamepad The browser gamepad
  92145. * @param leftStickX The x component of the left joystick
  92146. * @param leftStickY The y component of the left joystick
  92147. * @param rightStickX The x component of the right joystick
  92148. * @param rightStickY The y component of the right joystick
  92149. */
  92150. constructor(
  92151. /**
  92152. * The id of the gamepad
  92153. */
  92154. id: string,
  92155. /**
  92156. * The index of the gamepad
  92157. */
  92158. index: number,
  92159. /**
  92160. * The browser gamepad
  92161. */
  92162. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  92163. /**
  92164. * Callback triggered when the left joystick has changed
  92165. * @param callback
  92166. */
  92167. onleftstickchanged(callback: (values: StickValues) => void): void;
  92168. /**
  92169. * Callback triggered when the right joystick has changed
  92170. * @param callback
  92171. */
  92172. onrightstickchanged(callback: (values: StickValues) => void): void;
  92173. /**
  92174. * Gets the left joystick
  92175. */
  92176. get leftStick(): StickValues;
  92177. /**
  92178. * Sets the left joystick values
  92179. */
  92180. set leftStick(newValues: StickValues);
  92181. /**
  92182. * Gets the right joystick
  92183. */
  92184. get rightStick(): StickValues;
  92185. /**
  92186. * Sets the right joystick value
  92187. */
  92188. set rightStick(newValues: StickValues);
  92189. /**
  92190. * Updates the gamepad joystick positions
  92191. */
  92192. update(): void;
  92193. /**
  92194. * Disposes the gamepad
  92195. */
  92196. dispose(): void;
  92197. }
  92198. /**
  92199. * Represents a generic gamepad
  92200. */
  92201. export class GenericPad extends Gamepad {
  92202. private _buttons;
  92203. private _onbuttondown;
  92204. private _onbuttonup;
  92205. /**
  92206. * Observable triggered when a button has been pressed
  92207. */
  92208. onButtonDownObservable: Observable<number>;
  92209. /**
  92210. * Observable triggered when a button has been released
  92211. */
  92212. onButtonUpObservable: Observable<number>;
  92213. /**
  92214. * Callback triggered when a button has been pressed
  92215. * @param callback Called when a button has been pressed
  92216. */
  92217. onbuttondown(callback: (buttonPressed: number) => void): void;
  92218. /**
  92219. * Callback triggered when a button has been released
  92220. * @param callback Called when a button has been released
  92221. */
  92222. onbuttonup(callback: (buttonReleased: number) => void): void;
  92223. /**
  92224. * Initializes the generic gamepad
  92225. * @param id The id of the generic gamepad
  92226. * @param index The index of the generic gamepad
  92227. * @param browserGamepad The browser gamepad
  92228. */
  92229. constructor(id: string, index: number, browserGamepad: any);
  92230. private _setButtonValue;
  92231. /**
  92232. * Updates the generic gamepad
  92233. */
  92234. update(): void;
  92235. /**
  92236. * Disposes the generic gamepad
  92237. */
  92238. dispose(): void;
  92239. }
  92240. }
  92241. declare module BABYLON {
  92242. /**
  92243. * Defines the types of pose enabled controllers that are supported
  92244. */
  92245. export enum PoseEnabledControllerType {
  92246. /**
  92247. * HTC Vive
  92248. */
  92249. VIVE = 0,
  92250. /**
  92251. * Oculus Rift
  92252. */
  92253. OCULUS = 1,
  92254. /**
  92255. * Windows mixed reality
  92256. */
  92257. WINDOWS = 2,
  92258. /**
  92259. * Samsung gear VR
  92260. */
  92261. GEAR_VR = 3,
  92262. /**
  92263. * Google Daydream
  92264. */
  92265. DAYDREAM = 4,
  92266. /**
  92267. * Generic
  92268. */
  92269. GENERIC = 5
  92270. }
  92271. /**
  92272. * Defines the MutableGamepadButton interface for the state of a gamepad button
  92273. */
  92274. export interface MutableGamepadButton {
  92275. /**
  92276. * Value of the button/trigger
  92277. */
  92278. value: number;
  92279. /**
  92280. * If the button/trigger is currently touched
  92281. */
  92282. touched: boolean;
  92283. /**
  92284. * If the button/trigger is currently pressed
  92285. */
  92286. pressed: boolean;
  92287. }
  92288. /**
  92289. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  92290. * @hidden
  92291. */
  92292. export interface ExtendedGamepadButton extends GamepadButton {
  92293. /**
  92294. * If the button/trigger is currently pressed
  92295. */
  92296. readonly pressed: boolean;
  92297. /**
  92298. * If the button/trigger is currently touched
  92299. */
  92300. readonly touched: boolean;
  92301. /**
  92302. * Value of the button/trigger
  92303. */
  92304. readonly value: number;
  92305. }
  92306. /** @hidden */
  92307. export interface _GamePadFactory {
  92308. /**
  92309. * Returns whether or not the current gamepad can be created for this type of controller.
  92310. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  92311. * @returns true if it can be created, otherwise false
  92312. */
  92313. canCreate(gamepadInfo: any): boolean;
  92314. /**
  92315. * Creates a new instance of the Gamepad.
  92316. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  92317. * @returns the new gamepad instance
  92318. */
  92319. create(gamepadInfo: any): Gamepad;
  92320. }
  92321. /**
  92322. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  92323. */
  92324. export class PoseEnabledControllerHelper {
  92325. /** @hidden */
  92326. static _ControllerFactories: _GamePadFactory[];
  92327. /** @hidden */
  92328. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  92329. /**
  92330. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  92331. * @param vrGamepad the gamepad to initialized
  92332. * @returns a vr controller of the type the gamepad identified as
  92333. */
  92334. static InitiateController(vrGamepad: any): Gamepad;
  92335. }
  92336. /**
  92337. * Defines the PoseEnabledController object that contains state of a vr capable controller
  92338. */
  92339. export class PoseEnabledController extends Gamepad implements PoseControlled {
  92340. /**
  92341. * If the controller is used in a webXR session
  92342. */
  92343. isXR: boolean;
  92344. private _deviceRoomPosition;
  92345. private _deviceRoomRotationQuaternion;
  92346. /**
  92347. * The device position in babylon space
  92348. */
  92349. devicePosition: Vector3;
  92350. /**
  92351. * The device rotation in babylon space
  92352. */
  92353. deviceRotationQuaternion: Quaternion;
  92354. /**
  92355. * The scale factor of the device in babylon space
  92356. */
  92357. deviceScaleFactor: number;
  92358. /**
  92359. * (Likely devicePosition should be used instead) The device position in its room space
  92360. */
  92361. position: Vector3;
  92362. /**
  92363. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  92364. */
  92365. rotationQuaternion: Quaternion;
  92366. /**
  92367. * The type of controller (Eg. Windows mixed reality)
  92368. */
  92369. controllerType: PoseEnabledControllerType;
  92370. protected _calculatedPosition: Vector3;
  92371. private _calculatedRotation;
  92372. /**
  92373. * The raw pose from the device
  92374. */
  92375. rawPose: DevicePose;
  92376. private _trackPosition;
  92377. private _maxRotationDistFromHeadset;
  92378. private _draggedRoomRotation;
  92379. /**
  92380. * @hidden
  92381. */
  92382. _disableTrackPosition(fixedPosition: Vector3): void;
  92383. /**
  92384. * Internal, the mesh attached to the controller
  92385. * @hidden
  92386. */
  92387. _mesh: Nullable<AbstractMesh>;
  92388. private _poseControlledCamera;
  92389. private _leftHandSystemQuaternion;
  92390. /**
  92391. * Internal, matrix used to convert room space to babylon space
  92392. * @hidden
  92393. */
  92394. _deviceToWorld: Matrix;
  92395. /**
  92396. * Node to be used when casting a ray from the controller
  92397. * @hidden
  92398. */
  92399. _pointingPoseNode: Nullable<TransformNode>;
  92400. /**
  92401. * Name of the child mesh that can be used to cast a ray from the controller
  92402. */
  92403. static readonly POINTING_POSE: string;
  92404. /**
  92405. * Creates a new PoseEnabledController from a gamepad
  92406. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  92407. */
  92408. constructor(browserGamepad: any);
  92409. private _workingMatrix;
  92410. /**
  92411. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  92412. */
  92413. update(): void;
  92414. /**
  92415. * Updates only the pose device and mesh without doing any button event checking
  92416. */
  92417. protected _updatePoseAndMesh(): void;
  92418. /**
  92419. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  92420. * @param poseData raw pose fromthe device
  92421. */
  92422. updateFromDevice(poseData: DevicePose): void;
  92423. /**
  92424. * @hidden
  92425. */
  92426. _meshAttachedObservable: Observable<AbstractMesh>;
  92427. /**
  92428. * Attaches a mesh to the controller
  92429. * @param mesh the mesh to be attached
  92430. */
  92431. attachToMesh(mesh: AbstractMesh): void;
  92432. /**
  92433. * Attaches the controllers mesh to a camera
  92434. * @param camera the camera the mesh should be attached to
  92435. */
  92436. attachToPoseControlledCamera(camera: TargetCamera): void;
  92437. /**
  92438. * Disposes of the controller
  92439. */
  92440. dispose(): void;
  92441. /**
  92442. * The mesh that is attached to the controller
  92443. */
  92444. get mesh(): Nullable<AbstractMesh>;
  92445. /**
  92446. * Gets the ray of the controller in the direction the controller is pointing
  92447. * @param length the length the resulting ray should be
  92448. * @returns a ray in the direction the controller is pointing
  92449. */
  92450. getForwardRay(length?: number): Ray;
  92451. }
  92452. }
  92453. declare module BABYLON {
  92454. /**
  92455. * Defines the WebVRController object that represents controllers tracked in 3D space
  92456. */
  92457. export abstract class WebVRController extends PoseEnabledController {
  92458. /**
  92459. * Internal, the default controller model for the controller
  92460. */
  92461. protected _defaultModel: Nullable<AbstractMesh>;
  92462. /**
  92463. * Fired when the trigger state has changed
  92464. */
  92465. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  92466. /**
  92467. * Fired when the main button state has changed
  92468. */
  92469. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  92470. /**
  92471. * Fired when the secondary button state has changed
  92472. */
  92473. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  92474. /**
  92475. * Fired when the pad state has changed
  92476. */
  92477. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  92478. /**
  92479. * Fired when controllers stick values have changed
  92480. */
  92481. onPadValuesChangedObservable: Observable<StickValues>;
  92482. /**
  92483. * Array of button availible on the controller
  92484. */
  92485. protected _buttons: Array<MutableGamepadButton>;
  92486. private _onButtonStateChange;
  92487. /**
  92488. * Fired when a controller button's state has changed
  92489. * @param callback the callback containing the button that was modified
  92490. */
  92491. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  92492. /**
  92493. * X and Y axis corresponding to the controllers joystick
  92494. */
  92495. pad: StickValues;
  92496. /**
  92497. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  92498. */
  92499. hand: string;
  92500. /**
  92501. * The default controller model for the controller
  92502. */
  92503. get defaultModel(): Nullable<AbstractMesh>;
  92504. /**
  92505. * Creates a new WebVRController from a gamepad
  92506. * @param vrGamepad the gamepad that the WebVRController should be created from
  92507. */
  92508. constructor(vrGamepad: any);
  92509. /**
  92510. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  92511. */
  92512. update(): void;
  92513. /**
  92514. * Function to be called when a button is modified
  92515. */
  92516. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  92517. /**
  92518. * Loads a mesh and attaches it to the controller
  92519. * @param scene the scene the mesh should be added to
  92520. * @param meshLoaded callback for when the mesh has been loaded
  92521. */
  92522. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  92523. private _setButtonValue;
  92524. private _changes;
  92525. private _checkChanges;
  92526. /**
  92527. * Disposes of th webVRCOntroller
  92528. */
  92529. dispose(): void;
  92530. }
  92531. }
  92532. declare module BABYLON {
  92533. /**
  92534. * The HemisphericLight simulates the ambient environment light,
  92535. * so the passed direction is the light reflection direction, not the incoming direction.
  92536. */
  92537. export class HemisphericLight extends Light {
  92538. /**
  92539. * The groundColor is the light in the opposite direction to the one specified during creation.
  92540. * 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.
  92541. */
  92542. groundColor: Color3;
  92543. /**
  92544. * The light reflection direction, not the incoming direction.
  92545. */
  92546. direction: Vector3;
  92547. /**
  92548. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  92549. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  92550. * The HemisphericLight can't cast shadows.
  92551. * Documentation : https://doc.babylonjs.com/babylon101/lights
  92552. * @param name The friendly name of the light
  92553. * @param direction The direction of the light reflection
  92554. * @param scene The scene the light belongs to
  92555. */
  92556. constructor(name: string, direction: Vector3, scene: Scene);
  92557. protected _buildUniformLayout(): void;
  92558. /**
  92559. * Returns the string "HemisphericLight".
  92560. * @return The class name
  92561. */
  92562. getClassName(): string;
  92563. /**
  92564. * Sets the HemisphericLight direction towards the passed target (Vector3).
  92565. * Returns the updated direction.
  92566. * @param target The target the direction should point to
  92567. * @return The computed direction
  92568. */
  92569. setDirectionToTarget(target: Vector3): Vector3;
  92570. /**
  92571. * Returns the shadow generator associated to the light.
  92572. * @returns Always null for hemispheric lights because it does not support shadows.
  92573. */
  92574. getShadowGenerator(): Nullable<IShadowGenerator>;
  92575. /**
  92576. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  92577. * @param effect The effect to update
  92578. * @param lightIndex The index of the light in the effect to update
  92579. * @returns The hemispheric light
  92580. */
  92581. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  92582. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  92583. /**
  92584. * Computes the world matrix of the node
  92585. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92586. * @param useWasUpdatedFlag defines a reserved property
  92587. * @returns the world matrix
  92588. */
  92589. computeWorldMatrix(): Matrix;
  92590. /**
  92591. * Returns the integer 3.
  92592. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  92593. */
  92594. getTypeID(): number;
  92595. /**
  92596. * Prepares the list of defines specific to the light type.
  92597. * @param defines the list of defines
  92598. * @param lightIndex defines the index of the light for the effect
  92599. */
  92600. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  92601. }
  92602. }
  92603. declare module BABYLON {
  92604. /** @hidden */
  92605. export var vrMultiviewToSingleviewPixelShader: {
  92606. name: string;
  92607. shader: string;
  92608. };
  92609. }
  92610. declare module BABYLON {
  92611. /**
  92612. * Renders to multiple views with a single draw call
  92613. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  92614. */
  92615. export class MultiviewRenderTarget extends RenderTargetTexture {
  92616. /**
  92617. * Creates a multiview render target
  92618. * @param scene scene used with the render target
  92619. * @param size the size of the render target (used for each view)
  92620. */
  92621. constructor(scene: Scene, size?: number | {
  92622. width: number;
  92623. height: number;
  92624. } | {
  92625. ratio: number;
  92626. });
  92627. /**
  92628. * @hidden
  92629. * @param faceIndex the face index, if its a cube texture
  92630. */
  92631. _bindFrameBuffer(faceIndex?: number): void;
  92632. /**
  92633. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  92634. * @returns the view count
  92635. */
  92636. getViewCount(): number;
  92637. }
  92638. }
  92639. declare module BABYLON {
  92640. /**
  92641. * Represents a camera frustum
  92642. */
  92643. export class Frustum {
  92644. /**
  92645. * Gets the planes representing the frustum
  92646. * @param transform matrix to be applied to the returned planes
  92647. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  92648. */
  92649. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  92650. /**
  92651. * Gets the near frustum plane transformed by the transform matrix
  92652. * @param transform transformation matrix to be applied to the resulting frustum plane
  92653. * @param frustumPlane the resuling frustum plane
  92654. */
  92655. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92656. /**
  92657. * Gets the far frustum plane transformed by the transform matrix
  92658. * @param transform transformation matrix to be applied to the resulting frustum plane
  92659. * @param frustumPlane the resuling frustum plane
  92660. */
  92661. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92662. /**
  92663. * Gets the left frustum plane transformed by the transform matrix
  92664. * @param transform transformation matrix to be applied to the resulting frustum plane
  92665. * @param frustumPlane the resuling frustum plane
  92666. */
  92667. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92668. /**
  92669. * Gets the right frustum plane transformed by the transform matrix
  92670. * @param transform transformation matrix to be applied to the resulting frustum plane
  92671. * @param frustumPlane the resuling frustum plane
  92672. */
  92673. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92674. /**
  92675. * Gets the top frustum plane transformed by the transform matrix
  92676. * @param transform transformation matrix to be applied to the resulting frustum plane
  92677. * @param frustumPlane the resuling frustum plane
  92678. */
  92679. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92680. /**
  92681. * Gets the bottom frustum plane transformed by the transform matrix
  92682. * @param transform transformation matrix to be applied to the resulting frustum plane
  92683. * @param frustumPlane the resuling frustum plane
  92684. */
  92685. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92686. /**
  92687. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  92688. * @param transform transformation matrix to be applied to the resulting frustum planes
  92689. * @param frustumPlanes the resuling frustum planes
  92690. */
  92691. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  92692. }
  92693. }
  92694. declare module BABYLON {
  92695. interface Engine {
  92696. /**
  92697. * Creates a new multiview render target
  92698. * @param width defines the width of the texture
  92699. * @param height defines the height of the texture
  92700. * @returns the created multiview texture
  92701. */
  92702. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  92703. /**
  92704. * Binds a multiview framebuffer to be drawn to
  92705. * @param multiviewTexture texture to bind
  92706. */
  92707. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  92708. }
  92709. interface Camera {
  92710. /**
  92711. * @hidden
  92712. * 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)
  92713. */
  92714. _useMultiviewToSingleView: boolean;
  92715. /**
  92716. * @hidden
  92717. * 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)
  92718. */
  92719. _multiviewTexture: Nullable<RenderTargetTexture>;
  92720. /**
  92721. * @hidden
  92722. * ensures the multiview texture of the camera exists and has the specified width/height
  92723. * @param width height to set on the multiview texture
  92724. * @param height width to set on the multiview texture
  92725. */
  92726. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  92727. }
  92728. interface Scene {
  92729. /** @hidden */
  92730. _transformMatrixR: Matrix;
  92731. /** @hidden */
  92732. _multiviewSceneUbo: Nullable<UniformBuffer>;
  92733. /** @hidden */
  92734. _createMultiviewUbo(): void;
  92735. /** @hidden */
  92736. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  92737. /** @hidden */
  92738. _renderMultiviewToSingleView(camera: Camera): void;
  92739. }
  92740. }
  92741. declare module BABYLON {
  92742. /**
  92743. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  92744. * This will not be used for webXR as it supports displaying texture arrays directly
  92745. */
  92746. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  92747. /**
  92748. * Initializes a VRMultiviewToSingleview
  92749. * @param name name of the post process
  92750. * @param camera camera to be applied to
  92751. * @param scaleFactor scaling factor to the size of the output texture
  92752. */
  92753. constructor(name: string, camera: Camera, scaleFactor: number);
  92754. }
  92755. }
  92756. declare module BABYLON {
  92757. /**
  92758. * Interface used to define additional presentation attributes
  92759. */
  92760. export interface IVRPresentationAttributes {
  92761. /**
  92762. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  92763. */
  92764. highRefreshRate: boolean;
  92765. /**
  92766. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  92767. */
  92768. foveationLevel: number;
  92769. }
  92770. interface Engine {
  92771. /** @hidden */
  92772. _vrDisplay: any;
  92773. /** @hidden */
  92774. _vrSupported: boolean;
  92775. /** @hidden */
  92776. _oldSize: Size;
  92777. /** @hidden */
  92778. _oldHardwareScaleFactor: number;
  92779. /** @hidden */
  92780. _vrExclusivePointerMode: boolean;
  92781. /** @hidden */
  92782. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  92783. /** @hidden */
  92784. _onVRDisplayPointerRestricted: () => void;
  92785. /** @hidden */
  92786. _onVRDisplayPointerUnrestricted: () => void;
  92787. /** @hidden */
  92788. _onVrDisplayConnect: Nullable<(display: any) => void>;
  92789. /** @hidden */
  92790. _onVrDisplayDisconnect: Nullable<() => void>;
  92791. /** @hidden */
  92792. _onVrDisplayPresentChange: Nullable<() => void>;
  92793. /**
  92794. * Observable signaled when VR display mode changes
  92795. */
  92796. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  92797. /**
  92798. * Observable signaled when VR request present is complete
  92799. */
  92800. onVRRequestPresentComplete: Observable<boolean>;
  92801. /**
  92802. * Observable signaled when VR request present starts
  92803. */
  92804. onVRRequestPresentStart: Observable<Engine>;
  92805. /**
  92806. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  92807. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  92808. */
  92809. isInVRExclusivePointerMode: boolean;
  92810. /**
  92811. * Gets a boolean indicating if a webVR device was detected
  92812. * @returns true if a webVR device was detected
  92813. */
  92814. isVRDevicePresent(): boolean;
  92815. /**
  92816. * Gets the current webVR device
  92817. * @returns the current webVR device (or null)
  92818. */
  92819. getVRDevice(): any;
  92820. /**
  92821. * Initializes a webVR display and starts listening to display change events
  92822. * The onVRDisplayChangedObservable will be notified upon these changes
  92823. * @returns A promise containing a VRDisplay and if vr is supported
  92824. */
  92825. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  92826. /** @hidden */
  92827. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  92828. /**
  92829. * Gets or sets the presentation attributes used to configure VR rendering
  92830. */
  92831. vrPresentationAttributes?: IVRPresentationAttributes;
  92832. /**
  92833. * Call this function to switch to webVR mode
  92834. * Will do nothing if webVR is not supported or if there is no webVR device
  92835. * @param options the webvr options provided to the camera. mainly used for multiview
  92836. * @see http://doc.babylonjs.com/how_to/webvr_camera
  92837. */
  92838. enableVR(options: WebVROptions): void;
  92839. /** @hidden */
  92840. _onVRFullScreenTriggered(): void;
  92841. }
  92842. }
  92843. declare module BABYLON {
  92844. /**
  92845. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  92846. * IMPORTANT!! The data is right-hand data.
  92847. * @export
  92848. * @interface DevicePose
  92849. */
  92850. export interface DevicePose {
  92851. /**
  92852. * The position of the device, values in array are [x,y,z].
  92853. */
  92854. readonly position: Nullable<Float32Array>;
  92855. /**
  92856. * The linearVelocity of the device, values in array are [x,y,z].
  92857. */
  92858. readonly linearVelocity: Nullable<Float32Array>;
  92859. /**
  92860. * The linearAcceleration of the device, values in array are [x,y,z].
  92861. */
  92862. readonly linearAcceleration: Nullable<Float32Array>;
  92863. /**
  92864. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  92865. */
  92866. readonly orientation: Nullable<Float32Array>;
  92867. /**
  92868. * The angularVelocity of the device, values in array are [x,y,z].
  92869. */
  92870. readonly angularVelocity: Nullable<Float32Array>;
  92871. /**
  92872. * The angularAcceleration of the device, values in array are [x,y,z].
  92873. */
  92874. readonly angularAcceleration: Nullable<Float32Array>;
  92875. }
  92876. /**
  92877. * Interface representing a pose controlled object in Babylon.
  92878. * A pose controlled object has both regular pose values as well as pose values
  92879. * from an external device such as a VR head mounted display
  92880. */
  92881. export interface PoseControlled {
  92882. /**
  92883. * The position of the object in babylon space.
  92884. */
  92885. position: Vector3;
  92886. /**
  92887. * The rotation quaternion of the object in babylon space.
  92888. */
  92889. rotationQuaternion: Quaternion;
  92890. /**
  92891. * The position of the device in babylon space.
  92892. */
  92893. devicePosition?: Vector3;
  92894. /**
  92895. * The rotation quaternion of the device in babylon space.
  92896. */
  92897. deviceRotationQuaternion: Quaternion;
  92898. /**
  92899. * The raw pose coming from the device.
  92900. */
  92901. rawPose: Nullable<DevicePose>;
  92902. /**
  92903. * The scale of the device to be used when translating from device space to babylon space.
  92904. */
  92905. deviceScaleFactor: number;
  92906. /**
  92907. * Updates the poseControlled values based on the input device pose.
  92908. * @param poseData the pose data to update the object with
  92909. */
  92910. updateFromDevice(poseData: DevicePose): void;
  92911. }
  92912. /**
  92913. * Set of options to customize the webVRCamera
  92914. */
  92915. export interface WebVROptions {
  92916. /**
  92917. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  92918. */
  92919. trackPosition?: boolean;
  92920. /**
  92921. * Sets the scale of the vrDevice in babylon space. (default: 1)
  92922. */
  92923. positionScale?: number;
  92924. /**
  92925. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  92926. */
  92927. displayName?: string;
  92928. /**
  92929. * Should the native controller meshes be initialized. (default: true)
  92930. */
  92931. controllerMeshes?: boolean;
  92932. /**
  92933. * Creating a default HemiLight only on controllers. (default: true)
  92934. */
  92935. defaultLightingOnControllers?: boolean;
  92936. /**
  92937. * If you don't want to use the default VR button of the helper. (default: false)
  92938. */
  92939. useCustomVRButton?: boolean;
  92940. /**
  92941. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  92942. */
  92943. customVRButton?: HTMLButtonElement;
  92944. /**
  92945. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  92946. */
  92947. rayLength?: number;
  92948. /**
  92949. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  92950. */
  92951. defaultHeight?: number;
  92952. /**
  92953. * If multiview should be used if availible (default: false)
  92954. */
  92955. useMultiview?: boolean;
  92956. }
  92957. /**
  92958. * This represents a WebVR camera.
  92959. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  92960. * @example http://doc.babylonjs.com/how_to/webvr_camera
  92961. */
  92962. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  92963. private webVROptions;
  92964. /**
  92965. * @hidden
  92966. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  92967. */
  92968. _vrDevice: any;
  92969. /**
  92970. * The rawPose of the vrDevice.
  92971. */
  92972. rawPose: Nullable<DevicePose>;
  92973. private _onVREnabled;
  92974. private _specsVersion;
  92975. private _attached;
  92976. private _frameData;
  92977. protected _descendants: Array<Node>;
  92978. private _deviceRoomPosition;
  92979. /** @hidden */
  92980. _deviceRoomRotationQuaternion: Quaternion;
  92981. private _standingMatrix;
  92982. /**
  92983. * Represents device position in babylon space.
  92984. */
  92985. devicePosition: Vector3;
  92986. /**
  92987. * Represents device rotation in babylon space.
  92988. */
  92989. deviceRotationQuaternion: Quaternion;
  92990. /**
  92991. * The scale of the device to be used when translating from device space to babylon space.
  92992. */
  92993. deviceScaleFactor: number;
  92994. private _deviceToWorld;
  92995. private _worldToDevice;
  92996. /**
  92997. * References to the webVR controllers for the vrDevice.
  92998. */
  92999. controllers: Array<WebVRController>;
  93000. /**
  93001. * Emits an event when a controller is attached.
  93002. */
  93003. onControllersAttachedObservable: Observable<WebVRController[]>;
  93004. /**
  93005. * Emits an event when a controller's mesh has been loaded;
  93006. */
  93007. onControllerMeshLoadedObservable: Observable<WebVRController>;
  93008. /**
  93009. * Emits an event when the HMD's pose has been updated.
  93010. */
  93011. onPoseUpdatedFromDeviceObservable: Observable<any>;
  93012. private _poseSet;
  93013. /**
  93014. * If the rig cameras be used as parent instead of this camera.
  93015. */
  93016. rigParenting: boolean;
  93017. private _lightOnControllers;
  93018. private _defaultHeight?;
  93019. /**
  93020. * Instantiates a WebVRFreeCamera.
  93021. * @param name The name of the WebVRFreeCamera
  93022. * @param position The starting anchor position for the camera
  93023. * @param scene The scene the camera belongs to
  93024. * @param webVROptions a set of customizable options for the webVRCamera
  93025. */
  93026. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  93027. /**
  93028. * Gets the device distance from the ground in meters.
  93029. * @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.
  93030. */
  93031. deviceDistanceToRoomGround(): number;
  93032. /**
  93033. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  93034. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  93035. */
  93036. useStandingMatrix(callback?: (bool: boolean) => void): void;
  93037. /**
  93038. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  93039. * @returns A promise with a boolean set to if the standing matrix is supported.
  93040. */
  93041. useStandingMatrixAsync(): Promise<boolean>;
  93042. /**
  93043. * Disposes the camera
  93044. */
  93045. dispose(): void;
  93046. /**
  93047. * Gets a vrController by name.
  93048. * @param name The name of the controller to retreive
  93049. * @returns the controller matching the name specified or null if not found
  93050. */
  93051. getControllerByName(name: string): Nullable<WebVRController>;
  93052. private _leftController;
  93053. /**
  93054. * The controller corresponding to the users left hand.
  93055. */
  93056. get leftController(): Nullable<WebVRController>;
  93057. private _rightController;
  93058. /**
  93059. * The controller corresponding to the users right hand.
  93060. */
  93061. get rightController(): Nullable<WebVRController>;
  93062. /**
  93063. * Casts a ray forward from the vrCamera's gaze.
  93064. * @param length Length of the ray (default: 100)
  93065. * @returns the ray corresponding to the gaze
  93066. */
  93067. getForwardRay(length?: number): Ray;
  93068. /**
  93069. * @hidden
  93070. * Updates the camera based on device's frame data
  93071. */
  93072. _checkInputs(): void;
  93073. /**
  93074. * Updates the poseControlled values based on the input device pose.
  93075. * @param poseData Pose coming from the device
  93076. */
  93077. updateFromDevice(poseData: DevicePose): void;
  93078. private _htmlElementAttached;
  93079. private _detachIfAttached;
  93080. /**
  93081. * WebVR's attach control will start broadcasting frames to the device.
  93082. * Note that in certain browsers (chrome for example) this function must be called
  93083. * within a user-interaction callback. Example:
  93084. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  93085. *
  93086. * @param element html element to attach the vrDevice to
  93087. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  93088. */
  93089. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93090. /**
  93091. * Detaches the camera from the html element and disables VR
  93092. *
  93093. * @param element html element to detach from
  93094. */
  93095. detachControl(element: HTMLElement): void;
  93096. /**
  93097. * @returns the name of this class
  93098. */
  93099. getClassName(): string;
  93100. /**
  93101. * Calls resetPose on the vrDisplay
  93102. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  93103. */
  93104. resetToCurrentRotation(): void;
  93105. /**
  93106. * @hidden
  93107. * Updates the rig cameras (left and right eye)
  93108. */
  93109. _updateRigCameras(): void;
  93110. private _workingVector;
  93111. private _oneVector;
  93112. private _workingMatrix;
  93113. private updateCacheCalled;
  93114. private _correctPositionIfNotTrackPosition;
  93115. /**
  93116. * @hidden
  93117. * Updates the cached values of the camera
  93118. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  93119. */
  93120. _updateCache(ignoreParentClass?: boolean): void;
  93121. /**
  93122. * @hidden
  93123. * Get current device position in babylon world
  93124. */
  93125. _computeDevicePosition(): void;
  93126. /**
  93127. * Updates the current device position and rotation in the babylon world
  93128. */
  93129. update(): void;
  93130. /**
  93131. * @hidden
  93132. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  93133. * @returns an identity matrix
  93134. */
  93135. _getViewMatrix(): Matrix;
  93136. private _tmpMatrix;
  93137. /**
  93138. * This function is called by the two RIG cameras.
  93139. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  93140. * @hidden
  93141. */
  93142. _getWebVRViewMatrix(): Matrix;
  93143. /** @hidden */
  93144. _getWebVRProjectionMatrix(): Matrix;
  93145. private _onGamepadConnectedObserver;
  93146. private _onGamepadDisconnectedObserver;
  93147. private _updateCacheWhenTrackingDisabledObserver;
  93148. /**
  93149. * Initializes the controllers and their meshes
  93150. */
  93151. initControllers(): void;
  93152. }
  93153. }
  93154. declare module BABYLON {
  93155. /**
  93156. * Size options for a post process
  93157. */
  93158. export type PostProcessOptions = {
  93159. width: number;
  93160. height: number;
  93161. };
  93162. /**
  93163. * PostProcess can be used to apply a shader to a texture after it has been rendered
  93164. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  93165. */
  93166. export class PostProcess {
  93167. /** Name of the PostProcess. */
  93168. name: string;
  93169. /**
  93170. * Gets or sets the unique id of the post process
  93171. */
  93172. uniqueId: number;
  93173. /**
  93174. * Width of the texture to apply the post process on
  93175. */
  93176. width: number;
  93177. /**
  93178. * Height of the texture to apply the post process on
  93179. */
  93180. height: number;
  93181. /**
  93182. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  93183. * @hidden
  93184. */
  93185. _outputTexture: Nullable<InternalTexture>;
  93186. /**
  93187. * Sampling mode used by the shader
  93188. * See https://doc.babylonjs.com/classes/3.1/texture
  93189. */
  93190. renderTargetSamplingMode: number;
  93191. /**
  93192. * Clear color to use when screen clearing
  93193. */
  93194. clearColor: Color4;
  93195. /**
  93196. * If the buffer needs to be cleared before applying the post process. (default: true)
  93197. * Should be set to false if shader will overwrite all previous pixels.
  93198. */
  93199. autoClear: boolean;
  93200. /**
  93201. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  93202. */
  93203. alphaMode: number;
  93204. /**
  93205. * Sets the setAlphaBlendConstants of the babylon engine
  93206. */
  93207. alphaConstants: Color4;
  93208. /**
  93209. * Animations to be used for the post processing
  93210. */
  93211. animations: Animation[];
  93212. /**
  93213. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  93214. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  93215. */
  93216. enablePixelPerfectMode: boolean;
  93217. /**
  93218. * Force the postprocess to be applied without taking in account viewport
  93219. */
  93220. forceFullscreenViewport: boolean;
  93221. /**
  93222. * List of inspectable custom properties (used by the Inspector)
  93223. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93224. */
  93225. inspectableCustomProperties: IInspectable[];
  93226. /**
  93227. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  93228. *
  93229. * | Value | Type | Description |
  93230. * | ----- | ----------------------------------- | ----------- |
  93231. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  93232. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  93233. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  93234. *
  93235. */
  93236. scaleMode: number;
  93237. /**
  93238. * Force textures to be a power of two (default: false)
  93239. */
  93240. alwaysForcePOT: boolean;
  93241. private _samples;
  93242. /**
  93243. * Number of sample textures (default: 1)
  93244. */
  93245. get samples(): number;
  93246. set samples(n: number);
  93247. /**
  93248. * Modify the scale of the post process to be the same as the viewport (default: false)
  93249. */
  93250. adaptScaleToCurrentViewport: boolean;
  93251. private _camera;
  93252. private _scene;
  93253. private _engine;
  93254. private _options;
  93255. private _reusable;
  93256. private _textureType;
  93257. private _textureFormat;
  93258. /**
  93259. * Smart array of input and output textures for the post process.
  93260. * @hidden
  93261. */
  93262. _textures: SmartArray<InternalTexture>;
  93263. /**
  93264. * The index in _textures that corresponds to the output texture.
  93265. * @hidden
  93266. */
  93267. _currentRenderTextureInd: number;
  93268. private _effect;
  93269. private _samplers;
  93270. private _fragmentUrl;
  93271. private _vertexUrl;
  93272. private _parameters;
  93273. private _scaleRatio;
  93274. protected _indexParameters: any;
  93275. private _shareOutputWithPostProcess;
  93276. private _texelSize;
  93277. private _forcedOutputTexture;
  93278. /**
  93279. * Returns the fragment url or shader name used in the post process.
  93280. * @returns the fragment url or name in the shader store.
  93281. */
  93282. getEffectName(): string;
  93283. /**
  93284. * An event triggered when the postprocess is activated.
  93285. */
  93286. onActivateObservable: Observable<Camera>;
  93287. private _onActivateObserver;
  93288. /**
  93289. * A function that is added to the onActivateObservable
  93290. */
  93291. set onActivate(callback: Nullable<(camera: Camera) => void>);
  93292. /**
  93293. * An event triggered when the postprocess changes its size.
  93294. */
  93295. onSizeChangedObservable: Observable<PostProcess>;
  93296. private _onSizeChangedObserver;
  93297. /**
  93298. * A function that is added to the onSizeChangedObservable
  93299. */
  93300. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  93301. /**
  93302. * An event triggered when the postprocess applies its effect.
  93303. */
  93304. onApplyObservable: Observable<Effect>;
  93305. private _onApplyObserver;
  93306. /**
  93307. * A function that is added to the onApplyObservable
  93308. */
  93309. set onApply(callback: (effect: Effect) => void);
  93310. /**
  93311. * An event triggered before rendering the postprocess
  93312. */
  93313. onBeforeRenderObservable: Observable<Effect>;
  93314. private _onBeforeRenderObserver;
  93315. /**
  93316. * A function that is added to the onBeforeRenderObservable
  93317. */
  93318. set onBeforeRender(callback: (effect: Effect) => void);
  93319. /**
  93320. * An event triggered after rendering the postprocess
  93321. */
  93322. onAfterRenderObservable: Observable<Effect>;
  93323. private _onAfterRenderObserver;
  93324. /**
  93325. * A function that is added to the onAfterRenderObservable
  93326. */
  93327. set onAfterRender(callback: (efect: Effect) => void);
  93328. /**
  93329. * 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
  93330. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  93331. */
  93332. get inputTexture(): InternalTexture;
  93333. set inputTexture(value: InternalTexture);
  93334. /**
  93335. * Gets the camera which post process is applied to.
  93336. * @returns The camera the post process is applied to.
  93337. */
  93338. getCamera(): Camera;
  93339. /**
  93340. * Gets the texel size of the postprocess.
  93341. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  93342. */
  93343. get texelSize(): Vector2;
  93344. /**
  93345. * Creates a new instance PostProcess
  93346. * @param name The name of the PostProcess.
  93347. * @param fragmentUrl The url of the fragment shader to be used.
  93348. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  93349. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  93350. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  93351. * @param camera The camera to apply the render pass to.
  93352. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93353. * @param engine The engine which the post process will be applied. (default: current engine)
  93354. * @param reusable If the post process can be reused on the same frame. (default: false)
  93355. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  93356. * @param textureType Type of textures used when performing the post process. (default: 0)
  93357. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  93358. * @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
  93359. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  93360. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  93361. */
  93362. constructor(
  93363. /** Name of the PostProcess. */
  93364. 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);
  93365. /**
  93366. * Gets a string idenfifying the name of the class
  93367. * @returns "PostProcess" string
  93368. */
  93369. getClassName(): string;
  93370. /**
  93371. * Gets the engine which this post process belongs to.
  93372. * @returns The engine the post process was enabled with.
  93373. */
  93374. getEngine(): Engine;
  93375. /**
  93376. * The effect that is created when initializing the post process.
  93377. * @returns The created effect corresponding the the postprocess.
  93378. */
  93379. getEffect(): Effect;
  93380. /**
  93381. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  93382. * @param postProcess The post process to share the output with.
  93383. * @returns This post process.
  93384. */
  93385. shareOutputWith(postProcess: PostProcess): PostProcess;
  93386. /**
  93387. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  93388. * This should be called if the post process that shares output with this post process is disabled/disposed.
  93389. */
  93390. useOwnOutput(): void;
  93391. /**
  93392. * Updates the effect with the current post process compile time values and recompiles the shader.
  93393. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  93394. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  93395. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  93396. * @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
  93397. * @param onCompiled Called when the shader has been compiled.
  93398. * @param onError Called if there is an error when compiling a shader.
  93399. */
  93400. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93401. /**
  93402. * The post process is reusable if it can be used multiple times within one frame.
  93403. * @returns If the post process is reusable
  93404. */
  93405. isReusable(): boolean;
  93406. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  93407. markTextureDirty(): void;
  93408. /**
  93409. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  93410. * 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.
  93411. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  93412. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  93413. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  93414. * @returns The target texture that was bound to be written to.
  93415. */
  93416. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  93417. /**
  93418. * If the post process is supported.
  93419. */
  93420. get isSupported(): boolean;
  93421. /**
  93422. * The aspect ratio of the output texture.
  93423. */
  93424. get aspectRatio(): number;
  93425. /**
  93426. * Get a value indicating if the post-process is ready to be used
  93427. * @returns true if the post-process is ready (shader is compiled)
  93428. */
  93429. isReady(): boolean;
  93430. /**
  93431. * Binds all textures and uniforms to the shader, this will be run on every pass.
  93432. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  93433. */
  93434. apply(): Nullable<Effect>;
  93435. private _disposeTextures;
  93436. /**
  93437. * Disposes the post process.
  93438. * @param camera The camera to dispose the post process on.
  93439. */
  93440. dispose(camera?: Camera): void;
  93441. }
  93442. }
  93443. declare module BABYLON {
  93444. /** @hidden */
  93445. export var kernelBlurVaryingDeclaration: {
  93446. name: string;
  93447. shader: string;
  93448. };
  93449. }
  93450. declare module BABYLON {
  93451. /** @hidden */
  93452. export var kernelBlurFragment: {
  93453. name: string;
  93454. shader: string;
  93455. };
  93456. }
  93457. declare module BABYLON {
  93458. /** @hidden */
  93459. export var kernelBlurFragment2: {
  93460. name: string;
  93461. shader: string;
  93462. };
  93463. }
  93464. declare module BABYLON {
  93465. /** @hidden */
  93466. export var kernelBlurPixelShader: {
  93467. name: string;
  93468. shader: string;
  93469. };
  93470. }
  93471. declare module BABYLON {
  93472. /** @hidden */
  93473. export var kernelBlurVertex: {
  93474. name: string;
  93475. shader: string;
  93476. };
  93477. }
  93478. declare module BABYLON {
  93479. /** @hidden */
  93480. export var kernelBlurVertexShader: {
  93481. name: string;
  93482. shader: string;
  93483. };
  93484. }
  93485. declare module BABYLON {
  93486. /**
  93487. * The Blur Post Process which blurs an image based on a kernel and direction.
  93488. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  93489. */
  93490. export class BlurPostProcess extends PostProcess {
  93491. /** The direction in which to blur the image. */
  93492. direction: Vector2;
  93493. private blockCompilation;
  93494. protected _kernel: number;
  93495. protected _idealKernel: number;
  93496. protected _packedFloat: boolean;
  93497. private _staticDefines;
  93498. /**
  93499. * Sets the length in pixels of the blur sample region
  93500. */
  93501. set kernel(v: number);
  93502. /**
  93503. * Gets the length in pixels of the blur sample region
  93504. */
  93505. get kernel(): number;
  93506. /**
  93507. * Sets wether or not the blur needs to unpack/repack floats
  93508. */
  93509. set packedFloat(v: boolean);
  93510. /**
  93511. * Gets wether or not the blur is unpacking/repacking floats
  93512. */
  93513. get packedFloat(): boolean;
  93514. /**
  93515. * Creates a new instance BlurPostProcess
  93516. * @param name The name of the effect.
  93517. * @param direction The direction in which to blur the image.
  93518. * @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.
  93519. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  93520. * @param camera The camera to apply the render pass to.
  93521. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93522. * @param engine The engine which the post process will be applied. (default: current engine)
  93523. * @param reusable If the post process can be reused on the same frame. (default: false)
  93524. * @param textureType Type of textures used when performing the post process. (default: 0)
  93525. * @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)
  93526. */
  93527. constructor(name: string,
  93528. /** The direction in which to blur the image. */
  93529. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  93530. /**
  93531. * Updates the effect with the current post process compile time values and recompiles the shader.
  93532. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  93533. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  93534. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  93535. * @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
  93536. * @param onCompiled Called when the shader has been compiled.
  93537. * @param onError Called if there is an error when compiling a shader.
  93538. */
  93539. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93540. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93541. /**
  93542. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  93543. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  93544. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  93545. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  93546. * The gaps between physical kernels are compensated for in the weighting of the samples
  93547. * @param idealKernel Ideal blur kernel.
  93548. * @return Nearest best kernel.
  93549. */
  93550. protected _nearestBestKernel(idealKernel: number): number;
  93551. /**
  93552. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  93553. * @param x The point on the Gaussian distribution to sample.
  93554. * @return the value of the Gaussian function at x.
  93555. */
  93556. protected _gaussianWeight(x: number): number;
  93557. /**
  93558. * Generates a string that can be used as a floating point number in GLSL.
  93559. * @param x Value to print.
  93560. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  93561. * @return GLSL float string.
  93562. */
  93563. protected _glslFloat(x: number, decimalFigures?: number): string;
  93564. }
  93565. }
  93566. declare module BABYLON {
  93567. /**
  93568. * Mirror texture can be used to simulate the view from a mirror in a scene.
  93569. * It will dynamically be rendered every frame to adapt to the camera point of view.
  93570. * You can then easily use it as a reflectionTexture on a flat surface.
  93571. * In case the surface is not a plane, please consider relying on reflection probes.
  93572. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93573. */
  93574. export class MirrorTexture extends RenderTargetTexture {
  93575. private scene;
  93576. /**
  93577. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  93578. * 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.
  93579. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93580. */
  93581. mirrorPlane: Plane;
  93582. /**
  93583. * Define the blur ratio used to blur the reflection if needed.
  93584. */
  93585. set blurRatio(value: number);
  93586. get blurRatio(): number;
  93587. /**
  93588. * Define the adaptive blur kernel used to blur the reflection if needed.
  93589. * This will autocompute the closest best match for the `blurKernel`
  93590. */
  93591. set adaptiveBlurKernel(value: number);
  93592. /**
  93593. * Define the blur kernel used to blur the reflection if needed.
  93594. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93595. */
  93596. set blurKernel(value: number);
  93597. /**
  93598. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  93599. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93600. */
  93601. set blurKernelX(value: number);
  93602. get blurKernelX(): number;
  93603. /**
  93604. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  93605. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93606. */
  93607. set blurKernelY(value: number);
  93608. get blurKernelY(): number;
  93609. private _autoComputeBlurKernel;
  93610. protected _onRatioRescale(): void;
  93611. private _updateGammaSpace;
  93612. private _imageProcessingConfigChangeObserver;
  93613. private _transformMatrix;
  93614. private _mirrorMatrix;
  93615. private _savedViewMatrix;
  93616. private _blurX;
  93617. private _blurY;
  93618. private _adaptiveBlurKernel;
  93619. private _blurKernelX;
  93620. private _blurKernelY;
  93621. private _blurRatio;
  93622. /**
  93623. * Instantiates a Mirror Texture.
  93624. * Mirror texture can be used to simulate the view from a mirror in a scene.
  93625. * It will dynamically be rendered every frame to adapt to the camera point of view.
  93626. * You can then easily use it as a reflectionTexture on a flat surface.
  93627. * In case the surface is not a plane, please consider relying on reflection probes.
  93628. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93629. * @param name
  93630. * @param size
  93631. * @param scene
  93632. * @param generateMipMaps
  93633. * @param type
  93634. * @param samplingMode
  93635. * @param generateDepthBuffer
  93636. */
  93637. constructor(name: string, size: number | {
  93638. width: number;
  93639. height: number;
  93640. } | {
  93641. ratio: number;
  93642. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  93643. private _preparePostProcesses;
  93644. /**
  93645. * Clone the mirror texture.
  93646. * @returns the cloned texture
  93647. */
  93648. clone(): MirrorTexture;
  93649. /**
  93650. * Serialize the texture to a JSON representation you could use in Parse later on
  93651. * @returns the serialized JSON representation
  93652. */
  93653. serialize(): any;
  93654. /**
  93655. * Dispose the texture and release its associated resources.
  93656. */
  93657. dispose(): void;
  93658. }
  93659. }
  93660. declare module BABYLON {
  93661. /**
  93662. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  93663. * @see http://doc.babylonjs.com/babylon101/materials#texture
  93664. */
  93665. export class Texture extends BaseTexture {
  93666. /**
  93667. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  93668. */
  93669. static SerializeBuffers: boolean;
  93670. /** @hidden */
  93671. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  93672. /** @hidden */
  93673. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  93674. /** @hidden */
  93675. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  93676. /** nearest is mag = nearest and min = nearest and mip = linear */
  93677. static readonly NEAREST_SAMPLINGMODE: number;
  93678. /** nearest is mag = nearest and min = nearest and mip = linear */
  93679. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  93680. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93681. static readonly BILINEAR_SAMPLINGMODE: number;
  93682. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93683. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  93684. /** Trilinear is mag = linear and min = linear and mip = linear */
  93685. static readonly TRILINEAR_SAMPLINGMODE: number;
  93686. /** Trilinear is mag = linear and min = linear and mip = linear */
  93687. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  93688. /** mag = nearest and min = nearest and mip = nearest */
  93689. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  93690. /** mag = nearest and min = linear and mip = nearest */
  93691. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  93692. /** mag = nearest and min = linear and mip = linear */
  93693. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  93694. /** mag = nearest and min = linear and mip = none */
  93695. static readonly NEAREST_LINEAR: number;
  93696. /** mag = nearest and min = nearest and mip = none */
  93697. static readonly NEAREST_NEAREST: number;
  93698. /** mag = linear and min = nearest and mip = nearest */
  93699. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  93700. /** mag = linear and min = nearest and mip = linear */
  93701. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  93702. /** mag = linear and min = linear and mip = none */
  93703. static readonly LINEAR_LINEAR: number;
  93704. /** mag = linear and min = nearest and mip = none */
  93705. static readonly LINEAR_NEAREST: number;
  93706. /** Explicit coordinates mode */
  93707. static readonly EXPLICIT_MODE: number;
  93708. /** Spherical coordinates mode */
  93709. static readonly SPHERICAL_MODE: number;
  93710. /** Planar coordinates mode */
  93711. static readonly PLANAR_MODE: number;
  93712. /** Cubic coordinates mode */
  93713. static readonly CUBIC_MODE: number;
  93714. /** Projection coordinates mode */
  93715. static readonly PROJECTION_MODE: number;
  93716. /** Inverse Cubic coordinates mode */
  93717. static readonly SKYBOX_MODE: number;
  93718. /** Inverse Cubic coordinates mode */
  93719. static readonly INVCUBIC_MODE: number;
  93720. /** Equirectangular coordinates mode */
  93721. static readonly EQUIRECTANGULAR_MODE: number;
  93722. /** Equirectangular Fixed coordinates mode */
  93723. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  93724. /** Equirectangular Fixed Mirrored coordinates mode */
  93725. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  93726. /** Texture is not repeating outside of 0..1 UVs */
  93727. static readonly CLAMP_ADDRESSMODE: number;
  93728. /** Texture is repeating outside of 0..1 UVs */
  93729. static readonly WRAP_ADDRESSMODE: number;
  93730. /** Texture is repeating and mirrored */
  93731. static readonly MIRROR_ADDRESSMODE: number;
  93732. /**
  93733. * 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
  93734. */
  93735. static UseSerializedUrlIfAny: boolean;
  93736. /**
  93737. * Define the url of the texture.
  93738. */
  93739. url: Nullable<string>;
  93740. /**
  93741. * Define an offset on the texture to offset the u coordinates of the UVs
  93742. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  93743. */
  93744. uOffset: number;
  93745. /**
  93746. * Define an offset on the texture to offset the v coordinates of the UVs
  93747. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  93748. */
  93749. vOffset: number;
  93750. /**
  93751. * Define an offset on the texture to scale the u coordinates of the UVs
  93752. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  93753. */
  93754. uScale: number;
  93755. /**
  93756. * Define an offset on the texture to scale the v coordinates of the UVs
  93757. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  93758. */
  93759. vScale: number;
  93760. /**
  93761. * Define an offset on the texture to rotate around the u coordinates of the UVs
  93762. * @see http://doc.babylonjs.com/how_to/more_materials
  93763. */
  93764. uAng: number;
  93765. /**
  93766. * Define an offset on the texture to rotate around the v coordinates of the UVs
  93767. * @see http://doc.babylonjs.com/how_to/more_materials
  93768. */
  93769. vAng: number;
  93770. /**
  93771. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  93772. * @see http://doc.babylonjs.com/how_to/more_materials
  93773. */
  93774. wAng: number;
  93775. /**
  93776. * Defines the center of rotation (U)
  93777. */
  93778. uRotationCenter: number;
  93779. /**
  93780. * Defines the center of rotation (V)
  93781. */
  93782. vRotationCenter: number;
  93783. /**
  93784. * Defines the center of rotation (W)
  93785. */
  93786. wRotationCenter: number;
  93787. /**
  93788. * Are mip maps generated for this texture or not.
  93789. */
  93790. get noMipmap(): boolean;
  93791. /**
  93792. * List of inspectable custom properties (used by the Inspector)
  93793. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93794. */
  93795. inspectableCustomProperties: Nullable<IInspectable[]>;
  93796. private _noMipmap;
  93797. /** @hidden */
  93798. _invertY: boolean;
  93799. private _rowGenerationMatrix;
  93800. private _cachedTextureMatrix;
  93801. private _projectionModeMatrix;
  93802. private _t0;
  93803. private _t1;
  93804. private _t2;
  93805. private _cachedUOffset;
  93806. private _cachedVOffset;
  93807. private _cachedUScale;
  93808. private _cachedVScale;
  93809. private _cachedUAng;
  93810. private _cachedVAng;
  93811. private _cachedWAng;
  93812. private _cachedProjectionMatrixId;
  93813. private _cachedCoordinatesMode;
  93814. /** @hidden */
  93815. protected _initialSamplingMode: number;
  93816. /** @hidden */
  93817. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  93818. private _deleteBuffer;
  93819. protected _format: Nullable<number>;
  93820. private _delayedOnLoad;
  93821. private _delayedOnError;
  93822. private _mimeType?;
  93823. /**
  93824. * Observable triggered once the texture has been loaded.
  93825. */
  93826. onLoadObservable: Observable<Texture>;
  93827. protected _isBlocking: boolean;
  93828. /**
  93829. * Is the texture preventing material to render while loading.
  93830. * If false, a default texture will be used instead of the loading one during the preparation step.
  93831. */
  93832. set isBlocking(value: boolean);
  93833. get isBlocking(): boolean;
  93834. /**
  93835. * Get the current sampling mode associated with the texture.
  93836. */
  93837. get samplingMode(): number;
  93838. /**
  93839. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  93840. */
  93841. get invertY(): boolean;
  93842. /**
  93843. * Instantiates a new texture.
  93844. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  93845. * @see http://doc.babylonjs.com/babylon101/materials#texture
  93846. * @param url defines the url of the picture to load as a texture
  93847. * @param scene defines the scene or engine the texture will belong to
  93848. * @param noMipmap defines if the texture will require mip maps or not
  93849. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  93850. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93851. * @param onLoad defines a callback triggered when the texture has been loaded
  93852. * @param onError defines a callback triggered when an error occurred during the loading session
  93853. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  93854. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  93855. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93856. * @param mimeType defines an optional mime type information
  93857. */
  93858. 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);
  93859. /**
  93860. * Update the url (and optional buffer) of this texture if url was null during construction.
  93861. * @param url the url of the texture
  93862. * @param buffer the buffer of the texture (defaults to null)
  93863. * @param onLoad callback called when the texture is loaded (defaults to null)
  93864. */
  93865. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  93866. /**
  93867. * Finish the loading sequence of a texture flagged as delayed load.
  93868. * @hidden
  93869. */
  93870. delayLoad(): void;
  93871. private _prepareRowForTextureGeneration;
  93872. /**
  93873. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  93874. * @returns the transform matrix of the texture.
  93875. */
  93876. getTextureMatrix(uBase?: number): Matrix;
  93877. /**
  93878. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  93879. * @returns The reflection texture transform
  93880. */
  93881. getReflectionTextureMatrix(): Matrix;
  93882. /**
  93883. * Clones the texture.
  93884. * @returns the cloned texture
  93885. */
  93886. clone(): Texture;
  93887. /**
  93888. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  93889. * @returns The JSON representation of the texture
  93890. */
  93891. serialize(): any;
  93892. /**
  93893. * Get the current class name of the texture useful for serialization or dynamic coding.
  93894. * @returns "Texture"
  93895. */
  93896. getClassName(): string;
  93897. /**
  93898. * Dispose the texture and release its associated resources.
  93899. */
  93900. dispose(): void;
  93901. /**
  93902. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  93903. * @param parsedTexture Define the JSON representation of the texture
  93904. * @param scene Define the scene the parsed texture should be instantiated in
  93905. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  93906. * @returns The parsed texture if successful
  93907. */
  93908. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  93909. /**
  93910. * Creates a texture from its base 64 representation.
  93911. * @param data Define the base64 payload without the data: prefix
  93912. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  93913. * @param scene Define the scene the texture should belong to
  93914. * @param noMipmap Forces the texture to not create mip map information if true
  93915. * @param invertY define if the texture needs to be inverted on the y axis during loading
  93916. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93917. * @param onLoad define a callback triggered when the texture has been loaded
  93918. * @param onError define a callback triggered when an error occurred during the loading session
  93919. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93920. * @returns the created texture
  93921. */
  93922. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  93923. /**
  93924. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  93925. * @param data Define the base64 payload without the data: prefix
  93926. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  93927. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  93928. * @param scene Define the scene the texture should belong to
  93929. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  93930. * @param noMipmap Forces the texture to not create mip map information if true
  93931. * @param invertY define if the texture needs to be inverted on the y axis during loading
  93932. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93933. * @param onLoad define a callback triggered when the texture has been loaded
  93934. * @param onError define a callback triggered when an error occurred during the loading session
  93935. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93936. * @returns the created texture
  93937. */
  93938. 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;
  93939. }
  93940. }
  93941. declare module BABYLON {
  93942. /**
  93943. * PostProcessManager is used to manage one or more post processes or post process pipelines
  93944. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  93945. */
  93946. export class PostProcessManager {
  93947. private _scene;
  93948. private _indexBuffer;
  93949. private _vertexBuffers;
  93950. /**
  93951. * Creates a new instance PostProcess
  93952. * @param scene The scene that the post process is associated with.
  93953. */
  93954. constructor(scene: Scene);
  93955. private _prepareBuffers;
  93956. private _buildIndexBuffer;
  93957. /**
  93958. * Rebuilds the vertex buffers of the manager.
  93959. * @hidden
  93960. */
  93961. _rebuild(): void;
  93962. /**
  93963. * Prepares a frame to be run through a post process.
  93964. * @param sourceTexture The input texture to the post procesess. (default: null)
  93965. * @param postProcesses An array of post processes to be run. (default: null)
  93966. * @returns True if the post processes were able to be run.
  93967. * @hidden
  93968. */
  93969. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  93970. /**
  93971. * Manually render a set of post processes to a texture.
  93972. * @param postProcesses An array of post processes to be run.
  93973. * @param targetTexture The target texture to render to.
  93974. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  93975. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  93976. * @param lodLevel defines which lod of the texture to render to
  93977. */
  93978. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  93979. /**
  93980. * Finalize the result of the output of the postprocesses.
  93981. * @param doNotPresent If true the result will not be displayed to the screen.
  93982. * @param targetTexture The target texture to render to.
  93983. * @param faceIndex The index of the face to bind the target texture to.
  93984. * @param postProcesses The array of post processes to render.
  93985. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  93986. * @hidden
  93987. */
  93988. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  93989. /**
  93990. * Disposes of the post process manager.
  93991. */
  93992. dispose(): void;
  93993. }
  93994. }
  93995. declare module BABYLON {
  93996. /**
  93997. * This Helps creating a texture that will be created from a camera in your scene.
  93998. * It is basically a dynamic texture that could be used to create special effects for instance.
  93999. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  94000. */
  94001. export class RenderTargetTexture extends Texture {
  94002. isCube: boolean;
  94003. /**
  94004. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  94005. */
  94006. static readonly REFRESHRATE_RENDER_ONCE: number;
  94007. /**
  94008. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  94009. */
  94010. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  94011. /**
  94012. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  94013. * the central point of your effect and can save a lot of performances.
  94014. */
  94015. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  94016. /**
  94017. * Use this predicate to dynamically define the list of mesh you want to render.
  94018. * If set, the renderList property will be overwritten.
  94019. */
  94020. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  94021. private _renderList;
  94022. /**
  94023. * Use this list to define the list of mesh you want to render.
  94024. */
  94025. get renderList(): Nullable<Array<AbstractMesh>>;
  94026. set renderList(value: Nullable<Array<AbstractMesh>>);
  94027. /**
  94028. * Use this function to overload the renderList array at rendering time.
  94029. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  94030. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  94031. * the cube (if the RTT is a cube, else layerOrFace=0).
  94032. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  94033. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  94034. * hold dummy elements!
  94035. */
  94036. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  94037. private _hookArray;
  94038. /**
  94039. * Define if particles should be rendered in your texture.
  94040. */
  94041. renderParticles: boolean;
  94042. /**
  94043. * Define if sprites should be rendered in your texture.
  94044. */
  94045. renderSprites: boolean;
  94046. /**
  94047. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  94048. */
  94049. coordinatesMode: number;
  94050. /**
  94051. * Define the camera used to render the texture.
  94052. */
  94053. activeCamera: Nullable<Camera>;
  94054. /**
  94055. * Override the render function of the texture with your own one.
  94056. */
  94057. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  94058. /**
  94059. * Define if camera post processes should be use while rendering the texture.
  94060. */
  94061. useCameraPostProcesses: boolean;
  94062. /**
  94063. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  94064. */
  94065. ignoreCameraViewport: boolean;
  94066. private _postProcessManager;
  94067. private _postProcesses;
  94068. private _resizeObserver;
  94069. /**
  94070. * An event triggered when the texture is unbind.
  94071. */
  94072. onBeforeBindObservable: Observable<RenderTargetTexture>;
  94073. /**
  94074. * An event triggered when the texture is unbind.
  94075. */
  94076. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  94077. private _onAfterUnbindObserver;
  94078. /**
  94079. * Set a after unbind callback in the texture.
  94080. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  94081. */
  94082. set onAfterUnbind(callback: () => void);
  94083. /**
  94084. * An event triggered before rendering the texture
  94085. */
  94086. onBeforeRenderObservable: Observable<number>;
  94087. private _onBeforeRenderObserver;
  94088. /**
  94089. * Set a before render callback in the texture.
  94090. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  94091. */
  94092. set onBeforeRender(callback: (faceIndex: number) => void);
  94093. /**
  94094. * An event triggered after rendering the texture
  94095. */
  94096. onAfterRenderObservable: Observable<number>;
  94097. private _onAfterRenderObserver;
  94098. /**
  94099. * Set a after render callback in the texture.
  94100. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  94101. */
  94102. set onAfterRender(callback: (faceIndex: number) => void);
  94103. /**
  94104. * An event triggered after the texture clear
  94105. */
  94106. onClearObservable: Observable<Engine>;
  94107. private _onClearObserver;
  94108. /**
  94109. * Set a clear callback in the texture.
  94110. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  94111. */
  94112. set onClear(callback: (Engine: Engine) => void);
  94113. /**
  94114. * An event triggered when the texture is resized.
  94115. */
  94116. onResizeObservable: Observable<RenderTargetTexture>;
  94117. /**
  94118. * Define the clear color of the Render Target if it should be different from the scene.
  94119. */
  94120. clearColor: Color4;
  94121. protected _size: number | {
  94122. width: number;
  94123. height: number;
  94124. layers?: number;
  94125. };
  94126. protected _initialSizeParameter: number | {
  94127. width: number;
  94128. height: number;
  94129. } | {
  94130. ratio: number;
  94131. };
  94132. protected _sizeRatio: Nullable<number>;
  94133. /** @hidden */
  94134. _generateMipMaps: boolean;
  94135. protected _renderingManager: RenderingManager;
  94136. /** @hidden */
  94137. _waitingRenderList: string[];
  94138. protected _doNotChangeAspectRatio: boolean;
  94139. protected _currentRefreshId: number;
  94140. protected _refreshRate: number;
  94141. protected _textureMatrix: Matrix;
  94142. protected _samples: number;
  94143. protected _renderTargetOptions: RenderTargetCreationOptions;
  94144. /**
  94145. * Gets render target creation options that were used.
  94146. */
  94147. get renderTargetOptions(): RenderTargetCreationOptions;
  94148. protected _engine: Engine;
  94149. protected _onRatioRescale(): void;
  94150. /**
  94151. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  94152. * It must define where the camera used to render the texture is set
  94153. */
  94154. boundingBoxPosition: Vector3;
  94155. private _boundingBoxSize;
  94156. /**
  94157. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  94158. * When defined, the cubemap will switch to local mode
  94159. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  94160. * @example https://www.babylonjs-playground.com/#RNASML
  94161. */
  94162. set boundingBoxSize(value: Vector3);
  94163. get boundingBoxSize(): Vector3;
  94164. /**
  94165. * In case the RTT has been created with a depth texture, get the associated
  94166. * depth texture.
  94167. * Otherwise, return null.
  94168. */
  94169. get depthStencilTexture(): Nullable<InternalTexture>;
  94170. /**
  94171. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  94172. * or used a shadow, depth texture...
  94173. * @param name The friendly name of the texture
  94174. * @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)
  94175. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  94176. * @param generateMipMaps True if mip maps need to be generated after render.
  94177. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  94178. * @param type The type of the buffer in the RTT (int, half float, float...)
  94179. * @param isCube True if a cube texture needs to be created
  94180. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  94181. * @param generateDepthBuffer True to generate a depth buffer
  94182. * @param generateStencilBuffer True to generate a stencil buffer
  94183. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  94184. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  94185. * @param delayAllocation if the texture allocation should be delayed (default: false)
  94186. */
  94187. constructor(name: string, size: number | {
  94188. width: number;
  94189. height: number;
  94190. layers?: number;
  94191. } | {
  94192. ratio: number;
  94193. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  94194. /**
  94195. * Creates a depth stencil texture.
  94196. * This is only available in WebGL 2 or with the depth texture extension available.
  94197. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  94198. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  94199. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  94200. */
  94201. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  94202. private _processSizeParameter;
  94203. /**
  94204. * Define the number of samples to use in case of MSAA.
  94205. * It defaults to one meaning no MSAA has been enabled.
  94206. */
  94207. get samples(): number;
  94208. set samples(value: number);
  94209. /**
  94210. * Resets the refresh counter of the texture and start bak from scratch.
  94211. * Could be useful to regenerate the texture if it is setup to render only once.
  94212. */
  94213. resetRefreshCounter(): void;
  94214. /**
  94215. * Define the refresh rate of the texture or the rendering frequency.
  94216. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  94217. */
  94218. get refreshRate(): number;
  94219. set refreshRate(value: number);
  94220. /**
  94221. * Adds a post process to the render target rendering passes.
  94222. * @param postProcess define the post process to add
  94223. */
  94224. addPostProcess(postProcess: PostProcess): void;
  94225. /**
  94226. * Clear all the post processes attached to the render target
  94227. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  94228. */
  94229. clearPostProcesses(dispose?: boolean): void;
  94230. /**
  94231. * Remove one of the post process from the list of attached post processes to the texture
  94232. * @param postProcess define the post process to remove from the list
  94233. */
  94234. removePostProcess(postProcess: PostProcess): void;
  94235. /** @hidden */
  94236. _shouldRender(): boolean;
  94237. /**
  94238. * Gets the actual render size of the texture.
  94239. * @returns the width of the render size
  94240. */
  94241. getRenderSize(): number;
  94242. /**
  94243. * Gets the actual render width of the texture.
  94244. * @returns the width of the render size
  94245. */
  94246. getRenderWidth(): number;
  94247. /**
  94248. * Gets the actual render height of the texture.
  94249. * @returns the height of the render size
  94250. */
  94251. getRenderHeight(): number;
  94252. /**
  94253. * Gets the actual number of layers of the texture.
  94254. * @returns the number of layers
  94255. */
  94256. getRenderLayers(): number;
  94257. /**
  94258. * Get if the texture can be rescaled or not.
  94259. */
  94260. get canRescale(): boolean;
  94261. /**
  94262. * Resize the texture using a ratio.
  94263. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  94264. */
  94265. scale(ratio: number): void;
  94266. /**
  94267. * Get the texture reflection matrix used to rotate/transform the reflection.
  94268. * @returns the reflection matrix
  94269. */
  94270. getReflectionTextureMatrix(): Matrix;
  94271. /**
  94272. * Resize the texture to a new desired size.
  94273. * Be carrefull as it will recreate all the data in the new texture.
  94274. * @param size Define the new size. It can be:
  94275. * - a number for squared texture,
  94276. * - an object containing { width: number, height: number }
  94277. * - or an object containing a ratio { ratio: number }
  94278. */
  94279. resize(size: number | {
  94280. width: number;
  94281. height: number;
  94282. } | {
  94283. ratio: number;
  94284. }): void;
  94285. private _defaultRenderListPrepared;
  94286. /**
  94287. * Renders all the objects from the render list into the texture.
  94288. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  94289. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  94290. */
  94291. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  94292. private _bestReflectionRenderTargetDimension;
  94293. private _prepareRenderingManager;
  94294. /**
  94295. * @hidden
  94296. * @param faceIndex face index to bind to if this is a cubetexture
  94297. * @param layer defines the index of the texture to bind in the array
  94298. */
  94299. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  94300. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  94301. private renderToTarget;
  94302. /**
  94303. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  94304. * This allowed control for front to back rendering or reversly depending of the special needs.
  94305. *
  94306. * @param renderingGroupId The rendering group id corresponding to its index
  94307. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  94308. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  94309. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  94310. */
  94311. 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;
  94312. /**
  94313. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  94314. *
  94315. * @param renderingGroupId The rendering group id corresponding to its index
  94316. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  94317. */
  94318. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  94319. /**
  94320. * Clones the texture.
  94321. * @returns the cloned texture
  94322. */
  94323. clone(): RenderTargetTexture;
  94324. /**
  94325. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  94326. * @returns The JSON representation of the texture
  94327. */
  94328. serialize(): any;
  94329. /**
  94330. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  94331. */
  94332. disposeFramebufferObjects(): void;
  94333. /**
  94334. * Dispose the texture and release its associated resources.
  94335. */
  94336. dispose(): void;
  94337. /** @hidden */
  94338. _rebuild(): void;
  94339. /**
  94340. * Clear the info related to rendering groups preventing retention point in material dispose.
  94341. */
  94342. freeRenderingGroups(): void;
  94343. /**
  94344. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  94345. * @returns the view count
  94346. */
  94347. getViewCount(): number;
  94348. }
  94349. }
  94350. declare module BABYLON {
  94351. /**
  94352. * Options for compiling materials.
  94353. */
  94354. export interface IMaterialCompilationOptions {
  94355. /**
  94356. * Defines whether clip planes are enabled.
  94357. */
  94358. clipPlane: boolean;
  94359. /**
  94360. * Defines whether instances are enabled.
  94361. */
  94362. useInstances: boolean;
  94363. }
  94364. /**
  94365. * Base class for the main features of a material in Babylon.js
  94366. */
  94367. export class Material implements IAnimatable {
  94368. /**
  94369. * Returns the triangle fill mode
  94370. */
  94371. static readonly TriangleFillMode: number;
  94372. /**
  94373. * Returns the wireframe mode
  94374. */
  94375. static readonly WireFrameFillMode: number;
  94376. /**
  94377. * Returns the point fill mode
  94378. */
  94379. static readonly PointFillMode: number;
  94380. /**
  94381. * Returns the point list draw mode
  94382. */
  94383. static readonly PointListDrawMode: number;
  94384. /**
  94385. * Returns the line list draw mode
  94386. */
  94387. static readonly LineListDrawMode: number;
  94388. /**
  94389. * Returns the line loop draw mode
  94390. */
  94391. static readonly LineLoopDrawMode: number;
  94392. /**
  94393. * Returns the line strip draw mode
  94394. */
  94395. static readonly LineStripDrawMode: number;
  94396. /**
  94397. * Returns the triangle strip draw mode
  94398. */
  94399. static readonly TriangleStripDrawMode: number;
  94400. /**
  94401. * Returns the triangle fan draw mode
  94402. */
  94403. static readonly TriangleFanDrawMode: number;
  94404. /**
  94405. * Stores the clock-wise side orientation
  94406. */
  94407. static readonly ClockWiseSideOrientation: number;
  94408. /**
  94409. * Stores the counter clock-wise side orientation
  94410. */
  94411. static readonly CounterClockWiseSideOrientation: number;
  94412. /**
  94413. * The dirty texture flag value
  94414. */
  94415. static readonly TextureDirtyFlag: number;
  94416. /**
  94417. * The dirty light flag value
  94418. */
  94419. static readonly LightDirtyFlag: number;
  94420. /**
  94421. * The dirty fresnel flag value
  94422. */
  94423. static readonly FresnelDirtyFlag: number;
  94424. /**
  94425. * The dirty attribute flag value
  94426. */
  94427. static readonly AttributesDirtyFlag: number;
  94428. /**
  94429. * The dirty misc flag value
  94430. */
  94431. static readonly MiscDirtyFlag: number;
  94432. /**
  94433. * The all dirty flag value
  94434. */
  94435. static readonly AllDirtyFlag: number;
  94436. /**
  94437. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  94438. */
  94439. static readonly MATERIAL_OPAQUE: number;
  94440. /**
  94441. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  94442. */
  94443. static readonly MATERIAL_ALPHATEST: number;
  94444. /**
  94445. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  94446. */
  94447. static readonly MATERIAL_ALPHABLEND: number;
  94448. /**
  94449. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  94450. * They are also discarded below the alpha cutoff threshold to improve performances.
  94451. */
  94452. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  94453. /**
  94454. * The ID of the material
  94455. */
  94456. id: string;
  94457. /**
  94458. * Gets or sets the unique id of the material
  94459. */
  94460. uniqueId: number;
  94461. /**
  94462. * The name of the material
  94463. */
  94464. name: string;
  94465. /**
  94466. * Gets or sets user defined metadata
  94467. */
  94468. metadata: any;
  94469. /**
  94470. * For internal use only. Please do not use.
  94471. */
  94472. reservedDataStore: any;
  94473. /**
  94474. * Specifies if the ready state should be checked on each call
  94475. */
  94476. checkReadyOnEveryCall: boolean;
  94477. /**
  94478. * Specifies if the ready state should be checked once
  94479. */
  94480. checkReadyOnlyOnce: boolean;
  94481. /**
  94482. * The state of the material
  94483. */
  94484. state: string;
  94485. /**
  94486. * The alpha value of the material
  94487. */
  94488. protected _alpha: number;
  94489. /**
  94490. * List of inspectable custom properties (used by the Inspector)
  94491. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94492. */
  94493. inspectableCustomProperties: IInspectable[];
  94494. /**
  94495. * Sets the alpha value of the material
  94496. */
  94497. set alpha(value: number);
  94498. /**
  94499. * Gets the alpha value of the material
  94500. */
  94501. get alpha(): number;
  94502. /**
  94503. * Specifies if back face culling is enabled
  94504. */
  94505. protected _backFaceCulling: boolean;
  94506. /**
  94507. * Sets the back-face culling state
  94508. */
  94509. set backFaceCulling(value: boolean);
  94510. /**
  94511. * Gets the back-face culling state
  94512. */
  94513. get backFaceCulling(): boolean;
  94514. /**
  94515. * Stores the value for side orientation
  94516. */
  94517. sideOrientation: number;
  94518. /**
  94519. * Callback triggered when the material is compiled
  94520. */
  94521. onCompiled: Nullable<(effect: Effect) => void>;
  94522. /**
  94523. * Callback triggered when an error occurs
  94524. */
  94525. onError: Nullable<(effect: Effect, errors: string) => void>;
  94526. /**
  94527. * Callback triggered to get the render target textures
  94528. */
  94529. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  94530. /**
  94531. * Gets a boolean indicating that current material needs to register RTT
  94532. */
  94533. get hasRenderTargetTextures(): boolean;
  94534. /**
  94535. * Specifies if the material should be serialized
  94536. */
  94537. doNotSerialize: boolean;
  94538. /**
  94539. * @hidden
  94540. */
  94541. _storeEffectOnSubMeshes: boolean;
  94542. /**
  94543. * Stores the animations for the material
  94544. */
  94545. animations: Nullable<Array<Animation>>;
  94546. /**
  94547. * An event triggered when the material is disposed
  94548. */
  94549. onDisposeObservable: Observable<Material>;
  94550. /**
  94551. * An observer which watches for dispose events
  94552. */
  94553. private _onDisposeObserver;
  94554. private _onUnBindObservable;
  94555. /**
  94556. * Called during a dispose event
  94557. */
  94558. set onDispose(callback: () => void);
  94559. private _onBindObservable;
  94560. /**
  94561. * An event triggered when the material is bound
  94562. */
  94563. get onBindObservable(): Observable<AbstractMesh>;
  94564. /**
  94565. * An observer which watches for bind events
  94566. */
  94567. private _onBindObserver;
  94568. /**
  94569. * Called during a bind event
  94570. */
  94571. set onBind(callback: (Mesh: AbstractMesh) => void);
  94572. /**
  94573. * An event triggered when the material is unbound
  94574. */
  94575. get onUnBindObservable(): Observable<Material>;
  94576. /**
  94577. * Stores the value of the alpha mode
  94578. */
  94579. private _alphaMode;
  94580. /**
  94581. * Sets the value of the alpha mode.
  94582. *
  94583. * | Value | Type | Description |
  94584. * | --- | --- | --- |
  94585. * | 0 | ALPHA_DISABLE | |
  94586. * | 1 | ALPHA_ADD | |
  94587. * | 2 | ALPHA_COMBINE | |
  94588. * | 3 | ALPHA_SUBTRACT | |
  94589. * | 4 | ALPHA_MULTIPLY | |
  94590. * | 5 | ALPHA_MAXIMIZED | |
  94591. * | 6 | ALPHA_ONEONE | |
  94592. * | 7 | ALPHA_PREMULTIPLIED | |
  94593. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  94594. * | 9 | ALPHA_INTERPOLATE | |
  94595. * | 10 | ALPHA_SCREENMODE | |
  94596. *
  94597. */
  94598. set alphaMode(value: number);
  94599. /**
  94600. * Gets the value of the alpha mode
  94601. */
  94602. get alphaMode(): number;
  94603. /**
  94604. * Stores the state of the need depth pre-pass value
  94605. */
  94606. private _needDepthPrePass;
  94607. /**
  94608. * Sets the need depth pre-pass value
  94609. */
  94610. set needDepthPrePass(value: boolean);
  94611. /**
  94612. * Gets the depth pre-pass value
  94613. */
  94614. get needDepthPrePass(): boolean;
  94615. /**
  94616. * Specifies if depth writing should be disabled
  94617. */
  94618. disableDepthWrite: boolean;
  94619. /**
  94620. * Specifies if depth writing should be forced
  94621. */
  94622. forceDepthWrite: boolean;
  94623. /**
  94624. * Specifies the depth function that should be used. 0 means the default engine function
  94625. */
  94626. depthFunction: number;
  94627. /**
  94628. * Specifies if there should be a separate pass for culling
  94629. */
  94630. separateCullingPass: boolean;
  94631. /**
  94632. * Stores the state specifing if fog should be enabled
  94633. */
  94634. private _fogEnabled;
  94635. /**
  94636. * Sets the state for enabling fog
  94637. */
  94638. set fogEnabled(value: boolean);
  94639. /**
  94640. * Gets the value of the fog enabled state
  94641. */
  94642. get fogEnabled(): boolean;
  94643. /**
  94644. * Stores the size of points
  94645. */
  94646. pointSize: number;
  94647. /**
  94648. * Stores the z offset value
  94649. */
  94650. zOffset: number;
  94651. /**
  94652. * Gets a value specifying if wireframe mode is enabled
  94653. */
  94654. get wireframe(): boolean;
  94655. /**
  94656. * Sets the state of wireframe mode
  94657. */
  94658. set wireframe(value: boolean);
  94659. /**
  94660. * Gets the value specifying if point clouds are enabled
  94661. */
  94662. get pointsCloud(): boolean;
  94663. /**
  94664. * Sets the state of point cloud mode
  94665. */
  94666. set pointsCloud(value: boolean);
  94667. /**
  94668. * Gets the material fill mode
  94669. */
  94670. get fillMode(): number;
  94671. /**
  94672. * Sets the material fill mode
  94673. */
  94674. set fillMode(value: number);
  94675. /**
  94676. * @hidden
  94677. * Stores the effects for the material
  94678. */
  94679. _effect: Nullable<Effect>;
  94680. /**
  94681. * Specifies if uniform buffers should be used
  94682. */
  94683. private _useUBO;
  94684. /**
  94685. * Stores a reference to the scene
  94686. */
  94687. private _scene;
  94688. /**
  94689. * Stores the fill mode state
  94690. */
  94691. private _fillMode;
  94692. /**
  94693. * Specifies if the depth write state should be cached
  94694. */
  94695. private _cachedDepthWriteState;
  94696. /**
  94697. * Specifies if the depth function state should be cached
  94698. */
  94699. private _cachedDepthFunctionState;
  94700. /**
  94701. * Stores the uniform buffer
  94702. */
  94703. protected _uniformBuffer: UniformBuffer;
  94704. /** @hidden */
  94705. _indexInSceneMaterialArray: number;
  94706. /** @hidden */
  94707. meshMap: Nullable<{
  94708. [id: string]: AbstractMesh | undefined;
  94709. }>;
  94710. /**
  94711. * Creates a material instance
  94712. * @param name defines the name of the material
  94713. * @param scene defines the scene to reference
  94714. * @param doNotAdd specifies if the material should be added to the scene
  94715. */
  94716. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  94717. /**
  94718. * Returns a string representation of the current material
  94719. * @param fullDetails defines a boolean indicating which levels of logging is desired
  94720. * @returns a string with material information
  94721. */
  94722. toString(fullDetails?: boolean): string;
  94723. /**
  94724. * Gets the class name of the material
  94725. * @returns a string with the class name of the material
  94726. */
  94727. getClassName(): string;
  94728. /**
  94729. * Specifies if updates for the material been locked
  94730. */
  94731. get isFrozen(): boolean;
  94732. /**
  94733. * Locks updates for the material
  94734. */
  94735. freeze(): void;
  94736. /**
  94737. * Unlocks updates for the material
  94738. */
  94739. unfreeze(): void;
  94740. /**
  94741. * Specifies if the material is ready to be used
  94742. * @param mesh defines the mesh to check
  94743. * @param useInstances specifies if instances should be used
  94744. * @returns a boolean indicating if the material is ready to be used
  94745. */
  94746. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94747. /**
  94748. * Specifies that the submesh is ready to be used
  94749. * @param mesh defines the mesh to check
  94750. * @param subMesh defines which submesh to check
  94751. * @param useInstances specifies that instances should be used
  94752. * @returns a boolean indicating that the submesh is ready or not
  94753. */
  94754. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  94755. /**
  94756. * Returns the material effect
  94757. * @returns the effect associated with the material
  94758. */
  94759. getEffect(): Nullable<Effect>;
  94760. /**
  94761. * Returns the current scene
  94762. * @returns a Scene
  94763. */
  94764. getScene(): Scene;
  94765. /**
  94766. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  94767. */
  94768. protected _forceAlphaTest: boolean;
  94769. /**
  94770. * The transparency mode of the material.
  94771. */
  94772. protected _transparencyMode: Nullable<number>;
  94773. /**
  94774. * Gets the current transparency mode.
  94775. */
  94776. get transparencyMode(): Nullable<number>;
  94777. /**
  94778. * Sets the transparency mode of the material.
  94779. *
  94780. * | Value | Type | Description |
  94781. * | ----- | ----------------------------------- | ----------- |
  94782. * | 0 | OPAQUE | |
  94783. * | 1 | ALPHATEST | |
  94784. * | 2 | ALPHABLEND | |
  94785. * | 3 | ALPHATESTANDBLEND | |
  94786. *
  94787. */
  94788. set transparencyMode(value: Nullable<number>);
  94789. /**
  94790. * Returns true if alpha blending should be disabled.
  94791. */
  94792. protected get _disableAlphaBlending(): boolean;
  94793. /**
  94794. * Specifies whether or not this material should be rendered in alpha blend mode.
  94795. * @returns a boolean specifying if alpha blending is needed
  94796. */
  94797. needAlphaBlending(): boolean;
  94798. /**
  94799. * Specifies if the mesh will require alpha blending
  94800. * @param mesh defines the mesh to check
  94801. * @returns a boolean specifying if alpha blending is needed for the mesh
  94802. */
  94803. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  94804. /**
  94805. * Specifies whether or not this material should be rendered in alpha test mode.
  94806. * @returns a boolean specifying if an alpha test is needed.
  94807. */
  94808. needAlphaTesting(): boolean;
  94809. /**
  94810. * Specifies if material alpha testing should be turned on for the mesh
  94811. * @param mesh defines the mesh to check
  94812. */
  94813. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  94814. /**
  94815. * Gets the texture used for the alpha test
  94816. * @returns the texture to use for alpha testing
  94817. */
  94818. getAlphaTestTexture(): Nullable<BaseTexture>;
  94819. /**
  94820. * Marks the material to indicate that it needs to be re-calculated
  94821. */
  94822. markDirty(): void;
  94823. /** @hidden */
  94824. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  94825. /**
  94826. * Binds the material to the mesh
  94827. * @param world defines the world transformation matrix
  94828. * @param mesh defines the mesh to bind the material to
  94829. */
  94830. bind(world: Matrix, mesh?: Mesh): void;
  94831. /**
  94832. * Binds the submesh to the material
  94833. * @param world defines the world transformation matrix
  94834. * @param mesh defines the mesh containing the submesh
  94835. * @param subMesh defines the submesh to bind the material to
  94836. */
  94837. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94838. /**
  94839. * Binds the world matrix to the material
  94840. * @param world defines the world transformation matrix
  94841. */
  94842. bindOnlyWorldMatrix(world: Matrix): void;
  94843. /**
  94844. * Binds the scene's uniform buffer to the effect.
  94845. * @param effect defines the effect to bind to the scene uniform buffer
  94846. * @param sceneUbo defines the uniform buffer storing scene data
  94847. */
  94848. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  94849. /**
  94850. * Binds the view matrix to the effect
  94851. * @param effect defines the effect to bind the view matrix to
  94852. */
  94853. bindView(effect: Effect): void;
  94854. /**
  94855. * Binds the view projection matrix to the effect
  94856. * @param effect defines the effect to bind the view projection matrix to
  94857. */
  94858. bindViewProjection(effect: Effect): void;
  94859. /**
  94860. * Processes to execute after binding the material to a mesh
  94861. * @param mesh defines the rendered mesh
  94862. */
  94863. protected _afterBind(mesh?: Mesh): void;
  94864. /**
  94865. * Unbinds the material from the mesh
  94866. */
  94867. unbind(): void;
  94868. /**
  94869. * Gets the active textures from the material
  94870. * @returns an array of textures
  94871. */
  94872. getActiveTextures(): BaseTexture[];
  94873. /**
  94874. * Specifies if the material uses a texture
  94875. * @param texture defines the texture to check against the material
  94876. * @returns a boolean specifying if the material uses the texture
  94877. */
  94878. hasTexture(texture: BaseTexture): boolean;
  94879. /**
  94880. * Makes a duplicate of the material, and gives it a new name
  94881. * @param name defines the new name for the duplicated material
  94882. * @returns the cloned material
  94883. */
  94884. clone(name: string): Nullable<Material>;
  94885. /**
  94886. * Gets the meshes bound to the material
  94887. * @returns an array of meshes bound to the material
  94888. */
  94889. getBindedMeshes(): AbstractMesh[];
  94890. /**
  94891. * Force shader compilation
  94892. * @param mesh defines the mesh associated with this material
  94893. * @param onCompiled defines a function to execute once the material is compiled
  94894. * @param options defines the options to configure the compilation
  94895. * @param onError defines a function to execute if the material fails compiling
  94896. */
  94897. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  94898. /**
  94899. * Force shader compilation
  94900. * @param mesh defines the mesh that will use this material
  94901. * @param options defines additional options for compiling the shaders
  94902. * @returns a promise that resolves when the compilation completes
  94903. */
  94904. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  94905. private static readonly _AllDirtyCallBack;
  94906. private static readonly _ImageProcessingDirtyCallBack;
  94907. private static readonly _TextureDirtyCallBack;
  94908. private static readonly _FresnelDirtyCallBack;
  94909. private static readonly _MiscDirtyCallBack;
  94910. private static readonly _LightsDirtyCallBack;
  94911. private static readonly _AttributeDirtyCallBack;
  94912. private static _FresnelAndMiscDirtyCallBack;
  94913. private static _TextureAndMiscDirtyCallBack;
  94914. private static readonly _DirtyCallbackArray;
  94915. private static readonly _RunDirtyCallBacks;
  94916. /**
  94917. * Marks a define in the material to indicate that it needs to be re-computed
  94918. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  94919. */
  94920. markAsDirty(flag: number): void;
  94921. /**
  94922. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  94923. * @param func defines a function which checks material defines against the submeshes
  94924. */
  94925. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  94926. /**
  94927. * Indicates that we need to re-calculated for all submeshes
  94928. */
  94929. protected _markAllSubMeshesAsAllDirty(): void;
  94930. /**
  94931. * Indicates that image processing needs to be re-calculated for all submeshes
  94932. */
  94933. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  94934. /**
  94935. * Indicates that textures need to be re-calculated for all submeshes
  94936. */
  94937. protected _markAllSubMeshesAsTexturesDirty(): void;
  94938. /**
  94939. * Indicates that fresnel needs to be re-calculated for all submeshes
  94940. */
  94941. protected _markAllSubMeshesAsFresnelDirty(): void;
  94942. /**
  94943. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  94944. */
  94945. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  94946. /**
  94947. * Indicates that lights need to be re-calculated for all submeshes
  94948. */
  94949. protected _markAllSubMeshesAsLightsDirty(): void;
  94950. /**
  94951. * Indicates that attributes need to be re-calculated for all submeshes
  94952. */
  94953. protected _markAllSubMeshesAsAttributesDirty(): void;
  94954. /**
  94955. * Indicates that misc needs to be re-calculated for all submeshes
  94956. */
  94957. protected _markAllSubMeshesAsMiscDirty(): void;
  94958. /**
  94959. * Indicates that textures and misc need to be re-calculated for all submeshes
  94960. */
  94961. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  94962. /**
  94963. * Disposes the material
  94964. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  94965. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  94966. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  94967. */
  94968. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  94969. /** @hidden */
  94970. private releaseVertexArrayObject;
  94971. /**
  94972. * Serializes this material
  94973. * @returns the serialized material object
  94974. */
  94975. serialize(): any;
  94976. /**
  94977. * Creates a material from parsed material data
  94978. * @param parsedMaterial defines parsed material data
  94979. * @param scene defines the hosting scene
  94980. * @param rootUrl defines the root URL to use to load textures
  94981. * @returns a new material
  94982. */
  94983. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  94984. }
  94985. }
  94986. declare module BABYLON {
  94987. /**
  94988. * A multi-material is used to apply different materials to different parts of the same object without the need of
  94989. * separate meshes. This can be use to improve performances.
  94990. * @see http://doc.babylonjs.com/how_to/multi_materials
  94991. */
  94992. export class MultiMaterial extends Material {
  94993. private _subMaterials;
  94994. /**
  94995. * Gets or Sets the list of Materials used within the multi material.
  94996. * They need to be ordered according to the submeshes order in the associated mesh
  94997. */
  94998. get subMaterials(): Nullable<Material>[];
  94999. set subMaterials(value: Nullable<Material>[]);
  95000. /**
  95001. * Function used to align with Node.getChildren()
  95002. * @returns the list of Materials used within the multi material
  95003. */
  95004. getChildren(): Nullable<Material>[];
  95005. /**
  95006. * Instantiates a new Multi Material
  95007. * A multi-material is used to apply different materials to different parts of the same object without the need of
  95008. * separate meshes. This can be use to improve performances.
  95009. * @see http://doc.babylonjs.com/how_to/multi_materials
  95010. * @param name Define the name in the scene
  95011. * @param scene Define the scene the material belongs to
  95012. */
  95013. constructor(name: string, scene: Scene);
  95014. private _hookArray;
  95015. /**
  95016. * Get one of the submaterial by its index in the submaterials array
  95017. * @param index The index to look the sub material at
  95018. * @returns The Material if the index has been defined
  95019. */
  95020. getSubMaterial(index: number): Nullable<Material>;
  95021. /**
  95022. * Get the list of active textures for the whole sub materials list.
  95023. * @returns All the textures that will be used during the rendering
  95024. */
  95025. getActiveTextures(): BaseTexture[];
  95026. /**
  95027. * Gets the current class name of the material e.g. "MultiMaterial"
  95028. * Mainly use in serialization.
  95029. * @returns the class name
  95030. */
  95031. getClassName(): string;
  95032. /**
  95033. * Checks if the material is ready to render the requested sub mesh
  95034. * @param mesh Define the mesh the submesh belongs to
  95035. * @param subMesh Define the sub mesh to look readyness for
  95036. * @param useInstances Define whether or not the material is used with instances
  95037. * @returns true if ready, otherwise false
  95038. */
  95039. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  95040. /**
  95041. * Clones the current material and its related sub materials
  95042. * @param name Define the name of the newly cloned material
  95043. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  95044. * @returns the cloned material
  95045. */
  95046. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  95047. /**
  95048. * Serializes the materials into a JSON representation.
  95049. * @returns the JSON representation
  95050. */
  95051. serialize(): any;
  95052. /**
  95053. * Dispose the material and release its associated resources
  95054. * @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)
  95055. * @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)
  95056. * @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)
  95057. */
  95058. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  95059. /**
  95060. * Creates a MultiMaterial from parsed MultiMaterial data.
  95061. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  95062. * @param scene defines the hosting scene
  95063. * @returns a new MultiMaterial
  95064. */
  95065. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  95066. }
  95067. }
  95068. declare module BABYLON {
  95069. /**
  95070. * Base class for submeshes
  95071. */
  95072. export class BaseSubMesh {
  95073. /** @hidden */
  95074. _materialDefines: Nullable<MaterialDefines>;
  95075. /** @hidden */
  95076. _materialEffect: Nullable<Effect>;
  95077. /**
  95078. * Gets material defines used by the effect associated to the sub mesh
  95079. */
  95080. get materialDefines(): Nullable<MaterialDefines>;
  95081. /**
  95082. * Sets material defines used by the effect associated to the sub mesh
  95083. */
  95084. set materialDefines(defines: Nullable<MaterialDefines>);
  95085. /**
  95086. * Gets associated effect
  95087. */
  95088. get effect(): Nullable<Effect>;
  95089. /**
  95090. * Sets associated effect (effect used to render this submesh)
  95091. * @param effect defines the effect to associate with
  95092. * @param defines defines the set of defines used to compile this effect
  95093. */
  95094. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  95095. }
  95096. /**
  95097. * Defines a subdivision inside a mesh
  95098. */
  95099. export class SubMesh extends BaseSubMesh implements ICullable {
  95100. /** the material index to use */
  95101. materialIndex: number;
  95102. /** vertex index start */
  95103. verticesStart: number;
  95104. /** vertices count */
  95105. verticesCount: number;
  95106. /** index start */
  95107. indexStart: number;
  95108. /** indices count */
  95109. indexCount: number;
  95110. /** @hidden */
  95111. _linesIndexCount: number;
  95112. private _mesh;
  95113. private _renderingMesh;
  95114. private _boundingInfo;
  95115. private _linesIndexBuffer;
  95116. /** @hidden */
  95117. _lastColliderWorldVertices: Nullable<Vector3[]>;
  95118. /** @hidden */
  95119. _trianglePlanes: Plane[];
  95120. /** @hidden */
  95121. _lastColliderTransformMatrix: Nullable<Matrix>;
  95122. /** @hidden */
  95123. _renderId: number;
  95124. /** @hidden */
  95125. _alphaIndex: number;
  95126. /** @hidden */
  95127. _distanceToCamera: number;
  95128. /** @hidden */
  95129. _id: number;
  95130. private _currentMaterial;
  95131. /**
  95132. * Add a new submesh to a mesh
  95133. * @param materialIndex defines the material index to use
  95134. * @param verticesStart defines vertex index start
  95135. * @param verticesCount defines vertices count
  95136. * @param indexStart defines index start
  95137. * @param indexCount defines indices count
  95138. * @param mesh defines the parent mesh
  95139. * @param renderingMesh defines an optional rendering mesh
  95140. * @param createBoundingBox defines if bounding box should be created for this submesh
  95141. * @returns the new submesh
  95142. */
  95143. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  95144. /**
  95145. * Creates a new submesh
  95146. * @param materialIndex defines the material index to use
  95147. * @param verticesStart defines vertex index start
  95148. * @param verticesCount defines vertices count
  95149. * @param indexStart defines index start
  95150. * @param indexCount defines indices count
  95151. * @param mesh defines the parent mesh
  95152. * @param renderingMesh defines an optional rendering mesh
  95153. * @param createBoundingBox defines if bounding box should be created for this submesh
  95154. */
  95155. constructor(
  95156. /** the material index to use */
  95157. materialIndex: number,
  95158. /** vertex index start */
  95159. verticesStart: number,
  95160. /** vertices count */
  95161. verticesCount: number,
  95162. /** index start */
  95163. indexStart: number,
  95164. /** indices count */
  95165. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  95166. /**
  95167. * Returns true if this submesh covers the entire parent mesh
  95168. * @ignorenaming
  95169. */
  95170. get IsGlobal(): boolean;
  95171. /**
  95172. * Returns the submesh BoudingInfo object
  95173. * @returns current bounding info (or mesh's one if the submesh is global)
  95174. */
  95175. getBoundingInfo(): BoundingInfo;
  95176. /**
  95177. * Sets the submesh BoundingInfo
  95178. * @param boundingInfo defines the new bounding info to use
  95179. * @returns the SubMesh
  95180. */
  95181. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  95182. /**
  95183. * Returns the mesh of the current submesh
  95184. * @return the parent mesh
  95185. */
  95186. getMesh(): AbstractMesh;
  95187. /**
  95188. * Returns the rendering mesh of the submesh
  95189. * @returns the rendering mesh (could be different from parent mesh)
  95190. */
  95191. getRenderingMesh(): Mesh;
  95192. /**
  95193. * Returns the submesh material
  95194. * @returns null or the current material
  95195. */
  95196. getMaterial(): Nullable<Material>;
  95197. /**
  95198. * Sets a new updated BoundingInfo object to the submesh
  95199. * @param data defines an optional position array to use to determine the bounding info
  95200. * @returns the SubMesh
  95201. */
  95202. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  95203. /** @hidden */
  95204. _checkCollision(collider: Collider): boolean;
  95205. /**
  95206. * Updates the submesh BoundingInfo
  95207. * @param world defines the world matrix to use to update the bounding info
  95208. * @returns the submesh
  95209. */
  95210. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  95211. /**
  95212. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  95213. * @param frustumPlanes defines the frustum planes
  95214. * @returns true if the submesh is intersecting with the frustum
  95215. */
  95216. isInFrustum(frustumPlanes: Plane[]): boolean;
  95217. /**
  95218. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  95219. * @param frustumPlanes defines the frustum planes
  95220. * @returns true if the submesh is inside the frustum
  95221. */
  95222. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  95223. /**
  95224. * Renders the submesh
  95225. * @param enableAlphaMode defines if alpha needs to be used
  95226. * @returns the submesh
  95227. */
  95228. render(enableAlphaMode: boolean): SubMesh;
  95229. /**
  95230. * @hidden
  95231. */
  95232. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  95233. /**
  95234. * Checks if the submesh intersects with a ray
  95235. * @param ray defines the ray to test
  95236. * @returns true is the passed ray intersects the submesh bounding box
  95237. */
  95238. canIntersects(ray: Ray): boolean;
  95239. /**
  95240. * Intersects current submesh with a ray
  95241. * @param ray defines the ray to test
  95242. * @param positions defines mesh's positions array
  95243. * @param indices defines mesh's indices array
  95244. * @param fastCheck defines if only bounding info should be used
  95245. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  95246. * @returns intersection info or null if no intersection
  95247. */
  95248. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  95249. /** @hidden */
  95250. private _intersectLines;
  95251. /** @hidden */
  95252. private _intersectUnIndexedLines;
  95253. /** @hidden */
  95254. private _intersectTriangles;
  95255. /** @hidden */
  95256. private _intersectUnIndexedTriangles;
  95257. /** @hidden */
  95258. _rebuild(): void;
  95259. /**
  95260. * Creates a new submesh from the passed mesh
  95261. * @param newMesh defines the new hosting mesh
  95262. * @param newRenderingMesh defines an optional rendering mesh
  95263. * @returns the new submesh
  95264. */
  95265. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  95266. /**
  95267. * Release associated resources
  95268. */
  95269. dispose(): void;
  95270. /**
  95271. * Gets the class name
  95272. * @returns the string "SubMesh".
  95273. */
  95274. getClassName(): string;
  95275. /**
  95276. * Creates a new submesh from indices data
  95277. * @param materialIndex the index of the main mesh material
  95278. * @param startIndex the index where to start the copy in the mesh indices array
  95279. * @param indexCount the number of indices to copy then from the startIndex
  95280. * @param mesh the main mesh to create the submesh from
  95281. * @param renderingMesh the optional rendering mesh
  95282. * @returns a new submesh
  95283. */
  95284. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  95285. }
  95286. }
  95287. declare module BABYLON {
  95288. /**
  95289. * Class used to represent data loading progression
  95290. */
  95291. export class SceneLoaderFlags {
  95292. private static _ForceFullSceneLoadingForIncremental;
  95293. private static _ShowLoadingScreen;
  95294. private static _CleanBoneMatrixWeights;
  95295. private static _loggingLevel;
  95296. /**
  95297. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  95298. */
  95299. static get ForceFullSceneLoadingForIncremental(): boolean;
  95300. static set ForceFullSceneLoadingForIncremental(value: boolean);
  95301. /**
  95302. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  95303. */
  95304. static get ShowLoadingScreen(): boolean;
  95305. static set ShowLoadingScreen(value: boolean);
  95306. /**
  95307. * Defines the current logging level (while loading the scene)
  95308. * @ignorenaming
  95309. */
  95310. static get loggingLevel(): number;
  95311. static set loggingLevel(value: number);
  95312. /**
  95313. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  95314. */
  95315. static get CleanBoneMatrixWeights(): boolean;
  95316. static set CleanBoneMatrixWeights(value: boolean);
  95317. }
  95318. }
  95319. declare module BABYLON {
  95320. /**
  95321. * Class used to store geometry data (vertex buffers + index buffer)
  95322. */
  95323. export class Geometry implements IGetSetVerticesData {
  95324. /**
  95325. * Gets or sets the ID of the geometry
  95326. */
  95327. id: string;
  95328. /**
  95329. * Gets or sets the unique ID of the geometry
  95330. */
  95331. uniqueId: number;
  95332. /**
  95333. * Gets the delay loading state of the geometry (none by default which means not delayed)
  95334. */
  95335. delayLoadState: number;
  95336. /**
  95337. * Gets the file containing the data to load when running in delay load state
  95338. */
  95339. delayLoadingFile: Nullable<string>;
  95340. /**
  95341. * Callback called when the geometry is updated
  95342. */
  95343. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  95344. private _scene;
  95345. private _engine;
  95346. private _meshes;
  95347. private _totalVertices;
  95348. /** @hidden */
  95349. _indices: IndicesArray;
  95350. /** @hidden */
  95351. _vertexBuffers: {
  95352. [key: string]: VertexBuffer;
  95353. };
  95354. private _isDisposed;
  95355. private _extend;
  95356. private _boundingBias;
  95357. /** @hidden */
  95358. _delayInfo: Array<string>;
  95359. private _indexBuffer;
  95360. private _indexBufferIsUpdatable;
  95361. /** @hidden */
  95362. _boundingInfo: Nullable<BoundingInfo>;
  95363. /** @hidden */
  95364. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  95365. /** @hidden */
  95366. _softwareSkinningFrameId: number;
  95367. private _vertexArrayObjects;
  95368. private _updatable;
  95369. /** @hidden */
  95370. _positions: Nullable<Vector3[]>;
  95371. /**
  95372. * 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
  95373. */
  95374. get boundingBias(): Vector2;
  95375. /**
  95376. * 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
  95377. */
  95378. set boundingBias(value: Vector2);
  95379. /**
  95380. * Static function used to attach a new empty geometry to a mesh
  95381. * @param mesh defines the mesh to attach the geometry to
  95382. * @returns the new Geometry
  95383. */
  95384. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  95385. /**
  95386. * Creates a new geometry
  95387. * @param id defines the unique ID
  95388. * @param scene defines the hosting scene
  95389. * @param vertexData defines the VertexData used to get geometry data
  95390. * @param updatable defines if geometry must be updatable (false by default)
  95391. * @param mesh defines the mesh that will be associated with the geometry
  95392. */
  95393. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  95394. /**
  95395. * Gets the current extend of the geometry
  95396. */
  95397. get extend(): {
  95398. minimum: Vector3;
  95399. maximum: Vector3;
  95400. };
  95401. /**
  95402. * Gets the hosting scene
  95403. * @returns the hosting Scene
  95404. */
  95405. getScene(): Scene;
  95406. /**
  95407. * Gets the hosting engine
  95408. * @returns the hosting Engine
  95409. */
  95410. getEngine(): Engine;
  95411. /**
  95412. * Defines if the geometry is ready to use
  95413. * @returns true if the geometry is ready to be used
  95414. */
  95415. isReady(): boolean;
  95416. /**
  95417. * Gets a value indicating that the geometry should not be serialized
  95418. */
  95419. get doNotSerialize(): boolean;
  95420. /** @hidden */
  95421. _rebuild(): void;
  95422. /**
  95423. * Affects all geometry data in one call
  95424. * @param vertexData defines the geometry data
  95425. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  95426. */
  95427. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  95428. /**
  95429. * Set specific vertex data
  95430. * @param kind defines the data kind (Position, normal, etc...)
  95431. * @param data defines the vertex data to use
  95432. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  95433. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  95434. */
  95435. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  95436. /**
  95437. * Removes a specific vertex data
  95438. * @param kind defines the data kind (Position, normal, etc...)
  95439. */
  95440. removeVerticesData(kind: string): void;
  95441. /**
  95442. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  95443. * @param buffer defines the vertex buffer to use
  95444. * @param totalVertices defines the total number of vertices for position kind (could be null)
  95445. */
  95446. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  95447. /**
  95448. * Update a specific vertex buffer
  95449. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  95450. * It will do nothing if the buffer is not updatable
  95451. * @param kind defines the data kind (Position, normal, etc...)
  95452. * @param data defines the data to use
  95453. * @param offset defines the offset in the target buffer where to store the data
  95454. * @param useBytes set to true if the offset is in bytes
  95455. */
  95456. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  95457. /**
  95458. * Update a specific vertex buffer
  95459. * This function will create a new buffer if the current one is not updatable
  95460. * @param kind defines the data kind (Position, normal, etc...)
  95461. * @param data defines the data to use
  95462. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  95463. */
  95464. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  95465. private _updateBoundingInfo;
  95466. /** @hidden */
  95467. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  95468. /**
  95469. * Gets total number of vertices
  95470. * @returns the total number of vertices
  95471. */
  95472. getTotalVertices(): number;
  95473. /**
  95474. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  95475. * @param kind defines the data kind (Position, normal, etc...)
  95476. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95477. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95478. * @returns a float array containing vertex data
  95479. */
  95480. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95481. /**
  95482. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  95483. * @param kind defines the data kind (Position, normal, etc...)
  95484. * @returns true if the vertex buffer with the specified kind is updatable
  95485. */
  95486. isVertexBufferUpdatable(kind: string): boolean;
  95487. /**
  95488. * Gets a specific vertex buffer
  95489. * @param kind defines the data kind (Position, normal, etc...)
  95490. * @returns a VertexBuffer
  95491. */
  95492. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  95493. /**
  95494. * Returns all vertex buffers
  95495. * @return an object holding all vertex buffers indexed by kind
  95496. */
  95497. getVertexBuffers(): Nullable<{
  95498. [key: string]: VertexBuffer;
  95499. }>;
  95500. /**
  95501. * Gets a boolean indicating if specific vertex buffer is present
  95502. * @param kind defines the data kind (Position, normal, etc...)
  95503. * @returns true if data is present
  95504. */
  95505. isVerticesDataPresent(kind: string): boolean;
  95506. /**
  95507. * Gets a list of all attached data kinds (Position, normal, etc...)
  95508. * @returns a list of string containing all kinds
  95509. */
  95510. getVerticesDataKinds(): string[];
  95511. /**
  95512. * Update index buffer
  95513. * @param indices defines the indices to store in the index buffer
  95514. * @param offset defines the offset in the target buffer where to store the data
  95515. * @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)
  95516. */
  95517. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  95518. /**
  95519. * Creates a new index buffer
  95520. * @param indices defines the indices to store in the index buffer
  95521. * @param totalVertices defines the total number of vertices (could be null)
  95522. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  95523. */
  95524. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  95525. /**
  95526. * Return the total number of indices
  95527. * @returns the total number of indices
  95528. */
  95529. getTotalIndices(): number;
  95530. /**
  95531. * Gets the index buffer array
  95532. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95533. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95534. * @returns the index buffer array
  95535. */
  95536. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95537. /**
  95538. * Gets the index buffer
  95539. * @return the index buffer
  95540. */
  95541. getIndexBuffer(): Nullable<DataBuffer>;
  95542. /** @hidden */
  95543. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  95544. /**
  95545. * Release the associated resources for a specific mesh
  95546. * @param mesh defines the source mesh
  95547. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  95548. */
  95549. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  95550. /**
  95551. * Apply current geometry to a given mesh
  95552. * @param mesh defines the mesh to apply geometry to
  95553. */
  95554. applyToMesh(mesh: Mesh): void;
  95555. private _updateExtend;
  95556. private _applyToMesh;
  95557. private notifyUpdate;
  95558. /**
  95559. * Load the geometry if it was flagged as delay loaded
  95560. * @param scene defines the hosting scene
  95561. * @param onLoaded defines a callback called when the geometry is loaded
  95562. */
  95563. load(scene: Scene, onLoaded?: () => void): void;
  95564. private _queueLoad;
  95565. /**
  95566. * Invert the geometry to move from a right handed system to a left handed one.
  95567. */
  95568. toLeftHanded(): void;
  95569. /** @hidden */
  95570. _resetPointsArrayCache(): void;
  95571. /** @hidden */
  95572. _generatePointsArray(): boolean;
  95573. /**
  95574. * Gets a value indicating if the geometry is disposed
  95575. * @returns true if the geometry was disposed
  95576. */
  95577. isDisposed(): boolean;
  95578. private _disposeVertexArrayObjects;
  95579. /**
  95580. * Free all associated resources
  95581. */
  95582. dispose(): void;
  95583. /**
  95584. * Clone the current geometry into a new geometry
  95585. * @param id defines the unique ID of the new geometry
  95586. * @returns a new geometry object
  95587. */
  95588. copy(id: string): Geometry;
  95589. /**
  95590. * Serialize the current geometry info (and not the vertices data) into a JSON object
  95591. * @return a JSON representation of the current geometry data (without the vertices data)
  95592. */
  95593. serialize(): any;
  95594. private toNumberArray;
  95595. /**
  95596. * Serialize all vertices data into a JSON oject
  95597. * @returns a JSON representation of the current geometry data
  95598. */
  95599. serializeVerticeData(): any;
  95600. /**
  95601. * Extracts a clone of a mesh geometry
  95602. * @param mesh defines the source mesh
  95603. * @param id defines the unique ID of the new geometry object
  95604. * @returns the new geometry object
  95605. */
  95606. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  95607. /**
  95608. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  95609. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  95610. * Be aware Math.random() could cause collisions, but:
  95611. * "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"
  95612. * @returns a string containing a new GUID
  95613. */
  95614. static RandomId(): string;
  95615. /** @hidden */
  95616. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  95617. private static _CleanMatricesWeights;
  95618. /**
  95619. * Create a new geometry from persisted data (Using .babylon file format)
  95620. * @param parsedVertexData defines the persisted data
  95621. * @param scene defines the hosting scene
  95622. * @param rootUrl defines the root url to use to load assets (like delayed data)
  95623. * @returns the new geometry object
  95624. */
  95625. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  95626. }
  95627. }
  95628. declare module BABYLON {
  95629. /**
  95630. * Define an interface for all classes that will get and set the data on vertices
  95631. */
  95632. export interface IGetSetVerticesData {
  95633. /**
  95634. * Gets a boolean indicating if specific vertex data is present
  95635. * @param kind defines the vertex data kind to use
  95636. * @returns true is data kind is present
  95637. */
  95638. isVerticesDataPresent(kind: string): boolean;
  95639. /**
  95640. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  95641. * @param kind defines the data kind (Position, normal, etc...)
  95642. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95643. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95644. * @returns a float array containing vertex data
  95645. */
  95646. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95647. /**
  95648. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  95649. * @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.
  95650. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95651. * @returns the indices array or an empty array if the mesh has no geometry
  95652. */
  95653. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95654. /**
  95655. * Set specific vertex data
  95656. * @param kind defines the data kind (Position, normal, etc...)
  95657. * @param data defines the vertex data to use
  95658. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  95659. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  95660. */
  95661. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  95662. /**
  95663. * Update a specific associated vertex buffer
  95664. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  95665. * - VertexBuffer.PositionKind
  95666. * - VertexBuffer.UVKind
  95667. * - VertexBuffer.UV2Kind
  95668. * - VertexBuffer.UV3Kind
  95669. * - VertexBuffer.UV4Kind
  95670. * - VertexBuffer.UV5Kind
  95671. * - VertexBuffer.UV6Kind
  95672. * - VertexBuffer.ColorKind
  95673. * - VertexBuffer.MatricesIndicesKind
  95674. * - VertexBuffer.MatricesIndicesExtraKind
  95675. * - VertexBuffer.MatricesWeightsKind
  95676. * - VertexBuffer.MatricesWeightsExtraKind
  95677. * @param data defines the data source
  95678. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  95679. * @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)
  95680. */
  95681. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  95682. /**
  95683. * Creates a new index buffer
  95684. * @param indices defines the indices to store in the index buffer
  95685. * @param totalVertices defines the total number of vertices (could be null)
  95686. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  95687. */
  95688. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  95689. }
  95690. /**
  95691. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  95692. */
  95693. export class VertexData {
  95694. /**
  95695. * Mesh side orientation : usually the external or front surface
  95696. */
  95697. static readonly FRONTSIDE: number;
  95698. /**
  95699. * Mesh side orientation : usually the internal or back surface
  95700. */
  95701. static readonly BACKSIDE: number;
  95702. /**
  95703. * Mesh side orientation : both internal and external or front and back surfaces
  95704. */
  95705. static readonly DOUBLESIDE: number;
  95706. /**
  95707. * Mesh side orientation : by default, `FRONTSIDE`
  95708. */
  95709. static readonly DEFAULTSIDE: number;
  95710. /**
  95711. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  95712. */
  95713. positions: Nullable<FloatArray>;
  95714. /**
  95715. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  95716. */
  95717. normals: Nullable<FloatArray>;
  95718. /**
  95719. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  95720. */
  95721. tangents: Nullable<FloatArray>;
  95722. /**
  95723. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95724. */
  95725. uvs: Nullable<FloatArray>;
  95726. /**
  95727. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95728. */
  95729. uvs2: Nullable<FloatArray>;
  95730. /**
  95731. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95732. */
  95733. uvs3: Nullable<FloatArray>;
  95734. /**
  95735. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95736. */
  95737. uvs4: Nullable<FloatArray>;
  95738. /**
  95739. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95740. */
  95741. uvs5: Nullable<FloatArray>;
  95742. /**
  95743. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95744. */
  95745. uvs6: Nullable<FloatArray>;
  95746. /**
  95747. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  95748. */
  95749. colors: Nullable<FloatArray>;
  95750. /**
  95751. * 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).
  95752. */
  95753. matricesIndices: Nullable<FloatArray>;
  95754. /**
  95755. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  95756. */
  95757. matricesWeights: Nullable<FloatArray>;
  95758. /**
  95759. * An array extending the number of possible indices
  95760. */
  95761. matricesIndicesExtra: Nullable<FloatArray>;
  95762. /**
  95763. * An array extending the number of possible weights when the number of indices is extended
  95764. */
  95765. matricesWeightsExtra: Nullable<FloatArray>;
  95766. /**
  95767. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  95768. */
  95769. indices: Nullable<IndicesArray>;
  95770. /**
  95771. * Uses the passed data array to set the set the values for the specified kind of data
  95772. * @param data a linear array of floating numbers
  95773. * @param kind the type of data that is being set, eg positions, colors etc
  95774. */
  95775. set(data: FloatArray, kind: string): void;
  95776. /**
  95777. * Associates the vertexData to the passed Mesh.
  95778. * Sets it as updatable or not (default `false`)
  95779. * @param mesh the mesh the vertexData is applied to
  95780. * @param updatable when used and having the value true allows new data to update the vertexData
  95781. * @returns the VertexData
  95782. */
  95783. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  95784. /**
  95785. * Associates the vertexData to the passed Geometry.
  95786. * Sets it as updatable or not (default `false`)
  95787. * @param geometry the geometry the vertexData is applied to
  95788. * @param updatable when used and having the value true allows new data to update the vertexData
  95789. * @returns VertexData
  95790. */
  95791. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  95792. /**
  95793. * Updates the associated mesh
  95794. * @param mesh the mesh to be updated
  95795. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  95796. * @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
  95797. * @returns VertexData
  95798. */
  95799. updateMesh(mesh: Mesh): VertexData;
  95800. /**
  95801. * Updates the associated geometry
  95802. * @param geometry the geometry to be updated
  95803. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  95804. * @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
  95805. * @returns VertexData.
  95806. */
  95807. updateGeometry(geometry: Geometry): VertexData;
  95808. private _applyTo;
  95809. private _update;
  95810. /**
  95811. * Transforms each position and each normal of the vertexData according to the passed Matrix
  95812. * @param matrix the transforming matrix
  95813. * @returns the VertexData
  95814. */
  95815. transform(matrix: Matrix): VertexData;
  95816. /**
  95817. * Merges the passed VertexData into the current one
  95818. * @param other the VertexData to be merged into the current one
  95819. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  95820. * @returns the modified VertexData
  95821. */
  95822. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  95823. private _mergeElement;
  95824. private _validate;
  95825. /**
  95826. * Serializes the VertexData
  95827. * @returns a serialized object
  95828. */
  95829. serialize(): any;
  95830. /**
  95831. * Extracts the vertexData from a mesh
  95832. * @param mesh the mesh from which to extract the VertexData
  95833. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  95834. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  95835. * @returns the object VertexData associated to the passed mesh
  95836. */
  95837. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  95838. /**
  95839. * Extracts the vertexData from the geometry
  95840. * @param geometry the geometry from which to extract the VertexData
  95841. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  95842. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  95843. * @returns the object VertexData associated to the passed mesh
  95844. */
  95845. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  95846. private static _ExtractFrom;
  95847. /**
  95848. * Creates the VertexData for a Ribbon
  95849. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  95850. * * pathArray array of paths, each of which an array of successive Vector3
  95851. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  95852. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  95853. * * 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
  95854. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95855. * * 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)
  95856. * * 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)
  95857. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  95858. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  95859. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  95860. * @returns the VertexData of the ribbon
  95861. */
  95862. static CreateRibbon(options: {
  95863. pathArray: Vector3[][];
  95864. closeArray?: boolean;
  95865. closePath?: boolean;
  95866. offset?: number;
  95867. sideOrientation?: number;
  95868. frontUVs?: Vector4;
  95869. backUVs?: Vector4;
  95870. invertUV?: boolean;
  95871. uvs?: Vector2[];
  95872. colors?: Color4[];
  95873. }): VertexData;
  95874. /**
  95875. * Creates the VertexData for a box
  95876. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95877. * * size sets the width, height and depth of the box to the value of size, optional default 1
  95878. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  95879. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  95880. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  95881. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  95882. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  95883. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95884. * * 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)
  95885. * * 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)
  95886. * @returns the VertexData of the box
  95887. */
  95888. static CreateBox(options: {
  95889. size?: number;
  95890. width?: number;
  95891. height?: number;
  95892. depth?: number;
  95893. faceUV?: Vector4[];
  95894. faceColors?: Color4[];
  95895. sideOrientation?: number;
  95896. frontUVs?: Vector4;
  95897. backUVs?: Vector4;
  95898. }): VertexData;
  95899. /**
  95900. * Creates the VertexData for a tiled box
  95901. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95902. * * faceTiles sets the pattern, tile size and number of tiles for a face
  95903. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  95904. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  95905. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95906. * @returns the VertexData of the box
  95907. */
  95908. static CreateTiledBox(options: {
  95909. pattern?: number;
  95910. width?: number;
  95911. height?: number;
  95912. depth?: number;
  95913. tileSize?: number;
  95914. tileWidth?: number;
  95915. tileHeight?: number;
  95916. alignHorizontal?: number;
  95917. alignVertical?: number;
  95918. faceUV?: Vector4[];
  95919. faceColors?: Color4[];
  95920. sideOrientation?: number;
  95921. }): VertexData;
  95922. /**
  95923. * Creates the VertexData for a tiled plane
  95924. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95925. * * pattern a limited pattern arrangement depending on the number
  95926. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  95927. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  95928. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  95929. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95930. * * 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)
  95931. * * 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)
  95932. * @returns the VertexData of the tiled plane
  95933. */
  95934. static CreateTiledPlane(options: {
  95935. pattern?: number;
  95936. tileSize?: number;
  95937. tileWidth?: number;
  95938. tileHeight?: number;
  95939. size?: number;
  95940. width?: number;
  95941. height?: number;
  95942. alignHorizontal?: number;
  95943. alignVertical?: number;
  95944. sideOrientation?: number;
  95945. frontUVs?: Vector4;
  95946. backUVs?: Vector4;
  95947. }): VertexData;
  95948. /**
  95949. * Creates the VertexData for an ellipsoid, defaults to a sphere
  95950. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95951. * * segments sets the number of horizontal strips optional, default 32
  95952. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  95953. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  95954. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  95955. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  95956. * * 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
  95957. * * 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
  95958. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95959. * * 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)
  95960. * * 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)
  95961. * @returns the VertexData of the ellipsoid
  95962. */
  95963. static CreateSphere(options: {
  95964. segments?: number;
  95965. diameter?: number;
  95966. diameterX?: number;
  95967. diameterY?: number;
  95968. diameterZ?: number;
  95969. arc?: number;
  95970. slice?: number;
  95971. sideOrientation?: number;
  95972. frontUVs?: Vector4;
  95973. backUVs?: Vector4;
  95974. }): VertexData;
  95975. /**
  95976. * Creates the VertexData for a cylinder, cone or prism
  95977. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95978. * * height sets the height (y direction) of the cylinder, optional, default 2
  95979. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  95980. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  95981. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  95982. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  95983. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  95984. * * 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
  95985. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95986. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95987. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  95988. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  95989. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95990. * * 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)
  95991. * * 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)
  95992. * @returns the VertexData of the cylinder, cone or prism
  95993. */
  95994. static CreateCylinder(options: {
  95995. height?: number;
  95996. diameterTop?: number;
  95997. diameterBottom?: number;
  95998. diameter?: number;
  95999. tessellation?: number;
  96000. subdivisions?: number;
  96001. arc?: number;
  96002. faceColors?: Color4[];
  96003. faceUV?: Vector4[];
  96004. hasRings?: boolean;
  96005. enclose?: boolean;
  96006. sideOrientation?: number;
  96007. frontUVs?: Vector4;
  96008. backUVs?: Vector4;
  96009. }): VertexData;
  96010. /**
  96011. * Creates the VertexData for a torus
  96012. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96013. * * diameter the diameter of the torus, optional default 1
  96014. * * thickness the diameter of the tube forming the torus, optional default 0.5
  96015. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  96016. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96017. * * 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)
  96018. * * 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)
  96019. * @returns the VertexData of the torus
  96020. */
  96021. static CreateTorus(options: {
  96022. diameter?: number;
  96023. thickness?: number;
  96024. tessellation?: number;
  96025. sideOrientation?: number;
  96026. frontUVs?: Vector4;
  96027. backUVs?: Vector4;
  96028. }): VertexData;
  96029. /**
  96030. * Creates the VertexData of the LineSystem
  96031. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  96032. * - lines an array of lines, each line being an array of successive Vector3
  96033. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  96034. * @returns the VertexData of the LineSystem
  96035. */
  96036. static CreateLineSystem(options: {
  96037. lines: Vector3[][];
  96038. colors?: Nullable<Color4[][]>;
  96039. }): VertexData;
  96040. /**
  96041. * Create the VertexData for a DashedLines
  96042. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  96043. * - points an array successive Vector3
  96044. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  96045. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  96046. * - dashNb the intended total number of dashes, optional, default 200
  96047. * @returns the VertexData for the DashedLines
  96048. */
  96049. static CreateDashedLines(options: {
  96050. points: Vector3[];
  96051. dashSize?: number;
  96052. gapSize?: number;
  96053. dashNb?: number;
  96054. }): VertexData;
  96055. /**
  96056. * Creates the VertexData for a Ground
  96057. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  96058. * - width the width (x direction) of the ground, optional, default 1
  96059. * - height the height (z direction) of the ground, optional, default 1
  96060. * - subdivisions the number of subdivisions per side, optional, default 1
  96061. * @returns the VertexData of the Ground
  96062. */
  96063. static CreateGround(options: {
  96064. width?: number;
  96065. height?: number;
  96066. subdivisions?: number;
  96067. subdivisionsX?: number;
  96068. subdivisionsY?: number;
  96069. }): VertexData;
  96070. /**
  96071. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  96072. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  96073. * * xmin the ground minimum X coordinate, optional, default -1
  96074. * * zmin the ground minimum Z coordinate, optional, default -1
  96075. * * xmax the ground maximum X coordinate, optional, default 1
  96076. * * zmax the ground maximum Z coordinate, optional, default 1
  96077. * * 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}
  96078. * * 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}
  96079. * @returns the VertexData of the TiledGround
  96080. */
  96081. static CreateTiledGround(options: {
  96082. xmin: number;
  96083. zmin: number;
  96084. xmax: number;
  96085. zmax: number;
  96086. subdivisions?: {
  96087. w: number;
  96088. h: number;
  96089. };
  96090. precision?: {
  96091. w: number;
  96092. h: number;
  96093. };
  96094. }): VertexData;
  96095. /**
  96096. * Creates the VertexData of the Ground designed from a heightmap
  96097. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  96098. * * width the width (x direction) of the ground
  96099. * * height the height (z direction) of the ground
  96100. * * subdivisions the number of subdivisions per side
  96101. * * minHeight the minimum altitude on the ground, optional, default 0
  96102. * * maxHeight the maximum altitude on the ground, optional default 1
  96103. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  96104. * * buffer the array holding the image color data
  96105. * * bufferWidth the width of image
  96106. * * bufferHeight the height of image
  96107. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  96108. * @returns the VertexData of the Ground designed from a heightmap
  96109. */
  96110. static CreateGroundFromHeightMap(options: {
  96111. width: number;
  96112. height: number;
  96113. subdivisions: number;
  96114. minHeight: number;
  96115. maxHeight: number;
  96116. colorFilter: Color3;
  96117. buffer: Uint8Array;
  96118. bufferWidth: number;
  96119. bufferHeight: number;
  96120. alphaFilter: number;
  96121. }): VertexData;
  96122. /**
  96123. * Creates the VertexData for a Plane
  96124. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  96125. * * size sets the width and height of the plane to the value of size, optional default 1
  96126. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  96127. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  96128. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96129. * * 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)
  96130. * * 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)
  96131. * @returns the VertexData of the box
  96132. */
  96133. static CreatePlane(options: {
  96134. size?: number;
  96135. width?: number;
  96136. height?: number;
  96137. sideOrientation?: number;
  96138. frontUVs?: Vector4;
  96139. backUVs?: Vector4;
  96140. }): VertexData;
  96141. /**
  96142. * Creates the VertexData of the Disc or regular Polygon
  96143. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  96144. * * radius the radius of the disc, optional default 0.5
  96145. * * tessellation the number of polygon sides, optional, default 64
  96146. * * 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
  96147. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96148. * * 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)
  96149. * * 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)
  96150. * @returns the VertexData of the box
  96151. */
  96152. static CreateDisc(options: {
  96153. radius?: number;
  96154. tessellation?: number;
  96155. arc?: number;
  96156. sideOrientation?: number;
  96157. frontUVs?: Vector4;
  96158. backUVs?: Vector4;
  96159. }): VertexData;
  96160. /**
  96161. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  96162. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  96163. * @param polygon a mesh built from polygonTriangulation.build()
  96164. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96165. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  96166. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  96167. * @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)
  96168. * @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)
  96169. * @returns the VertexData of the Polygon
  96170. */
  96171. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  96172. /**
  96173. * Creates the VertexData of the IcoSphere
  96174. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  96175. * * radius the radius of the IcoSphere, optional default 1
  96176. * * radiusX allows stretching in the x direction, optional, default radius
  96177. * * radiusY allows stretching in the y direction, optional, default radius
  96178. * * radiusZ allows stretching in the z direction, optional, default radius
  96179. * * flat when true creates a flat shaded mesh, optional, default true
  96180. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  96181. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96182. * * 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)
  96183. * * 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)
  96184. * @returns the VertexData of the IcoSphere
  96185. */
  96186. static CreateIcoSphere(options: {
  96187. radius?: number;
  96188. radiusX?: number;
  96189. radiusY?: number;
  96190. radiusZ?: number;
  96191. flat?: boolean;
  96192. subdivisions?: number;
  96193. sideOrientation?: number;
  96194. frontUVs?: Vector4;
  96195. backUVs?: Vector4;
  96196. }): VertexData;
  96197. /**
  96198. * Creates the VertexData for a Polyhedron
  96199. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  96200. * * type provided types are:
  96201. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  96202. * * 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)
  96203. * * size the size of the IcoSphere, optional default 1
  96204. * * sizeX allows stretching in the x direction, optional, default size
  96205. * * sizeY allows stretching in the y direction, optional, default size
  96206. * * sizeZ allows stretching in the z direction, optional, default size
  96207. * * 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
  96208. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  96209. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  96210. * * flat when true creates a flat shaded mesh, optional, default true
  96211. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  96212. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96213. * * 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)
  96214. * * 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)
  96215. * @returns the VertexData of the Polyhedron
  96216. */
  96217. static CreatePolyhedron(options: {
  96218. type?: number;
  96219. size?: number;
  96220. sizeX?: number;
  96221. sizeY?: number;
  96222. sizeZ?: number;
  96223. custom?: any;
  96224. faceUV?: Vector4[];
  96225. faceColors?: Color4[];
  96226. flat?: boolean;
  96227. sideOrientation?: number;
  96228. frontUVs?: Vector4;
  96229. backUVs?: Vector4;
  96230. }): VertexData;
  96231. /**
  96232. * Creates the VertexData for a TorusKnot
  96233. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  96234. * * radius the radius of the torus knot, optional, default 2
  96235. * * tube the thickness of the tube, optional, default 0.5
  96236. * * radialSegments the number of sides on each tube segments, optional, default 32
  96237. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  96238. * * p the number of windings around the z axis, optional, default 2
  96239. * * q the number of windings around the x axis, optional, default 3
  96240. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96241. * * 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)
  96242. * * 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)
  96243. * @returns the VertexData of the Torus Knot
  96244. */
  96245. static CreateTorusKnot(options: {
  96246. radius?: number;
  96247. tube?: number;
  96248. radialSegments?: number;
  96249. tubularSegments?: number;
  96250. p?: number;
  96251. q?: number;
  96252. sideOrientation?: number;
  96253. frontUVs?: Vector4;
  96254. backUVs?: Vector4;
  96255. }): VertexData;
  96256. /**
  96257. * Compute normals for given positions and indices
  96258. * @param positions an array of vertex positions, [...., x, y, z, ......]
  96259. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  96260. * @param normals an array of vertex normals, [...., x, y, z, ......]
  96261. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  96262. * * facetNormals : optional array of facet normals (vector3)
  96263. * * facetPositions : optional array of facet positions (vector3)
  96264. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  96265. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  96266. * * bInfo : optional bounding info, required for facetPartitioning computation
  96267. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  96268. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  96269. * * useRightHandedSystem: optional boolean to for right handed system computation
  96270. * * depthSort : optional boolean to enable the facet depth sort computation
  96271. * * distanceTo : optional Vector3 to compute the facet depth from this location
  96272. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  96273. */
  96274. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  96275. facetNormals?: any;
  96276. facetPositions?: any;
  96277. facetPartitioning?: any;
  96278. ratio?: number;
  96279. bInfo?: any;
  96280. bbSize?: Vector3;
  96281. subDiv?: any;
  96282. useRightHandedSystem?: boolean;
  96283. depthSort?: boolean;
  96284. distanceTo?: Vector3;
  96285. depthSortedFacets?: any;
  96286. }): void;
  96287. /** @hidden */
  96288. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  96289. /**
  96290. * Applies VertexData created from the imported parameters to the geometry
  96291. * @param parsedVertexData the parsed data from an imported file
  96292. * @param geometry the geometry to apply the VertexData to
  96293. */
  96294. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  96295. }
  96296. }
  96297. declare module BABYLON {
  96298. /**
  96299. * Defines a target to use with MorphTargetManager
  96300. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  96301. */
  96302. export class MorphTarget implements IAnimatable {
  96303. /** defines the name of the target */
  96304. name: string;
  96305. /**
  96306. * Gets or sets the list of animations
  96307. */
  96308. animations: Animation[];
  96309. private _scene;
  96310. private _positions;
  96311. private _normals;
  96312. private _tangents;
  96313. private _uvs;
  96314. private _influence;
  96315. private _uniqueId;
  96316. /**
  96317. * Observable raised when the influence changes
  96318. */
  96319. onInfluenceChanged: Observable<boolean>;
  96320. /** @hidden */
  96321. _onDataLayoutChanged: Observable<void>;
  96322. /**
  96323. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  96324. */
  96325. get influence(): number;
  96326. set influence(influence: number);
  96327. /**
  96328. * Gets or sets the id of the morph Target
  96329. */
  96330. id: string;
  96331. private _animationPropertiesOverride;
  96332. /**
  96333. * Gets or sets the animation properties override
  96334. */
  96335. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  96336. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  96337. /**
  96338. * Creates a new MorphTarget
  96339. * @param name defines the name of the target
  96340. * @param influence defines the influence to use
  96341. * @param scene defines the scene the morphtarget belongs to
  96342. */
  96343. constructor(
  96344. /** defines the name of the target */
  96345. name: string, influence?: number, scene?: Nullable<Scene>);
  96346. /**
  96347. * Gets the unique ID of this manager
  96348. */
  96349. get uniqueId(): number;
  96350. /**
  96351. * Gets a boolean defining if the target contains position data
  96352. */
  96353. get hasPositions(): boolean;
  96354. /**
  96355. * Gets a boolean defining if the target contains normal data
  96356. */
  96357. get hasNormals(): boolean;
  96358. /**
  96359. * Gets a boolean defining if the target contains tangent data
  96360. */
  96361. get hasTangents(): boolean;
  96362. /**
  96363. * Gets a boolean defining if the target contains texture coordinates data
  96364. */
  96365. get hasUVs(): boolean;
  96366. /**
  96367. * Affects position data to this target
  96368. * @param data defines the position data to use
  96369. */
  96370. setPositions(data: Nullable<FloatArray>): void;
  96371. /**
  96372. * Gets the position data stored in this target
  96373. * @returns a FloatArray containing the position data (or null if not present)
  96374. */
  96375. getPositions(): Nullable<FloatArray>;
  96376. /**
  96377. * Affects normal data to this target
  96378. * @param data defines the normal data to use
  96379. */
  96380. setNormals(data: Nullable<FloatArray>): void;
  96381. /**
  96382. * Gets the normal data stored in this target
  96383. * @returns a FloatArray containing the normal data (or null if not present)
  96384. */
  96385. getNormals(): Nullable<FloatArray>;
  96386. /**
  96387. * Affects tangent data to this target
  96388. * @param data defines the tangent data to use
  96389. */
  96390. setTangents(data: Nullable<FloatArray>): void;
  96391. /**
  96392. * Gets the tangent data stored in this target
  96393. * @returns a FloatArray containing the tangent data (or null if not present)
  96394. */
  96395. getTangents(): Nullable<FloatArray>;
  96396. /**
  96397. * Affects texture coordinates data to this target
  96398. * @param data defines the texture coordinates data to use
  96399. */
  96400. setUVs(data: Nullable<FloatArray>): void;
  96401. /**
  96402. * Gets the texture coordinates data stored in this target
  96403. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  96404. */
  96405. getUVs(): Nullable<FloatArray>;
  96406. /**
  96407. * Clone the current target
  96408. * @returns a new MorphTarget
  96409. */
  96410. clone(): MorphTarget;
  96411. /**
  96412. * Serializes the current target into a Serialization object
  96413. * @returns the serialized object
  96414. */
  96415. serialize(): any;
  96416. /**
  96417. * Returns the string "MorphTarget"
  96418. * @returns "MorphTarget"
  96419. */
  96420. getClassName(): string;
  96421. /**
  96422. * Creates a new target from serialized data
  96423. * @param serializationObject defines the serialized data to use
  96424. * @returns a new MorphTarget
  96425. */
  96426. static Parse(serializationObject: any): MorphTarget;
  96427. /**
  96428. * Creates a MorphTarget from mesh data
  96429. * @param mesh defines the source mesh
  96430. * @param name defines the name to use for the new target
  96431. * @param influence defines the influence to attach to the target
  96432. * @returns a new MorphTarget
  96433. */
  96434. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  96435. }
  96436. }
  96437. declare module BABYLON {
  96438. /**
  96439. * This class is used to deform meshes using morphing between different targets
  96440. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  96441. */
  96442. export class MorphTargetManager {
  96443. private _targets;
  96444. private _targetInfluenceChangedObservers;
  96445. private _targetDataLayoutChangedObservers;
  96446. private _activeTargets;
  96447. private _scene;
  96448. private _influences;
  96449. private _supportsNormals;
  96450. private _supportsTangents;
  96451. private _supportsUVs;
  96452. private _vertexCount;
  96453. private _uniqueId;
  96454. private _tempInfluences;
  96455. /**
  96456. * Gets or sets a boolean indicating if normals must be morphed
  96457. */
  96458. enableNormalMorphing: boolean;
  96459. /**
  96460. * Gets or sets a boolean indicating if tangents must be morphed
  96461. */
  96462. enableTangentMorphing: boolean;
  96463. /**
  96464. * Gets or sets a boolean indicating if UV must be morphed
  96465. */
  96466. enableUVMorphing: boolean;
  96467. /**
  96468. * Creates a new MorphTargetManager
  96469. * @param scene defines the current scene
  96470. */
  96471. constructor(scene?: Nullable<Scene>);
  96472. /**
  96473. * Gets the unique ID of this manager
  96474. */
  96475. get uniqueId(): number;
  96476. /**
  96477. * Gets the number of vertices handled by this manager
  96478. */
  96479. get vertexCount(): number;
  96480. /**
  96481. * Gets a boolean indicating if this manager supports morphing of normals
  96482. */
  96483. get supportsNormals(): boolean;
  96484. /**
  96485. * Gets a boolean indicating if this manager supports morphing of tangents
  96486. */
  96487. get supportsTangents(): boolean;
  96488. /**
  96489. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  96490. */
  96491. get supportsUVs(): boolean;
  96492. /**
  96493. * Gets the number of targets stored in this manager
  96494. */
  96495. get numTargets(): number;
  96496. /**
  96497. * Gets the number of influencers (ie. the number of targets with influences > 0)
  96498. */
  96499. get numInfluencers(): number;
  96500. /**
  96501. * Gets the list of influences (one per target)
  96502. */
  96503. get influences(): Float32Array;
  96504. /**
  96505. * Gets the active target at specified index. An active target is a target with an influence > 0
  96506. * @param index defines the index to check
  96507. * @returns the requested target
  96508. */
  96509. getActiveTarget(index: number): MorphTarget;
  96510. /**
  96511. * Gets the target at specified index
  96512. * @param index defines the index to check
  96513. * @returns the requested target
  96514. */
  96515. getTarget(index: number): MorphTarget;
  96516. /**
  96517. * Add a new target to this manager
  96518. * @param target defines the target to add
  96519. */
  96520. addTarget(target: MorphTarget): void;
  96521. /**
  96522. * Removes a target from the manager
  96523. * @param target defines the target to remove
  96524. */
  96525. removeTarget(target: MorphTarget): void;
  96526. /**
  96527. * Clone the current manager
  96528. * @returns a new MorphTargetManager
  96529. */
  96530. clone(): MorphTargetManager;
  96531. /**
  96532. * Serializes the current manager into a Serialization object
  96533. * @returns the serialized object
  96534. */
  96535. serialize(): any;
  96536. private _syncActiveTargets;
  96537. /**
  96538. * Syncrhonize the targets with all the meshes using this morph target manager
  96539. */
  96540. synchronize(): void;
  96541. /**
  96542. * Creates a new MorphTargetManager from serialized data
  96543. * @param serializationObject defines the serialized data
  96544. * @param scene defines the hosting scene
  96545. * @returns the new MorphTargetManager
  96546. */
  96547. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  96548. }
  96549. }
  96550. declare module BABYLON {
  96551. /**
  96552. * Class used to represent a specific level of detail of a mesh
  96553. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  96554. */
  96555. export class MeshLODLevel {
  96556. /** Defines the distance where this level should start being displayed */
  96557. distance: number;
  96558. /** Defines the mesh to use to render this level */
  96559. mesh: Nullable<Mesh>;
  96560. /**
  96561. * Creates a new LOD level
  96562. * @param distance defines the distance where this level should star being displayed
  96563. * @param mesh defines the mesh to use to render this level
  96564. */
  96565. constructor(
  96566. /** Defines the distance where this level should start being displayed */
  96567. distance: number,
  96568. /** Defines the mesh to use to render this level */
  96569. mesh: Nullable<Mesh>);
  96570. }
  96571. }
  96572. declare module BABYLON {
  96573. /**
  96574. * Mesh representing the gorund
  96575. */
  96576. export class GroundMesh extends Mesh {
  96577. /** If octree should be generated */
  96578. generateOctree: boolean;
  96579. private _heightQuads;
  96580. /** @hidden */
  96581. _subdivisionsX: number;
  96582. /** @hidden */
  96583. _subdivisionsY: number;
  96584. /** @hidden */
  96585. _width: number;
  96586. /** @hidden */
  96587. _height: number;
  96588. /** @hidden */
  96589. _minX: number;
  96590. /** @hidden */
  96591. _maxX: number;
  96592. /** @hidden */
  96593. _minZ: number;
  96594. /** @hidden */
  96595. _maxZ: number;
  96596. constructor(name: string, scene: Scene);
  96597. /**
  96598. * "GroundMesh"
  96599. * @returns "GroundMesh"
  96600. */
  96601. getClassName(): string;
  96602. /**
  96603. * The minimum of x and y subdivisions
  96604. */
  96605. get subdivisions(): number;
  96606. /**
  96607. * X subdivisions
  96608. */
  96609. get subdivisionsX(): number;
  96610. /**
  96611. * Y subdivisions
  96612. */
  96613. get subdivisionsY(): number;
  96614. /**
  96615. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  96616. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  96617. * @param chunksCount the number of subdivisions for x and y
  96618. * @param octreeBlocksSize (Default: 32)
  96619. */
  96620. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  96621. /**
  96622. * Returns a height (y) value in the Worl system :
  96623. * the ground altitude at the coordinates (x, z) expressed in the World system.
  96624. * @param x x coordinate
  96625. * @param z z coordinate
  96626. * @returns the ground y position if (x, z) are outside the ground surface.
  96627. */
  96628. getHeightAtCoordinates(x: number, z: number): number;
  96629. /**
  96630. * Returns a normalized vector (Vector3) orthogonal to the ground
  96631. * at the ground coordinates (x, z) expressed in the World system.
  96632. * @param x x coordinate
  96633. * @param z z coordinate
  96634. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  96635. */
  96636. getNormalAtCoordinates(x: number, z: number): Vector3;
  96637. /**
  96638. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  96639. * at the ground coordinates (x, z) expressed in the World system.
  96640. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  96641. * @param x x coordinate
  96642. * @param z z coordinate
  96643. * @param ref vector to store the result
  96644. * @returns the GroundMesh.
  96645. */
  96646. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  96647. /**
  96648. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  96649. * if the ground has been updated.
  96650. * This can be used in the render loop.
  96651. * @returns the GroundMesh.
  96652. */
  96653. updateCoordinateHeights(): GroundMesh;
  96654. private _getFacetAt;
  96655. private _initHeightQuads;
  96656. private _computeHeightQuads;
  96657. /**
  96658. * Serializes this ground mesh
  96659. * @param serializationObject object to write serialization to
  96660. */
  96661. serialize(serializationObject: any): void;
  96662. /**
  96663. * Parses a serialized ground mesh
  96664. * @param parsedMesh the serialized mesh
  96665. * @param scene the scene to create the ground mesh in
  96666. * @returns the created ground mesh
  96667. */
  96668. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  96669. }
  96670. }
  96671. declare module BABYLON {
  96672. /**
  96673. * Interface for Physics-Joint data
  96674. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96675. */
  96676. export interface PhysicsJointData {
  96677. /**
  96678. * The main pivot of the joint
  96679. */
  96680. mainPivot?: Vector3;
  96681. /**
  96682. * The connected pivot of the joint
  96683. */
  96684. connectedPivot?: Vector3;
  96685. /**
  96686. * The main axis of the joint
  96687. */
  96688. mainAxis?: Vector3;
  96689. /**
  96690. * The connected axis of the joint
  96691. */
  96692. connectedAxis?: Vector3;
  96693. /**
  96694. * The collision of the joint
  96695. */
  96696. collision?: boolean;
  96697. /**
  96698. * Native Oimo/Cannon/Energy data
  96699. */
  96700. nativeParams?: any;
  96701. }
  96702. /**
  96703. * This is a holder class for the physics joint created by the physics plugin
  96704. * It holds a set of functions to control the underlying joint
  96705. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96706. */
  96707. export class PhysicsJoint {
  96708. /**
  96709. * The type of the physics joint
  96710. */
  96711. type: number;
  96712. /**
  96713. * The data for the physics joint
  96714. */
  96715. jointData: PhysicsJointData;
  96716. private _physicsJoint;
  96717. protected _physicsPlugin: IPhysicsEnginePlugin;
  96718. /**
  96719. * Initializes the physics joint
  96720. * @param type The type of the physics joint
  96721. * @param jointData The data for the physics joint
  96722. */
  96723. constructor(
  96724. /**
  96725. * The type of the physics joint
  96726. */
  96727. type: number,
  96728. /**
  96729. * The data for the physics joint
  96730. */
  96731. jointData: PhysicsJointData);
  96732. /**
  96733. * Gets the physics joint
  96734. */
  96735. get physicsJoint(): any;
  96736. /**
  96737. * Sets the physics joint
  96738. */
  96739. set physicsJoint(newJoint: any);
  96740. /**
  96741. * Sets the physics plugin
  96742. */
  96743. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  96744. /**
  96745. * Execute a function that is physics-plugin specific.
  96746. * @param {Function} func the function that will be executed.
  96747. * It accepts two parameters: the physics world and the physics joint
  96748. */
  96749. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  96750. /**
  96751. * Distance-Joint type
  96752. */
  96753. static DistanceJoint: number;
  96754. /**
  96755. * Hinge-Joint type
  96756. */
  96757. static HingeJoint: number;
  96758. /**
  96759. * Ball-and-Socket joint type
  96760. */
  96761. static BallAndSocketJoint: number;
  96762. /**
  96763. * Wheel-Joint type
  96764. */
  96765. static WheelJoint: number;
  96766. /**
  96767. * Slider-Joint type
  96768. */
  96769. static SliderJoint: number;
  96770. /**
  96771. * Prismatic-Joint type
  96772. */
  96773. static PrismaticJoint: number;
  96774. /**
  96775. * Universal-Joint type
  96776. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  96777. */
  96778. static UniversalJoint: number;
  96779. /**
  96780. * Hinge-Joint 2 type
  96781. */
  96782. static Hinge2Joint: number;
  96783. /**
  96784. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  96785. */
  96786. static PointToPointJoint: number;
  96787. /**
  96788. * Spring-Joint type
  96789. */
  96790. static SpringJoint: number;
  96791. /**
  96792. * Lock-Joint type
  96793. */
  96794. static LockJoint: number;
  96795. }
  96796. /**
  96797. * A class representing a physics distance joint
  96798. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96799. */
  96800. export class DistanceJoint extends PhysicsJoint {
  96801. /**
  96802. *
  96803. * @param jointData The data for the Distance-Joint
  96804. */
  96805. constructor(jointData: DistanceJointData);
  96806. /**
  96807. * Update the predefined distance.
  96808. * @param maxDistance The maximum preferred distance
  96809. * @param minDistance The minimum preferred distance
  96810. */
  96811. updateDistance(maxDistance: number, minDistance?: number): void;
  96812. }
  96813. /**
  96814. * Represents a Motor-Enabled Joint
  96815. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96816. */
  96817. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  96818. /**
  96819. * Initializes the Motor-Enabled Joint
  96820. * @param type The type of the joint
  96821. * @param jointData The physica joint data for the joint
  96822. */
  96823. constructor(type: number, jointData: PhysicsJointData);
  96824. /**
  96825. * Set the motor values.
  96826. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96827. * @param force the force to apply
  96828. * @param maxForce max force for this motor.
  96829. */
  96830. setMotor(force?: number, maxForce?: number): void;
  96831. /**
  96832. * Set the motor's limits.
  96833. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96834. * @param upperLimit The upper limit of the motor
  96835. * @param lowerLimit The lower limit of the motor
  96836. */
  96837. setLimit(upperLimit: number, lowerLimit?: number): void;
  96838. }
  96839. /**
  96840. * This class represents a single physics Hinge-Joint
  96841. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96842. */
  96843. export class HingeJoint extends MotorEnabledJoint {
  96844. /**
  96845. * Initializes the Hinge-Joint
  96846. * @param jointData The joint data for the Hinge-Joint
  96847. */
  96848. constructor(jointData: PhysicsJointData);
  96849. /**
  96850. * Set the motor values.
  96851. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96852. * @param {number} force the force to apply
  96853. * @param {number} maxForce max force for this motor.
  96854. */
  96855. setMotor(force?: number, maxForce?: number): void;
  96856. /**
  96857. * Set the motor's limits.
  96858. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96859. * @param upperLimit The upper limit of the motor
  96860. * @param lowerLimit The lower limit of the motor
  96861. */
  96862. setLimit(upperLimit: number, lowerLimit?: number): void;
  96863. }
  96864. /**
  96865. * This class represents a dual hinge physics joint (same as wheel joint)
  96866. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96867. */
  96868. export class Hinge2Joint extends MotorEnabledJoint {
  96869. /**
  96870. * Initializes the Hinge2-Joint
  96871. * @param jointData The joint data for the Hinge2-Joint
  96872. */
  96873. constructor(jointData: PhysicsJointData);
  96874. /**
  96875. * Set the motor values.
  96876. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96877. * @param {number} targetSpeed the speed the motor is to reach
  96878. * @param {number} maxForce max force for this motor.
  96879. * @param {motorIndex} the motor's index, 0 or 1.
  96880. */
  96881. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  96882. /**
  96883. * Set the motor limits.
  96884. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96885. * @param {number} upperLimit the upper limit
  96886. * @param {number} lowerLimit lower limit
  96887. * @param {motorIndex} the motor's index, 0 or 1.
  96888. */
  96889. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96890. }
  96891. /**
  96892. * Interface for a motor enabled joint
  96893. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96894. */
  96895. export interface IMotorEnabledJoint {
  96896. /**
  96897. * Physics joint
  96898. */
  96899. physicsJoint: any;
  96900. /**
  96901. * Sets the motor of the motor-enabled joint
  96902. * @param force The force of the motor
  96903. * @param maxForce The maximum force of the motor
  96904. * @param motorIndex The index of the motor
  96905. */
  96906. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  96907. /**
  96908. * Sets the limit of the motor
  96909. * @param upperLimit The upper limit of the motor
  96910. * @param lowerLimit The lower limit of the motor
  96911. * @param motorIndex The index of the motor
  96912. */
  96913. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96914. }
  96915. /**
  96916. * Joint data for a Distance-Joint
  96917. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96918. */
  96919. export interface DistanceJointData extends PhysicsJointData {
  96920. /**
  96921. * Max distance the 2 joint objects can be apart
  96922. */
  96923. maxDistance: number;
  96924. }
  96925. /**
  96926. * Joint data from a spring joint
  96927. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96928. */
  96929. export interface SpringJointData extends PhysicsJointData {
  96930. /**
  96931. * Length of the spring
  96932. */
  96933. length: number;
  96934. /**
  96935. * Stiffness of the spring
  96936. */
  96937. stiffness: number;
  96938. /**
  96939. * Damping of the spring
  96940. */
  96941. damping: number;
  96942. /** this callback will be called when applying the force to the impostors. */
  96943. forceApplicationCallback: () => void;
  96944. }
  96945. }
  96946. declare module BABYLON {
  96947. /**
  96948. * Holds the data for the raycast result
  96949. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96950. */
  96951. export class PhysicsRaycastResult {
  96952. private _hasHit;
  96953. private _hitDistance;
  96954. private _hitNormalWorld;
  96955. private _hitPointWorld;
  96956. private _rayFromWorld;
  96957. private _rayToWorld;
  96958. /**
  96959. * Gets if there was a hit
  96960. */
  96961. get hasHit(): boolean;
  96962. /**
  96963. * Gets the distance from the hit
  96964. */
  96965. get hitDistance(): number;
  96966. /**
  96967. * Gets the hit normal/direction in the world
  96968. */
  96969. get hitNormalWorld(): Vector3;
  96970. /**
  96971. * Gets the hit point in the world
  96972. */
  96973. get hitPointWorld(): Vector3;
  96974. /**
  96975. * Gets the ray "start point" of the ray in the world
  96976. */
  96977. get rayFromWorld(): Vector3;
  96978. /**
  96979. * Gets the ray "end point" of the ray in the world
  96980. */
  96981. get rayToWorld(): Vector3;
  96982. /**
  96983. * Sets the hit data (normal & point in world space)
  96984. * @param hitNormalWorld defines the normal in world space
  96985. * @param hitPointWorld defines the point in world space
  96986. */
  96987. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  96988. /**
  96989. * Sets the distance from the start point to the hit point
  96990. * @param distance
  96991. */
  96992. setHitDistance(distance: number): void;
  96993. /**
  96994. * Calculates the distance manually
  96995. */
  96996. calculateHitDistance(): void;
  96997. /**
  96998. * Resets all the values to default
  96999. * @param from The from point on world space
  97000. * @param to The to point on world space
  97001. */
  97002. reset(from?: Vector3, to?: Vector3): void;
  97003. }
  97004. /**
  97005. * Interface for the size containing width and height
  97006. */
  97007. interface IXYZ {
  97008. /**
  97009. * X
  97010. */
  97011. x: number;
  97012. /**
  97013. * Y
  97014. */
  97015. y: number;
  97016. /**
  97017. * Z
  97018. */
  97019. z: number;
  97020. }
  97021. }
  97022. declare module BABYLON {
  97023. /**
  97024. * Interface used to describe a physics joint
  97025. */
  97026. export interface PhysicsImpostorJoint {
  97027. /** Defines the main impostor to which the joint is linked */
  97028. mainImpostor: PhysicsImpostor;
  97029. /** Defines the impostor that is connected to the main impostor using this joint */
  97030. connectedImpostor: PhysicsImpostor;
  97031. /** Defines the joint itself */
  97032. joint: PhysicsJoint;
  97033. }
  97034. /** @hidden */
  97035. export interface IPhysicsEnginePlugin {
  97036. world: any;
  97037. name: string;
  97038. setGravity(gravity: Vector3): void;
  97039. setTimeStep(timeStep: number): void;
  97040. getTimeStep(): number;
  97041. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  97042. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  97043. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  97044. generatePhysicsBody(impostor: PhysicsImpostor): void;
  97045. removePhysicsBody(impostor: PhysicsImpostor): void;
  97046. generateJoint(joint: PhysicsImpostorJoint): void;
  97047. removeJoint(joint: PhysicsImpostorJoint): void;
  97048. isSupported(): boolean;
  97049. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  97050. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  97051. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  97052. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  97053. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  97054. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  97055. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  97056. getBodyMass(impostor: PhysicsImpostor): number;
  97057. getBodyFriction(impostor: PhysicsImpostor): number;
  97058. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  97059. getBodyRestitution(impostor: PhysicsImpostor): number;
  97060. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  97061. getBodyPressure?(impostor: PhysicsImpostor): number;
  97062. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  97063. getBodyStiffness?(impostor: PhysicsImpostor): number;
  97064. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  97065. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  97066. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  97067. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  97068. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  97069. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  97070. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  97071. sleepBody(impostor: PhysicsImpostor): void;
  97072. wakeUpBody(impostor: PhysicsImpostor): void;
  97073. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  97074. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  97075. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  97076. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  97077. getRadius(impostor: PhysicsImpostor): number;
  97078. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  97079. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  97080. dispose(): void;
  97081. }
  97082. /**
  97083. * Interface used to define a physics engine
  97084. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  97085. */
  97086. export interface IPhysicsEngine {
  97087. /**
  97088. * Gets the gravity vector used by the simulation
  97089. */
  97090. gravity: Vector3;
  97091. /**
  97092. * Sets the gravity vector used by the simulation
  97093. * @param gravity defines the gravity vector to use
  97094. */
  97095. setGravity(gravity: Vector3): void;
  97096. /**
  97097. * Set the time step of the physics engine.
  97098. * Default is 1/60.
  97099. * To slow it down, enter 1/600 for example.
  97100. * To speed it up, 1/30
  97101. * @param newTimeStep the new timestep to apply to this world.
  97102. */
  97103. setTimeStep(newTimeStep: number): void;
  97104. /**
  97105. * Get the time step of the physics engine.
  97106. * @returns the current time step
  97107. */
  97108. getTimeStep(): number;
  97109. /**
  97110. * Set the sub time step of the physics engine.
  97111. * Default is 0 meaning there is no sub steps
  97112. * To increase physics resolution precision, set a small value (like 1 ms)
  97113. * @param subTimeStep defines the new sub timestep used for physics resolution.
  97114. */
  97115. setSubTimeStep(subTimeStep: number): void;
  97116. /**
  97117. * Get the sub time step of the physics engine.
  97118. * @returns the current sub time step
  97119. */
  97120. getSubTimeStep(): number;
  97121. /**
  97122. * Release all resources
  97123. */
  97124. dispose(): void;
  97125. /**
  97126. * Gets the name of the current physics plugin
  97127. * @returns the name of the plugin
  97128. */
  97129. getPhysicsPluginName(): string;
  97130. /**
  97131. * Adding a new impostor for the impostor tracking.
  97132. * This will be done by the impostor itself.
  97133. * @param impostor the impostor to add
  97134. */
  97135. addImpostor(impostor: PhysicsImpostor): void;
  97136. /**
  97137. * Remove an impostor from the engine.
  97138. * This impostor and its mesh will not longer be updated by the physics engine.
  97139. * @param impostor the impostor to remove
  97140. */
  97141. removeImpostor(impostor: PhysicsImpostor): void;
  97142. /**
  97143. * Add a joint to the physics engine
  97144. * @param mainImpostor defines the main impostor to which the joint is added.
  97145. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  97146. * @param joint defines the joint that will connect both impostors.
  97147. */
  97148. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  97149. /**
  97150. * Removes a joint from the simulation
  97151. * @param mainImpostor defines the impostor used with the joint
  97152. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  97153. * @param joint defines the joint to remove
  97154. */
  97155. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  97156. /**
  97157. * Gets the current plugin used to run the simulation
  97158. * @returns current plugin
  97159. */
  97160. getPhysicsPlugin(): IPhysicsEnginePlugin;
  97161. /**
  97162. * Gets the list of physic impostors
  97163. * @returns an array of PhysicsImpostor
  97164. */
  97165. getImpostors(): Array<PhysicsImpostor>;
  97166. /**
  97167. * Gets the impostor for a physics enabled object
  97168. * @param object defines the object impersonated by the impostor
  97169. * @returns the PhysicsImpostor or null if not found
  97170. */
  97171. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  97172. /**
  97173. * Gets the impostor for a physics body object
  97174. * @param body defines physics body used by the impostor
  97175. * @returns the PhysicsImpostor or null if not found
  97176. */
  97177. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  97178. /**
  97179. * Does a raycast in the physics world
  97180. * @param from when should the ray start?
  97181. * @param to when should the ray end?
  97182. * @returns PhysicsRaycastResult
  97183. */
  97184. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  97185. /**
  97186. * Called by the scene. No need to call it.
  97187. * @param delta defines the timespam between frames
  97188. */
  97189. _step(delta: number): void;
  97190. }
  97191. }
  97192. declare module BABYLON {
  97193. /**
  97194. * The interface for the physics imposter parameters
  97195. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97196. */
  97197. export interface PhysicsImpostorParameters {
  97198. /**
  97199. * The mass of the physics imposter
  97200. */
  97201. mass: number;
  97202. /**
  97203. * The friction of the physics imposter
  97204. */
  97205. friction?: number;
  97206. /**
  97207. * The coefficient of restitution of the physics imposter
  97208. */
  97209. restitution?: number;
  97210. /**
  97211. * The native options of the physics imposter
  97212. */
  97213. nativeOptions?: any;
  97214. /**
  97215. * Specifies if the parent should be ignored
  97216. */
  97217. ignoreParent?: boolean;
  97218. /**
  97219. * Specifies if bi-directional transformations should be disabled
  97220. */
  97221. disableBidirectionalTransformation?: boolean;
  97222. /**
  97223. * The pressure inside the physics imposter, soft object only
  97224. */
  97225. pressure?: number;
  97226. /**
  97227. * The stiffness the physics imposter, soft object only
  97228. */
  97229. stiffness?: number;
  97230. /**
  97231. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  97232. */
  97233. velocityIterations?: number;
  97234. /**
  97235. * The number of iterations used in maintaining consistent vertex positions, soft object only
  97236. */
  97237. positionIterations?: number;
  97238. /**
  97239. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  97240. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  97241. * Add to fix multiple points
  97242. */
  97243. fixedPoints?: number;
  97244. /**
  97245. * The collision margin around a soft object
  97246. */
  97247. margin?: number;
  97248. /**
  97249. * The collision margin around a soft object
  97250. */
  97251. damping?: number;
  97252. /**
  97253. * The path for a rope based on an extrusion
  97254. */
  97255. path?: any;
  97256. /**
  97257. * The shape of an extrusion used for a rope based on an extrusion
  97258. */
  97259. shape?: any;
  97260. }
  97261. /**
  97262. * Interface for a physics-enabled object
  97263. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97264. */
  97265. export interface IPhysicsEnabledObject {
  97266. /**
  97267. * The position of the physics-enabled object
  97268. */
  97269. position: Vector3;
  97270. /**
  97271. * The rotation of the physics-enabled object
  97272. */
  97273. rotationQuaternion: Nullable<Quaternion>;
  97274. /**
  97275. * The scale of the physics-enabled object
  97276. */
  97277. scaling: Vector3;
  97278. /**
  97279. * The rotation of the physics-enabled object
  97280. */
  97281. rotation?: Vector3;
  97282. /**
  97283. * The parent of the physics-enabled object
  97284. */
  97285. parent?: any;
  97286. /**
  97287. * The bounding info of the physics-enabled object
  97288. * @returns The bounding info of the physics-enabled object
  97289. */
  97290. getBoundingInfo(): BoundingInfo;
  97291. /**
  97292. * Computes the world matrix
  97293. * @param force Specifies if the world matrix should be computed by force
  97294. * @returns A world matrix
  97295. */
  97296. computeWorldMatrix(force: boolean): Matrix;
  97297. /**
  97298. * Gets the world matrix
  97299. * @returns A world matrix
  97300. */
  97301. getWorldMatrix?(): Matrix;
  97302. /**
  97303. * Gets the child meshes
  97304. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  97305. * @returns An array of abstract meshes
  97306. */
  97307. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  97308. /**
  97309. * Gets the vertex data
  97310. * @param kind The type of vertex data
  97311. * @returns A nullable array of numbers, or a float32 array
  97312. */
  97313. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  97314. /**
  97315. * Gets the indices from the mesh
  97316. * @returns A nullable array of index arrays
  97317. */
  97318. getIndices?(): Nullable<IndicesArray>;
  97319. /**
  97320. * Gets the scene from the mesh
  97321. * @returns the indices array or null
  97322. */
  97323. getScene?(): Scene;
  97324. /**
  97325. * Gets the absolute position from the mesh
  97326. * @returns the absolute position
  97327. */
  97328. getAbsolutePosition(): Vector3;
  97329. /**
  97330. * Gets the absolute pivot point from the mesh
  97331. * @returns the absolute pivot point
  97332. */
  97333. getAbsolutePivotPoint(): Vector3;
  97334. /**
  97335. * Rotates the mesh
  97336. * @param axis The axis of rotation
  97337. * @param amount The amount of rotation
  97338. * @param space The space of the rotation
  97339. * @returns The rotation transform node
  97340. */
  97341. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  97342. /**
  97343. * Translates the mesh
  97344. * @param axis The axis of translation
  97345. * @param distance The distance of translation
  97346. * @param space The space of the translation
  97347. * @returns The transform node
  97348. */
  97349. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  97350. /**
  97351. * Sets the absolute position of the mesh
  97352. * @param absolutePosition The absolute position of the mesh
  97353. * @returns The transform node
  97354. */
  97355. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  97356. /**
  97357. * Gets the class name of the mesh
  97358. * @returns The class name
  97359. */
  97360. getClassName(): string;
  97361. }
  97362. /**
  97363. * Represents a physics imposter
  97364. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97365. */
  97366. export class PhysicsImpostor {
  97367. /**
  97368. * The physics-enabled object used as the physics imposter
  97369. */
  97370. object: IPhysicsEnabledObject;
  97371. /**
  97372. * The type of the physics imposter
  97373. */
  97374. type: number;
  97375. private _options;
  97376. private _scene?;
  97377. /**
  97378. * The default object size of the imposter
  97379. */
  97380. static DEFAULT_OBJECT_SIZE: Vector3;
  97381. /**
  97382. * The identity quaternion of the imposter
  97383. */
  97384. static IDENTITY_QUATERNION: Quaternion;
  97385. /** @hidden */
  97386. _pluginData: any;
  97387. private _physicsEngine;
  97388. private _physicsBody;
  97389. private _bodyUpdateRequired;
  97390. private _onBeforePhysicsStepCallbacks;
  97391. private _onAfterPhysicsStepCallbacks;
  97392. /** @hidden */
  97393. _onPhysicsCollideCallbacks: Array<{
  97394. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  97395. otherImpostors: Array<PhysicsImpostor>;
  97396. }>;
  97397. private _deltaPosition;
  97398. private _deltaRotation;
  97399. private _deltaRotationConjugated;
  97400. /** @hidden */
  97401. _isFromLine: boolean;
  97402. private _parent;
  97403. private _isDisposed;
  97404. private static _tmpVecs;
  97405. private static _tmpQuat;
  97406. /**
  97407. * Specifies if the physics imposter is disposed
  97408. */
  97409. get isDisposed(): boolean;
  97410. /**
  97411. * Gets the mass of the physics imposter
  97412. */
  97413. get mass(): number;
  97414. set mass(value: number);
  97415. /**
  97416. * Gets the coefficient of friction
  97417. */
  97418. get friction(): number;
  97419. /**
  97420. * Sets the coefficient of friction
  97421. */
  97422. set friction(value: number);
  97423. /**
  97424. * Gets the coefficient of restitution
  97425. */
  97426. get restitution(): number;
  97427. /**
  97428. * Sets the coefficient of restitution
  97429. */
  97430. set restitution(value: number);
  97431. /**
  97432. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  97433. */
  97434. get pressure(): number;
  97435. /**
  97436. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  97437. */
  97438. set pressure(value: number);
  97439. /**
  97440. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  97441. */
  97442. get stiffness(): number;
  97443. /**
  97444. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  97445. */
  97446. set stiffness(value: number);
  97447. /**
  97448. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  97449. */
  97450. get velocityIterations(): number;
  97451. /**
  97452. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  97453. */
  97454. set velocityIterations(value: number);
  97455. /**
  97456. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  97457. */
  97458. get positionIterations(): number;
  97459. /**
  97460. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  97461. */
  97462. set positionIterations(value: number);
  97463. /**
  97464. * The unique id of the physics imposter
  97465. * set by the physics engine when adding this impostor to the array
  97466. */
  97467. uniqueId: number;
  97468. /**
  97469. * @hidden
  97470. */
  97471. soft: boolean;
  97472. /**
  97473. * @hidden
  97474. */
  97475. segments: number;
  97476. private _joints;
  97477. /**
  97478. * Initializes the physics imposter
  97479. * @param object The physics-enabled object used as the physics imposter
  97480. * @param type The type of the physics imposter
  97481. * @param _options The options for the physics imposter
  97482. * @param _scene The Babylon scene
  97483. */
  97484. constructor(
  97485. /**
  97486. * The physics-enabled object used as the physics imposter
  97487. */
  97488. object: IPhysicsEnabledObject,
  97489. /**
  97490. * The type of the physics imposter
  97491. */
  97492. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  97493. /**
  97494. * This function will completly initialize this impostor.
  97495. * It will create a new body - but only if this mesh has no parent.
  97496. * If it has, this impostor will not be used other than to define the impostor
  97497. * of the child mesh.
  97498. * @hidden
  97499. */
  97500. _init(): void;
  97501. private _getPhysicsParent;
  97502. /**
  97503. * Should a new body be generated.
  97504. * @returns boolean specifying if body initialization is required
  97505. */
  97506. isBodyInitRequired(): boolean;
  97507. /**
  97508. * Sets the updated scaling
  97509. * @param updated Specifies if the scaling is updated
  97510. */
  97511. setScalingUpdated(): void;
  97512. /**
  97513. * Force a regeneration of this or the parent's impostor's body.
  97514. * Use under cautious - This will remove all joints already implemented.
  97515. */
  97516. forceUpdate(): void;
  97517. /**
  97518. * Gets the body that holds this impostor. Either its own, or its parent.
  97519. */
  97520. get physicsBody(): any;
  97521. /**
  97522. * Get the parent of the physics imposter
  97523. * @returns Physics imposter or null
  97524. */
  97525. get parent(): Nullable<PhysicsImpostor>;
  97526. /**
  97527. * Sets the parent of the physics imposter
  97528. */
  97529. set parent(value: Nullable<PhysicsImpostor>);
  97530. /**
  97531. * Set the physics body. Used mainly by the physics engine/plugin
  97532. */
  97533. set physicsBody(physicsBody: any);
  97534. /**
  97535. * Resets the update flags
  97536. */
  97537. resetUpdateFlags(): void;
  97538. /**
  97539. * Gets the object extend size
  97540. * @returns the object extend size
  97541. */
  97542. getObjectExtendSize(): Vector3;
  97543. /**
  97544. * Gets the object center
  97545. * @returns The object center
  97546. */
  97547. getObjectCenter(): Vector3;
  97548. /**
  97549. * Get a specific parameter from the options parameters
  97550. * @param paramName The object parameter name
  97551. * @returns The object parameter
  97552. */
  97553. getParam(paramName: string): any;
  97554. /**
  97555. * Sets a specific parameter in the options given to the physics plugin
  97556. * @param paramName The parameter name
  97557. * @param value The value of the parameter
  97558. */
  97559. setParam(paramName: string, value: number): void;
  97560. /**
  97561. * Specifically change the body's mass option. Won't recreate the physics body object
  97562. * @param mass The mass of the physics imposter
  97563. */
  97564. setMass(mass: number): void;
  97565. /**
  97566. * Gets the linear velocity
  97567. * @returns linear velocity or null
  97568. */
  97569. getLinearVelocity(): Nullable<Vector3>;
  97570. /**
  97571. * Sets the linear velocity
  97572. * @param velocity linear velocity or null
  97573. */
  97574. setLinearVelocity(velocity: Nullable<Vector3>): void;
  97575. /**
  97576. * Gets the angular velocity
  97577. * @returns angular velocity or null
  97578. */
  97579. getAngularVelocity(): Nullable<Vector3>;
  97580. /**
  97581. * Sets the angular velocity
  97582. * @param velocity The velocity or null
  97583. */
  97584. setAngularVelocity(velocity: Nullable<Vector3>): void;
  97585. /**
  97586. * Execute a function with the physics plugin native code
  97587. * Provide a function the will have two variables - the world object and the physics body object
  97588. * @param func The function to execute with the physics plugin native code
  97589. */
  97590. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  97591. /**
  97592. * Register a function that will be executed before the physics world is stepping forward
  97593. * @param func The function to execute before the physics world is stepped forward
  97594. */
  97595. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97596. /**
  97597. * Unregister a function that will be executed before the physics world is stepping forward
  97598. * @param func The function to execute before the physics world is stepped forward
  97599. */
  97600. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97601. /**
  97602. * Register a function that will be executed after the physics step
  97603. * @param func The function to execute after physics step
  97604. */
  97605. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97606. /**
  97607. * Unregisters a function that will be executed after the physics step
  97608. * @param func The function to execute after physics step
  97609. */
  97610. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97611. /**
  97612. * register a function that will be executed when this impostor collides against a different body
  97613. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  97614. * @param func Callback that is executed on collision
  97615. */
  97616. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  97617. /**
  97618. * Unregisters the physics imposter on contact
  97619. * @param collideAgainst The physics object to collide against
  97620. * @param func Callback to execute on collision
  97621. */
  97622. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  97623. private _tmpQuat;
  97624. private _tmpQuat2;
  97625. /**
  97626. * Get the parent rotation
  97627. * @returns The parent rotation
  97628. */
  97629. getParentsRotation(): Quaternion;
  97630. /**
  97631. * this function is executed by the physics engine.
  97632. */
  97633. beforeStep: () => void;
  97634. /**
  97635. * this function is executed by the physics engine
  97636. */
  97637. afterStep: () => void;
  97638. /**
  97639. * Legacy collision detection event support
  97640. */
  97641. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  97642. /**
  97643. * event and body object due to cannon's event-based architecture.
  97644. */
  97645. onCollide: (e: {
  97646. body: any;
  97647. }) => void;
  97648. /**
  97649. * Apply a force
  97650. * @param force The force to apply
  97651. * @param contactPoint The contact point for the force
  97652. * @returns The physics imposter
  97653. */
  97654. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  97655. /**
  97656. * Apply an impulse
  97657. * @param force The impulse force
  97658. * @param contactPoint The contact point for the impulse force
  97659. * @returns The physics imposter
  97660. */
  97661. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  97662. /**
  97663. * A help function to create a joint
  97664. * @param otherImpostor A physics imposter used to create a joint
  97665. * @param jointType The type of joint
  97666. * @param jointData The data for the joint
  97667. * @returns The physics imposter
  97668. */
  97669. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  97670. /**
  97671. * Add a joint to this impostor with a different impostor
  97672. * @param otherImpostor A physics imposter used to add a joint
  97673. * @param joint The joint to add
  97674. * @returns The physics imposter
  97675. */
  97676. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  97677. /**
  97678. * Add an anchor to a cloth impostor
  97679. * @param otherImpostor rigid impostor to anchor to
  97680. * @param width ratio across width from 0 to 1
  97681. * @param height ratio up height from 0 to 1
  97682. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  97683. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  97684. * @returns impostor the soft imposter
  97685. */
  97686. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  97687. /**
  97688. * Add a hook to a rope impostor
  97689. * @param otherImpostor rigid impostor to anchor to
  97690. * @param length ratio across rope from 0 to 1
  97691. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  97692. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  97693. * @returns impostor the rope imposter
  97694. */
  97695. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  97696. /**
  97697. * Will keep this body still, in a sleep mode.
  97698. * @returns the physics imposter
  97699. */
  97700. sleep(): PhysicsImpostor;
  97701. /**
  97702. * Wake the body up.
  97703. * @returns The physics imposter
  97704. */
  97705. wakeUp(): PhysicsImpostor;
  97706. /**
  97707. * Clones the physics imposter
  97708. * @param newObject The physics imposter clones to this physics-enabled object
  97709. * @returns A nullable physics imposter
  97710. */
  97711. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  97712. /**
  97713. * Disposes the physics imposter
  97714. */
  97715. dispose(): void;
  97716. /**
  97717. * Sets the delta position
  97718. * @param position The delta position amount
  97719. */
  97720. setDeltaPosition(position: Vector3): void;
  97721. /**
  97722. * Sets the delta rotation
  97723. * @param rotation The delta rotation amount
  97724. */
  97725. setDeltaRotation(rotation: Quaternion): void;
  97726. /**
  97727. * Gets the box size of the physics imposter and stores the result in the input parameter
  97728. * @param result Stores the box size
  97729. * @returns The physics imposter
  97730. */
  97731. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  97732. /**
  97733. * Gets the radius of the physics imposter
  97734. * @returns Radius of the physics imposter
  97735. */
  97736. getRadius(): number;
  97737. /**
  97738. * Sync a bone with this impostor
  97739. * @param bone The bone to sync to the impostor.
  97740. * @param boneMesh The mesh that the bone is influencing.
  97741. * @param jointPivot The pivot of the joint / bone in local space.
  97742. * @param distToJoint Optional distance from the impostor to the joint.
  97743. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  97744. */
  97745. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  97746. /**
  97747. * Sync impostor to a bone
  97748. * @param bone The bone that the impostor will be synced to.
  97749. * @param boneMesh The mesh that the bone is influencing.
  97750. * @param jointPivot The pivot of the joint / bone in local space.
  97751. * @param distToJoint Optional distance from the impostor to the joint.
  97752. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  97753. * @param boneAxis Optional vector3 axis the bone is aligned with
  97754. */
  97755. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  97756. /**
  97757. * No-Imposter type
  97758. */
  97759. static NoImpostor: number;
  97760. /**
  97761. * Sphere-Imposter type
  97762. */
  97763. static SphereImpostor: number;
  97764. /**
  97765. * Box-Imposter type
  97766. */
  97767. static BoxImpostor: number;
  97768. /**
  97769. * Plane-Imposter type
  97770. */
  97771. static PlaneImpostor: number;
  97772. /**
  97773. * Mesh-imposter type
  97774. */
  97775. static MeshImpostor: number;
  97776. /**
  97777. * Capsule-Impostor type (Ammo.js plugin only)
  97778. */
  97779. static CapsuleImpostor: number;
  97780. /**
  97781. * Cylinder-Imposter type
  97782. */
  97783. static CylinderImpostor: number;
  97784. /**
  97785. * Particle-Imposter type
  97786. */
  97787. static ParticleImpostor: number;
  97788. /**
  97789. * Heightmap-Imposter type
  97790. */
  97791. static HeightmapImpostor: number;
  97792. /**
  97793. * ConvexHull-Impostor type (Ammo.js plugin only)
  97794. */
  97795. static ConvexHullImpostor: number;
  97796. /**
  97797. * Custom-Imposter type (Ammo.js plugin only)
  97798. */
  97799. static CustomImpostor: number;
  97800. /**
  97801. * Rope-Imposter type
  97802. */
  97803. static RopeImpostor: number;
  97804. /**
  97805. * Cloth-Imposter type
  97806. */
  97807. static ClothImpostor: number;
  97808. /**
  97809. * Softbody-Imposter type
  97810. */
  97811. static SoftbodyImpostor: number;
  97812. }
  97813. }
  97814. declare module BABYLON {
  97815. /**
  97816. * @hidden
  97817. **/
  97818. export class _CreationDataStorage {
  97819. closePath?: boolean;
  97820. closeArray?: boolean;
  97821. idx: number[];
  97822. dashSize: number;
  97823. gapSize: number;
  97824. path3D: Path3D;
  97825. pathArray: Vector3[][];
  97826. arc: number;
  97827. radius: number;
  97828. cap: number;
  97829. tessellation: number;
  97830. }
  97831. /**
  97832. * @hidden
  97833. **/
  97834. class _InstanceDataStorage {
  97835. visibleInstances: any;
  97836. batchCache: _InstancesBatch;
  97837. instancesBufferSize: number;
  97838. instancesBuffer: Nullable<Buffer>;
  97839. instancesData: Float32Array;
  97840. overridenInstanceCount: number;
  97841. isFrozen: boolean;
  97842. previousBatch: Nullable<_InstancesBatch>;
  97843. hardwareInstancedRendering: boolean;
  97844. sideOrientation: number;
  97845. manualUpdate: boolean;
  97846. }
  97847. /**
  97848. * @hidden
  97849. **/
  97850. export class _InstancesBatch {
  97851. mustReturn: boolean;
  97852. visibleInstances: Nullable<InstancedMesh[]>[];
  97853. renderSelf: boolean[];
  97854. hardwareInstancedRendering: boolean[];
  97855. }
  97856. /**
  97857. * Class used to represent renderable models
  97858. */
  97859. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  97860. /**
  97861. * Mesh side orientation : usually the external or front surface
  97862. */
  97863. static readonly FRONTSIDE: number;
  97864. /**
  97865. * Mesh side orientation : usually the internal or back surface
  97866. */
  97867. static readonly BACKSIDE: number;
  97868. /**
  97869. * Mesh side orientation : both internal and external or front and back surfaces
  97870. */
  97871. static readonly DOUBLESIDE: number;
  97872. /**
  97873. * Mesh side orientation : by default, `FRONTSIDE`
  97874. */
  97875. static readonly DEFAULTSIDE: number;
  97876. /**
  97877. * Mesh cap setting : no cap
  97878. */
  97879. static readonly NO_CAP: number;
  97880. /**
  97881. * Mesh cap setting : one cap at the beginning of the mesh
  97882. */
  97883. static readonly CAP_START: number;
  97884. /**
  97885. * Mesh cap setting : one cap at the end of the mesh
  97886. */
  97887. static readonly CAP_END: number;
  97888. /**
  97889. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  97890. */
  97891. static readonly CAP_ALL: number;
  97892. /**
  97893. * Mesh pattern setting : no flip or rotate
  97894. */
  97895. static readonly NO_FLIP: number;
  97896. /**
  97897. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  97898. */
  97899. static readonly FLIP_TILE: number;
  97900. /**
  97901. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  97902. */
  97903. static readonly ROTATE_TILE: number;
  97904. /**
  97905. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  97906. */
  97907. static readonly FLIP_ROW: number;
  97908. /**
  97909. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  97910. */
  97911. static readonly ROTATE_ROW: number;
  97912. /**
  97913. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  97914. */
  97915. static readonly FLIP_N_ROTATE_TILE: number;
  97916. /**
  97917. * Mesh pattern setting : rotate pattern and rotate
  97918. */
  97919. static readonly FLIP_N_ROTATE_ROW: number;
  97920. /**
  97921. * Mesh tile positioning : part tiles same on left/right or top/bottom
  97922. */
  97923. static readonly CENTER: number;
  97924. /**
  97925. * Mesh tile positioning : part tiles on left
  97926. */
  97927. static readonly LEFT: number;
  97928. /**
  97929. * Mesh tile positioning : part tiles on right
  97930. */
  97931. static readonly RIGHT: number;
  97932. /**
  97933. * Mesh tile positioning : part tiles on top
  97934. */
  97935. static readonly TOP: number;
  97936. /**
  97937. * Mesh tile positioning : part tiles on bottom
  97938. */
  97939. static readonly BOTTOM: number;
  97940. /**
  97941. * Gets the default side orientation.
  97942. * @param orientation the orientation to value to attempt to get
  97943. * @returns the default orientation
  97944. * @hidden
  97945. */
  97946. static _GetDefaultSideOrientation(orientation?: number): number;
  97947. private _internalMeshDataInfo;
  97948. /**
  97949. * An event triggered before rendering the mesh
  97950. */
  97951. get onBeforeRenderObservable(): Observable<Mesh>;
  97952. /**
  97953. * An event triggered before binding the mesh
  97954. */
  97955. get onBeforeBindObservable(): Observable<Mesh>;
  97956. /**
  97957. * An event triggered after rendering the mesh
  97958. */
  97959. get onAfterRenderObservable(): Observable<Mesh>;
  97960. /**
  97961. * An event triggered before drawing the mesh
  97962. */
  97963. get onBeforeDrawObservable(): Observable<Mesh>;
  97964. private _onBeforeDrawObserver;
  97965. /**
  97966. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  97967. */
  97968. set onBeforeDraw(callback: () => void);
  97969. get hasInstances(): boolean;
  97970. /**
  97971. * Gets the delay loading state of the mesh (when delay loading is turned on)
  97972. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  97973. */
  97974. delayLoadState: number;
  97975. /**
  97976. * Gets the list of instances created from this mesh
  97977. * it is not supposed to be modified manually.
  97978. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  97979. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  97980. */
  97981. instances: InstancedMesh[];
  97982. /**
  97983. * Gets the file containing delay loading data for this mesh
  97984. */
  97985. delayLoadingFile: string;
  97986. /** @hidden */
  97987. _binaryInfo: any;
  97988. /**
  97989. * User defined function used to change how LOD level selection is done
  97990. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  97991. */
  97992. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  97993. /**
  97994. * Gets or sets the morph target manager
  97995. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  97996. */
  97997. get morphTargetManager(): Nullable<MorphTargetManager>;
  97998. set morphTargetManager(value: Nullable<MorphTargetManager>);
  97999. /** @hidden */
  98000. _creationDataStorage: Nullable<_CreationDataStorage>;
  98001. /** @hidden */
  98002. _geometry: Nullable<Geometry>;
  98003. /** @hidden */
  98004. _delayInfo: Array<string>;
  98005. /** @hidden */
  98006. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  98007. /** @hidden */
  98008. _instanceDataStorage: _InstanceDataStorage;
  98009. private _effectiveMaterial;
  98010. /** @hidden */
  98011. _shouldGenerateFlatShading: boolean;
  98012. /** @hidden */
  98013. _originalBuilderSideOrientation: number;
  98014. /**
  98015. * Use this property to change the original side orientation defined at construction time
  98016. */
  98017. overrideMaterialSideOrientation: Nullable<number>;
  98018. /**
  98019. * Gets the source mesh (the one used to clone this one from)
  98020. */
  98021. get source(): Nullable<Mesh>;
  98022. /**
  98023. * Gets or sets a boolean indicating that this mesh does not use index buffer
  98024. */
  98025. get isUnIndexed(): boolean;
  98026. set isUnIndexed(value: boolean);
  98027. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  98028. get worldMatrixInstancedBuffer(): Float32Array;
  98029. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  98030. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  98031. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  98032. /**
  98033. * @constructor
  98034. * @param name The value used by scene.getMeshByName() to do a lookup.
  98035. * @param scene The scene to add this mesh to.
  98036. * @param parent The parent of this mesh, if it has one
  98037. * @param source An optional Mesh from which geometry is shared, cloned.
  98038. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  98039. * When false, achieved by calling a clone(), also passing False.
  98040. * This will make creation of children, recursive.
  98041. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  98042. */
  98043. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  98044. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  98045. doNotInstantiate: boolean;
  98046. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  98047. /**
  98048. * Gets the class name
  98049. * @returns the string "Mesh".
  98050. */
  98051. getClassName(): string;
  98052. /** @hidden */
  98053. get _isMesh(): boolean;
  98054. /**
  98055. * Returns a description of this mesh
  98056. * @param fullDetails define if full details about this mesh must be used
  98057. * @returns a descriptive string representing this mesh
  98058. */
  98059. toString(fullDetails?: boolean): string;
  98060. /** @hidden */
  98061. _unBindEffect(): void;
  98062. /**
  98063. * Gets a boolean indicating if this mesh has LOD
  98064. */
  98065. get hasLODLevels(): boolean;
  98066. /**
  98067. * Gets the list of MeshLODLevel associated with the current mesh
  98068. * @returns an array of MeshLODLevel
  98069. */
  98070. getLODLevels(): MeshLODLevel[];
  98071. private _sortLODLevels;
  98072. /**
  98073. * Add a mesh as LOD level triggered at the given distance.
  98074. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98075. * @param distance The distance from the center of the object to show this level
  98076. * @param mesh The mesh to be added as LOD level (can be null)
  98077. * @return This mesh (for chaining)
  98078. */
  98079. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  98080. /**
  98081. * Returns the LOD level mesh at the passed distance or null if not found.
  98082. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98083. * @param distance The distance from the center of the object to show this level
  98084. * @returns a Mesh or `null`
  98085. */
  98086. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  98087. /**
  98088. * Remove a mesh from the LOD array
  98089. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98090. * @param mesh defines the mesh to be removed
  98091. * @return This mesh (for chaining)
  98092. */
  98093. removeLODLevel(mesh: Mesh): Mesh;
  98094. /**
  98095. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  98096. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98097. * @param camera defines the camera to use to compute distance
  98098. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  98099. * @return This mesh (for chaining)
  98100. */
  98101. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  98102. /**
  98103. * Gets the mesh internal Geometry object
  98104. */
  98105. get geometry(): Nullable<Geometry>;
  98106. /**
  98107. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  98108. * @returns the total number of vertices
  98109. */
  98110. getTotalVertices(): number;
  98111. /**
  98112. * Returns the content of an associated vertex buffer
  98113. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  98114. * - VertexBuffer.PositionKind
  98115. * - VertexBuffer.UVKind
  98116. * - VertexBuffer.UV2Kind
  98117. * - VertexBuffer.UV3Kind
  98118. * - VertexBuffer.UV4Kind
  98119. * - VertexBuffer.UV5Kind
  98120. * - VertexBuffer.UV6Kind
  98121. * - VertexBuffer.ColorKind
  98122. * - VertexBuffer.MatricesIndicesKind
  98123. * - VertexBuffer.MatricesIndicesExtraKind
  98124. * - VertexBuffer.MatricesWeightsKind
  98125. * - VertexBuffer.MatricesWeightsExtraKind
  98126. * @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
  98127. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  98128. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  98129. */
  98130. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  98131. /**
  98132. * Returns the mesh VertexBuffer object from the requested `kind`
  98133. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  98134. * - VertexBuffer.PositionKind
  98135. * - VertexBuffer.NormalKind
  98136. * - VertexBuffer.UVKind
  98137. * - VertexBuffer.UV2Kind
  98138. * - VertexBuffer.UV3Kind
  98139. * - VertexBuffer.UV4Kind
  98140. * - VertexBuffer.UV5Kind
  98141. * - VertexBuffer.UV6Kind
  98142. * - VertexBuffer.ColorKind
  98143. * - VertexBuffer.MatricesIndicesKind
  98144. * - VertexBuffer.MatricesIndicesExtraKind
  98145. * - VertexBuffer.MatricesWeightsKind
  98146. * - VertexBuffer.MatricesWeightsExtraKind
  98147. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  98148. */
  98149. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  98150. /**
  98151. * Tests if a specific vertex buffer is associated with this mesh
  98152. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  98153. * - VertexBuffer.PositionKind
  98154. * - VertexBuffer.NormalKind
  98155. * - VertexBuffer.UVKind
  98156. * - VertexBuffer.UV2Kind
  98157. * - VertexBuffer.UV3Kind
  98158. * - VertexBuffer.UV4Kind
  98159. * - VertexBuffer.UV5Kind
  98160. * - VertexBuffer.UV6Kind
  98161. * - VertexBuffer.ColorKind
  98162. * - VertexBuffer.MatricesIndicesKind
  98163. * - VertexBuffer.MatricesIndicesExtraKind
  98164. * - VertexBuffer.MatricesWeightsKind
  98165. * - VertexBuffer.MatricesWeightsExtraKind
  98166. * @returns a boolean
  98167. */
  98168. isVerticesDataPresent(kind: string): boolean;
  98169. /**
  98170. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  98171. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  98172. * - VertexBuffer.PositionKind
  98173. * - VertexBuffer.UVKind
  98174. * - VertexBuffer.UV2Kind
  98175. * - VertexBuffer.UV3Kind
  98176. * - VertexBuffer.UV4Kind
  98177. * - VertexBuffer.UV5Kind
  98178. * - VertexBuffer.UV6Kind
  98179. * - VertexBuffer.ColorKind
  98180. * - VertexBuffer.MatricesIndicesKind
  98181. * - VertexBuffer.MatricesIndicesExtraKind
  98182. * - VertexBuffer.MatricesWeightsKind
  98183. * - VertexBuffer.MatricesWeightsExtraKind
  98184. * @returns a boolean
  98185. */
  98186. isVertexBufferUpdatable(kind: string): boolean;
  98187. /**
  98188. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  98189. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  98190. * - VertexBuffer.PositionKind
  98191. * - VertexBuffer.NormalKind
  98192. * - VertexBuffer.UVKind
  98193. * - VertexBuffer.UV2Kind
  98194. * - VertexBuffer.UV3Kind
  98195. * - VertexBuffer.UV4Kind
  98196. * - VertexBuffer.UV5Kind
  98197. * - VertexBuffer.UV6Kind
  98198. * - VertexBuffer.ColorKind
  98199. * - VertexBuffer.MatricesIndicesKind
  98200. * - VertexBuffer.MatricesIndicesExtraKind
  98201. * - VertexBuffer.MatricesWeightsKind
  98202. * - VertexBuffer.MatricesWeightsExtraKind
  98203. * @returns an array of strings
  98204. */
  98205. getVerticesDataKinds(): string[];
  98206. /**
  98207. * Returns a positive integer : the total number of indices in this mesh geometry.
  98208. * @returns the numner of indices or zero if the mesh has no geometry.
  98209. */
  98210. getTotalIndices(): number;
  98211. /**
  98212. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  98213. * @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.
  98214. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  98215. * @returns the indices array or an empty array if the mesh has no geometry
  98216. */
  98217. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  98218. get isBlocked(): boolean;
  98219. /**
  98220. * Determine if the current mesh is ready to be rendered
  98221. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  98222. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  98223. * @returns true if all associated assets are ready (material, textures, shaders)
  98224. */
  98225. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  98226. /**
  98227. * 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.
  98228. */
  98229. get areNormalsFrozen(): boolean;
  98230. /**
  98231. * 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.
  98232. * @returns the current mesh
  98233. */
  98234. freezeNormals(): Mesh;
  98235. /**
  98236. * 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
  98237. * @returns the current mesh
  98238. */
  98239. unfreezeNormals(): Mesh;
  98240. /**
  98241. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  98242. */
  98243. set overridenInstanceCount(count: number);
  98244. /** @hidden */
  98245. _preActivate(): Mesh;
  98246. /** @hidden */
  98247. _preActivateForIntermediateRendering(renderId: number): Mesh;
  98248. /** @hidden */
  98249. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  98250. /**
  98251. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  98252. * This means the mesh underlying bounding box and sphere are recomputed.
  98253. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  98254. * @returns the current mesh
  98255. */
  98256. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  98257. /** @hidden */
  98258. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  98259. /**
  98260. * This function will subdivide the mesh into multiple submeshes
  98261. * @param count defines the expected number of submeshes
  98262. */
  98263. subdivide(count: number): void;
  98264. /**
  98265. * Copy a FloatArray into a specific associated vertex buffer
  98266. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  98267. * - VertexBuffer.PositionKind
  98268. * - VertexBuffer.UVKind
  98269. * - VertexBuffer.UV2Kind
  98270. * - VertexBuffer.UV3Kind
  98271. * - VertexBuffer.UV4Kind
  98272. * - VertexBuffer.UV5Kind
  98273. * - VertexBuffer.UV6Kind
  98274. * - VertexBuffer.ColorKind
  98275. * - VertexBuffer.MatricesIndicesKind
  98276. * - VertexBuffer.MatricesIndicesExtraKind
  98277. * - VertexBuffer.MatricesWeightsKind
  98278. * - VertexBuffer.MatricesWeightsExtraKind
  98279. * @param data defines the data source
  98280. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  98281. * @param stride defines the data stride size (can be null)
  98282. * @returns the current mesh
  98283. */
  98284. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  98285. /**
  98286. * Delete a vertex buffer associated with this mesh
  98287. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  98288. * - VertexBuffer.PositionKind
  98289. * - VertexBuffer.UVKind
  98290. * - VertexBuffer.UV2Kind
  98291. * - VertexBuffer.UV3Kind
  98292. * - VertexBuffer.UV4Kind
  98293. * - VertexBuffer.UV5Kind
  98294. * - VertexBuffer.UV6Kind
  98295. * - VertexBuffer.ColorKind
  98296. * - VertexBuffer.MatricesIndicesKind
  98297. * - VertexBuffer.MatricesIndicesExtraKind
  98298. * - VertexBuffer.MatricesWeightsKind
  98299. * - VertexBuffer.MatricesWeightsExtraKind
  98300. */
  98301. removeVerticesData(kind: string): void;
  98302. /**
  98303. * Flags an associated vertex buffer as updatable
  98304. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  98305. * - VertexBuffer.PositionKind
  98306. * - VertexBuffer.UVKind
  98307. * - VertexBuffer.UV2Kind
  98308. * - VertexBuffer.UV3Kind
  98309. * - VertexBuffer.UV4Kind
  98310. * - VertexBuffer.UV5Kind
  98311. * - VertexBuffer.UV6Kind
  98312. * - VertexBuffer.ColorKind
  98313. * - VertexBuffer.MatricesIndicesKind
  98314. * - VertexBuffer.MatricesIndicesExtraKind
  98315. * - VertexBuffer.MatricesWeightsKind
  98316. * - VertexBuffer.MatricesWeightsExtraKind
  98317. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  98318. */
  98319. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  98320. /**
  98321. * Sets the mesh global Vertex Buffer
  98322. * @param buffer defines the buffer to use
  98323. * @returns the current mesh
  98324. */
  98325. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  98326. /**
  98327. * Update a specific associated vertex buffer
  98328. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  98329. * - VertexBuffer.PositionKind
  98330. * - VertexBuffer.UVKind
  98331. * - VertexBuffer.UV2Kind
  98332. * - VertexBuffer.UV3Kind
  98333. * - VertexBuffer.UV4Kind
  98334. * - VertexBuffer.UV5Kind
  98335. * - VertexBuffer.UV6Kind
  98336. * - VertexBuffer.ColorKind
  98337. * - VertexBuffer.MatricesIndicesKind
  98338. * - VertexBuffer.MatricesIndicesExtraKind
  98339. * - VertexBuffer.MatricesWeightsKind
  98340. * - VertexBuffer.MatricesWeightsExtraKind
  98341. * @param data defines the data source
  98342. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  98343. * @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)
  98344. * @returns the current mesh
  98345. */
  98346. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  98347. /**
  98348. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  98349. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  98350. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  98351. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  98352. * @returns the current mesh
  98353. */
  98354. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  98355. /**
  98356. * Creates a un-shared specific occurence of the geometry for the mesh.
  98357. * @returns the current mesh
  98358. */
  98359. makeGeometryUnique(): Mesh;
  98360. /**
  98361. * Set the index buffer of this mesh
  98362. * @param indices defines the source data
  98363. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  98364. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  98365. * @returns the current mesh
  98366. */
  98367. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  98368. /**
  98369. * Update the current index buffer
  98370. * @param indices defines the source data
  98371. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  98372. * @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)
  98373. * @returns the current mesh
  98374. */
  98375. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  98376. /**
  98377. * Invert the geometry to move from a right handed system to a left handed one.
  98378. * @returns the current mesh
  98379. */
  98380. toLeftHanded(): Mesh;
  98381. /** @hidden */
  98382. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  98383. /** @hidden */
  98384. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  98385. /**
  98386. * Registers for this mesh a javascript function called just before the rendering process
  98387. * @param func defines the function to call before rendering this mesh
  98388. * @returns the current mesh
  98389. */
  98390. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  98391. /**
  98392. * Disposes a previously registered javascript function called before the rendering
  98393. * @param func defines the function to remove
  98394. * @returns the current mesh
  98395. */
  98396. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  98397. /**
  98398. * Registers for this mesh a javascript function called just after the rendering is complete
  98399. * @param func defines the function to call after rendering this mesh
  98400. * @returns the current mesh
  98401. */
  98402. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  98403. /**
  98404. * Disposes a previously registered javascript function called after the rendering.
  98405. * @param func defines the function to remove
  98406. * @returns the current mesh
  98407. */
  98408. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  98409. /** @hidden */
  98410. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  98411. /** @hidden */
  98412. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  98413. /** @hidden */
  98414. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  98415. /** @hidden */
  98416. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  98417. /** @hidden */
  98418. _rebuild(): void;
  98419. /** @hidden */
  98420. _freeze(): void;
  98421. /** @hidden */
  98422. _unFreeze(): void;
  98423. /**
  98424. * 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
  98425. * @param subMesh defines the subMesh to render
  98426. * @param enableAlphaMode defines if alpha mode can be changed
  98427. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  98428. * @returns the current mesh
  98429. */
  98430. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  98431. private _onBeforeDraw;
  98432. /**
  98433. * Renormalize the mesh and patch it up if there are no weights
  98434. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  98435. * However in the case of zero weights then we set just a single influence to 1.
  98436. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  98437. */
  98438. cleanMatrixWeights(): void;
  98439. private normalizeSkinFourWeights;
  98440. private normalizeSkinWeightsAndExtra;
  98441. /**
  98442. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  98443. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  98444. * the user know there was an issue with importing the mesh
  98445. * @returns a validation object with skinned, valid and report string
  98446. */
  98447. validateSkinning(): {
  98448. skinned: boolean;
  98449. valid: boolean;
  98450. report: string;
  98451. };
  98452. /** @hidden */
  98453. _checkDelayState(): Mesh;
  98454. private _queueLoad;
  98455. /**
  98456. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  98457. * A mesh is in the frustum if its bounding box intersects the frustum
  98458. * @param frustumPlanes defines the frustum to test
  98459. * @returns true if the mesh is in the frustum planes
  98460. */
  98461. isInFrustum(frustumPlanes: Plane[]): boolean;
  98462. /**
  98463. * Sets the mesh material by the material or multiMaterial `id` property
  98464. * @param id is a string identifying the material or the multiMaterial
  98465. * @returns the current mesh
  98466. */
  98467. setMaterialByID(id: string): Mesh;
  98468. /**
  98469. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  98470. * @returns an array of IAnimatable
  98471. */
  98472. getAnimatables(): IAnimatable[];
  98473. /**
  98474. * Modifies the mesh geometry according to the passed transformation matrix.
  98475. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  98476. * The mesh normals are modified using the same transformation.
  98477. * Note that, under the hood, this method sets a new VertexBuffer each call.
  98478. * @param transform defines the transform matrix to use
  98479. * @see http://doc.babylonjs.com/resources/baking_transformations
  98480. * @returns the current mesh
  98481. */
  98482. bakeTransformIntoVertices(transform: Matrix): Mesh;
  98483. /**
  98484. * Modifies the mesh geometry according to its own current World Matrix.
  98485. * The mesh World Matrix is then reset.
  98486. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  98487. * Note that, under the hood, this method sets a new VertexBuffer each call.
  98488. * @see http://doc.babylonjs.com/resources/baking_transformations
  98489. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  98490. * @returns the current mesh
  98491. */
  98492. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  98493. /** @hidden */
  98494. get _positions(): Nullable<Vector3[]>;
  98495. /** @hidden */
  98496. _resetPointsArrayCache(): Mesh;
  98497. /** @hidden */
  98498. _generatePointsArray(): boolean;
  98499. /**
  98500. * Returns a new Mesh object generated from the current mesh properties.
  98501. * This method must not get confused with createInstance()
  98502. * @param name is a string, the name given to the new mesh
  98503. * @param newParent can be any Node object (default `null`)
  98504. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  98505. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  98506. * @returns a new mesh
  98507. */
  98508. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  98509. /**
  98510. * Releases resources associated with this mesh.
  98511. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98512. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98513. */
  98514. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98515. /** @hidden */
  98516. _disposeInstanceSpecificData(): void;
  98517. /**
  98518. * Modifies the mesh geometry according to a displacement map.
  98519. * 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.
  98520. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  98521. * @param url is a string, the URL from the image file is to be downloaded.
  98522. * @param minHeight is the lower limit of the displacement.
  98523. * @param maxHeight is the upper limit of the displacement.
  98524. * @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.
  98525. * @param uvOffset is an optional vector2 used to offset UV.
  98526. * @param uvScale is an optional vector2 used to scale UV.
  98527. * @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.
  98528. * @returns the Mesh.
  98529. */
  98530. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  98531. /**
  98532. * Modifies the mesh geometry according to a displacementMap buffer.
  98533. * 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.
  98534. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  98535. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  98536. * @param heightMapWidth is the width of the buffer image.
  98537. * @param heightMapHeight is the height of the buffer image.
  98538. * @param minHeight is the lower limit of the displacement.
  98539. * @param maxHeight is the upper limit of the displacement.
  98540. * @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.
  98541. * @param uvOffset is an optional vector2 used to offset UV.
  98542. * @param uvScale is an optional vector2 used to scale UV.
  98543. * @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.
  98544. * @returns the Mesh.
  98545. */
  98546. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  98547. /**
  98548. * Modify the mesh to get a flat shading rendering.
  98549. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  98550. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  98551. * @returns current mesh
  98552. */
  98553. convertToFlatShadedMesh(): Mesh;
  98554. /**
  98555. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  98556. * In other words, more vertices, no more indices and a single bigger VBO.
  98557. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  98558. * @returns current mesh
  98559. */
  98560. convertToUnIndexedMesh(): Mesh;
  98561. /**
  98562. * Inverses facet orientations.
  98563. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98564. * @param flipNormals will also inverts the normals
  98565. * @returns current mesh
  98566. */
  98567. flipFaces(flipNormals?: boolean): Mesh;
  98568. /**
  98569. * Increase the number of facets and hence vertices in a mesh
  98570. * Vertex normals are interpolated from existing vertex normals
  98571. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98572. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  98573. */
  98574. increaseVertices(numberPerEdge: number): void;
  98575. /**
  98576. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  98577. * This will undo any application of covertToFlatShadedMesh
  98578. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98579. */
  98580. forceSharedVertices(): void;
  98581. /** @hidden */
  98582. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  98583. /** @hidden */
  98584. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  98585. /**
  98586. * Creates a new InstancedMesh object from the mesh model.
  98587. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  98588. * @param name defines the name of the new instance
  98589. * @returns a new InstancedMesh
  98590. */
  98591. createInstance(name: string): InstancedMesh;
  98592. /**
  98593. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  98594. * After this call, all the mesh instances have the same submeshes than the current mesh.
  98595. * @returns the current mesh
  98596. */
  98597. synchronizeInstances(): Mesh;
  98598. /**
  98599. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  98600. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  98601. * This should be used together with the simplification to avoid disappearing triangles.
  98602. * @param successCallback an optional success callback to be called after the optimization finished.
  98603. * @returns the current mesh
  98604. */
  98605. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  98606. /**
  98607. * Serialize current mesh
  98608. * @param serializationObject defines the object which will receive the serialization data
  98609. */
  98610. serialize(serializationObject: any): void;
  98611. /** @hidden */
  98612. _syncGeometryWithMorphTargetManager(): void;
  98613. /** @hidden */
  98614. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  98615. /**
  98616. * Returns a new Mesh object parsed from the source provided.
  98617. * @param parsedMesh is the source
  98618. * @param scene defines the hosting scene
  98619. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  98620. * @returns a new Mesh
  98621. */
  98622. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  98623. /**
  98624. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  98625. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98626. * @param name defines the name of the mesh to create
  98627. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  98628. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  98629. * @param closePath creates a seam between the first and the last points of each path of the path array
  98630. * @param offset is taken in account only if the `pathArray` is containing a single path
  98631. * @param scene defines the hosting scene
  98632. * @param updatable defines if the mesh must be flagged as updatable
  98633. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98634. * @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)
  98635. * @returns a new Mesh
  98636. */
  98637. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98638. /**
  98639. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  98640. * @param name defines the name of the mesh to create
  98641. * @param radius sets the radius size (float) of the polygon (default 0.5)
  98642. * @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
  98643. * @param scene defines the hosting scene
  98644. * @param updatable defines if the mesh must be flagged as updatable
  98645. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98646. * @returns a new Mesh
  98647. */
  98648. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  98649. /**
  98650. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  98651. * @param name defines the name of the mesh to create
  98652. * @param size sets the size (float) of each box side (default 1)
  98653. * @param scene defines the hosting scene
  98654. * @param updatable defines if the mesh must be flagged as updatable
  98655. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98656. * @returns a new Mesh
  98657. */
  98658. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  98659. /**
  98660. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  98661. * @param name defines the name of the mesh to create
  98662. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  98663. * @param diameter sets the diameter size (float) of the sphere (default 1)
  98664. * @param scene defines the hosting scene
  98665. * @param updatable defines if the mesh must be flagged as updatable
  98666. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98667. * @returns a new Mesh
  98668. */
  98669. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98670. /**
  98671. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  98672. * @param name defines the name of the mesh to create
  98673. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  98674. * @param diameter sets the diameter size (float) of the sphere (default 1)
  98675. * @param scene defines the hosting scene
  98676. * @returns a new Mesh
  98677. */
  98678. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  98679. /**
  98680. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  98681. * @param name defines the name of the mesh to create
  98682. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  98683. * @param diameterTop set the top cap diameter (floats, default 1)
  98684. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  98685. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  98686. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  98687. * @param scene defines the hosting scene
  98688. * @param updatable defines if the mesh must be flagged as updatable
  98689. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98690. * @returns a new Mesh
  98691. */
  98692. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  98693. /**
  98694. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  98695. * @param name defines the name of the mesh to create
  98696. * @param diameter sets the diameter size (float) of the torus (default 1)
  98697. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  98698. * @param tessellation sets the number of torus sides (postive integer, default 16)
  98699. * @param scene defines the hosting scene
  98700. * @param updatable defines if the mesh must be flagged as updatable
  98701. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98702. * @returns a new Mesh
  98703. */
  98704. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98705. /**
  98706. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  98707. * @param name defines the name of the mesh to create
  98708. * @param radius sets the global radius size (float) of the torus knot (default 2)
  98709. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  98710. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  98711. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  98712. * @param p the number of windings on X axis (positive integers, default 2)
  98713. * @param q the number of windings on Y axis (positive integers, default 3)
  98714. * @param scene defines the hosting scene
  98715. * @param updatable defines if the mesh must be flagged as updatable
  98716. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98717. * @returns a new Mesh
  98718. */
  98719. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98720. /**
  98721. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  98722. * @param name defines the name of the mesh to create
  98723. * @param points is an array successive Vector3
  98724. * @param scene defines the hosting scene
  98725. * @param updatable defines if the mesh must be flagged as updatable
  98726. * @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).
  98727. * @returns a new Mesh
  98728. */
  98729. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  98730. /**
  98731. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  98732. * @param name defines the name of the mesh to create
  98733. * @param points is an array successive Vector3
  98734. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  98735. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  98736. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  98737. * @param scene defines the hosting scene
  98738. * @param updatable defines if the mesh must be flagged as updatable
  98739. * @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)
  98740. * @returns a new Mesh
  98741. */
  98742. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  98743. /**
  98744. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  98745. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  98746. * 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.
  98747. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98748. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98749. * Remember you can only change the shape positions, not their number when updating a polygon.
  98750. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  98751. * @param name defines the name of the mesh to create
  98752. * @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
  98753. * @param scene defines the hosting scene
  98754. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  98755. * @param updatable defines if the mesh must be flagged as updatable
  98756. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98757. * @param earcutInjection can be used to inject your own earcut reference
  98758. * @returns a new Mesh
  98759. */
  98760. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  98761. /**
  98762. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  98763. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  98764. * @param name defines the name of the mesh to create
  98765. * @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
  98766. * @param depth defines the height of extrusion
  98767. * @param scene defines the hosting scene
  98768. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  98769. * @param updatable defines if the mesh must be flagged as updatable
  98770. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98771. * @param earcutInjection can be used to inject your own earcut reference
  98772. * @returns a new Mesh
  98773. */
  98774. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  98775. /**
  98776. * Creates an extruded shape mesh.
  98777. * 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
  98778. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98779. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  98780. * @param name defines the name of the mesh to create
  98781. * @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
  98782. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  98783. * @param scale is the value to scale the shape
  98784. * @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
  98785. * @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
  98786. * @param scene defines the hosting scene
  98787. * @param updatable defines if the mesh must be flagged as updatable
  98788. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98789. * @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)
  98790. * @returns a new Mesh
  98791. */
  98792. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98793. /**
  98794. * Creates an custom extruded shape mesh.
  98795. * The custom extrusion is a parametric shape.
  98796. * It has no predefined shape. Its final shape will depend on the input parameters.
  98797. * Please consider using the same method from the MeshBuilder class instead
  98798. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  98799. * @param name defines the name of the mesh to create
  98800. * @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
  98801. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  98802. * @param scaleFunction is a custom Javascript function called on each path point
  98803. * @param rotationFunction is a custom Javascript function called on each path point
  98804. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  98805. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  98806. * @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
  98807. * @param scene defines the hosting scene
  98808. * @param updatable defines if the mesh must be flagged as updatable
  98809. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98810. * @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)
  98811. * @returns a new Mesh
  98812. */
  98813. 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;
  98814. /**
  98815. * Creates lathe mesh.
  98816. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  98817. * Please consider using the same method from the MeshBuilder class instead
  98818. * @param name defines the name of the mesh to create
  98819. * @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
  98820. * @param radius is the radius value of the lathe
  98821. * @param tessellation is the side number of the lathe.
  98822. * @param scene defines the hosting scene
  98823. * @param updatable defines if the mesh must be flagged as updatable
  98824. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98825. * @returns a new Mesh
  98826. */
  98827. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98828. /**
  98829. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  98830. * @param name defines the name of the mesh to create
  98831. * @param size sets the size (float) of both sides of the plane at once (default 1)
  98832. * @param scene defines the hosting scene
  98833. * @param updatable defines if the mesh must be flagged as updatable
  98834. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98835. * @returns a new Mesh
  98836. */
  98837. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98838. /**
  98839. * Creates a ground mesh.
  98840. * Please consider using the same method from the MeshBuilder class instead
  98841. * @param name defines the name of the mesh to create
  98842. * @param width set the width of the ground
  98843. * @param height set the height of the ground
  98844. * @param subdivisions sets the number of subdivisions per side
  98845. * @param scene defines the hosting scene
  98846. * @param updatable defines if the mesh must be flagged as updatable
  98847. * @returns a new Mesh
  98848. */
  98849. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  98850. /**
  98851. * Creates a tiled ground mesh.
  98852. * Please consider using the same method from the MeshBuilder class instead
  98853. * @param name defines the name of the mesh to create
  98854. * @param xmin set the ground minimum X coordinate
  98855. * @param zmin set the ground minimum Y coordinate
  98856. * @param xmax set the ground maximum X coordinate
  98857. * @param zmax set the ground maximum Z coordinate
  98858. * @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
  98859. * @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
  98860. * @param scene defines the hosting scene
  98861. * @param updatable defines if the mesh must be flagged as updatable
  98862. * @returns a new Mesh
  98863. */
  98864. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  98865. w: number;
  98866. h: number;
  98867. }, precision: {
  98868. w: number;
  98869. h: number;
  98870. }, scene: Scene, updatable?: boolean): Mesh;
  98871. /**
  98872. * Creates a ground mesh from a height map.
  98873. * Please consider using the same method from the MeshBuilder class instead
  98874. * @see http://doc.babylonjs.com/babylon101/height_map
  98875. * @param name defines the name of the mesh to create
  98876. * @param url sets the URL of the height map image resource
  98877. * @param width set the ground width size
  98878. * @param height set the ground height size
  98879. * @param subdivisions sets the number of subdivision per side
  98880. * @param minHeight is the minimum altitude on the ground
  98881. * @param maxHeight is the maximum altitude on the ground
  98882. * @param scene defines the hosting scene
  98883. * @param updatable defines if the mesh must be flagged as updatable
  98884. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  98885. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  98886. * @returns a new Mesh
  98887. */
  98888. 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;
  98889. /**
  98890. * Creates a tube mesh.
  98891. * The tube is a parametric shape.
  98892. * It has no predefined shape. Its final shape will depend on the input parameters.
  98893. * Please consider using the same method from the MeshBuilder class instead
  98894. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98895. * @param name defines the name of the mesh to create
  98896. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  98897. * @param radius sets the tube radius size
  98898. * @param tessellation is the number of sides on the tubular surface
  98899. * @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
  98900. * @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
  98901. * @param scene defines the hosting scene
  98902. * @param updatable defines if the mesh must be flagged as updatable
  98903. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98904. * @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)
  98905. * @returns a new Mesh
  98906. */
  98907. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  98908. (i: number, distance: number): number;
  98909. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98910. /**
  98911. * Creates a polyhedron mesh.
  98912. * Please consider using the same method from the MeshBuilder class instead.
  98913. * * 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
  98914. * * The parameter `size` (positive float, default 1) sets the polygon size
  98915. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  98916. * * 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`
  98917. * * 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
  98918. * * 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)`)
  98919. * * 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
  98920. * * 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
  98921. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98922. * * If you create a double-sided mesh, you can choose what parts of 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
  98923. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98924. * @param name defines the name of the mesh to create
  98925. * @param options defines the options used to create the mesh
  98926. * @param scene defines the hosting scene
  98927. * @returns a new Mesh
  98928. */
  98929. static CreatePolyhedron(name: string, options: {
  98930. type?: number;
  98931. size?: number;
  98932. sizeX?: number;
  98933. sizeY?: number;
  98934. sizeZ?: number;
  98935. custom?: any;
  98936. faceUV?: Vector4[];
  98937. faceColors?: Color4[];
  98938. updatable?: boolean;
  98939. sideOrientation?: number;
  98940. }, scene: Scene): Mesh;
  98941. /**
  98942. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  98943. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  98944. * * 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`)
  98945. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  98946. * * 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
  98947. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98948. * * If you create a double-sided mesh, you can choose what parts of 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
  98949. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98950. * @param name defines the name of the mesh
  98951. * @param options defines the options used to create the mesh
  98952. * @param scene defines the hosting scene
  98953. * @returns a new Mesh
  98954. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  98955. */
  98956. static CreateIcoSphere(name: string, options: {
  98957. radius?: number;
  98958. flat?: boolean;
  98959. subdivisions?: number;
  98960. sideOrientation?: number;
  98961. updatable?: boolean;
  98962. }, scene: Scene): Mesh;
  98963. /**
  98964. * Creates a decal mesh.
  98965. * Please consider using the same method from the MeshBuilder class instead.
  98966. * A decal is a mesh usually applied as a model onto the surface of another mesh
  98967. * @param name defines the name of the mesh
  98968. * @param sourceMesh defines the mesh receiving the decal
  98969. * @param position sets the position of the decal in world coordinates
  98970. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  98971. * @param size sets the decal scaling
  98972. * @param angle sets the angle to rotate the decal
  98973. * @returns a new Mesh
  98974. */
  98975. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  98976. /**
  98977. * Prepare internal position array for software CPU skinning
  98978. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  98979. */
  98980. setPositionsForCPUSkinning(): Float32Array;
  98981. /**
  98982. * Prepare internal normal array for software CPU skinning
  98983. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  98984. */
  98985. setNormalsForCPUSkinning(): Float32Array;
  98986. /**
  98987. * Updates the vertex buffer by applying transformation from the bones
  98988. * @param skeleton defines the skeleton to apply to current mesh
  98989. * @returns the current mesh
  98990. */
  98991. applySkeleton(skeleton: Skeleton): Mesh;
  98992. /**
  98993. * 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
  98994. * @param meshes defines the list of meshes to scan
  98995. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  98996. */
  98997. static MinMax(meshes: AbstractMesh[]): {
  98998. min: Vector3;
  98999. max: Vector3;
  99000. };
  99001. /**
  99002. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  99003. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  99004. * @returns a vector3
  99005. */
  99006. static Center(meshesOrMinMaxVector: {
  99007. min: Vector3;
  99008. max: Vector3;
  99009. } | AbstractMesh[]): Vector3;
  99010. /**
  99011. * Merge the array of meshes into a single mesh for performance reasons.
  99012. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  99013. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  99014. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  99015. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  99016. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  99017. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  99018. * @returns a new mesh
  99019. */
  99020. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  99021. /** @hidden */
  99022. addInstance(instance: InstancedMesh): void;
  99023. /** @hidden */
  99024. removeInstance(instance: InstancedMesh): void;
  99025. }
  99026. }
  99027. declare module BABYLON {
  99028. /**
  99029. * This is the base class of all the camera used in the application.
  99030. * @see http://doc.babylonjs.com/features/cameras
  99031. */
  99032. export class Camera extends Node {
  99033. /** @hidden */
  99034. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  99035. /**
  99036. * This is the default projection mode used by the cameras.
  99037. * It helps recreating a feeling of perspective and better appreciate depth.
  99038. * This is the best way to simulate real life cameras.
  99039. */
  99040. static readonly PERSPECTIVE_CAMERA: number;
  99041. /**
  99042. * This helps creating camera with an orthographic mode.
  99043. * 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.
  99044. */
  99045. static readonly ORTHOGRAPHIC_CAMERA: number;
  99046. /**
  99047. * This is the default FOV mode for perspective cameras.
  99048. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  99049. */
  99050. static readonly FOVMODE_VERTICAL_FIXED: number;
  99051. /**
  99052. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  99053. */
  99054. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  99055. /**
  99056. * This specifies ther is no need for a camera rig.
  99057. * Basically only one eye is rendered corresponding to the camera.
  99058. */
  99059. static readonly RIG_MODE_NONE: number;
  99060. /**
  99061. * Simulates a camera Rig with one blue eye and one red eye.
  99062. * This can be use with 3d blue and red glasses.
  99063. */
  99064. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  99065. /**
  99066. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  99067. */
  99068. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  99069. /**
  99070. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  99071. */
  99072. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  99073. /**
  99074. * Defines that both eyes of the camera will be rendered over under each other.
  99075. */
  99076. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  99077. /**
  99078. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  99079. */
  99080. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  99081. /**
  99082. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  99083. */
  99084. static readonly RIG_MODE_VR: number;
  99085. /**
  99086. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  99087. */
  99088. static readonly RIG_MODE_WEBVR: number;
  99089. /**
  99090. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  99091. */
  99092. static readonly RIG_MODE_CUSTOM: number;
  99093. /**
  99094. * Defines if by default attaching controls should prevent the default javascript event to continue.
  99095. */
  99096. static ForceAttachControlToAlwaysPreventDefault: boolean;
  99097. /**
  99098. * Define the input manager associated with the camera.
  99099. */
  99100. inputs: CameraInputsManager<Camera>;
  99101. /** @hidden */
  99102. _position: Vector3;
  99103. /**
  99104. * Define the current local position of the camera in the scene
  99105. */
  99106. get position(): Vector3;
  99107. set position(newPosition: Vector3);
  99108. /**
  99109. * The vector the camera should consider as up.
  99110. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  99111. */
  99112. upVector: Vector3;
  99113. /**
  99114. * Define the current limit on the left side for an orthographic camera
  99115. * In scene unit
  99116. */
  99117. orthoLeft: Nullable<number>;
  99118. /**
  99119. * Define the current limit on the right side for an orthographic camera
  99120. * In scene unit
  99121. */
  99122. orthoRight: Nullable<number>;
  99123. /**
  99124. * Define the current limit on the bottom side for an orthographic camera
  99125. * In scene unit
  99126. */
  99127. orthoBottom: Nullable<number>;
  99128. /**
  99129. * Define the current limit on the top side for an orthographic camera
  99130. * In scene unit
  99131. */
  99132. orthoTop: Nullable<number>;
  99133. /**
  99134. * Field Of View is set in Radians. (default is 0.8)
  99135. */
  99136. fov: number;
  99137. /**
  99138. * Define the minimum distance the camera can see from.
  99139. * This is important to note that the depth buffer are not infinite and the closer it starts
  99140. * the more your scene might encounter depth fighting issue.
  99141. */
  99142. minZ: number;
  99143. /**
  99144. * Define the maximum distance the camera can see to.
  99145. * This is important to note that the depth buffer are not infinite and the further it end
  99146. * the more your scene might encounter depth fighting issue.
  99147. */
  99148. maxZ: number;
  99149. /**
  99150. * Define the default inertia of the camera.
  99151. * This helps giving a smooth feeling to the camera movement.
  99152. */
  99153. inertia: number;
  99154. /**
  99155. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  99156. */
  99157. mode: number;
  99158. /**
  99159. * Define whether the camera is intermediate.
  99160. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  99161. */
  99162. isIntermediate: boolean;
  99163. /**
  99164. * Define the viewport of the camera.
  99165. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  99166. */
  99167. viewport: Viewport;
  99168. /**
  99169. * Restricts the camera to viewing objects with the same layerMask.
  99170. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  99171. */
  99172. layerMask: number;
  99173. /**
  99174. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  99175. */
  99176. fovMode: number;
  99177. /**
  99178. * Rig mode of the camera.
  99179. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  99180. * This is normally controlled byt the camera themselves as internal use.
  99181. */
  99182. cameraRigMode: number;
  99183. /**
  99184. * Defines the distance between both "eyes" in case of a RIG
  99185. */
  99186. interaxialDistance: number;
  99187. /**
  99188. * Defines if stereoscopic rendering is done side by side or over under.
  99189. */
  99190. isStereoscopicSideBySide: boolean;
  99191. /**
  99192. * 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
  99193. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  99194. * else in the scene. (Eg. security camera)
  99195. *
  99196. * 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)
  99197. */
  99198. customRenderTargets: RenderTargetTexture[];
  99199. /**
  99200. * When set, the camera will render to this render target instead of the default canvas
  99201. *
  99202. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  99203. */
  99204. outputRenderTarget: Nullable<RenderTargetTexture>;
  99205. /**
  99206. * Observable triggered when the camera view matrix has changed.
  99207. */
  99208. onViewMatrixChangedObservable: Observable<Camera>;
  99209. /**
  99210. * Observable triggered when the camera Projection matrix has changed.
  99211. */
  99212. onProjectionMatrixChangedObservable: Observable<Camera>;
  99213. /**
  99214. * Observable triggered when the inputs have been processed.
  99215. */
  99216. onAfterCheckInputsObservable: Observable<Camera>;
  99217. /**
  99218. * Observable triggered when reset has been called and applied to the camera.
  99219. */
  99220. onRestoreStateObservable: Observable<Camera>;
  99221. /**
  99222. * Is this camera a part of a rig system?
  99223. */
  99224. isRigCamera: boolean;
  99225. /**
  99226. * If isRigCamera set to true this will be set with the parent camera.
  99227. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  99228. */
  99229. rigParent?: Camera;
  99230. /** @hidden */
  99231. _cameraRigParams: any;
  99232. /** @hidden */
  99233. _rigCameras: Camera[];
  99234. /** @hidden */
  99235. _rigPostProcess: Nullable<PostProcess>;
  99236. protected _webvrViewMatrix: Matrix;
  99237. /** @hidden */
  99238. _skipRendering: boolean;
  99239. /** @hidden */
  99240. _projectionMatrix: Matrix;
  99241. /** @hidden */
  99242. _postProcesses: Nullable<PostProcess>[];
  99243. /** @hidden */
  99244. _activeMeshes: SmartArray<AbstractMesh>;
  99245. protected _globalPosition: Vector3;
  99246. /** @hidden */
  99247. _computedViewMatrix: Matrix;
  99248. private _doNotComputeProjectionMatrix;
  99249. private _transformMatrix;
  99250. private _frustumPlanes;
  99251. private _refreshFrustumPlanes;
  99252. private _storedFov;
  99253. private _stateStored;
  99254. /**
  99255. * Instantiates a new camera object.
  99256. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  99257. * @see http://doc.babylonjs.com/features/cameras
  99258. * @param name Defines the name of the camera in the scene
  99259. * @param position Defines the position of the camera
  99260. * @param scene Defines the scene the camera belongs too
  99261. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  99262. */
  99263. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99264. /**
  99265. * Store current camera state (fov, position, etc..)
  99266. * @returns the camera
  99267. */
  99268. storeState(): Camera;
  99269. /**
  99270. * Restores the camera state values if it has been stored. You must call storeState() first
  99271. */
  99272. protected _restoreStateValues(): boolean;
  99273. /**
  99274. * Restored camera state. You must call storeState() first.
  99275. * @returns true if restored and false otherwise
  99276. */
  99277. restoreState(): boolean;
  99278. /**
  99279. * Gets the class name of the camera.
  99280. * @returns the class name
  99281. */
  99282. getClassName(): string;
  99283. /** @hidden */
  99284. readonly _isCamera: boolean;
  99285. /**
  99286. * Gets a string representation of the camera useful for debug purpose.
  99287. * @param fullDetails Defines that a more verboe level of logging is required
  99288. * @returns the string representation
  99289. */
  99290. toString(fullDetails?: boolean): string;
  99291. /**
  99292. * Gets the current world space position of the camera.
  99293. */
  99294. get globalPosition(): Vector3;
  99295. /**
  99296. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  99297. * @returns the active meshe list
  99298. */
  99299. getActiveMeshes(): SmartArray<AbstractMesh>;
  99300. /**
  99301. * Check whether a mesh is part of the current active mesh list of the camera
  99302. * @param mesh Defines the mesh to check
  99303. * @returns true if active, false otherwise
  99304. */
  99305. isActiveMesh(mesh: Mesh): boolean;
  99306. /**
  99307. * Is this camera ready to be used/rendered
  99308. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  99309. * @return true if the camera is ready
  99310. */
  99311. isReady(completeCheck?: boolean): boolean;
  99312. /** @hidden */
  99313. _initCache(): void;
  99314. /** @hidden */
  99315. _updateCache(ignoreParentClass?: boolean): void;
  99316. /** @hidden */
  99317. _isSynchronized(): boolean;
  99318. /** @hidden */
  99319. _isSynchronizedViewMatrix(): boolean;
  99320. /** @hidden */
  99321. _isSynchronizedProjectionMatrix(): boolean;
  99322. /**
  99323. * Attach the input controls to a specific dom element to get the input from.
  99324. * @param element Defines the element the controls should be listened from
  99325. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99326. */
  99327. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99328. /**
  99329. * Detach the current controls from the specified dom element.
  99330. * @param element Defines the element to stop listening the inputs from
  99331. */
  99332. detachControl(element: HTMLElement): void;
  99333. /**
  99334. * Update the camera state according to the different inputs gathered during the frame.
  99335. */
  99336. update(): void;
  99337. /** @hidden */
  99338. _checkInputs(): void;
  99339. /** @hidden */
  99340. get rigCameras(): Camera[];
  99341. /**
  99342. * Gets the post process used by the rig cameras
  99343. */
  99344. get rigPostProcess(): Nullable<PostProcess>;
  99345. /**
  99346. * Internal, gets the first post proces.
  99347. * @returns the first post process to be run on this camera.
  99348. */
  99349. _getFirstPostProcess(): Nullable<PostProcess>;
  99350. private _cascadePostProcessesToRigCams;
  99351. /**
  99352. * Attach a post process to the camera.
  99353. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  99354. * @param postProcess The post process to attach to the camera
  99355. * @param insertAt The position of the post process in case several of them are in use in the scene
  99356. * @returns the position the post process has been inserted at
  99357. */
  99358. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  99359. /**
  99360. * Detach a post process to the camera.
  99361. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  99362. * @param postProcess The post process to detach from the camera
  99363. */
  99364. detachPostProcess(postProcess: PostProcess): void;
  99365. /**
  99366. * Gets the current world matrix of the camera
  99367. */
  99368. getWorldMatrix(): Matrix;
  99369. /** @hidden */
  99370. _getViewMatrix(): Matrix;
  99371. /**
  99372. * Gets the current view matrix of the camera.
  99373. * @param force forces the camera to recompute the matrix without looking at the cached state
  99374. * @returns the view matrix
  99375. */
  99376. getViewMatrix(force?: boolean): Matrix;
  99377. /**
  99378. * Freeze the projection matrix.
  99379. * It will prevent the cache check of the camera projection compute and can speed up perf
  99380. * if no parameter of the camera are meant to change
  99381. * @param projection Defines manually a projection if necessary
  99382. */
  99383. freezeProjectionMatrix(projection?: Matrix): void;
  99384. /**
  99385. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  99386. */
  99387. unfreezeProjectionMatrix(): void;
  99388. /**
  99389. * Gets the current projection matrix of the camera.
  99390. * @param force forces the camera to recompute the matrix without looking at the cached state
  99391. * @returns the projection matrix
  99392. */
  99393. getProjectionMatrix(force?: boolean): Matrix;
  99394. /**
  99395. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  99396. * @returns a Matrix
  99397. */
  99398. getTransformationMatrix(): Matrix;
  99399. private _updateFrustumPlanes;
  99400. /**
  99401. * Checks if a cullable object (mesh...) is in the camera frustum
  99402. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  99403. * @param target The object to check
  99404. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  99405. * @returns true if the object is in frustum otherwise false
  99406. */
  99407. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  99408. /**
  99409. * Checks if a cullable object (mesh...) is in the camera frustum
  99410. * Unlike isInFrustum this cheks the full bounding box
  99411. * @param target The object to check
  99412. * @returns true if the object is in frustum otherwise false
  99413. */
  99414. isCompletelyInFrustum(target: ICullable): boolean;
  99415. /**
  99416. * Gets a ray in the forward direction from the camera.
  99417. * @param length Defines the length of the ray to create
  99418. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  99419. * @param origin Defines the start point of the ray which defaults to the camera position
  99420. * @returns the forward ray
  99421. */
  99422. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  99423. /**
  99424. * Releases resources associated with this node.
  99425. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99426. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99427. */
  99428. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99429. /** @hidden */
  99430. _isLeftCamera: boolean;
  99431. /**
  99432. * Gets the left camera of a rig setup in case of Rigged Camera
  99433. */
  99434. get isLeftCamera(): boolean;
  99435. /** @hidden */
  99436. _isRightCamera: boolean;
  99437. /**
  99438. * Gets the right camera of a rig setup in case of Rigged Camera
  99439. */
  99440. get isRightCamera(): boolean;
  99441. /**
  99442. * Gets the left camera of a rig setup in case of Rigged Camera
  99443. */
  99444. get leftCamera(): Nullable<FreeCamera>;
  99445. /**
  99446. * Gets the right camera of a rig setup in case of Rigged Camera
  99447. */
  99448. get rightCamera(): Nullable<FreeCamera>;
  99449. /**
  99450. * Gets the left camera target of a rig setup in case of Rigged Camera
  99451. * @returns the target position
  99452. */
  99453. getLeftTarget(): Nullable<Vector3>;
  99454. /**
  99455. * Gets the right camera target of a rig setup in case of Rigged Camera
  99456. * @returns the target position
  99457. */
  99458. getRightTarget(): Nullable<Vector3>;
  99459. /**
  99460. * @hidden
  99461. */
  99462. setCameraRigMode(mode: number, rigParams: any): void;
  99463. /** @hidden */
  99464. static _setStereoscopicRigMode(camera: Camera): void;
  99465. /** @hidden */
  99466. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  99467. /** @hidden */
  99468. static _setVRRigMode(camera: Camera, rigParams: any): void;
  99469. /** @hidden */
  99470. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  99471. /** @hidden */
  99472. _getVRProjectionMatrix(): Matrix;
  99473. protected _updateCameraRotationMatrix(): void;
  99474. protected _updateWebVRCameraRotationMatrix(): void;
  99475. /**
  99476. * This function MUST be overwritten by the different WebVR cameras available.
  99477. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  99478. * @hidden
  99479. */
  99480. _getWebVRProjectionMatrix(): Matrix;
  99481. /**
  99482. * This function MUST be overwritten by the different WebVR cameras available.
  99483. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  99484. * @hidden
  99485. */
  99486. _getWebVRViewMatrix(): Matrix;
  99487. /** @hidden */
  99488. setCameraRigParameter(name: string, value: any): void;
  99489. /**
  99490. * needs to be overridden by children so sub has required properties to be copied
  99491. * @hidden
  99492. */
  99493. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  99494. /**
  99495. * May need to be overridden by children
  99496. * @hidden
  99497. */
  99498. _updateRigCameras(): void;
  99499. /** @hidden */
  99500. _setupInputs(): void;
  99501. /**
  99502. * Serialiaze the camera setup to a json represention
  99503. * @returns the JSON representation
  99504. */
  99505. serialize(): any;
  99506. /**
  99507. * Clones the current camera.
  99508. * @param name The cloned camera name
  99509. * @returns the cloned camera
  99510. */
  99511. clone(name: string): Camera;
  99512. /**
  99513. * Gets the direction of the camera relative to a given local axis.
  99514. * @param localAxis Defines the reference axis to provide a relative direction.
  99515. * @return the direction
  99516. */
  99517. getDirection(localAxis: Vector3): Vector3;
  99518. /**
  99519. * Returns the current camera absolute rotation
  99520. */
  99521. get absoluteRotation(): Quaternion;
  99522. /**
  99523. * Gets the direction of the camera relative to a given local axis into a passed vector.
  99524. * @param localAxis Defines the reference axis to provide a relative direction.
  99525. * @param result Defines the vector to store the result in
  99526. */
  99527. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  99528. /**
  99529. * Gets a camera constructor for a given camera type
  99530. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  99531. * @param name The name of the camera the result will be able to instantiate
  99532. * @param scene The scene the result will construct the camera in
  99533. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  99534. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  99535. * @returns a factory method to construc the camera
  99536. */
  99537. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  99538. /**
  99539. * Compute the world matrix of the camera.
  99540. * @returns the camera world matrix
  99541. */
  99542. computeWorldMatrix(): Matrix;
  99543. /**
  99544. * Parse a JSON and creates the camera from the parsed information
  99545. * @param parsedCamera The JSON to parse
  99546. * @param scene The scene to instantiate the camera in
  99547. * @returns the newly constructed camera
  99548. */
  99549. static Parse(parsedCamera: any, scene: Scene): Camera;
  99550. }
  99551. }
  99552. declare module BABYLON {
  99553. /**
  99554. * Class containing static functions to help procedurally build meshes
  99555. */
  99556. export class DiscBuilder {
  99557. /**
  99558. * Creates a plane polygonal mesh. By default, this is a disc
  99559. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  99560. * * 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
  99561. * * 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
  99562. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99563. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99564. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99565. * @param name defines the name of the mesh
  99566. * @param options defines the options used to create the mesh
  99567. * @param scene defines the hosting scene
  99568. * @returns the plane polygonal mesh
  99569. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  99570. */
  99571. static CreateDisc(name: string, options: {
  99572. radius?: number;
  99573. tessellation?: number;
  99574. arc?: number;
  99575. updatable?: boolean;
  99576. sideOrientation?: number;
  99577. frontUVs?: Vector4;
  99578. backUVs?: Vector4;
  99579. }, scene?: Nullable<Scene>): Mesh;
  99580. }
  99581. }
  99582. declare module BABYLON {
  99583. /**
  99584. * This represents all the required information to add a fresnel effect on a material:
  99585. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99586. */
  99587. export class FresnelParameters {
  99588. private _isEnabled;
  99589. /**
  99590. * Define if the fresnel effect is enable or not.
  99591. */
  99592. get isEnabled(): boolean;
  99593. set isEnabled(value: boolean);
  99594. /**
  99595. * Define the color used on edges (grazing angle)
  99596. */
  99597. leftColor: Color3;
  99598. /**
  99599. * Define the color used on center
  99600. */
  99601. rightColor: Color3;
  99602. /**
  99603. * Define bias applied to computed fresnel term
  99604. */
  99605. bias: number;
  99606. /**
  99607. * Defined the power exponent applied to fresnel term
  99608. */
  99609. power: number;
  99610. /**
  99611. * Clones the current fresnel and its valuues
  99612. * @returns a clone fresnel configuration
  99613. */
  99614. clone(): FresnelParameters;
  99615. /**
  99616. * Serializes the current fresnel parameters to a JSON representation.
  99617. * @return the JSON serialization
  99618. */
  99619. serialize(): any;
  99620. /**
  99621. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  99622. * @param parsedFresnelParameters Define the JSON representation
  99623. * @returns the parsed parameters
  99624. */
  99625. static Parse(parsedFresnelParameters: any): FresnelParameters;
  99626. }
  99627. }
  99628. declare module BABYLON {
  99629. /**
  99630. * Base class of materials working in push mode in babylon JS
  99631. * @hidden
  99632. */
  99633. export class PushMaterial extends Material {
  99634. protected _activeEffect: Effect;
  99635. protected _normalMatrix: Matrix;
  99636. /**
  99637. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  99638. * This means that the material can keep using a previous shader while a new one is being compiled.
  99639. * This is mostly used when shader parallel compilation is supported (true by default)
  99640. */
  99641. allowShaderHotSwapping: boolean;
  99642. constructor(name: string, scene: Scene);
  99643. getEffect(): Effect;
  99644. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  99645. /**
  99646. * Binds the given world matrix to the active effect
  99647. *
  99648. * @param world the matrix to bind
  99649. */
  99650. bindOnlyWorldMatrix(world: Matrix): void;
  99651. /**
  99652. * Binds the given normal matrix to the active effect
  99653. *
  99654. * @param normalMatrix the matrix to bind
  99655. */
  99656. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  99657. bind(world: Matrix, mesh?: Mesh): void;
  99658. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  99659. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  99660. }
  99661. }
  99662. declare module BABYLON {
  99663. /**
  99664. * This groups all the flags used to control the materials channel.
  99665. */
  99666. export class MaterialFlags {
  99667. private static _DiffuseTextureEnabled;
  99668. /**
  99669. * Are diffuse textures enabled in the application.
  99670. */
  99671. static get DiffuseTextureEnabled(): boolean;
  99672. static set DiffuseTextureEnabled(value: boolean);
  99673. private static _AmbientTextureEnabled;
  99674. /**
  99675. * Are ambient textures enabled in the application.
  99676. */
  99677. static get AmbientTextureEnabled(): boolean;
  99678. static set AmbientTextureEnabled(value: boolean);
  99679. private static _OpacityTextureEnabled;
  99680. /**
  99681. * Are opacity textures enabled in the application.
  99682. */
  99683. static get OpacityTextureEnabled(): boolean;
  99684. static set OpacityTextureEnabled(value: boolean);
  99685. private static _ReflectionTextureEnabled;
  99686. /**
  99687. * Are reflection textures enabled in the application.
  99688. */
  99689. static get ReflectionTextureEnabled(): boolean;
  99690. static set ReflectionTextureEnabled(value: boolean);
  99691. private static _EmissiveTextureEnabled;
  99692. /**
  99693. * Are emissive textures enabled in the application.
  99694. */
  99695. static get EmissiveTextureEnabled(): boolean;
  99696. static set EmissiveTextureEnabled(value: boolean);
  99697. private static _SpecularTextureEnabled;
  99698. /**
  99699. * Are specular textures enabled in the application.
  99700. */
  99701. static get SpecularTextureEnabled(): boolean;
  99702. static set SpecularTextureEnabled(value: boolean);
  99703. private static _BumpTextureEnabled;
  99704. /**
  99705. * Are bump textures enabled in the application.
  99706. */
  99707. static get BumpTextureEnabled(): boolean;
  99708. static set BumpTextureEnabled(value: boolean);
  99709. private static _LightmapTextureEnabled;
  99710. /**
  99711. * Are lightmap textures enabled in the application.
  99712. */
  99713. static get LightmapTextureEnabled(): boolean;
  99714. static set LightmapTextureEnabled(value: boolean);
  99715. private static _RefractionTextureEnabled;
  99716. /**
  99717. * Are refraction textures enabled in the application.
  99718. */
  99719. static get RefractionTextureEnabled(): boolean;
  99720. static set RefractionTextureEnabled(value: boolean);
  99721. private static _ColorGradingTextureEnabled;
  99722. /**
  99723. * Are color grading textures enabled in the application.
  99724. */
  99725. static get ColorGradingTextureEnabled(): boolean;
  99726. static set ColorGradingTextureEnabled(value: boolean);
  99727. private static _FresnelEnabled;
  99728. /**
  99729. * Are fresnels enabled in the application.
  99730. */
  99731. static get FresnelEnabled(): boolean;
  99732. static set FresnelEnabled(value: boolean);
  99733. private static _ClearCoatTextureEnabled;
  99734. /**
  99735. * Are clear coat textures enabled in the application.
  99736. */
  99737. static get ClearCoatTextureEnabled(): boolean;
  99738. static set ClearCoatTextureEnabled(value: boolean);
  99739. private static _ClearCoatBumpTextureEnabled;
  99740. /**
  99741. * Are clear coat bump textures enabled in the application.
  99742. */
  99743. static get ClearCoatBumpTextureEnabled(): boolean;
  99744. static set ClearCoatBumpTextureEnabled(value: boolean);
  99745. private static _ClearCoatTintTextureEnabled;
  99746. /**
  99747. * Are clear coat tint textures enabled in the application.
  99748. */
  99749. static get ClearCoatTintTextureEnabled(): boolean;
  99750. static set ClearCoatTintTextureEnabled(value: boolean);
  99751. private static _SheenTextureEnabled;
  99752. /**
  99753. * Are sheen textures enabled in the application.
  99754. */
  99755. static get SheenTextureEnabled(): boolean;
  99756. static set SheenTextureEnabled(value: boolean);
  99757. private static _AnisotropicTextureEnabled;
  99758. /**
  99759. * Are anisotropic textures enabled in the application.
  99760. */
  99761. static get AnisotropicTextureEnabled(): boolean;
  99762. static set AnisotropicTextureEnabled(value: boolean);
  99763. private static _ThicknessTextureEnabled;
  99764. /**
  99765. * Are thickness textures enabled in the application.
  99766. */
  99767. static get ThicknessTextureEnabled(): boolean;
  99768. static set ThicknessTextureEnabled(value: boolean);
  99769. }
  99770. }
  99771. declare module BABYLON {
  99772. /** @hidden */
  99773. export var defaultFragmentDeclaration: {
  99774. name: string;
  99775. shader: string;
  99776. };
  99777. }
  99778. declare module BABYLON {
  99779. /** @hidden */
  99780. export var defaultUboDeclaration: {
  99781. name: string;
  99782. shader: string;
  99783. };
  99784. }
  99785. declare module BABYLON {
  99786. /** @hidden */
  99787. export var lightFragmentDeclaration: {
  99788. name: string;
  99789. shader: string;
  99790. };
  99791. }
  99792. declare module BABYLON {
  99793. /** @hidden */
  99794. export var lightUboDeclaration: {
  99795. name: string;
  99796. shader: string;
  99797. };
  99798. }
  99799. declare module BABYLON {
  99800. /** @hidden */
  99801. export var lightsFragmentFunctions: {
  99802. name: string;
  99803. shader: string;
  99804. };
  99805. }
  99806. declare module BABYLON {
  99807. /** @hidden */
  99808. export var shadowsFragmentFunctions: {
  99809. name: string;
  99810. shader: string;
  99811. };
  99812. }
  99813. declare module BABYLON {
  99814. /** @hidden */
  99815. export var fresnelFunction: {
  99816. name: string;
  99817. shader: string;
  99818. };
  99819. }
  99820. declare module BABYLON {
  99821. /** @hidden */
  99822. export var reflectionFunction: {
  99823. name: string;
  99824. shader: string;
  99825. };
  99826. }
  99827. declare module BABYLON {
  99828. /** @hidden */
  99829. export var bumpFragmentFunctions: {
  99830. name: string;
  99831. shader: string;
  99832. };
  99833. }
  99834. declare module BABYLON {
  99835. /** @hidden */
  99836. export var logDepthDeclaration: {
  99837. name: string;
  99838. shader: string;
  99839. };
  99840. }
  99841. declare module BABYLON {
  99842. /** @hidden */
  99843. export var bumpFragment: {
  99844. name: string;
  99845. shader: string;
  99846. };
  99847. }
  99848. declare module BABYLON {
  99849. /** @hidden */
  99850. export var depthPrePass: {
  99851. name: string;
  99852. shader: string;
  99853. };
  99854. }
  99855. declare module BABYLON {
  99856. /** @hidden */
  99857. export var lightFragment: {
  99858. name: string;
  99859. shader: string;
  99860. };
  99861. }
  99862. declare module BABYLON {
  99863. /** @hidden */
  99864. export var logDepthFragment: {
  99865. name: string;
  99866. shader: string;
  99867. };
  99868. }
  99869. declare module BABYLON {
  99870. /** @hidden */
  99871. export var defaultPixelShader: {
  99872. name: string;
  99873. shader: string;
  99874. };
  99875. }
  99876. declare module BABYLON {
  99877. /** @hidden */
  99878. export var defaultVertexDeclaration: {
  99879. name: string;
  99880. shader: string;
  99881. };
  99882. }
  99883. declare module BABYLON {
  99884. /** @hidden */
  99885. export var bumpVertexDeclaration: {
  99886. name: string;
  99887. shader: string;
  99888. };
  99889. }
  99890. declare module BABYLON {
  99891. /** @hidden */
  99892. export var bumpVertex: {
  99893. name: string;
  99894. shader: string;
  99895. };
  99896. }
  99897. declare module BABYLON {
  99898. /** @hidden */
  99899. export var fogVertex: {
  99900. name: string;
  99901. shader: string;
  99902. };
  99903. }
  99904. declare module BABYLON {
  99905. /** @hidden */
  99906. export var shadowsVertex: {
  99907. name: string;
  99908. shader: string;
  99909. };
  99910. }
  99911. declare module BABYLON {
  99912. /** @hidden */
  99913. export var pointCloudVertex: {
  99914. name: string;
  99915. shader: string;
  99916. };
  99917. }
  99918. declare module BABYLON {
  99919. /** @hidden */
  99920. export var logDepthVertex: {
  99921. name: string;
  99922. shader: string;
  99923. };
  99924. }
  99925. declare module BABYLON {
  99926. /** @hidden */
  99927. export var defaultVertexShader: {
  99928. name: string;
  99929. shader: string;
  99930. };
  99931. }
  99932. declare module BABYLON {
  99933. /** @hidden */
  99934. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  99935. MAINUV1: boolean;
  99936. MAINUV2: boolean;
  99937. DIFFUSE: boolean;
  99938. DIFFUSEDIRECTUV: number;
  99939. AMBIENT: boolean;
  99940. AMBIENTDIRECTUV: number;
  99941. OPACITY: boolean;
  99942. OPACITYDIRECTUV: number;
  99943. OPACITYRGB: boolean;
  99944. REFLECTION: boolean;
  99945. EMISSIVE: boolean;
  99946. EMISSIVEDIRECTUV: number;
  99947. SPECULAR: boolean;
  99948. SPECULARDIRECTUV: number;
  99949. BUMP: boolean;
  99950. BUMPDIRECTUV: number;
  99951. PARALLAX: boolean;
  99952. PARALLAXOCCLUSION: boolean;
  99953. SPECULAROVERALPHA: boolean;
  99954. CLIPPLANE: boolean;
  99955. CLIPPLANE2: boolean;
  99956. CLIPPLANE3: boolean;
  99957. CLIPPLANE4: boolean;
  99958. CLIPPLANE5: boolean;
  99959. CLIPPLANE6: boolean;
  99960. ALPHATEST: boolean;
  99961. DEPTHPREPASS: boolean;
  99962. ALPHAFROMDIFFUSE: boolean;
  99963. POINTSIZE: boolean;
  99964. FOG: boolean;
  99965. SPECULARTERM: boolean;
  99966. DIFFUSEFRESNEL: boolean;
  99967. OPACITYFRESNEL: boolean;
  99968. REFLECTIONFRESNEL: boolean;
  99969. REFRACTIONFRESNEL: boolean;
  99970. EMISSIVEFRESNEL: boolean;
  99971. FRESNEL: boolean;
  99972. NORMAL: boolean;
  99973. UV1: boolean;
  99974. UV2: boolean;
  99975. VERTEXCOLOR: boolean;
  99976. VERTEXALPHA: boolean;
  99977. NUM_BONE_INFLUENCERS: number;
  99978. BonesPerMesh: number;
  99979. BONETEXTURE: boolean;
  99980. INSTANCES: boolean;
  99981. GLOSSINESS: boolean;
  99982. ROUGHNESS: boolean;
  99983. EMISSIVEASILLUMINATION: boolean;
  99984. LINKEMISSIVEWITHDIFFUSE: boolean;
  99985. REFLECTIONFRESNELFROMSPECULAR: boolean;
  99986. LIGHTMAP: boolean;
  99987. LIGHTMAPDIRECTUV: number;
  99988. OBJECTSPACE_NORMALMAP: boolean;
  99989. USELIGHTMAPASSHADOWMAP: boolean;
  99990. REFLECTIONMAP_3D: boolean;
  99991. REFLECTIONMAP_SPHERICAL: boolean;
  99992. REFLECTIONMAP_PLANAR: boolean;
  99993. REFLECTIONMAP_CUBIC: boolean;
  99994. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  99995. REFLECTIONMAP_PROJECTION: boolean;
  99996. REFLECTIONMAP_SKYBOX: boolean;
  99997. REFLECTIONMAP_EXPLICIT: boolean;
  99998. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  99999. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  100000. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  100001. INVERTCUBICMAP: boolean;
  100002. LOGARITHMICDEPTH: boolean;
  100003. REFRACTION: boolean;
  100004. REFRACTIONMAP_3D: boolean;
  100005. REFLECTIONOVERALPHA: boolean;
  100006. TWOSIDEDLIGHTING: boolean;
  100007. SHADOWFLOAT: boolean;
  100008. MORPHTARGETS: boolean;
  100009. MORPHTARGETS_NORMAL: boolean;
  100010. MORPHTARGETS_TANGENT: boolean;
  100011. MORPHTARGETS_UV: boolean;
  100012. NUM_MORPH_INFLUENCERS: number;
  100013. NONUNIFORMSCALING: boolean;
  100014. PREMULTIPLYALPHA: boolean;
  100015. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  100016. ALPHABLEND: boolean;
  100017. IMAGEPROCESSING: boolean;
  100018. VIGNETTE: boolean;
  100019. VIGNETTEBLENDMODEMULTIPLY: boolean;
  100020. VIGNETTEBLENDMODEOPAQUE: boolean;
  100021. TONEMAPPING: boolean;
  100022. TONEMAPPING_ACES: boolean;
  100023. CONTRAST: boolean;
  100024. COLORCURVES: boolean;
  100025. COLORGRADING: boolean;
  100026. COLORGRADING3D: boolean;
  100027. SAMPLER3DGREENDEPTH: boolean;
  100028. SAMPLER3DBGRMAP: boolean;
  100029. IMAGEPROCESSINGPOSTPROCESS: boolean;
  100030. MULTIVIEW: boolean;
  100031. /**
  100032. * If the reflection texture on this material is in linear color space
  100033. * @hidden
  100034. */
  100035. IS_REFLECTION_LINEAR: boolean;
  100036. /**
  100037. * If the refraction texture on this material is in linear color space
  100038. * @hidden
  100039. */
  100040. IS_REFRACTION_LINEAR: boolean;
  100041. EXPOSURE: boolean;
  100042. constructor();
  100043. setReflectionMode(modeToEnable: string): void;
  100044. }
  100045. /**
  100046. * This is the default material used in Babylon. It is the best trade off between quality
  100047. * and performances.
  100048. * @see http://doc.babylonjs.com/babylon101/materials
  100049. */
  100050. export class StandardMaterial extends PushMaterial {
  100051. private _diffuseTexture;
  100052. /**
  100053. * The basic texture of the material as viewed under a light.
  100054. */
  100055. diffuseTexture: Nullable<BaseTexture>;
  100056. private _ambientTexture;
  100057. /**
  100058. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  100059. */
  100060. ambientTexture: Nullable<BaseTexture>;
  100061. private _opacityTexture;
  100062. /**
  100063. * Define the transparency of the material from a texture.
  100064. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  100065. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  100066. */
  100067. opacityTexture: Nullable<BaseTexture>;
  100068. private _reflectionTexture;
  100069. /**
  100070. * Define the texture used to display the reflection.
  100071. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100072. */
  100073. reflectionTexture: Nullable<BaseTexture>;
  100074. private _emissiveTexture;
  100075. /**
  100076. * Define texture of the material as if self lit.
  100077. * This will be mixed in the final result even in the absence of light.
  100078. */
  100079. emissiveTexture: Nullable<BaseTexture>;
  100080. private _specularTexture;
  100081. /**
  100082. * Define how the color and intensity of the highlight given by the light in the material.
  100083. */
  100084. specularTexture: Nullable<BaseTexture>;
  100085. private _bumpTexture;
  100086. /**
  100087. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  100088. * 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.
  100089. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  100090. */
  100091. bumpTexture: Nullable<BaseTexture>;
  100092. private _lightmapTexture;
  100093. /**
  100094. * Complex lighting can be computationally expensive to compute at runtime.
  100095. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  100096. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  100097. */
  100098. lightmapTexture: Nullable<BaseTexture>;
  100099. private _refractionTexture;
  100100. /**
  100101. * Define the texture used to display the refraction.
  100102. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100103. */
  100104. refractionTexture: Nullable<BaseTexture>;
  100105. /**
  100106. * The color of the material lit by the environmental background lighting.
  100107. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  100108. */
  100109. ambientColor: Color3;
  100110. /**
  100111. * The basic color of the material as viewed under a light.
  100112. */
  100113. diffuseColor: Color3;
  100114. /**
  100115. * Define how the color and intensity of the highlight given by the light in the material.
  100116. */
  100117. specularColor: Color3;
  100118. /**
  100119. * Define the color of the material as if self lit.
  100120. * This will be mixed in the final result even in the absence of light.
  100121. */
  100122. emissiveColor: Color3;
  100123. /**
  100124. * Defines how sharp are the highlights in the material.
  100125. * The bigger the value the sharper giving a more glossy feeling to the result.
  100126. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  100127. */
  100128. specularPower: number;
  100129. private _useAlphaFromDiffuseTexture;
  100130. /**
  100131. * Does the transparency come from the diffuse texture alpha channel.
  100132. */
  100133. useAlphaFromDiffuseTexture: boolean;
  100134. private _useEmissiveAsIllumination;
  100135. /**
  100136. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  100137. */
  100138. useEmissiveAsIllumination: boolean;
  100139. private _linkEmissiveWithDiffuse;
  100140. /**
  100141. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  100142. * the emissive level when the final color is close to one.
  100143. */
  100144. linkEmissiveWithDiffuse: boolean;
  100145. private _useSpecularOverAlpha;
  100146. /**
  100147. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  100148. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  100149. */
  100150. useSpecularOverAlpha: boolean;
  100151. private _useReflectionOverAlpha;
  100152. /**
  100153. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  100154. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  100155. */
  100156. useReflectionOverAlpha: boolean;
  100157. private _disableLighting;
  100158. /**
  100159. * Does lights from the scene impacts this material.
  100160. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  100161. */
  100162. disableLighting: boolean;
  100163. private _useObjectSpaceNormalMap;
  100164. /**
  100165. * Allows using an object space normal map (instead of tangent space).
  100166. */
  100167. useObjectSpaceNormalMap: boolean;
  100168. private _useParallax;
  100169. /**
  100170. * Is parallax enabled or not.
  100171. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  100172. */
  100173. useParallax: boolean;
  100174. private _useParallaxOcclusion;
  100175. /**
  100176. * Is parallax occlusion enabled or not.
  100177. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  100178. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  100179. */
  100180. useParallaxOcclusion: boolean;
  100181. /**
  100182. * 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.
  100183. */
  100184. parallaxScaleBias: number;
  100185. private _roughness;
  100186. /**
  100187. * Helps to define how blurry the reflections should appears in the material.
  100188. */
  100189. roughness: number;
  100190. /**
  100191. * In case of refraction, define the value of the index of refraction.
  100192. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100193. */
  100194. indexOfRefraction: number;
  100195. /**
  100196. * Invert the refraction texture alongside the y axis.
  100197. * It can be useful with procedural textures or probe for instance.
  100198. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100199. */
  100200. invertRefractionY: boolean;
  100201. /**
  100202. * Defines the alpha limits in alpha test mode.
  100203. */
  100204. alphaCutOff: number;
  100205. private _useLightmapAsShadowmap;
  100206. /**
  100207. * In case of light mapping, define whether the map contains light or shadow informations.
  100208. */
  100209. useLightmapAsShadowmap: boolean;
  100210. private _diffuseFresnelParameters;
  100211. /**
  100212. * Define the diffuse fresnel parameters of the material.
  100213. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100214. */
  100215. diffuseFresnelParameters: FresnelParameters;
  100216. private _opacityFresnelParameters;
  100217. /**
  100218. * Define the opacity fresnel parameters of the material.
  100219. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100220. */
  100221. opacityFresnelParameters: FresnelParameters;
  100222. private _reflectionFresnelParameters;
  100223. /**
  100224. * Define the reflection fresnel parameters of the material.
  100225. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100226. */
  100227. reflectionFresnelParameters: FresnelParameters;
  100228. private _refractionFresnelParameters;
  100229. /**
  100230. * Define the refraction fresnel parameters of the material.
  100231. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100232. */
  100233. refractionFresnelParameters: FresnelParameters;
  100234. private _emissiveFresnelParameters;
  100235. /**
  100236. * Define the emissive fresnel parameters of the material.
  100237. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100238. */
  100239. emissiveFresnelParameters: FresnelParameters;
  100240. private _useReflectionFresnelFromSpecular;
  100241. /**
  100242. * If true automatically deducts the fresnels values from the material specularity.
  100243. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100244. */
  100245. useReflectionFresnelFromSpecular: boolean;
  100246. private _useGlossinessFromSpecularMapAlpha;
  100247. /**
  100248. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  100249. */
  100250. useGlossinessFromSpecularMapAlpha: boolean;
  100251. private _maxSimultaneousLights;
  100252. /**
  100253. * Defines the maximum number of lights that can be used in the material
  100254. */
  100255. maxSimultaneousLights: number;
  100256. private _invertNormalMapX;
  100257. /**
  100258. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  100259. */
  100260. invertNormalMapX: boolean;
  100261. private _invertNormalMapY;
  100262. /**
  100263. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  100264. */
  100265. invertNormalMapY: boolean;
  100266. private _twoSidedLighting;
  100267. /**
  100268. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  100269. */
  100270. twoSidedLighting: boolean;
  100271. /**
  100272. * Default configuration related to image processing available in the standard Material.
  100273. */
  100274. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100275. /**
  100276. * Gets the image processing configuration used either in this material.
  100277. */
  100278. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  100279. /**
  100280. * Sets the Default image processing configuration used either in the this material.
  100281. *
  100282. * If sets to null, the scene one is in use.
  100283. */
  100284. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  100285. /**
  100286. * Keep track of the image processing observer to allow dispose and replace.
  100287. */
  100288. private _imageProcessingObserver;
  100289. /**
  100290. * Attaches a new image processing configuration to the Standard Material.
  100291. * @param configuration
  100292. */
  100293. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  100294. /**
  100295. * Gets wether the color curves effect is enabled.
  100296. */
  100297. get cameraColorCurvesEnabled(): boolean;
  100298. /**
  100299. * Sets wether the color curves effect is enabled.
  100300. */
  100301. set cameraColorCurvesEnabled(value: boolean);
  100302. /**
  100303. * Gets wether the color grading effect is enabled.
  100304. */
  100305. get cameraColorGradingEnabled(): boolean;
  100306. /**
  100307. * Gets wether the color grading effect is enabled.
  100308. */
  100309. set cameraColorGradingEnabled(value: boolean);
  100310. /**
  100311. * Gets wether tonemapping is enabled or not.
  100312. */
  100313. get cameraToneMappingEnabled(): boolean;
  100314. /**
  100315. * Sets wether tonemapping is enabled or not
  100316. */
  100317. set cameraToneMappingEnabled(value: boolean);
  100318. /**
  100319. * The camera exposure used on this material.
  100320. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100321. * This corresponds to a photographic exposure.
  100322. */
  100323. get cameraExposure(): number;
  100324. /**
  100325. * The camera exposure used on this material.
  100326. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100327. * This corresponds to a photographic exposure.
  100328. */
  100329. set cameraExposure(value: number);
  100330. /**
  100331. * Gets The camera contrast used on this material.
  100332. */
  100333. get cameraContrast(): number;
  100334. /**
  100335. * Sets The camera contrast used on this material.
  100336. */
  100337. set cameraContrast(value: number);
  100338. /**
  100339. * Gets the Color Grading 2D Lookup Texture.
  100340. */
  100341. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  100342. /**
  100343. * Sets the Color Grading 2D Lookup Texture.
  100344. */
  100345. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  100346. /**
  100347. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100348. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100349. * 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;
  100350. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100351. */
  100352. get cameraColorCurves(): Nullable<ColorCurves>;
  100353. /**
  100354. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100355. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100356. * 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;
  100357. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100358. */
  100359. set cameraColorCurves(value: Nullable<ColorCurves>);
  100360. /**
  100361. * Custom callback helping to override the default shader used in the material.
  100362. */
  100363. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  100364. protected _renderTargets: SmartArray<RenderTargetTexture>;
  100365. protected _worldViewProjectionMatrix: Matrix;
  100366. protected _globalAmbientColor: Color3;
  100367. protected _useLogarithmicDepth: boolean;
  100368. protected _rebuildInParallel: boolean;
  100369. /**
  100370. * Instantiates a new standard material.
  100371. * This is the default material used in Babylon. It is the best trade off between quality
  100372. * and performances.
  100373. * @see http://doc.babylonjs.com/babylon101/materials
  100374. * @param name Define the name of the material in the scene
  100375. * @param scene Define the scene the material belong to
  100376. */
  100377. constructor(name: string, scene: Scene);
  100378. /**
  100379. * Gets a boolean indicating that current material needs to register RTT
  100380. */
  100381. get hasRenderTargetTextures(): boolean;
  100382. /**
  100383. * Gets the current class name of the material e.g. "StandardMaterial"
  100384. * Mainly use in serialization.
  100385. * @returns the class name
  100386. */
  100387. getClassName(): string;
  100388. /**
  100389. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  100390. * You can try switching to logarithmic depth.
  100391. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  100392. */
  100393. get useLogarithmicDepth(): boolean;
  100394. set useLogarithmicDepth(value: boolean);
  100395. /**
  100396. * Specifies if the material will require alpha blending
  100397. * @returns a boolean specifying if alpha blending is needed
  100398. */
  100399. needAlphaBlending(): boolean;
  100400. /**
  100401. * Specifies if this material should be rendered in alpha test mode
  100402. * @returns a boolean specifying if an alpha test is needed.
  100403. */
  100404. needAlphaTesting(): boolean;
  100405. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  100406. /**
  100407. * Get the texture used for alpha test purpose.
  100408. * @returns the diffuse texture in case of the standard material.
  100409. */
  100410. getAlphaTestTexture(): Nullable<BaseTexture>;
  100411. /**
  100412. * Get if the submesh is ready to be used and all its information available.
  100413. * Child classes can use it to update shaders
  100414. * @param mesh defines the mesh to check
  100415. * @param subMesh defines which submesh to check
  100416. * @param useInstances specifies that instances should be used
  100417. * @returns a boolean indicating that the submesh is ready or not
  100418. */
  100419. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100420. /**
  100421. * Builds the material UBO layouts.
  100422. * Used internally during the effect preparation.
  100423. */
  100424. buildUniformLayout(): void;
  100425. /**
  100426. * Unbinds the material from the mesh
  100427. */
  100428. unbind(): void;
  100429. /**
  100430. * Binds the submesh to this material by preparing the effect and shader to draw
  100431. * @param world defines the world transformation matrix
  100432. * @param mesh defines the mesh containing the submesh
  100433. * @param subMesh defines the submesh to bind the material to
  100434. */
  100435. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100436. /**
  100437. * Get the list of animatables in the material.
  100438. * @returns the list of animatables object used in the material
  100439. */
  100440. getAnimatables(): IAnimatable[];
  100441. /**
  100442. * Gets the active textures from the material
  100443. * @returns an array of textures
  100444. */
  100445. getActiveTextures(): BaseTexture[];
  100446. /**
  100447. * Specifies if the material uses a texture
  100448. * @param texture defines the texture to check against the material
  100449. * @returns a boolean specifying if the material uses the texture
  100450. */
  100451. hasTexture(texture: BaseTexture): boolean;
  100452. /**
  100453. * Disposes the material
  100454. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  100455. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  100456. */
  100457. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  100458. /**
  100459. * Makes a duplicate of the material, and gives it a new name
  100460. * @param name defines the new name for the duplicated material
  100461. * @returns the cloned material
  100462. */
  100463. clone(name: string): StandardMaterial;
  100464. /**
  100465. * Serializes this material in a JSON representation
  100466. * @returns the serialized material object
  100467. */
  100468. serialize(): any;
  100469. /**
  100470. * Creates a standard material from parsed material data
  100471. * @param source defines the JSON representation of the material
  100472. * @param scene defines the hosting scene
  100473. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100474. * @returns a new standard material
  100475. */
  100476. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  100477. /**
  100478. * Are diffuse textures enabled in the application.
  100479. */
  100480. static get DiffuseTextureEnabled(): boolean;
  100481. static set DiffuseTextureEnabled(value: boolean);
  100482. /**
  100483. * Are ambient textures enabled in the application.
  100484. */
  100485. static get AmbientTextureEnabled(): boolean;
  100486. static set AmbientTextureEnabled(value: boolean);
  100487. /**
  100488. * Are opacity textures enabled in the application.
  100489. */
  100490. static get OpacityTextureEnabled(): boolean;
  100491. static set OpacityTextureEnabled(value: boolean);
  100492. /**
  100493. * Are reflection textures enabled in the application.
  100494. */
  100495. static get ReflectionTextureEnabled(): boolean;
  100496. static set ReflectionTextureEnabled(value: boolean);
  100497. /**
  100498. * Are emissive textures enabled in the application.
  100499. */
  100500. static get EmissiveTextureEnabled(): boolean;
  100501. static set EmissiveTextureEnabled(value: boolean);
  100502. /**
  100503. * Are specular textures enabled in the application.
  100504. */
  100505. static get SpecularTextureEnabled(): boolean;
  100506. static set SpecularTextureEnabled(value: boolean);
  100507. /**
  100508. * Are bump textures enabled in the application.
  100509. */
  100510. static get BumpTextureEnabled(): boolean;
  100511. static set BumpTextureEnabled(value: boolean);
  100512. /**
  100513. * Are lightmap textures enabled in the application.
  100514. */
  100515. static get LightmapTextureEnabled(): boolean;
  100516. static set LightmapTextureEnabled(value: boolean);
  100517. /**
  100518. * Are refraction textures enabled in the application.
  100519. */
  100520. static get RefractionTextureEnabled(): boolean;
  100521. static set RefractionTextureEnabled(value: boolean);
  100522. /**
  100523. * Are color grading textures enabled in the application.
  100524. */
  100525. static get ColorGradingTextureEnabled(): boolean;
  100526. static set ColorGradingTextureEnabled(value: boolean);
  100527. /**
  100528. * Are fresnels enabled in the application.
  100529. */
  100530. static get FresnelEnabled(): boolean;
  100531. static set FresnelEnabled(value: boolean);
  100532. }
  100533. }
  100534. declare module BABYLON {
  100535. /**
  100536. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  100537. *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.
  100538. * The SPS is also a particle system. It provides some methods to manage the particles.
  100539. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  100540. *
  100541. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  100542. */
  100543. export class SolidParticleSystem implements IDisposable {
  100544. /**
  100545. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  100546. * Example : var p = SPS.particles[i];
  100547. */
  100548. particles: SolidParticle[];
  100549. /**
  100550. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  100551. */
  100552. nbParticles: number;
  100553. /**
  100554. * If the particles must ever face the camera (default false). Useful for planar particles.
  100555. */
  100556. billboard: boolean;
  100557. /**
  100558. * Recompute normals when adding a shape
  100559. */
  100560. recomputeNormals: boolean;
  100561. /**
  100562. * This a counter ofr your own usage. It's not set by any SPS functions.
  100563. */
  100564. counter: number;
  100565. /**
  100566. * The SPS name. This name is also given to the underlying mesh.
  100567. */
  100568. name: string;
  100569. /**
  100570. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  100571. */
  100572. mesh: Mesh;
  100573. /**
  100574. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  100575. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  100576. */
  100577. vars: any;
  100578. /**
  100579. * This array is populated when the SPS is set as 'pickable'.
  100580. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  100581. * Each element of this array is an object `{idx: int, faceId: int}`.
  100582. * `idx` is the picked particle index in the `SPS.particles` array
  100583. * `faceId` is the picked face index counted within this particle.
  100584. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  100585. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  100586. * Use the method SPS.pickedParticle(pickingInfo) instead.
  100587. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  100588. */
  100589. pickedParticles: {
  100590. idx: number;
  100591. faceId: number;
  100592. }[];
  100593. /**
  100594. * This array is populated when the SPS is set as 'pickable'
  100595. * Each key of this array is a submesh index.
  100596. * Each element of this array is a second array defined like this :
  100597. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  100598. * Each element of this second array is an object `{idx: int, faceId: int}`.
  100599. * `idx` is the picked particle index in the `SPS.particles` array
  100600. * `faceId` is the picked face index counted within this particle.
  100601. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  100602. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  100603. */
  100604. pickedBySubMesh: {
  100605. idx: number;
  100606. faceId: number;
  100607. }[][];
  100608. /**
  100609. * This array is populated when `enableDepthSort` is set to true.
  100610. * Each element of this array is an instance of the class DepthSortedParticle.
  100611. */
  100612. depthSortedParticles: DepthSortedParticle[];
  100613. /**
  100614. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  100615. * @hidden
  100616. */
  100617. _bSphereOnly: boolean;
  100618. /**
  100619. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  100620. * @hidden
  100621. */
  100622. _bSphereRadiusFactor: number;
  100623. private _scene;
  100624. private _positions;
  100625. private _indices;
  100626. private _normals;
  100627. private _colors;
  100628. private _uvs;
  100629. private _indices32;
  100630. private _positions32;
  100631. private _normals32;
  100632. private _fixedNormal32;
  100633. private _colors32;
  100634. private _uvs32;
  100635. private _index;
  100636. private _updatable;
  100637. private _pickable;
  100638. private _isVisibilityBoxLocked;
  100639. private _alwaysVisible;
  100640. private _depthSort;
  100641. private _expandable;
  100642. private _shapeCounter;
  100643. private _copy;
  100644. private _color;
  100645. private _computeParticleColor;
  100646. private _computeParticleTexture;
  100647. private _computeParticleRotation;
  100648. private _computeParticleVertex;
  100649. private _computeBoundingBox;
  100650. private _depthSortParticles;
  100651. private _camera;
  100652. private _mustUnrotateFixedNormals;
  100653. private _particlesIntersect;
  100654. private _needs32Bits;
  100655. private _isNotBuilt;
  100656. private _lastParticleId;
  100657. private _idxOfId;
  100658. private _multimaterialEnabled;
  100659. private _useModelMaterial;
  100660. private _indicesByMaterial;
  100661. private _materialIndexes;
  100662. private _depthSortFunction;
  100663. private _materialSortFunction;
  100664. private _materials;
  100665. private _multimaterial;
  100666. private _materialIndexesById;
  100667. private _defaultMaterial;
  100668. private _autoUpdateSubMeshes;
  100669. /**
  100670. * Creates a SPS (Solid Particle System) object.
  100671. * @param name (String) is the SPS name, this will be the underlying mesh name.
  100672. * @param scene (Scene) is the scene in which the SPS is added.
  100673. * @param options defines the options of the sps e.g.
  100674. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  100675. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  100676. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  100677. * * 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.
  100678. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  100679. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  100680. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  100681. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  100682. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  100683. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  100684. */
  100685. constructor(name: string, scene: Scene, options?: {
  100686. updatable?: boolean;
  100687. isPickable?: boolean;
  100688. enableDepthSort?: boolean;
  100689. particleIntersection?: boolean;
  100690. boundingSphereOnly?: boolean;
  100691. bSphereRadiusFactor?: number;
  100692. expandable?: boolean;
  100693. useModelMaterial?: boolean;
  100694. enableMultiMaterial?: boolean;
  100695. });
  100696. /**
  100697. * Builds the SPS underlying mesh. Returns a standard Mesh.
  100698. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  100699. * @returns the created mesh
  100700. */
  100701. buildMesh(): Mesh;
  100702. /**
  100703. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  100704. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  100705. * Thus the particles generated from `digest()` have their property `position` set yet.
  100706. * @param mesh ( Mesh ) is the mesh to be digested
  100707. * @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
  100708. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  100709. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  100710. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  100711. * @returns the current SPS
  100712. */
  100713. digest(mesh: Mesh, options?: {
  100714. facetNb?: number;
  100715. number?: number;
  100716. delta?: number;
  100717. storage?: [];
  100718. }): SolidParticleSystem;
  100719. /**
  100720. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  100721. * @hidden
  100722. */
  100723. private _unrotateFixedNormals;
  100724. /**
  100725. * Resets the temporary working copy particle
  100726. * @hidden
  100727. */
  100728. private _resetCopy;
  100729. /**
  100730. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  100731. * @param p the current index in the positions array to be updated
  100732. * @param ind the current index in the indices array
  100733. * @param shape a Vector3 array, the shape geometry
  100734. * @param positions the positions array to be updated
  100735. * @param meshInd the shape indices array
  100736. * @param indices the indices array to be updated
  100737. * @param meshUV the shape uv array
  100738. * @param uvs the uv array to be updated
  100739. * @param meshCol the shape color array
  100740. * @param colors the color array to be updated
  100741. * @param meshNor the shape normals array
  100742. * @param normals the normals array to be updated
  100743. * @param idx the particle index
  100744. * @param idxInShape the particle index in its shape
  100745. * @param options the addShape() method passed options
  100746. * @model the particle model
  100747. * @hidden
  100748. */
  100749. private _meshBuilder;
  100750. /**
  100751. * Returns a shape Vector3 array from positions float array
  100752. * @param positions float array
  100753. * @returns a vector3 array
  100754. * @hidden
  100755. */
  100756. private _posToShape;
  100757. /**
  100758. * Returns a shapeUV array from a float uvs (array deep copy)
  100759. * @param uvs as a float array
  100760. * @returns a shapeUV array
  100761. * @hidden
  100762. */
  100763. private _uvsToShapeUV;
  100764. /**
  100765. * Adds a new particle object in the particles array
  100766. * @param idx particle index in particles array
  100767. * @param id particle id
  100768. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  100769. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  100770. * @param model particle ModelShape object
  100771. * @param shapeId model shape identifier
  100772. * @param idxInShape index of the particle in the current model
  100773. * @param bInfo model bounding info object
  100774. * @param storage target storage array, if any
  100775. * @hidden
  100776. */
  100777. private _addParticle;
  100778. /**
  100779. * Adds some particles to the SPS from the model shape. Returns the shape id.
  100780. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  100781. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  100782. * @param nb (positive integer) the number of particles to be created from this model
  100783. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  100784. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  100785. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  100786. * @returns the number of shapes in the system
  100787. */
  100788. addShape(mesh: Mesh, nb: number, options?: {
  100789. positionFunction?: any;
  100790. vertexFunction?: any;
  100791. storage?: [];
  100792. }): number;
  100793. /**
  100794. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  100795. * @hidden
  100796. */
  100797. private _rebuildParticle;
  100798. /**
  100799. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  100800. * @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.
  100801. * @returns the SPS.
  100802. */
  100803. rebuildMesh(reset?: boolean): SolidParticleSystem;
  100804. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  100805. * Returns an array with the removed particles.
  100806. * 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.
  100807. * The SPS can't be empty so at least one particle needs to remain in place.
  100808. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  100809. * @param start index of the first particle to remove
  100810. * @param end index of the last particle to remove (included)
  100811. * @returns an array populated with the removed particles
  100812. */
  100813. removeParticles(start: number, end: number): SolidParticle[];
  100814. /**
  100815. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  100816. * @param solidParticleArray an array populated with Solid Particles objects
  100817. * @returns the SPS
  100818. */
  100819. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  100820. /**
  100821. * Creates a new particle and modifies the SPS mesh geometry :
  100822. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  100823. * - calls _addParticle() to populate the particle array
  100824. * factorized code from addShape() and insertParticlesFromArray()
  100825. * @param idx particle index in the particles array
  100826. * @param i particle index in its shape
  100827. * @param modelShape particle ModelShape object
  100828. * @param shape shape vertex array
  100829. * @param meshInd shape indices array
  100830. * @param meshUV shape uv array
  100831. * @param meshCol shape color array
  100832. * @param meshNor shape normals array
  100833. * @param bbInfo shape bounding info
  100834. * @param storage target particle storage
  100835. * @options addShape() passed options
  100836. * @hidden
  100837. */
  100838. private _insertNewParticle;
  100839. /**
  100840. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  100841. * This method calls `updateParticle()` for each particle of the SPS.
  100842. * For an animated SPS, it is usually called within the render loop.
  100843. * 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.
  100844. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  100845. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  100846. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  100847. * @returns the SPS.
  100848. */
  100849. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  100850. /**
  100851. * Disposes the SPS.
  100852. */
  100853. dispose(): void;
  100854. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  100855. * idx is the particle index in the SPS
  100856. * faceId is the picked face index counted within this particle.
  100857. * Returns null if the pickInfo can't identify a picked particle.
  100858. * @param pickingInfo (PickingInfo object)
  100859. * @returns {idx: number, faceId: number} or null
  100860. */
  100861. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  100862. idx: number;
  100863. faceId: number;
  100864. }>;
  100865. /**
  100866. * Returns a SolidParticle object from its identifier : particle.id
  100867. * @param id (integer) the particle Id
  100868. * @returns the searched particle or null if not found in the SPS.
  100869. */
  100870. getParticleById(id: number): Nullable<SolidParticle>;
  100871. /**
  100872. * Returns a new array populated with the particles having the passed shapeId.
  100873. * @param shapeId (integer) the shape identifier
  100874. * @returns a new solid particle array
  100875. */
  100876. getParticlesByShapeId(shapeId: number): SolidParticle[];
  100877. /**
  100878. * Populates the passed array "ref" with the particles having the passed shapeId.
  100879. * @param shapeId the shape identifier
  100880. * @returns the SPS
  100881. * @param ref
  100882. */
  100883. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  100884. /**
  100885. * Computes the required SubMeshes according the materials assigned to the particles.
  100886. * @returns the solid particle system.
  100887. * Does nothing if called before the SPS mesh is built.
  100888. */
  100889. computeSubMeshes(): SolidParticleSystem;
  100890. /**
  100891. * Sorts the solid particles by material when MultiMaterial is enabled.
  100892. * Updates the indices32 array.
  100893. * Updates the indicesByMaterial array.
  100894. * Updates the mesh indices array.
  100895. * @returns the SPS
  100896. * @hidden
  100897. */
  100898. private _sortParticlesByMaterial;
  100899. /**
  100900. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  100901. * @hidden
  100902. */
  100903. private _setMaterialIndexesById;
  100904. /**
  100905. * Returns an array with unique values of Materials from the passed array
  100906. * @param array the material array to be checked and filtered
  100907. * @hidden
  100908. */
  100909. private _filterUniqueMaterialId;
  100910. /**
  100911. * Sets a new Standard Material as _defaultMaterial if not already set.
  100912. * @hidden
  100913. */
  100914. private _setDefaultMaterial;
  100915. /**
  100916. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  100917. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100918. * @returns the SPS.
  100919. */
  100920. refreshVisibleSize(): SolidParticleSystem;
  100921. /**
  100922. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  100923. * @param size the size (float) of the visibility box
  100924. * note : this doesn't lock the SPS mesh bounding box.
  100925. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100926. */
  100927. setVisibilityBox(size: number): void;
  100928. /**
  100929. * Gets whether the SPS as always visible or not
  100930. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100931. */
  100932. get isAlwaysVisible(): boolean;
  100933. /**
  100934. * Sets the SPS as always visible or not
  100935. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100936. */
  100937. set isAlwaysVisible(val: boolean);
  100938. /**
  100939. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100940. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100941. */
  100942. set isVisibilityBoxLocked(val: boolean);
  100943. /**
  100944. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100945. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100946. */
  100947. get isVisibilityBoxLocked(): boolean;
  100948. /**
  100949. * Tells to `setParticles()` to compute the particle rotations or not.
  100950. * Default value : true. The SPS is faster when it's set to false.
  100951. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  100952. */
  100953. set computeParticleRotation(val: boolean);
  100954. /**
  100955. * Tells to `setParticles()` to compute the particle colors or not.
  100956. * Default value : true. The SPS is faster when it's set to false.
  100957. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  100958. */
  100959. set computeParticleColor(val: boolean);
  100960. set computeParticleTexture(val: boolean);
  100961. /**
  100962. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  100963. * Default value : false. The SPS is faster when it's set to false.
  100964. * Note : the particle custom vertex positions aren't stored values.
  100965. */
  100966. set computeParticleVertex(val: boolean);
  100967. /**
  100968. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  100969. */
  100970. set computeBoundingBox(val: boolean);
  100971. /**
  100972. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  100973. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  100974. * Default : `true`
  100975. */
  100976. set depthSortParticles(val: boolean);
  100977. /**
  100978. * Gets if `setParticles()` computes the particle rotations or not.
  100979. * Default value : true. The SPS is faster when it's set to false.
  100980. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  100981. */
  100982. get computeParticleRotation(): boolean;
  100983. /**
  100984. * Gets if `setParticles()` computes the particle colors or not.
  100985. * Default value : true. The SPS is faster when it's set to false.
  100986. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  100987. */
  100988. get computeParticleColor(): boolean;
  100989. /**
  100990. * Gets if `setParticles()` computes the particle textures or not.
  100991. * Default value : true. The SPS is faster when it's set to false.
  100992. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  100993. */
  100994. get computeParticleTexture(): boolean;
  100995. /**
  100996. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  100997. * Default value : false. The SPS is faster when it's set to false.
  100998. * Note : the particle custom vertex positions aren't stored values.
  100999. */
  101000. get computeParticleVertex(): boolean;
  101001. /**
  101002. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  101003. */
  101004. get computeBoundingBox(): boolean;
  101005. /**
  101006. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  101007. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  101008. * Default : `true`
  101009. */
  101010. get depthSortParticles(): boolean;
  101011. /**
  101012. * Gets if the SPS is created as expandable at construction time.
  101013. * Default : `false`
  101014. */
  101015. get expandable(): boolean;
  101016. /**
  101017. * Gets if the SPS supports the Multi Materials
  101018. */
  101019. get multimaterialEnabled(): boolean;
  101020. /**
  101021. * Gets if the SPS uses the model materials for its own multimaterial.
  101022. */
  101023. get useModelMaterial(): boolean;
  101024. /**
  101025. * The SPS used material array.
  101026. */
  101027. get materials(): Material[];
  101028. /**
  101029. * Sets the SPS MultiMaterial from the passed materials.
  101030. * Note : the passed array is internally copied and not used then by reference.
  101031. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  101032. */
  101033. setMultiMaterial(materials: Material[]): void;
  101034. /**
  101035. * The SPS computed multimaterial object
  101036. */
  101037. get multimaterial(): MultiMaterial;
  101038. set multimaterial(mm: MultiMaterial);
  101039. /**
  101040. * If the subMeshes must be updated on the next call to setParticles()
  101041. */
  101042. get autoUpdateSubMeshes(): boolean;
  101043. set autoUpdateSubMeshes(val: boolean);
  101044. /**
  101045. * This function does nothing. It may be overwritten to set all the particle first values.
  101046. * The SPS doesn't call this function, you may have to call it by your own.
  101047. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  101048. */
  101049. initParticles(): void;
  101050. /**
  101051. * This function does nothing. It may be overwritten to recycle a particle.
  101052. * The SPS doesn't call this function, you may have to call it by your own.
  101053. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  101054. * @param particle The particle to recycle
  101055. * @returns the recycled particle
  101056. */
  101057. recycleParticle(particle: SolidParticle): SolidParticle;
  101058. /**
  101059. * Updates a particle : this function should be overwritten by the user.
  101060. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  101061. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  101062. * @example : just set a particle position or velocity and recycle conditions
  101063. * @param particle The particle to update
  101064. * @returns the updated particle
  101065. */
  101066. updateParticle(particle: SolidParticle): SolidParticle;
  101067. /**
  101068. * Updates a vertex of a particle : it can be overwritten by the user.
  101069. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  101070. * @param particle the current particle
  101071. * @param vertex the current index of the current particle
  101072. * @param pt the index of the current vertex in the particle shape
  101073. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  101074. * @example : just set a vertex particle position
  101075. * @returns the updated vertex
  101076. */
  101077. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  101078. /**
  101079. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  101080. * This does nothing and may be overwritten by the user.
  101081. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  101082. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  101083. * @param update the boolean update value actually passed to setParticles()
  101084. */
  101085. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  101086. /**
  101087. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  101088. * This will be passed three parameters.
  101089. * This does nothing and may be overwritten by the user.
  101090. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  101091. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  101092. * @param update the boolean update value actually passed to setParticles()
  101093. */
  101094. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  101095. }
  101096. }
  101097. declare module BABYLON {
  101098. /**
  101099. * Represents one particle of a solid particle system.
  101100. */
  101101. export class SolidParticle {
  101102. /**
  101103. * particle global index
  101104. */
  101105. idx: number;
  101106. /**
  101107. * particle identifier
  101108. */
  101109. id: number;
  101110. /**
  101111. * The color of the particle
  101112. */
  101113. color: Nullable<Color4>;
  101114. /**
  101115. * The world space position of the particle.
  101116. */
  101117. position: Vector3;
  101118. /**
  101119. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  101120. */
  101121. rotation: Vector3;
  101122. /**
  101123. * The world space rotation quaternion of the particle.
  101124. */
  101125. rotationQuaternion: Nullable<Quaternion>;
  101126. /**
  101127. * The scaling of the particle.
  101128. */
  101129. scaling: Vector3;
  101130. /**
  101131. * The uvs of the particle.
  101132. */
  101133. uvs: Vector4;
  101134. /**
  101135. * The current speed of the particle.
  101136. */
  101137. velocity: Vector3;
  101138. /**
  101139. * The pivot point in the particle local space.
  101140. */
  101141. pivot: Vector3;
  101142. /**
  101143. * Must the particle be translated from its pivot point in its local space ?
  101144. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  101145. * Default : false
  101146. */
  101147. translateFromPivot: boolean;
  101148. /**
  101149. * Is the particle active or not ?
  101150. */
  101151. alive: boolean;
  101152. /**
  101153. * Is the particle visible or not ?
  101154. */
  101155. isVisible: boolean;
  101156. /**
  101157. * Index of this particle in the global "positions" array (Internal use)
  101158. * @hidden
  101159. */
  101160. _pos: number;
  101161. /**
  101162. * @hidden Index of this particle in the global "indices" array (Internal use)
  101163. */
  101164. _ind: number;
  101165. /**
  101166. * @hidden ModelShape of this particle (Internal use)
  101167. */
  101168. _model: ModelShape;
  101169. /**
  101170. * ModelShape id of this particle
  101171. */
  101172. shapeId: number;
  101173. /**
  101174. * Index of the particle in its shape id
  101175. */
  101176. idxInShape: number;
  101177. /**
  101178. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  101179. */
  101180. _modelBoundingInfo: BoundingInfo;
  101181. /**
  101182. * @hidden Particle BoundingInfo object (Internal use)
  101183. */
  101184. _boundingInfo: BoundingInfo;
  101185. /**
  101186. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  101187. */
  101188. _sps: SolidParticleSystem;
  101189. /**
  101190. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  101191. */
  101192. _stillInvisible: boolean;
  101193. /**
  101194. * @hidden Last computed particle rotation matrix
  101195. */
  101196. _rotationMatrix: number[];
  101197. /**
  101198. * Parent particle Id, if any.
  101199. * Default null.
  101200. */
  101201. parentId: Nullable<number>;
  101202. /**
  101203. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  101204. */
  101205. materialIndex: Nullable<number>;
  101206. /**
  101207. * Custom object or properties.
  101208. */
  101209. props: Nullable<any>;
  101210. /**
  101211. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  101212. * The possible values are :
  101213. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  101214. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  101215. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  101216. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  101217. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  101218. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  101219. * */
  101220. cullingStrategy: number;
  101221. /**
  101222. * @hidden Internal global position in the SPS.
  101223. */
  101224. _globalPosition: Vector3;
  101225. /**
  101226. * Creates a Solid Particle object.
  101227. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  101228. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  101229. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  101230. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  101231. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  101232. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  101233. * @param shapeId (integer) is the model shape identifier in the SPS.
  101234. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  101235. * @param sps defines the sps it is associated to
  101236. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  101237. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  101238. */
  101239. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  101240. /**
  101241. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  101242. * @param target the particle target
  101243. * @returns the current particle
  101244. */
  101245. copyToRef(target: SolidParticle): SolidParticle;
  101246. /**
  101247. * Legacy support, changed scale to scaling
  101248. */
  101249. get scale(): Vector3;
  101250. /**
  101251. * Legacy support, changed scale to scaling
  101252. */
  101253. set scale(scale: Vector3);
  101254. /**
  101255. * Legacy support, changed quaternion to rotationQuaternion
  101256. */
  101257. get quaternion(): Nullable<Quaternion>;
  101258. /**
  101259. * Legacy support, changed quaternion to rotationQuaternion
  101260. */
  101261. set quaternion(q: Nullable<Quaternion>);
  101262. /**
  101263. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  101264. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  101265. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  101266. * @returns true if it intersects
  101267. */
  101268. intersectsMesh(target: Mesh | SolidParticle): boolean;
  101269. /**
  101270. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  101271. * A particle is in the frustum if its bounding box intersects the frustum
  101272. * @param frustumPlanes defines the frustum to test
  101273. * @returns true if the particle is in the frustum planes
  101274. */
  101275. isInFrustum(frustumPlanes: Plane[]): boolean;
  101276. /**
  101277. * get the rotation matrix of the particle
  101278. * @hidden
  101279. */
  101280. getRotationMatrix(m: Matrix): void;
  101281. }
  101282. /**
  101283. * Represents the shape of the model used by one particle of a solid particle system.
  101284. * SPS internal tool, don't use it manually.
  101285. */
  101286. export class ModelShape {
  101287. /**
  101288. * The shape id
  101289. * @hidden
  101290. */
  101291. shapeID: number;
  101292. /**
  101293. * flat array of model positions (internal use)
  101294. * @hidden
  101295. */
  101296. _shape: Vector3[];
  101297. /**
  101298. * flat array of model UVs (internal use)
  101299. * @hidden
  101300. */
  101301. _shapeUV: number[];
  101302. /**
  101303. * color array of the model
  101304. * @hidden
  101305. */
  101306. _shapeColors: number[];
  101307. /**
  101308. * indices array of the model
  101309. * @hidden
  101310. */
  101311. _indices: number[];
  101312. /**
  101313. * normals array of the model
  101314. * @hidden
  101315. */
  101316. _normals: number[];
  101317. /**
  101318. * length of the shape in the model indices array (internal use)
  101319. * @hidden
  101320. */
  101321. _indicesLength: number;
  101322. /**
  101323. * Custom position function (internal use)
  101324. * @hidden
  101325. */
  101326. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  101327. /**
  101328. * Custom vertex function (internal use)
  101329. * @hidden
  101330. */
  101331. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  101332. /**
  101333. * Model material (internal use)
  101334. * @hidden
  101335. */
  101336. _material: Nullable<Material>;
  101337. /**
  101338. * 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.
  101339. * SPS internal tool, don't use it manually.
  101340. * @hidden
  101341. */
  101342. 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>);
  101343. }
  101344. /**
  101345. * Represents a Depth Sorted Particle in the solid particle system.
  101346. * @hidden
  101347. */
  101348. export class DepthSortedParticle {
  101349. /**
  101350. * Particle index
  101351. */
  101352. idx: number;
  101353. /**
  101354. * Index of the particle in the "indices" array
  101355. */
  101356. ind: number;
  101357. /**
  101358. * Length of the particle shape in the "indices" array
  101359. */
  101360. indicesLength: number;
  101361. /**
  101362. * Squared distance from the particle to the camera
  101363. */
  101364. sqDistance: number;
  101365. /**
  101366. * Material index when used with MultiMaterials
  101367. */
  101368. materialIndex: number;
  101369. /**
  101370. * Creates a new sorted particle
  101371. * @param materialIndex
  101372. */
  101373. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  101374. }
  101375. }
  101376. declare module BABYLON {
  101377. /**
  101378. * @hidden
  101379. */
  101380. export class _MeshCollisionData {
  101381. _checkCollisions: boolean;
  101382. _collisionMask: number;
  101383. _collisionGroup: number;
  101384. _collider: Nullable<Collider>;
  101385. _oldPositionForCollisions: Vector3;
  101386. _diffPositionForCollisions: Vector3;
  101387. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  101388. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  101389. }
  101390. }
  101391. declare module BABYLON {
  101392. /** @hidden */
  101393. class _FacetDataStorage {
  101394. facetPositions: Vector3[];
  101395. facetNormals: Vector3[];
  101396. facetPartitioning: number[][];
  101397. facetNb: number;
  101398. partitioningSubdivisions: number;
  101399. partitioningBBoxRatio: number;
  101400. facetDataEnabled: boolean;
  101401. facetParameters: any;
  101402. bbSize: Vector3;
  101403. subDiv: {
  101404. max: number;
  101405. X: number;
  101406. Y: number;
  101407. Z: number;
  101408. };
  101409. facetDepthSort: boolean;
  101410. facetDepthSortEnabled: boolean;
  101411. depthSortedIndices: IndicesArray;
  101412. depthSortedFacets: {
  101413. ind: number;
  101414. sqDistance: number;
  101415. }[];
  101416. facetDepthSortFunction: (f1: {
  101417. ind: number;
  101418. sqDistance: number;
  101419. }, f2: {
  101420. ind: number;
  101421. sqDistance: number;
  101422. }) => number;
  101423. facetDepthSortFrom: Vector3;
  101424. facetDepthSortOrigin: Vector3;
  101425. invertedMatrix: Matrix;
  101426. }
  101427. /**
  101428. * @hidden
  101429. **/
  101430. class _InternalAbstractMeshDataInfo {
  101431. _hasVertexAlpha: boolean;
  101432. _useVertexColors: boolean;
  101433. _numBoneInfluencers: number;
  101434. _applyFog: boolean;
  101435. _receiveShadows: boolean;
  101436. _facetData: _FacetDataStorage;
  101437. _visibility: number;
  101438. _skeleton: Nullable<Skeleton>;
  101439. _layerMask: number;
  101440. _computeBonesUsingShaders: boolean;
  101441. _isActive: boolean;
  101442. _onlyForInstances: boolean;
  101443. _isActiveIntermediate: boolean;
  101444. _onlyForInstancesIntermediate: boolean;
  101445. _actAsRegularMesh: boolean;
  101446. }
  101447. /**
  101448. * Class used to store all common mesh properties
  101449. */
  101450. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  101451. /** No occlusion */
  101452. static OCCLUSION_TYPE_NONE: number;
  101453. /** Occlusion set to optimisitic */
  101454. static OCCLUSION_TYPE_OPTIMISTIC: number;
  101455. /** Occlusion set to strict */
  101456. static OCCLUSION_TYPE_STRICT: number;
  101457. /** Use an accurante occlusion algorithm */
  101458. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  101459. /** Use a conservative occlusion algorithm */
  101460. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  101461. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  101462. * Test order :
  101463. * Is the bounding sphere outside the frustum ?
  101464. * If not, are the bounding box vertices outside the frustum ?
  101465. * It not, then the cullable object is in the frustum.
  101466. */
  101467. static readonly CULLINGSTRATEGY_STANDARD: number;
  101468. /** Culling strategy : Bounding Sphere Only.
  101469. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  101470. * It's also less accurate than the standard because some not visible objects can still be selected.
  101471. * Test : is the bounding sphere outside the frustum ?
  101472. * If not, then the cullable object is in the frustum.
  101473. */
  101474. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  101475. /** Culling strategy : Optimistic Inclusion.
  101476. * This in an inclusion test first, then the standard exclusion test.
  101477. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  101478. * 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.
  101479. * Anyway, it's as accurate as the standard strategy.
  101480. * Test :
  101481. * Is the cullable object bounding sphere center in the frustum ?
  101482. * If not, apply the default culling strategy.
  101483. */
  101484. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  101485. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  101486. * This in an inclusion test first, then the bounding sphere only exclusion test.
  101487. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  101488. * 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.
  101489. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  101490. * Test :
  101491. * Is the cullable object bounding sphere center in the frustum ?
  101492. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  101493. */
  101494. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  101495. /**
  101496. * No billboard
  101497. */
  101498. static get BILLBOARDMODE_NONE(): number;
  101499. /** Billboard on X axis */
  101500. static get BILLBOARDMODE_X(): number;
  101501. /** Billboard on Y axis */
  101502. static get BILLBOARDMODE_Y(): number;
  101503. /** Billboard on Z axis */
  101504. static get BILLBOARDMODE_Z(): number;
  101505. /** Billboard on all axes */
  101506. static get BILLBOARDMODE_ALL(): number;
  101507. /** Billboard on using position instead of orientation */
  101508. static get BILLBOARDMODE_USE_POSITION(): number;
  101509. /** @hidden */
  101510. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  101511. /**
  101512. * The culling strategy to use to check whether the mesh must be rendered or not.
  101513. * This value can be changed at any time and will be used on the next render mesh selection.
  101514. * The possible values are :
  101515. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  101516. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  101517. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  101518. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  101519. * Please read each static variable documentation to get details about the culling process.
  101520. * */
  101521. cullingStrategy: number;
  101522. /**
  101523. * Gets the number of facets in the mesh
  101524. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  101525. */
  101526. get facetNb(): number;
  101527. /**
  101528. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  101529. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  101530. */
  101531. get partitioningSubdivisions(): number;
  101532. set partitioningSubdivisions(nb: number);
  101533. /**
  101534. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  101535. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  101536. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  101537. */
  101538. get partitioningBBoxRatio(): number;
  101539. set partitioningBBoxRatio(ratio: number);
  101540. /**
  101541. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  101542. * Works only for updatable meshes.
  101543. * Doesn't work with multi-materials
  101544. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  101545. */
  101546. get mustDepthSortFacets(): boolean;
  101547. set mustDepthSortFacets(sort: boolean);
  101548. /**
  101549. * The location (Vector3) where the facet depth sort must be computed from.
  101550. * By default, the active camera position.
  101551. * Used only when facet depth sort is enabled
  101552. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  101553. */
  101554. get facetDepthSortFrom(): Vector3;
  101555. set facetDepthSortFrom(location: Vector3);
  101556. /**
  101557. * gets a boolean indicating if facetData is enabled
  101558. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  101559. */
  101560. get isFacetDataEnabled(): boolean;
  101561. /** @hidden */
  101562. _updateNonUniformScalingState(value: boolean): boolean;
  101563. /**
  101564. * An event triggered when this mesh collides with another one
  101565. */
  101566. onCollideObservable: Observable<AbstractMesh>;
  101567. /** Set a function to call when this mesh collides with another one */
  101568. set onCollide(callback: () => void);
  101569. /**
  101570. * An event triggered when the collision's position changes
  101571. */
  101572. onCollisionPositionChangeObservable: Observable<Vector3>;
  101573. /** Set a function to call when the collision's position changes */
  101574. set onCollisionPositionChange(callback: () => void);
  101575. /**
  101576. * An event triggered when material is changed
  101577. */
  101578. onMaterialChangedObservable: Observable<AbstractMesh>;
  101579. /**
  101580. * Gets or sets the orientation for POV movement & rotation
  101581. */
  101582. definedFacingForward: boolean;
  101583. /** @hidden */
  101584. _occlusionQuery: Nullable<WebGLQuery>;
  101585. /** @hidden */
  101586. _renderingGroup: Nullable<RenderingGroup>;
  101587. /**
  101588. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  101589. */
  101590. get visibility(): number;
  101591. /**
  101592. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  101593. */
  101594. set visibility(value: number);
  101595. /** Gets or sets the alpha index used to sort transparent meshes
  101596. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  101597. */
  101598. alphaIndex: number;
  101599. /**
  101600. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  101601. */
  101602. isVisible: boolean;
  101603. /**
  101604. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  101605. */
  101606. isPickable: boolean;
  101607. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  101608. showSubMeshesBoundingBox: boolean;
  101609. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  101610. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101611. */
  101612. isBlocker: boolean;
  101613. /**
  101614. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  101615. */
  101616. enablePointerMoveEvents: boolean;
  101617. /**
  101618. * Specifies the rendering group id for this mesh (0 by default)
  101619. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  101620. */
  101621. renderingGroupId: number;
  101622. private _material;
  101623. /** Gets or sets current material */
  101624. get material(): Nullable<Material>;
  101625. set material(value: Nullable<Material>);
  101626. /**
  101627. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  101628. * @see http://doc.babylonjs.com/babylon101/shadows
  101629. */
  101630. get receiveShadows(): boolean;
  101631. set receiveShadows(value: boolean);
  101632. /** Defines color to use when rendering outline */
  101633. outlineColor: Color3;
  101634. /** Define width to use when rendering outline */
  101635. outlineWidth: number;
  101636. /** Defines color to use when rendering overlay */
  101637. overlayColor: Color3;
  101638. /** Defines alpha to use when rendering overlay */
  101639. overlayAlpha: number;
  101640. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  101641. get hasVertexAlpha(): boolean;
  101642. set hasVertexAlpha(value: boolean);
  101643. /** 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) */
  101644. get useVertexColors(): boolean;
  101645. set useVertexColors(value: boolean);
  101646. /**
  101647. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  101648. */
  101649. get computeBonesUsingShaders(): boolean;
  101650. set computeBonesUsingShaders(value: boolean);
  101651. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  101652. get numBoneInfluencers(): number;
  101653. set numBoneInfluencers(value: number);
  101654. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  101655. get applyFog(): boolean;
  101656. set applyFog(value: boolean);
  101657. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  101658. useOctreeForRenderingSelection: boolean;
  101659. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  101660. useOctreeForPicking: boolean;
  101661. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  101662. useOctreeForCollisions: boolean;
  101663. /**
  101664. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  101665. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  101666. */
  101667. get layerMask(): number;
  101668. set layerMask(value: number);
  101669. /**
  101670. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  101671. */
  101672. alwaysSelectAsActiveMesh: boolean;
  101673. /**
  101674. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  101675. */
  101676. doNotSyncBoundingInfo: boolean;
  101677. /**
  101678. * Gets or sets the current action manager
  101679. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101680. */
  101681. actionManager: Nullable<AbstractActionManager>;
  101682. private _meshCollisionData;
  101683. /**
  101684. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  101685. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101686. */
  101687. ellipsoid: Vector3;
  101688. /**
  101689. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  101690. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101691. */
  101692. ellipsoidOffset: Vector3;
  101693. /**
  101694. * Gets or sets a collision mask used to mask collisions (default is -1).
  101695. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  101696. */
  101697. get collisionMask(): number;
  101698. set collisionMask(mask: number);
  101699. /**
  101700. * Gets or sets the current collision group mask (-1 by default).
  101701. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  101702. */
  101703. get collisionGroup(): number;
  101704. set collisionGroup(mask: number);
  101705. /**
  101706. * Defines edge width used when edgesRenderer is enabled
  101707. * @see https://www.babylonjs-playground.com/#10OJSG#13
  101708. */
  101709. edgesWidth: number;
  101710. /**
  101711. * Defines edge color used when edgesRenderer is enabled
  101712. * @see https://www.babylonjs-playground.com/#10OJSG#13
  101713. */
  101714. edgesColor: Color4;
  101715. /** @hidden */
  101716. _edgesRenderer: Nullable<IEdgesRenderer>;
  101717. /** @hidden */
  101718. _masterMesh: Nullable<AbstractMesh>;
  101719. /** @hidden */
  101720. _boundingInfo: Nullable<BoundingInfo>;
  101721. /** @hidden */
  101722. _renderId: number;
  101723. /**
  101724. * Gets or sets the list of subMeshes
  101725. * @see http://doc.babylonjs.com/how_to/multi_materials
  101726. */
  101727. subMeshes: SubMesh[];
  101728. /** @hidden */
  101729. _intersectionsInProgress: AbstractMesh[];
  101730. /** @hidden */
  101731. _unIndexed: boolean;
  101732. /** @hidden */
  101733. _lightSources: Light[];
  101734. /** Gets the list of lights affecting that mesh */
  101735. get lightSources(): Light[];
  101736. /** @hidden */
  101737. get _positions(): Nullable<Vector3[]>;
  101738. /** @hidden */
  101739. _waitingData: {
  101740. lods: Nullable<any>;
  101741. actions: Nullable<any>;
  101742. freezeWorldMatrix: Nullable<boolean>;
  101743. };
  101744. /** @hidden */
  101745. _bonesTransformMatrices: Nullable<Float32Array>;
  101746. /** @hidden */
  101747. _transformMatrixTexture: Nullable<RawTexture>;
  101748. /**
  101749. * Gets or sets a skeleton to apply skining transformations
  101750. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  101751. */
  101752. set skeleton(value: Nullable<Skeleton>);
  101753. get skeleton(): Nullable<Skeleton>;
  101754. /**
  101755. * An event triggered when the mesh is rebuilt.
  101756. */
  101757. onRebuildObservable: Observable<AbstractMesh>;
  101758. /**
  101759. * Creates a new AbstractMesh
  101760. * @param name defines the name of the mesh
  101761. * @param scene defines the hosting scene
  101762. */
  101763. constructor(name: string, scene?: Nullable<Scene>);
  101764. /**
  101765. * Returns the string "AbstractMesh"
  101766. * @returns "AbstractMesh"
  101767. */
  101768. getClassName(): string;
  101769. /**
  101770. * Gets a string representation of the current mesh
  101771. * @param fullDetails defines a boolean indicating if full details must be included
  101772. * @returns a string representation of the current mesh
  101773. */
  101774. toString(fullDetails?: boolean): string;
  101775. /**
  101776. * @hidden
  101777. */
  101778. protected _getEffectiveParent(): Nullable<Node>;
  101779. /** @hidden */
  101780. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  101781. /** @hidden */
  101782. _rebuild(): void;
  101783. /** @hidden */
  101784. _resyncLightSources(): void;
  101785. /** @hidden */
  101786. _resyncLightSource(light: Light): void;
  101787. /** @hidden */
  101788. _unBindEffect(): void;
  101789. /** @hidden */
  101790. _removeLightSource(light: Light, dispose: boolean): void;
  101791. private _markSubMeshesAsDirty;
  101792. /** @hidden */
  101793. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  101794. /** @hidden */
  101795. _markSubMeshesAsAttributesDirty(): void;
  101796. /** @hidden */
  101797. _markSubMeshesAsMiscDirty(): void;
  101798. /**
  101799. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  101800. */
  101801. get scaling(): Vector3;
  101802. set scaling(newScaling: Vector3);
  101803. /**
  101804. * Returns true if the mesh is blocked. Implemented by child classes
  101805. */
  101806. get isBlocked(): boolean;
  101807. /**
  101808. * Returns the mesh itself by default. Implemented by child classes
  101809. * @param camera defines the camera to use to pick the right LOD level
  101810. * @returns the currentAbstractMesh
  101811. */
  101812. getLOD(camera: Camera): Nullable<AbstractMesh>;
  101813. /**
  101814. * Returns 0 by default. Implemented by child classes
  101815. * @returns an integer
  101816. */
  101817. getTotalVertices(): number;
  101818. /**
  101819. * Returns a positive integer : the total number of indices in this mesh geometry.
  101820. * @returns the numner of indices or zero if the mesh has no geometry.
  101821. */
  101822. getTotalIndices(): number;
  101823. /**
  101824. * Returns null by default. Implemented by child classes
  101825. * @returns null
  101826. */
  101827. getIndices(): Nullable<IndicesArray>;
  101828. /**
  101829. * Returns the array of the requested vertex data kind. Implemented by child classes
  101830. * @param kind defines the vertex data kind to use
  101831. * @returns null
  101832. */
  101833. getVerticesData(kind: string): Nullable<FloatArray>;
  101834. /**
  101835. * Sets the vertex data of the mesh geometry for the requested `kind`.
  101836. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  101837. * Note that a new underlying VertexBuffer object is created each call.
  101838. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  101839. * @param kind defines vertex data kind:
  101840. * * VertexBuffer.PositionKind
  101841. * * VertexBuffer.UVKind
  101842. * * VertexBuffer.UV2Kind
  101843. * * VertexBuffer.UV3Kind
  101844. * * VertexBuffer.UV4Kind
  101845. * * VertexBuffer.UV5Kind
  101846. * * VertexBuffer.UV6Kind
  101847. * * VertexBuffer.ColorKind
  101848. * * VertexBuffer.MatricesIndicesKind
  101849. * * VertexBuffer.MatricesIndicesExtraKind
  101850. * * VertexBuffer.MatricesWeightsKind
  101851. * * VertexBuffer.MatricesWeightsExtraKind
  101852. * @param data defines the data source
  101853. * @param updatable defines if the data must be flagged as updatable (or static)
  101854. * @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
  101855. * @returns the current mesh
  101856. */
  101857. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  101858. /**
  101859. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  101860. * If the mesh has no geometry, it is simply returned as it is.
  101861. * @param kind defines vertex data kind:
  101862. * * VertexBuffer.PositionKind
  101863. * * VertexBuffer.UVKind
  101864. * * VertexBuffer.UV2Kind
  101865. * * VertexBuffer.UV3Kind
  101866. * * VertexBuffer.UV4Kind
  101867. * * VertexBuffer.UV5Kind
  101868. * * VertexBuffer.UV6Kind
  101869. * * VertexBuffer.ColorKind
  101870. * * VertexBuffer.MatricesIndicesKind
  101871. * * VertexBuffer.MatricesIndicesExtraKind
  101872. * * VertexBuffer.MatricesWeightsKind
  101873. * * VertexBuffer.MatricesWeightsExtraKind
  101874. * @param data defines the data source
  101875. * @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
  101876. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  101877. * @returns the current mesh
  101878. */
  101879. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  101880. /**
  101881. * Sets the mesh indices,
  101882. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  101883. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  101884. * @param totalVertices Defines the total number of vertices
  101885. * @returns the current mesh
  101886. */
  101887. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  101888. /**
  101889. * Gets a boolean indicating if specific vertex data is present
  101890. * @param kind defines the vertex data kind to use
  101891. * @returns true is data kind is present
  101892. */
  101893. isVerticesDataPresent(kind: string): boolean;
  101894. /**
  101895. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  101896. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  101897. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  101898. * @returns a BoundingInfo
  101899. */
  101900. getBoundingInfo(): BoundingInfo;
  101901. /**
  101902. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  101903. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  101904. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  101905. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  101906. * @returns the current mesh
  101907. */
  101908. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  101909. /**
  101910. * Overwrite the current bounding info
  101911. * @param boundingInfo defines the new bounding info
  101912. * @returns the current mesh
  101913. */
  101914. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  101915. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  101916. get useBones(): boolean;
  101917. /** @hidden */
  101918. _preActivate(): void;
  101919. /** @hidden */
  101920. _preActivateForIntermediateRendering(renderId: number): void;
  101921. /** @hidden */
  101922. _activate(renderId: number, intermediateRendering: boolean): boolean;
  101923. /** @hidden */
  101924. _postActivate(): void;
  101925. /** @hidden */
  101926. _freeze(): void;
  101927. /** @hidden */
  101928. _unFreeze(): void;
  101929. /**
  101930. * Gets the current world matrix
  101931. * @returns a Matrix
  101932. */
  101933. getWorldMatrix(): Matrix;
  101934. /** @hidden */
  101935. _getWorldMatrixDeterminant(): number;
  101936. /**
  101937. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  101938. */
  101939. get isAnInstance(): boolean;
  101940. /**
  101941. * Gets a boolean indicating if this mesh has instances
  101942. */
  101943. get hasInstances(): boolean;
  101944. /**
  101945. * Perform relative position change from the point of view of behind the front of the mesh.
  101946. * This is performed taking into account the meshes current rotation, so you do not have to care.
  101947. * Supports definition of mesh facing forward or backward
  101948. * @param amountRight defines the distance on the right axis
  101949. * @param amountUp defines the distance on the up axis
  101950. * @param amountForward defines the distance on the forward axis
  101951. * @returns the current mesh
  101952. */
  101953. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  101954. /**
  101955. * Calculate relative position change from the point of view of behind the front of the mesh.
  101956. * This is performed taking into account the meshes current rotation, so you do not have to care.
  101957. * Supports definition of mesh facing forward or backward
  101958. * @param amountRight defines the distance on the right axis
  101959. * @param amountUp defines the distance on the up axis
  101960. * @param amountForward defines the distance on the forward axis
  101961. * @returns the new displacement vector
  101962. */
  101963. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  101964. /**
  101965. * Perform relative rotation change from the point of view of behind the front of the mesh.
  101966. * Supports definition of mesh facing forward or backward
  101967. * @param flipBack defines the flip
  101968. * @param twirlClockwise defines the twirl
  101969. * @param tiltRight defines the tilt
  101970. * @returns the current mesh
  101971. */
  101972. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  101973. /**
  101974. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  101975. * Supports definition of mesh facing forward or backward.
  101976. * @param flipBack defines the flip
  101977. * @param twirlClockwise defines the twirl
  101978. * @param tiltRight defines the tilt
  101979. * @returns the new rotation vector
  101980. */
  101981. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  101982. /**
  101983. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  101984. * This means the mesh underlying bounding box and sphere are recomputed.
  101985. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  101986. * @returns the current mesh
  101987. */
  101988. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  101989. /** @hidden */
  101990. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  101991. /** @hidden */
  101992. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  101993. /** @hidden */
  101994. _updateBoundingInfo(): AbstractMesh;
  101995. /** @hidden */
  101996. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  101997. /** @hidden */
  101998. protected _afterComputeWorldMatrix(): void;
  101999. /** @hidden */
  102000. get _effectiveMesh(): AbstractMesh;
  102001. /**
  102002. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  102003. * A mesh is in the frustum if its bounding box intersects the frustum
  102004. * @param frustumPlanes defines the frustum to test
  102005. * @returns true if the mesh is in the frustum planes
  102006. */
  102007. isInFrustum(frustumPlanes: Plane[]): boolean;
  102008. /**
  102009. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  102010. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  102011. * @param frustumPlanes defines the frustum to test
  102012. * @returns true if the mesh is completely in the frustum planes
  102013. */
  102014. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  102015. /**
  102016. * True if the mesh intersects another mesh or a SolidParticle object
  102017. * @param mesh defines a target mesh or SolidParticle to test
  102018. * @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)
  102019. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  102020. * @returns true if there is an intersection
  102021. */
  102022. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  102023. /**
  102024. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  102025. * @param point defines the point to test
  102026. * @returns true if there is an intersection
  102027. */
  102028. intersectsPoint(point: Vector3): boolean;
  102029. /**
  102030. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  102031. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102032. */
  102033. get checkCollisions(): boolean;
  102034. set checkCollisions(collisionEnabled: boolean);
  102035. /**
  102036. * Gets Collider object used to compute collisions (not physics)
  102037. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102038. */
  102039. get collider(): Nullable<Collider>;
  102040. /**
  102041. * Move the mesh using collision engine
  102042. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102043. * @param displacement defines the requested displacement vector
  102044. * @returns the current mesh
  102045. */
  102046. moveWithCollisions(displacement: Vector3): AbstractMesh;
  102047. private _onCollisionPositionChange;
  102048. /** @hidden */
  102049. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  102050. /** @hidden */
  102051. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  102052. /** @hidden */
  102053. _checkCollision(collider: Collider): AbstractMesh;
  102054. /** @hidden */
  102055. _generatePointsArray(): boolean;
  102056. /**
  102057. * Checks if the passed Ray intersects with the mesh
  102058. * @param ray defines the ray to use
  102059. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  102060. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102061. * @returns the picking info
  102062. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  102063. */
  102064. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  102065. /**
  102066. * Clones the current mesh
  102067. * @param name defines the mesh name
  102068. * @param newParent defines the new mesh parent
  102069. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  102070. * @returns the new mesh
  102071. */
  102072. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  102073. /**
  102074. * Disposes all the submeshes of the current meshnp
  102075. * @returns the current mesh
  102076. */
  102077. releaseSubMeshes(): AbstractMesh;
  102078. /**
  102079. * Releases resources associated with this abstract mesh.
  102080. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102081. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102082. */
  102083. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102084. /**
  102085. * Adds the passed mesh as a child to the current mesh
  102086. * @param mesh defines the child mesh
  102087. * @returns the current mesh
  102088. */
  102089. addChild(mesh: AbstractMesh): AbstractMesh;
  102090. /**
  102091. * Removes the passed mesh from the current mesh children list
  102092. * @param mesh defines the child mesh
  102093. * @returns the current mesh
  102094. */
  102095. removeChild(mesh: AbstractMesh): AbstractMesh;
  102096. /** @hidden */
  102097. private _initFacetData;
  102098. /**
  102099. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  102100. * This method can be called within the render loop.
  102101. * 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
  102102. * @returns the current mesh
  102103. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102104. */
  102105. updateFacetData(): AbstractMesh;
  102106. /**
  102107. * Returns the facetLocalNormals array.
  102108. * The normals are expressed in the mesh local spac
  102109. * @returns an array of Vector3
  102110. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102111. */
  102112. getFacetLocalNormals(): Vector3[];
  102113. /**
  102114. * Returns the facetLocalPositions array.
  102115. * The facet positions are expressed in the mesh local space
  102116. * @returns an array of Vector3
  102117. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102118. */
  102119. getFacetLocalPositions(): Vector3[];
  102120. /**
  102121. * Returns the facetLocalPartioning array
  102122. * @returns an array of array of numbers
  102123. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102124. */
  102125. getFacetLocalPartitioning(): number[][];
  102126. /**
  102127. * Returns the i-th facet position in the world system.
  102128. * This method allocates a new Vector3 per call
  102129. * @param i defines the facet index
  102130. * @returns a new Vector3
  102131. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102132. */
  102133. getFacetPosition(i: number): Vector3;
  102134. /**
  102135. * Sets the reference Vector3 with the i-th facet position in the world system
  102136. * @param i defines the facet index
  102137. * @param ref defines the target vector
  102138. * @returns the current mesh
  102139. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102140. */
  102141. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  102142. /**
  102143. * Returns the i-th facet normal in the world system.
  102144. * This method allocates a new Vector3 per call
  102145. * @param i defines the facet index
  102146. * @returns a new Vector3
  102147. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102148. */
  102149. getFacetNormal(i: number): Vector3;
  102150. /**
  102151. * Sets the reference Vector3 with the i-th facet normal in the world system
  102152. * @param i defines the facet index
  102153. * @param ref defines the target vector
  102154. * @returns the current mesh
  102155. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102156. */
  102157. getFacetNormalToRef(i: number, ref: Vector3): this;
  102158. /**
  102159. * 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)
  102160. * @param x defines x coordinate
  102161. * @param y defines y coordinate
  102162. * @param z defines z coordinate
  102163. * @returns the array of facet indexes
  102164. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102165. */
  102166. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  102167. /**
  102168. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  102169. * @param projected sets as the (x,y,z) world projection on the facet
  102170. * @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
  102171. * @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
  102172. * @param x defines x coordinate
  102173. * @param y defines y coordinate
  102174. * @param z defines z coordinate
  102175. * @returns the face index if found (or null instead)
  102176. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102177. */
  102178. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  102179. /**
  102180. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  102181. * @param projected sets as the (x,y,z) local projection on the facet
  102182. * @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
  102183. * @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
  102184. * @param x defines x coordinate
  102185. * @param y defines y coordinate
  102186. * @param z defines z coordinate
  102187. * @returns the face index if found (or null instead)
  102188. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102189. */
  102190. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  102191. /**
  102192. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  102193. * @returns the parameters
  102194. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102195. */
  102196. getFacetDataParameters(): any;
  102197. /**
  102198. * Disables the feature FacetData and frees the related memory
  102199. * @returns the current mesh
  102200. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102201. */
  102202. disableFacetData(): AbstractMesh;
  102203. /**
  102204. * Updates the AbstractMesh indices array
  102205. * @param indices defines the data source
  102206. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  102207. * @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)
  102208. * @returns the current mesh
  102209. */
  102210. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  102211. /**
  102212. * Creates new normals data for the mesh
  102213. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  102214. * @returns the current mesh
  102215. */
  102216. createNormals(updatable: boolean): AbstractMesh;
  102217. /**
  102218. * Align the mesh with a normal
  102219. * @param normal defines the normal to use
  102220. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  102221. * @returns the current mesh
  102222. */
  102223. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  102224. /** @hidden */
  102225. _checkOcclusionQuery(): boolean;
  102226. /**
  102227. * Disables the mesh edge rendering mode
  102228. * @returns the currentAbstractMesh
  102229. */
  102230. disableEdgesRendering(): AbstractMesh;
  102231. /**
  102232. * Enables the edge rendering mode on the mesh.
  102233. * This mode makes the mesh edges visible
  102234. * @param epsilon defines the maximal distance between two angles to detect a face
  102235. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  102236. * @returns the currentAbstractMesh
  102237. * @see https://www.babylonjs-playground.com/#19O9TU#0
  102238. */
  102239. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  102240. }
  102241. }
  102242. declare module BABYLON {
  102243. /**
  102244. * Interface used to define ActionEvent
  102245. */
  102246. export interface IActionEvent {
  102247. /** The mesh or sprite that triggered the action */
  102248. source: any;
  102249. /** The X mouse cursor position at the time of the event */
  102250. pointerX: number;
  102251. /** The Y mouse cursor position at the time of the event */
  102252. pointerY: number;
  102253. /** The mesh that is currently pointed at (can be null) */
  102254. meshUnderPointer: Nullable<AbstractMesh>;
  102255. /** the original (browser) event that triggered the ActionEvent */
  102256. sourceEvent?: any;
  102257. /** additional data for the event */
  102258. additionalData?: any;
  102259. }
  102260. /**
  102261. * ActionEvent is the event being sent when an action is triggered.
  102262. */
  102263. export class ActionEvent implements IActionEvent {
  102264. /** The mesh or sprite that triggered the action */
  102265. source: any;
  102266. /** The X mouse cursor position at the time of the event */
  102267. pointerX: number;
  102268. /** The Y mouse cursor position at the time of the event */
  102269. pointerY: number;
  102270. /** The mesh that is currently pointed at (can be null) */
  102271. meshUnderPointer: Nullable<AbstractMesh>;
  102272. /** the original (browser) event that triggered the ActionEvent */
  102273. sourceEvent?: any;
  102274. /** additional data for the event */
  102275. additionalData?: any;
  102276. /**
  102277. * Creates a new ActionEvent
  102278. * @param source The mesh or sprite that triggered the action
  102279. * @param pointerX The X mouse cursor position at the time of the event
  102280. * @param pointerY The Y mouse cursor position at the time of the event
  102281. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  102282. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  102283. * @param additionalData additional data for the event
  102284. */
  102285. constructor(
  102286. /** The mesh or sprite that triggered the action */
  102287. source: any,
  102288. /** The X mouse cursor position at the time of the event */
  102289. pointerX: number,
  102290. /** The Y mouse cursor position at the time of the event */
  102291. pointerY: number,
  102292. /** The mesh that is currently pointed at (can be null) */
  102293. meshUnderPointer: Nullable<AbstractMesh>,
  102294. /** the original (browser) event that triggered the ActionEvent */
  102295. sourceEvent?: any,
  102296. /** additional data for the event */
  102297. additionalData?: any);
  102298. /**
  102299. * Helper function to auto-create an ActionEvent from a source mesh.
  102300. * @param source The source mesh that triggered the event
  102301. * @param evt The original (browser) event
  102302. * @param additionalData additional data for the event
  102303. * @returns the new ActionEvent
  102304. */
  102305. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  102306. /**
  102307. * Helper function to auto-create an ActionEvent from a source sprite
  102308. * @param source The source sprite that triggered the event
  102309. * @param scene Scene associated with the sprite
  102310. * @param evt The original (browser) event
  102311. * @param additionalData additional data for the event
  102312. * @returns the new ActionEvent
  102313. */
  102314. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  102315. /**
  102316. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  102317. * @param scene the scene where the event occurred
  102318. * @param evt The original (browser) event
  102319. * @returns the new ActionEvent
  102320. */
  102321. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  102322. /**
  102323. * Helper function to auto-create an ActionEvent from a primitive
  102324. * @param prim defines the target primitive
  102325. * @param pointerPos defines the pointer position
  102326. * @param evt The original (browser) event
  102327. * @param additionalData additional data for the event
  102328. * @returns the new ActionEvent
  102329. */
  102330. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  102331. }
  102332. }
  102333. declare module BABYLON {
  102334. /**
  102335. * Abstract class used to decouple action Manager from scene and meshes.
  102336. * Do not instantiate.
  102337. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  102338. */
  102339. export abstract class AbstractActionManager implements IDisposable {
  102340. /** Gets the list of active triggers */
  102341. static Triggers: {
  102342. [key: string]: number;
  102343. };
  102344. /** Gets the cursor to use when hovering items */
  102345. hoverCursor: string;
  102346. /** Gets the list of actions */
  102347. actions: IAction[];
  102348. /**
  102349. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  102350. */
  102351. isRecursive: boolean;
  102352. /**
  102353. * Releases all associated resources
  102354. */
  102355. abstract dispose(): void;
  102356. /**
  102357. * Does this action manager has pointer triggers
  102358. */
  102359. abstract get hasPointerTriggers(): boolean;
  102360. /**
  102361. * Does this action manager has pick triggers
  102362. */
  102363. abstract get hasPickTriggers(): boolean;
  102364. /**
  102365. * Process a specific trigger
  102366. * @param trigger defines the trigger to process
  102367. * @param evt defines the event details to be processed
  102368. */
  102369. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  102370. /**
  102371. * Does this action manager handles actions of any of the given triggers
  102372. * @param triggers defines the triggers to be tested
  102373. * @return a boolean indicating whether one (or more) of the triggers is handled
  102374. */
  102375. abstract hasSpecificTriggers(triggers: number[]): boolean;
  102376. /**
  102377. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  102378. * speed.
  102379. * @param triggerA defines the trigger to be tested
  102380. * @param triggerB defines the trigger to be tested
  102381. * @return a boolean indicating whether one (or more) of the triggers is handled
  102382. */
  102383. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  102384. /**
  102385. * Does this action manager handles actions of a given trigger
  102386. * @param trigger defines the trigger to be tested
  102387. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  102388. * @return whether the trigger is handled
  102389. */
  102390. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  102391. /**
  102392. * Serialize this manager to a JSON object
  102393. * @param name defines the property name to store this manager
  102394. * @returns a JSON representation of this manager
  102395. */
  102396. abstract serialize(name: string): any;
  102397. /**
  102398. * Registers an action to this action manager
  102399. * @param action defines the action to be registered
  102400. * @return the action amended (prepared) after registration
  102401. */
  102402. abstract registerAction(action: IAction): Nullable<IAction>;
  102403. /**
  102404. * Unregisters an action to this action manager
  102405. * @param action defines the action to be unregistered
  102406. * @return a boolean indicating whether the action has been unregistered
  102407. */
  102408. abstract unregisterAction(action: IAction): Boolean;
  102409. /**
  102410. * Does exist one action manager with at least one trigger
  102411. **/
  102412. static get HasTriggers(): boolean;
  102413. /**
  102414. * Does exist one action manager with at least one pick trigger
  102415. **/
  102416. static get HasPickTriggers(): boolean;
  102417. /**
  102418. * Does exist one action manager that handles actions of a given trigger
  102419. * @param trigger defines the trigger to be tested
  102420. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  102421. **/
  102422. static HasSpecificTrigger(trigger: number): boolean;
  102423. }
  102424. }
  102425. declare module BABYLON {
  102426. /**
  102427. * Defines how a node can be built from a string name.
  102428. */
  102429. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  102430. /**
  102431. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  102432. */
  102433. export class Node implements IBehaviorAware<Node> {
  102434. /** @hidden */
  102435. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  102436. private static _NodeConstructors;
  102437. /**
  102438. * Add a new node constructor
  102439. * @param type defines the type name of the node to construct
  102440. * @param constructorFunc defines the constructor function
  102441. */
  102442. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  102443. /**
  102444. * Returns a node constructor based on type name
  102445. * @param type defines the type name
  102446. * @param name defines the new node name
  102447. * @param scene defines the hosting scene
  102448. * @param options defines optional options to transmit to constructors
  102449. * @returns the new constructor or null
  102450. */
  102451. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  102452. /**
  102453. * Gets or sets the name of the node
  102454. */
  102455. name: string;
  102456. /**
  102457. * Gets or sets the id of the node
  102458. */
  102459. id: string;
  102460. /**
  102461. * Gets or sets the unique id of the node
  102462. */
  102463. uniqueId: number;
  102464. /**
  102465. * Gets or sets a string used to store user defined state for the node
  102466. */
  102467. state: string;
  102468. /**
  102469. * Gets or sets an object used to store user defined information for the node
  102470. */
  102471. metadata: any;
  102472. /**
  102473. * For internal use only. Please do not use.
  102474. */
  102475. reservedDataStore: any;
  102476. /**
  102477. * List of inspectable custom properties (used by the Inspector)
  102478. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  102479. */
  102480. inspectableCustomProperties: IInspectable[];
  102481. private _doNotSerialize;
  102482. /**
  102483. * Gets or sets a boolean used to define if the node must be serialized
  102484. */
  102485. get doNotSerialize(): boolean;
  102486. set doNotSerialize(value: boolean);
  102487. /** @hidden */
  102488. _isDisposed: boolean;
  102489. /**
  102490. * Gets a list of Animations associated with the node
  102491. */
  102492. animations: Animation[];
  102493. protected _ranges: {
  102494. [name: string]: Nullable<AnimationRange>;
  102495. };
  102496. /**
  102497. * Callback raised when the node is ready to be used
  102498. */
  102499. onReady: Nullable<(node: Node) => void>;
  102500. private _isEnabled;
  102501. private _isParentEnabled;
  102502. private _isReady;
  102503. /** @hidden */
  102504. _currentRenderId: number;
  102505. private _parentUpdateId;
  102506. /** @hidden */
  102507. _childUpdateId: number;
  102508. /** @hidden */
  102509. _waitingParentId: Nullable<string>;
  102510. /** @hidden */
  102511. _scene: Scene;
  102512. /** @hidden */
  102513. _cache: any;
  102514. private _parentNode;
  102515. private _children;
  102516. /** @hidden */
  102517. _worldMatrix: Matrix;
  102518. /** @hidden */
  102519. _worldMatrixDeterminant: number;
  102520. /** @hidden */
  102521. _worldMatrixDeterminantIsDirty: boolean;
  102522. /** @hidden */
  102523. private _sceneRootNodesIndex;
  102524. /**
  102525. * Gets a boolean indicating if the node has been disposed
  102526. * @returns true if the node was disposed
  102527. */
  102528. isDisposed(): boolean;
  102529. /**
  102530. * Gets or sets the parent of the node (without keeping the current position in the scene)
  102531. * @see https://doc.babylonjs.com/how_to/parenting
  102532. */
  102533. set parent(parent: Nullable<Node>);
  102534. get parent(): Nullable<Node>;
  102535. /** @hidden */
  102536. _addToSceneRootNodes(): void;
  102537. /** @hidden */
  102538. _removeFromSceneRootNodes(): void;
  102539. private _animationPropertiesOverride;
  102540. /**
  102541. * Gets or sets the animation properties override
  102542. */
  102543. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  102544. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  102545. /**
  102546. * Gets a string idenfifying the name of the class
  102547. * @returns "Node" string
  102548. */
  102549. getClassName(): string;
  102550. /** @hidden */
  102551. readonly _isNode: boolean;
  102552. /**
  102553. * An event triggered when the mesh is disposed
  102554. */
  102555. onDisposeObservable: Observable<Node>;
  102556. private _onDisposeObserver;
  102557. /**
  102558. * Sets a callback that will be raised when the node will be disposed
  102559. */
  102560. set onDispose(callback: () => void);
  102561. /**
  102562. * Creates a new Node
  102563. * @param name the name and id to be given to this node
  102564. * @param scene the scene this node will be added to
  102565. */
  102566. constructor(name: string, scene?: Nullable<Scene>);
  102567. /**
  102568. * Gets the scene of the node
  102569. * @returns a scene
  102570. */
  102571. getScene(): Scene;
  102572. /**
  102573. * Gets the engine of the node
  102574. * @returns a Engine
  102575. */
  102576. getEngine(): Engine;
  102577. private _behaviors;
  102578. /**
  102579. * Attach a behavior to the node
  102580. * @see http://doc.babylonjs.com/features/behaviour
  102581. * @param behavior defines the behavior to attach
  102582. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  102583. * @returns the current Node
  102584. */
  102585. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  102586. /**
  102587. * Remove an attached behavior
  102588. * @see http://doc.babylonjs.com/features/behaviour
  102589. * @param behavior defines the behavior to attach
  102590. * @returns the current Node
  102591. */
  102592. removeBehavior(behavior: Behavior<Node>): Node;
  102593. /**
  102594. * Gets the list of attached behaviors
  102595. * @see http://doc.babylonjs.com/features/behaviour
  102596. */
  102597. get behaviors(): Behavior<Node>[];
  102598. /**
  102599. * Gets an attached behavior by name
  102600. * @param name defines the name of the behavior to look for
  102601. * @see http://doc.babylonjs.com/features/behaviour
  102602. * @returns null if behavior was not found else the requested behavior
  102603. */
  102604. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  102605. /**
  102606. * Returns the latest update of the World matrix
  102607. * @returns a Matrix
  102608. */
  102609. getWorldMatrix(): Matrix;
  102610. /** @hidden */
  102611. _getWorldMatrixDeterminant(): number;
  102612. /**
  102613. * Returns directly the latest state of the mesh World matrix.
  102614. * A Matrix is returned.
  102615. */
  102616. get worldMatrixFromCache(): Matrix;
  102617. /** @hidden */
  102618. _initCache(): void;
  102619. /** @hidden */
  102620. updateCache(force?: boolean): void;
  102621. /** @hidden */
  102622. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  102623. /** @hidden */
  102624. _updateCache(ignoreParentClass?: boolean): void;
  102625. /** @hidden */
  102626. _isSynchronized(): boolean;
  102627. /** @hidden */
  102628. _markSyncedWithParent(): void;
  102629. /** @hidden */
  102630. isSynchronizedWithParent(): boolean;
  102631. /** @hidden */
  102632. isSynchronized(): boolean;
  102633. /**
  102634. * Is this node ready to be used/rendered
  102635. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  102636. * @return true if the node is ready
  102637. */
  102638. isReady(completeCheck?: boolean): boolean;
  102639. /**
  102640. * Is this node enabled?
  102641. * 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
  102642. * @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
  102643. * @return whether this node (and its parent) is enabled
  102644. */
  102645. isEnabled(checkAncestors?: boolean): boolean;
  102646. /** @hidden */
  102647. protected _syncParentEnabledState(): void;
  102648. /**
  102649. * Set the enabled state of this node
  102650. * @param value defines the new enabled state
  102651. */
  102652. setEnabled(value: boolean): void;
  102653. /**
  102654. * Is this node a descendant of the given node?
  102655. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  102656. * @param ancestor defines the parent node to inspect
  102657. * @returns a boolean indicating if this node is a descendant of the given node
  102658. */
  102659. isDescendantOf(ancestor: Node): boolean;
  102660. /** @hidden */
  102661. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  102662. /**
  102663. * Will return all nodes that have this node as ascendant
  102664. * @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
  102665. * @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
  102666. * @return all children nodes of all types
  102667. */
  102668. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  102669. /**
  102670. * Get all child-meshes of this node
  102671. * @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)
  102672. * @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
  102673. * @returns an array of AbstractMesh
  102674. */
  102675. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  102676. /**
  102677. * Get all direct children of this node
  102678. * @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
  102679. * @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)
  102680. * @returns an array of Node
  102681. */
  102682. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  102683. /** @hidden */
  102684. _setReady(state: boolean): void;
  102685. /**
  102686. * Get an animation by name
  102687. * @param name defines the name of the animation to look for
  102688. * @returns null if not found else the requested animation
  102689. */
  102690. getAnimationByName(name: string): Nullable<Animation>;
  102691. /**
  102692. * Creates an animation range for this node
  102693. * @param name defines the name of the range
  102694. * @param from defines the starting key
  102695. * @param to defines the end key
  102696. */
  102697. createAnimationRange(name: string, from: number, to: number): void;
  102698. /**
  102699. * Delete a specific animation range
  102700. * @param name defines the name of the range to delete
  102701. * @param deleteFrames defines if animation frames from the range must be deleted as well
  102702. */
  102703. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  102704. /**
  102705. * Get an animation range by name
  102706. * @param name defines the name of the animation range to look for
  102707. * @returns null if not found else the requested animation range
  102708. */
  102709. getAnimationRange(name: string): Nullable<AnimationRange>;
  102710. /**
  102711. * Gets the list of all animation ranges defined on this node
  102712. * @returns an array
  102713. */
  102714. getAnimationRanges(): Nullable<AnimationRange>[];
  102715. /**
  102716. * Will start the animation sequence
  102717. * @param name defines the range frames for animation sequence
  102718. * @param loop defines if the animation should loop (false by default)
  102719. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  102720. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  102721. * @returns the object created for this animation. If range does not exist, it will return null
  102722. */
  102723. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  102724. /**
  102725. * Serialize animation ranges into a JSON compatible object
  102726. * @returns serialization object
  102727. */
  102728. serializeAnimationRanges(): any;
  102729. /**
  102730. * Computes the world matrix of the node
  102731. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  102732. * @returns the world matrix
  102733. */
  102734. computeWorldMatrix(force?: boolean): Matrix;
  102735. /**
  102736. * Releases resources associated with this node.
  102737. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102738. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102739. */
  102740. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102741. /**
  102742. * Parse animation range data from a serialization object and store them into a given node
  102743. * @param node defines where to store the animation ranges
  102744. * @param parsedNode defines the serialization object to read data from
  102745. * @param scene defines the hosting scene
  102746. */
  102747. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  102748. /**
  102749. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  102750. * @param includeDescendants Include bounding info from descendants as well (true by default)
  102751. * @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
  102752. * @returns the new bounding vectors
  102753. */
  102754. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  102755. min: Vector3;
  102756. max: Vector3;
  102757. };
  102758. }
  102759. }
  102760. declare module BABYLON {
  102761. /**
  102762. * @hidden
  102763. */
  102764. export class _IAnimationState {
  102765. key: number;
  102766. repeatCount: number;
  102767. workValue?: any;
  102768. loopMode?: number;
  102769. offsetValue?: any;
  102770. highLimitValue?: any;
  102771. }
  102772. /**
  102773. * Class used to store any kind of animation
  102774. */
  102775. export class Animation {
  102776. /**Name of the animation */
  102777. name: string;
  102778. /**Property to animate */
  102779. targetProperty: string;
  102780. /**The frames per second of the animation */
  102781. framePerSecond: number;
  102782. /**The data type of the animation */
  102783. dataType: number;
  102784. /**The loop mode of the animation */
  102785. loopMode?: number | undefined;
  102786. /**Specifies if blending should be enabled */
  102787. enableBlending?: boolean | undefined;
  102788. /**
  102789. * Use matrix interpolation instead of using direct key value when animating matrices
  102790. */
  102791. static AllowMatricesInterpolation: boolean;
  102792. /**
  102793. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  102794. */
  102795. static AllowMatrixDecomposeForInterpolation: boolean;
  102796. /**
  102797. * Stores the key frames of the animation
  102798. */
  102799. private _keys;
  102800. /**
  102801. * Stores the easing function of the animation
  102802. */
  102803. private _easingFunction;
  102804. /**
  102805. * @hidden Internal use only
  102806. */
  102807. _runtimeAnimations: RuntimeAnimation[];
  102808. /**
  102809. * The set of event that will be linked to this animation
  102810. */
  102811. private _events;
  102812. /**
  102813. * Stores an array of target property paths
  102814. */
  102815. targetPropertyPath: string[];
  102816. /**
  102817. * Stores the blending speed of the animation
  102818. */
  102819. blendingSpeed: number;
  102820. /**
  102821. * Stores the animation ranges for the animation
  102822. */
  102823. private _ranges;
  102824. /**
  102825. * @hidden Internal use
  102826. */
  102827. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  102828. /**
  102829. * Sets up an animation
  102830. * @param property The property to animate
  102831. * @param animationType The animation type to apply
  102832. * @param framePerSecond The frames per second of the animation
  102833. * @param easingFunction The easing function used in the animation
  102834. * @returns The created animation
  102835. */
  102836. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  102837. /**
  102838. * Create and start an animation on a node
  102839. * @param name defines the name of the global animation that will be run on all nodes
  102840. * @param node defines the root node where the animation will take place
  102841. * @param targetProperty defines property to animate
  102842. * @param framePerSecond defines the number of frame per second yo use
  102843. * @param totalFrame defines the number of frames in total
  102844. * @param from defines the initial value
  102845. * @param to defines the final value
  102846. * @param loopMode defines which loop mode you want to use (off by default)
  102847. * @param easingFunction defines the easing function to use (linear by default)
  102848. * @param onAnimationEnd defines the callback to call when animation end
  102849. * @returns the animatable created for this animation
  102850. */
  102851. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  102852. /**
  102853. * Create and start an animation on a node and its descendants
  102854. * @param name defines the name of the global animation that will be run on all nodes
  102855. * @param node defines the root node where the animation will take place
  102856. * @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
  102857. * @param targetProperty defines property to animate
  102858. * @param framePerSecond defines the number of frame per second to use
  102859. * @param totalFrame defines the number of frames in total
  102860. * @param from defines the initial value
  102861. * @param to defines the final value
  102862. * @param loopMode defines which loop mode you want to use (off by default)
  102863. * @param easingFunction defines the easing function to use (linear by default)
  102864. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  102865. * @returns the list of animatables created for all nodes
  102866. * @example https://www.babylonjs-playground.com/#MH0VLI
  102867. */
  102868. 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[]>;
  102869. /**
  102870. * Creates a new animation, merges it with the existing animations and starts it
  102871. * @param name Name of the animation
  102872. * @param node Node which contains the scene that begins the animations
  102873. * @param targetProperty Specifies which property to animate
  102874. * @param framePerSecond The frames per second of the animation
  102875. * @param totalFrame The total number of frames
  102876. * @param from The frame at the beginning of the animation
  102877. * @param to The frame at the end of the animation
  102878. * @param loopMode Specifies the loop mode of the animation
  102879. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  102880. * @param onAnimationEnd Callback to run once the animation is complete
  102881. * @returns Nullable animation
  102882. */
  102883. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  102884. /**
  102885. * Transition property of an host to the target Value
  102886. * @param property The property to transition
  102887. * @param targetValue The target Value of the property
  102888. * @param host The object where the property to animate belongs
  102889. * @param scene Scene used to run the animation
  102890. * @param frameRate Framerate (in frame/s) to use
  102891. * @param transition The transition type we want to use
  102892. * @param duration The duration of the animation, in milliseconds
  102893. * @param onAnimationEnd Callback trigger at the end of the animation
  102894. * @returns Nullable animation
  102895. */
  102896. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  102897. /**
  102898. * Return the array of runtime animations currently using this animation
  102899. */
  102900. get runtimeAnimations(): RuntimeAnimation[];
  102901. /**
  102902. * Specifies if any of the runtime animations are currently running
  102903. */
  102904. get hasRunningRuntimeAnimations(): boolean;
  102905. /**
  102906. * Initializes the animation
  102907. * @param name Name of the animation
  102908. * @param targetProperty Property to animate
  102909. * @param framePerSecond The frames per second of the animation
  102910. * @param dataType The data type of the animation
  102911. * @param loopMode The loop mode of the animation
  102912. * @param enableBlending Specifies if blending should be enabled
  102913. */
  102914. constructor(
  102915. /**Name of the animation */
  102916. name: string,
  102917. /**Property to animate */
  102918. targetProperty: string,
  102919. /**The frames per second of the animation */
  102920. framePerSecond: number,
  102921. /**The data type of the animation */
  102922. dataType: number,
  102923. /**The loop mode of the animation */
  102924. loopMode?: number | undefined,
  102925. /**Specifies if blending should be enabled */
  102926. enableBlending?: boolean | undefined);
  102927. /**
  102928. * Converts the animation to a string
  102929. * @param fullDetails support for multiple levels of logging within scene loading
  102930. * @returns String form of the animation
  102931. */
  102932. toString(fullDetails?: boolean): string;
  102933. /**
  102934. * Add an event to this animation
  102935. * @param event Event to add
  102936. */
  102937. addEvent(event: AnimationEvent): void;
  102938. /**
  102939. * Remove all events found at the given frame
  102940. * @param frame The frame to remove events from
  102941. */
  102942. removeEvents(frame: number): void;
  102943. /**
  102944. * Retrieves all the events from the animation
  102945. * @returns Events from the animation
  102946. */
  102947. getEvents(): AnimationEvent[];
  102948. /**
  102949. * Creates an animation range
  102950. * @param name Name of the animation range
  102951. * @param from Starting frame of the animation range
  102952. * @param to Ending frame of the animation
  102953. */
  102954. createRange(name: string, from: number, to: number): void;
  102955. /**
  102956. * Deletes an animation range by name
  102957. * @param name Name of the animation range to delete
  102958. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  102959. */
  102960. deleteRange(name: string, deleteFrames?: boolean): void;
  102961. /**
  102962. * Gets the animation range by name, or null if not defined
  102963. * @param name Name of the animation range
  102964. * @returns Nullable animation range
  102965. */
  102966. getRange(name: string): Nullable<AnimationRange>;
  102967. /**
  102968. * Gets the key frames from the animation
  102969. * @returns The key frames of the animation
  102970. */
  102971. getKeys(): Array<IAnimationKey>;
  102972. /**
  102973. * Gets the highest frame rate of the animation
  102974. * @returns Highest frame rate of the animation
  102975. */
  102976. getHighestFrame(): number;
  102977. /**
  102978. * Gets the easing function of the animation
  102979. * @returns Easing function of the animation
  102980. */
  102981. getEasingFunction(): IEasingFunction;
  102982. /**
  102983. * Sets the easing function of the animation
  102984. * @param easingFunction A custom mathematical formula for animation
  102985. */
  102986. setEasingFunction(easingFunction: EasingFunction): void;
  102987. /**
  102988. * Interpolates a scalar linearly
  102989. * @param startValue Start value of the animation curve
  102990. * @param endValue End value of the animation curve
  102991. * @param gradient Scalar amount to interpolate
  102992. * @returns Interpolated scalar value
  102993. */
  102994. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  102995. /**
  102996. * Interpolates a scalar cubically
  102997. * @param startValue Start value of the animation curve
  102998. * @param outTangent End tangent of the animation
  102999. * @param endValue End value of the animation curve
  103000. * @param inTangent Start tangent of the animation curve
  103001. * @param gradient Scalar amount to interpolate
  103002. * @returns Interpolated scalar value
  103003. */
  103004. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  103005. /**
  103006. * Interpolates a quaternion using a spherical linear interpolation
  103007. * @param startValue Start value of the animation curve
  103008. * @param endValue End value of the animation curve
  103009. * @param gradient Scalar amount to interpolate
  103010. * @returns Interpolated quaternion value
  103011. */
  103012. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  103013. /**
  103014. * Interpolates a quaternion cubically
  103015. * @param startValue Start value of the animation curve
  103016. * @param outTangent End tangent of the animation curve
  103017. * @param endValue End value of the animation curve
  103018. * @param inTangent Start tangent of the animation curve
  103019. * @param gradient Scalar amount to interpolate
  103020. * @returns Interpolated quaternion value
  103021. */
  103022. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  103023. /**
  103024. * Interpolates a Vector3 linearl
  103025. * @param startValue Start value of the animation curve
  103026. * @param endValue End value of the animation curve
  103027. * @param gradient Scalar amount to interpolate
  103028. * @returns Interpolated scalar value
  103029. */
  103030. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  103031. /**
  103032. * Interpolates a Vector3 cubically
  103033. * @param startValue Start value of the animation curve
  103034. * @param outTangent End tangent of the animation
  103035. * @param endValue End value of the animation curve
  103036. * @param inTangent Start tangent of the animation curve
  103037. * @param gradient Scalar amount to interpolate
  103038. * @returns InterpolatedVector3 value
  103039. */
  103040. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  103041. /**
  103042. * Interpolates a Vector2 linearly
  103043. * @param startValue Start value of the animation curve
  103044. * @param endValue End value of the animation curve
  103045. * @param gradient Scalar amount to interpolate
  103046. * @returns Interpolated Vector2 value
  103047. */
  103048. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  103049. /**
  103050. * Interpolates a Vector2 cubically
  103051. * @param startValue Start value of the animation curve
  103052. * @param outTangent End tangent of the animation
  103053. * @param endValue End value of the animation curve
  103054. * @param inTangent Start tangent of the animation curve
  103055. * @param gradient Scalar amount to interpolate
  103056. * @returns Interpolated Vector2 value
  103057. */
  103058. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  103059. /**
  103060. * Interpolates a size linearly
  103061. * @param startValue Start value of the animation curve
  103062. * @param endValue End value of the animation curve
  103063. * @param gradient Scalar amount to interpolate
  103064. * @returns Interpolated Size value
  103065. */
  103066. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  103067. /**
  103068. * Interpolates a Color3 linearly
  103069. * @param startValue Start value of the animation curve
  103070. * @param endValue End value of the animation curve
  103071. * @param gradient Scalar amount to interpolate
  103072. * @returns Interpolated Color3 value
  103073. */
  103074. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  103075. /**
  103076. * Interpolates a Color4 linearly
  103077. * @param startValue Start value of the animation curve
  103078. * @param endValue End value of the animation curve
  103079. * @param gradient Scalar amount to interpolate
  103080. * @returns Interpolated Color3 value
  103081. */
  103082. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  103083. /**
  103084. * @hidden Internal use only
  103085. */
  103086. _getKeyValue(value: any): any;
  103087. /**
  103088. * @hidden Internal use only
  103089. */
  103090. _interpolate(currentFrame: number, state: _IAnimationState): any;
  103091. /**
  103092. * Defines the function to use to interpolate matrices
  103093. * @param startValue defines the start matrix
  103094. * @param endValue defines the end matrix
  103095. * @param gradient defines the gradient between both matrices
  103096. * @param result defines an optional target matrix where to store the interpolation
  103097. * @returns the interpolated matrix
  103098. */
  103099. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  103100. /**
  103101. * Makes a copy of the animation
  103102. * @returns Cloned animation
  103103. */
  103104. clone(): Animation;
  103105. /**
  103106. * Sets the key frames of the animation
  103107. * @param values The animation key frames to set
  103108. */
  103109. setKeys(values: Array<IAnimationKey>): void;
  103110. /**
  103111. * Serializes the animation to an object
  103112. * @returns Serialized object
  103113. */
  103114. serialize(): any;
  103115. /**
  103116. * Float animation type
  103117. */
  103118. static readonly ANIMATIONTYPE_FLOAT: number;
  103119. /**
  103120. * Vector3 animation type
  103121. */
  103122. static readonly ANIMATIONTYPE_VECTOR3: number;
  103123. /**
  103124. * Quaternion animation type
  103125. */
  103126. static readonly ANIMATIONTYPE_QUATERNION: number;
  103127. /**
  103128. * Matrix animation type
  103129. */
  103130. static readonly ANIMATIONTYPE_MATRIX: number;
  103131. /**
  103132. * Color3 animation type
  103133. */
  103134. static readonly ANIMATIONTYPE_COLOR3: number;
  103135. /**
  103136. * Color3 animation type
  103137. */
  103138. static readonly ANIMATIONTYPE_COLOR4: number;
  103139. /**
  103140. * Vector2 animation type
  103141. */
  103142. static readonly ANIMATIONTYPE_VECTOR2: number;
  103143. /**
  103144. * Size animation type
  103145. */
  103146. static readonly ANIMATIONTYPE_SIZE: number;
  103147. /**
  103148. * Relative Loop Mode
  103149. */
  103150. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  103151. /**
  103152. * Cycle Loop Mode
  103153. */
  103154. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  103155. /**
  103156. * Constant Loop Mode
  103157. */
  103158. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  103159. /** @hidden */
  103160. static _UniversalLerp(left: any, right: any, amount: number): any;
  103161. /**
  103162. * Parses an animation object and creates an animation
  103163. * @param parsedAnimation Parsed animation object
  103164. * @returns Animation object
  103165. */
  103166. static Parse(parsedAnimation: any): Animation;
  103167. /**
  103168. * Appends the serialized animations from the source animations
  103169. * @param source Source containing the animations
  103170. * @param destination Target to store the animations
  103171. */
  103172. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  103173. }
  103174. }
  103175. declare module BABYLON {
  103176. /**
  103177. * Interface containing an array of animations
  103178. */
  103179. export interface IAnimatable {
  103180. /**
  103181. * Array of animations
  103182. */
  103183. animations: Nullable<Array<Animation>>;
  103184. }
  103185. }
  103186. declare module BABYLON {
  103187. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  103188. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103189. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103190. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103191. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103192. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103193. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103194. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103195. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103196. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103197. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103198. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103199. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103200. /**
  103201. * Decorator used to define property that can be serialized as reference to a camera
  103202. * @param sourceName defines the name of the property to decorate
  103203. */
  103204. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103205. /**
  103206. * Class used to help serialization objects
  103207. */
  103208. export class SerializationHelper {
  103209. /** @hidden */
  103210. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  103211. /** @hidden */
  103212. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  103213. /** @hidden */
  103214. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  103215. /** @hidden */
  103216. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  103217. /**
  103218. * Appends the serialized animations from the source animations
  103219. * @param source Source containing the animations
  103220. * @param destination Target to store the animations
  103221. */
  103222. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  103223. /**
  103224. * Static function used to serialized a specific entity
  103225. * @param entity defines the entity to serialize
  103226. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  103227. * @returns a JSON compatible object representing the serialization of the entity
  103228. */
  103229. static Serialize<T>(entity: T, serializationObject?: any): any;
  103230. /**
  103231. * Creates a new entity from a serialization data object
  103232. * @param creationFunction defines a function used to instanciated the new entity
  103233. * @param source defines the source serialization data
  103234. * @param scene defines the hosting scene
  103235. * @param rootUrl defines the root url for resources
  103236. * @returns a new entity
  103237. */
  103238. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  103239. /**
  103240. * Clones an object
  103241. * @param creationFunction defines the function used to instanciate the new object
  103242. * @param source defines the source object
  103243. * @returns the cloned object
  103244. */
  103245. static Clone<T>(creationFunction: () => T, source: T): T;
  103246. /**
  103247. * Instanciates a new object based on a source one (some data will be shared between both object)
  103248. * @param creationFunction defines the function used to instanciate the new object
  103249. * @param source defines the source object
  103250. * @returns the new object
  103251. */
  103252. static Instanciate<T>(creationFunction: () => T, source: T): T;
  103253. }
  103254. }
  103255. declare module BABYLON {
  103256. /**
  103257. * Class used to manipulate GUIDs
  103258. */
  103259. export class GUID {
  103260. /**
  103261. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  103262. * Be aware Math.random() could cause collisions, but:
  103263. * "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"
  103264. * @returns a pseudo random id
  103265. */
  103266. static RandomId(): string;
  103267. }
  103268. }
  103269. declare module BABYLON {
  103270. /**
  103271. * Base class of all the textures in babylon.
  103272. * It groups all the common properties the materials, post process, lights... might need
  103273. * in order to make a correct use of the texture.
  103274. */
  103275. export class BaseTexture implements IAnimatable {
  103276. /**
  103277. * Default anisotropic filtering level for the application.
  103278. * It is set to 4 as a good tradeoff between perf and quality.
  103279. */
  103280. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  103281. /**
  103282. * Gets or sets the unique id of the texture
  103283. */
  103284. uniqueId: number;
  103285. /**
  103286. * Define the name of the texture.
  103287. */
  103288. name: string;
  103289. /**
  103290. * Gets or sets an object used to store user defined information.
  103291. */
  103292. metadata: any;
  103293. /**
  103294. * For internal use only. Please do not use.
  103295. */
  103296. reservedDataStore: any;
  103297. private _hasAlpha;
  103298. /**
  103299. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  103300. */
  103301. set hasAlpha(value: boolean);
  103302. get hasAlpha(): boolean;
  103303. /**
  103304. * Defines if the alpha value should be determined via the rgb values.
  103305. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  103306. */
  103307. getAlphaFromRGB: boolean;
  103308. /**
  103309. * Intensity or strength of the texture.
  103310. * It is commonly used by materials to fine tune the intensity of the texture
  103311. */
  103312. level: number;
  103313. /**
  103314. * Define the UV chanel to use starting from 0 and defaulting to 0.
  103315. * This is part of the texture as textures usually maps to one uv set.
  103316. */
  103317. coordinatesIndex: number;
  103318. private _coordinatesMode;
  103319. /**
  103320. * How a texture is mapped.
  103321. *
  103322. * | Value | Type | Description |
  103323. * | ----- | ----------------------------------- | ----------- |
  103324. * | 0 | EXPLICIT_MODE | |
  103325. * | 1 | SPHERICAL_MODE | |
  103326. * | 2 | PLANAR_MODE | |
  103327. * | 3 | CUBIC_MODE | |
  103328. * | 4 | PROJECTION_MODE | |
  103329. * | 5 | SKYBOX_MODE | |
  103330. * | 6 | INVCUBIC_MODE | |
  103331. * | 7 | EQUIRECTANGULAR_MODE | |
  103332. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  103333. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  103334. */
  103335. set coordinatesMode(value: number);
  103336. get coordinatesMode(): number;
  103337. /**
  103338. * | Value | Type | Description |
  103339. * | ----- | ------------------ | ----------- |
  103340. * | 0 | CLAMP_ADDRESSMODE | |
  103341. * | 1 | WRAP_ADDRESSMODE | |
  103342. * | 2 | MIRROR_ADDRESSMODE | |
  103343. */
  103344. wrapU: number;
  103345. /**
  103346. * | Value | Type | Description |
  103347. * | ----- | ------------------ | ----------- |
  103348. * | 0 | CLAMP_ADDRESSMODE | |
  103349. * | 1 | WRAP_ADDRESSMODE | |
  103350. * | 2 | MIRROR_ADDRESSMODE | |
  103351. */
  103352. wrapV: number;
  103353. /**
  103354. * | Value | Type | Description |
  103355. * | ----- | ------------------ | ----------- |
  103356. * | 0 | CLAMP_ADDRESSMODE | |
  103357. * | 1 | WRAP_ADDRESSMODE | |
  103358. * | 2 | MIRROR_ADDRESSMODE | |
  103359. */
  103360. wrapR: number;
  103361. /**
  103362. * With compliant hardware and browser (supporting anisotropic filtering)
  103363. * this defines the level of anisotropic filtering in the texture.
  103364. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  103365. */
  103366. anisotropicFilteringLevel: number;
  103367. /**
  103368. * Define if the texture is a cube texture or if false a 2d texture.
  103369. */
  103370. get isCube(): boolean;
  103371. set isCube(value: boolean);
  103372. /**
  103373. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  103374. */
  103375. get is3D(): boolean;
  103376. set is3D(value: boolean);
  103377. /**
  103378. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  103379. */
  103380. get is2DArray(): boolean;
  103381. set is2DArray(value: boolean);
  103382. /**
  103383. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  103384. * HDR texture are usually stored in linear space.
  103385. * This only impacts the PBR and Background materials
  103386. */
  103387. gammaSpace: boolean;
  103388. /**
  103389. * Gets or sets whether or not the texture contains RGBD data.
  103390. */
  103391. get isRGBD(): boolean;
  103392. set isRGBD(value: boolean);
  103393. /**
  103394. * Is Z inverted in the texture (useful in a cube texture).
  103395. */
  103396. invertZ: boolean;
  103397. /**
  103398. * Are mip maps generated for this texture or not.
  103399. */
  103400. get noMipmap(): boolean;
  103401. /**
  103402. * @hidden
  103403. */
  103404. lodLevelInAlpha: boolean;
  103405. /**
  103406. * With prefiltered texture, defined the offset used during the prefiltering steps.
  103407. */
  103408. get lodGenerationOffset(): number;
  103409. set lodGenerationOffset(value: number);
  103410. /**
  103411. * With prefiltered texture, defined the scale used during the prefiltering steps.
  103412. */
  103413. get lodGenerationScale(): number;
  103414. set lodGenerationScale(value: number);
  103415. /**
  103416. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  103417. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  103418. * average roughness values.
  103419. */
  103420. get linearSpecularLOD(): boolean;
  103421. set linearSpecularLOD(value: boolean);
  103422. /**
  103423. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  103424. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  103425. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  103426. */
  103427. get irradianceTexture(): Nullable<BaseTexture>;
  103428. set irradianceTexture(value: Nullable<BaseTexture>);
  103429. /**
  103430. * Define if the texture is a render target.
  103431. */
  103432. isRenderTarget: boolean;
  103433. /**
  103434. * Define the unique id of the texture in the scene.
  103435. */
  103436. get uid(): string;
  103437. /**
  103438. * Return a string representation of the texture.
  103439. * @returns the texture as a string
  103440. */
  103441. toString(): string;
  103442. /**
  103443. * Get the class name of the texture.
  103444. * @returns "BaseTexture"
  103445. */
  103446. getClassName(): string;
  103447. /**
  103448. * Define the list of animation attached to the texture.
  103449. */
  103450. animations: Animation[];
  103451. /**
  103452. * An event triggered when the texture is disposed.
  103453. */
  103454. onDisposeObservable: Observable<BaseTexture>;
  103455. private _onDisposeObserver;
  103456. /**
  103457. * Callback triggered when the texture has been disposed.
  103458. * Kept for back compatibility, you can use the onDisposeObservable instead.
  103459. */
  103460. set onDispose(callback: () => void);
  103461. /**
  103462. * Define the current state of the loading sequence when in delayed load mode.
  103463. */
  103464. delayLoadState: number;
  103465. private _scene;
  103466. /** @hidden */
  103467. _texture: Nullable<InternalTexture>;
  103468. private _uid;
  103469. /**
  103470. * Define if the texture is preventinga material to render or not.
  103471. * If not and the texture is not ready, the engine will use a default black texture instead.
  103472. */
  103473. get isBlocking(): boolean;
  103474. /**
  103475. * Instantiates a new BaseTexture.
  103476. * Base class of all the textures in babylon.
  103477. * It groups all the common properties the materials, post process, lights... might need
  103478. * in order to make a correct use of the texture.
  103479. * @param scene Define the scene the texture blongs to
  103480. */
  103481. constructor(scene: Nullable<Scene>);
  103482. /**
  103483. * Get the scene the texture belongs to.
  103484. * @returns the scene or null if undefined
  103485. */
  103486. getScene(): Nullable<Scene>;
  103487. /**
  103488. * Get the texture transform matrix used to offset tile the texture for istance.
  103489. * @returns the transformation matrix
  103490. */
  103491. getTextureMatrix(): Matrix;
  103492. /**
  103493. * Get the texture reflection matrix used to rotate/transform the reflection.
  103494. * @returns the reflection matrix
  103495. */
  103496. getReflectionTextureMatrix(): Matrix;
  103497. /**
  103498. * Get the underlying lower level texture from Babylon.
  103499. * @returns the insternal texture
  103500. */
  103501. getInternalTexture(): Nullable<InternalTexture>;
  103502. /**
  103503. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  103504. * @returns true if ready or not blocking
  103505. */
  103506. isReadyOrNotBlocking(): boolean;
  103507. /**
  103508. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  103509. * @returns true if fully ready
  103510. */
  103511. isReady(): boolean;
  103512. private _cachedSize;
  103513. /**
  103514. * Get the size of the texture.
  103515. * @returns the texture size.
  103516. */
  103517. getSize(): ISize;
  103518. /**
  103519. * Get the base size of the texture.
  103520. * It can be different from the size if the texture has been resized for POT for instance
  103521. * @returns the base size
  103522. */
  103523. getBaseSize(): ISize;
  103524. /**
  103525. * Update the sampling mode of the texture.
  103526. * Default is Trilinear mode.
  103527. *
  103528. * | Value | Type | Description |
  103529. * | ----- | ------------------ | ----------- |
  103530. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  103531. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  103532. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  103533. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  103534. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  103535. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  103536. * | 7 | NEAREST_LINEAR | |
  103537. * | 8 | NEAREST_NEAREST | |
  103538. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  103539. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  103540. * | 11 | LINEAR_LINEAR | |
  103541. * | 12 | LINEAR_NEAREST | |
  103542. *
  103543. * > _mag_: magnification filter (close to the viewer)
  103544. * > _min_: minification filter (far from the viewer)
  103545. * > _mip_: filter used between mip map levels
  103546. *@param samplingMode Define the new sampling mode of the texture
  103547. */
  103548. updateSamplingMode(samplingMode: number): void;
  103549. /**
  103550. * Scales the texture if is `canRescale()`
  103551. * @param ratio the resize factor we want to use to rescale
  103552. */
  103553. scale(ratio: number): void;
  103554. /**
  103555. * Get if the texture can rescale.
  103556. */
  103557. get canRescale(): boolean;
  103558. /** @hidden */
  103559. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  103560. /** @hidden */
  103561. _rebuild(): void;
  103562. /**
  103563. * Triggers the load sequence in delayed load mode.
  103564. */
  103565. delayLoad(): void;
  103566. /**
  103567. * Clones the texture.
  103568. * @returns the cloned texture
  103569. */
  103570. clone(): Nullable<BaseTexture>;
  103571. /**
  103572. * Get the texture underlying type (INT, FLOAT...)
  103573. */
  103574. get textureType(): number;
  103575. /**
  103576. * Get the texture underlying format (RGB, RGBA...)
  103577. */
  103578. get textureFormat(): number;
  103579. /**
  103580. * Indicates that textures need to be re-calculated for all materials
  103581. */
  103582. protected _markAllSubMeshesAsTexturesDirty(): void;
  103583. /**
  103584. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  103585. * This will returns an RGBA array buffer containing either in values (0-255) or
  103586. * float values (0-1) depending of the underlying buffer type.
  103587. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  103588. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  103589. * @param buffer defines a user defined buffer to fill with data (can be null)
  103590. * @returns The Array buffer containing the pixels data.
  103591. */
  103592. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  103593. /**
  103594. * Release and destroy the underlying lower level texture aka internalTexture.
  103595. */
  103596. releaseInternalTexture(): void;
  103597. /** @hidden */
  103598. get _lodTextureHigh(): Nullable<BaseTexture>;
  103599. /** @hidden */
  103600. get _lodTextureMid(): Nullable<BaseTexture>;
  103601. /** @hidden */
  103602. get _lodTextureLow(): Nullable<BaseTexture>;
  103603. /**
  103604. * Dispose the texture and release its associated resources.
  103605. */
  103606. dispose(): void;
  103607. /**
  103608. * Serialize the texture into a JSON representation that can be parsed later on.
  103609. * @returns the JSON representation of the texture
  103610. */
  103611. serialize(): any;
  103612. /**
  103613. * Helper function to be called back once a list of texture contains only ready textures.
  103614. * @param textures Define the list of textures to wait for
  103615. * @param callback Define the callback triggered once the entire list will be ready
  103616. */
  103617. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  103618. }
  103619. }
  103620. declare module BABYLON {
  103621. /**
  103622. * Options to be used when creating an effect.
  103623. */
  103624. export interface IEffectCreationOptions {
  103625. /**
  103626. * Atrributes that will be used in the shader.
  103627. */
  103628. attributes: string[];
  103629. /**
  103630. * Uniform varible names that will be set in the shader.
  103631. */
  103632. uniformsNames: string[];
  103633. /**
  103634. * Uniform buffer variable names that will be set in the shader.
  103635. */
  103636. uniformBuffersNames: string[];
  103637. /**
  103638. * Sampler texture variable names that will be set in the shader.
  103639. */
  103640. samplers: string[];
  103641. /**
  103642. * Define statements that will be set in the shader.
  103643. */
  103644. defines: any;
  103645. /**
  103646. * Possible fallbacks for this effect to improve performance when needed.
  103647. */
  103648. fallbacks: Nullable<IEffectFallbacks>;
  103649. /**
  103650. * Callback that will be called when the shader is compiled.
  103651. */
  103652. onCompiled: Nullable<(effect: Effect) => void>;
  103653. /**
  103654. * Callback that will be called if an error occurs during shader compilation.
  103655. */
  103656. onError: Nullable<(effect: Effect, errors: string) => void>;
  103657. /**
  103658. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  103659. */
  103660. indexParameters?: any;
  103661. /**
  103662. * Max number of lights that can be used in the shader.
  103663. */
  103664. maxSimultaneousLights?: number;
  103665. /**
  103666. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  103667. */
  103668. transformFeedbackVaryings?: Nullable<string[]>;
  103669. }
  103670. /**
  103671. * Effect containing vertex and fragment shader that can be executed on an object.
  103672. */
  103673. export class Effect implements IDisposable {
  103674. /**
  103675. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  103676. */
  103677. static ShadersRepository: string;
  103678. /**
  103679. * Enable logging of the shader code when a compilation error occurs
  103680. */
  103681. static LogShaderCodeOnCompilationError: boolean;
  103682. /**
  103683. * Name of the effect.
  103684. */
  103685. name: any;
  103686. /**
  103687. * String container all the define statements that should be set on the shader.
  103688. */
  103689. defines: string;
  103690. /**
  103691. * Callback that will be called when the shader is compiled.
  103692. */
  103693. onCompiled: Nullable<(effect: Effect) => void>;
  103694. /**
  103695. * Callback that will be called if an error occurs during shader compilation.
  103696. */
  103697. onError: Nullable<(effect: Effect, errors: string) => void>;
  103698. /**
  103699. * Callback that will be called when effect is bound.
  103700. */
  103701. onBind: Nullable<(effect: Effect) => void>;
  103702. /**
  103703. * Unique ID of the effect.
  103704. */
  103705. uniqueId: number;
  103706. /**
  103707. * Observable that will be called when the shader is compiled.
  103708. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  103709. */
  103710. onCompileObservable: Observable<Effect>;
  103711. /**
  103712. * Observable that will be called if an error occurs during shader compilation.
  103713. */
  103714. onErrorObservable: Observable<Effect>;
  103715. /** @hidden */
  103716. _onBindObservable: Nullable<Observable<Effect>>;
  103717. /**
  103718. * @hidden
  103719. * Specifies if the effect was previously ready
  103720. */
  103721. _wasPreviouslyReady: boolean;
  103722. /**
  103723. * Observable that will be called when effect is bound.
  103724. */
  103725. get onBindObservable(): Observable<Effect>;
  103726. /** @hidden */
  103727. _bonesComputationForcedToCPU: boolean;
  103728. private static _uniqueIdSeed;
  103729. private _engine;
  103730. private _uniformBuffersNames;
  103731. private _uniformsNames;
  103732. private _samplerList;
  103733. private _samplers;
  103734. private _isReady;
  103735. private _compilationError;
  103736. private _allFallbacksProcessed;
  103737. private _attributesNames;
  103738. private _attributes;
  103739. private _attributeLocationByName;
  103740. private _uniforms;
  103741. /**
  103742. * Key for the effect.
  103743. * @hidden
  103744. */
  103745. _key: string;
  103746. private _indexParameters;
  103747. private _fallbacks;
  103748. private _vertexSourceCode;
  103749. private _fragmentSourceCode;
  103750. private _vertexSourceCodeOverride;
  103751. private _fragmentSourceCodeOverride;
  103752. private _transformFeedbackVaryings;
  103753. /**
  103754. * Compiled shader to webGL program.
  103755. * @hidden
  103756. */
  103757. _pipelineContext: Nullable<IPipelineContext>;
  103758. private _valueCache;
  103759. private static _baseCache;
  103760. /**
  103761. * Instantiates an effect.
  103762. * An effect can be used to create/manage/execute vertex and fragment shaders.
  103763. * @param baseName Name of the effect.
  103764. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  103765. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  103766. * @param samplers List of sampler variables that will be passed to the shader.
  103767. * @param engine Engine to be used to render the effect
  103768. * @param defines Define statements to be added to the shader.
  103769. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  103770. * @param onCompiled Callback that will be called when the shader is compiled.
  103771. * @param onError Callback that will be called if an error occurs during shader compilation.
  103772. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  103773. */
  103774. 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);
  103775. private _useFinalCode;
  103776. /**
  103777. * Unique key for this effect
  103778. */
  103779. get key(): string;
  103780. /**
  103781. * If the effect has been compiled and prepared.
  103782. * @returns if the effect is compiled and prepared.
  103783. */
  103784. isReady(): boolean;
  103785. private _isReadyInternal;
  103786. /**
  103787. * The engine the effect was initialized with.
  103788. * @returns the engine.
  103789. */
  103790. getEngine(): Engine;
  103791. /**
  103792. * The pipeline context for this effect
  103793. * @returns the associated pipeline context
  103794. */
  103795. getPipelineContext(): Nullable<IPipelineContext>;
  103796. /**
  103797. * The set of names of attribute variables for the shader.
  103798. * @returns An array of attribute names.
  103799. */
  103800. getAttributesNames(): string[];
  103801. /**
  103802. * Returns the attribute at the given index.
  103803. * @param index The index of the attribute.
  103804. * @returns The location of the attribute.
  103805. */
  103806. getAttributeLocation(index: number): number;
  103807. /**
  103808. * Returns the attribute based on the name of the variable.
  103809. * @param name of the attribute to look up.
  103810. * @returns the attribute location.
  103811. */
  103812. getAttributeLocationByName(name: string): number;
  103813. /**
  103814. * The number of attributes.
  103815. * @returns the numnber of attributes.
  103816. */
  103817. getAttributesCount(): number;
  103818. /**
  103819. * Gets the index of a uniform variable.
  103820. * @param uniformName of the uniform to look up.
  103821. * @returns the index.
  103822. */
  103823. getUniformIndex(uniformName: string): number;
  103824. /**
  103825. * Returns the attribute based on the name of the variable.
  103826. * @param uniformName of the uniform to look up.
  103827. * @returns the location of the uniform.
  103828. */
  103829. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  103830. /**
  103831. * Returns an array of sampler variable names
  103832. * @returns The array of sampler variable neames.
  103833. */
  103834. getSamplers(): string[];
  103835. /**
  103836. * The error from the last compilation.
  103837. * @returns the error string.
  103838. */
  103839. getCompilationError(): string;
  103840. /**
  103841. * Gets a boolean indicating that all fallbacks were used during compilation
  103842. * @returns true if all fallbacks were used
  103843. */
  103844. allFallbacksProcessed(): boolean;
  103845. /**
  103846. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  103847. * @param func The callback to be used.
  103848. */
  103849. executeWhenCompiled(func: (effect: Effect) => void): void;
  103850. private _checkIsReady;
  103851. private _loadShader;
  103852. /**
  103853. * Recompiles the webGL program
  103854. * @param vertexSourceCode The source code for the vertex shader.
  103855. * @param fragmentSourceCode The source code for the fragment shader.
  103856. * @param onCompiled Callback called when completed.
  103857. * @param onError Callback called on error.
  103858. * @hidden
  103859. */
  103860. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  103861. /**
  103862. * Prepares the effect
  103863. * @hidden
  103864. */
  103865. _prepareEffect(): void;
  103866. private _getShaderCodeAndErrorLine;
  103867. private _processCompilationErrors;
  103868. /**
  103869. * Checks if the effect is supported. (Must be called after compilation)
  103870. */
  103871. get isSupported(): boolean;
  103872. /**
  103873. * Binds a texture to the engine to be used as output of the shader.
  103874. * @param channel Name of the output variable.
  103875. * @param texture Texture to bind.
  103876. * @hidden
  103877. */
  103878. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  103879. /**
  103880. * Sets a texture on the engine to be used in the shader.
  103881. * @param channel Name of the sampler variable.
  103882. * @param texture Texture to set.
  103883. */
  103884. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  103885. /**
  103886. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  103887. * @param channel Name of the sampler variable.
  103888. * @param texture Texture to set.
  103889. */
  103890. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  103891. /**
  103892. * Sets an array of textures on the engine to be used in the shader.
  103893. * @param channel Name of the variable.
  103894. * @param textures Textures to set.
  103895. */
  103896. setTextureArray(channel: string, textures: BaseTexture[]): void;
  103897. /**
  103898. * 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)
  103899. * @param channel Name of the sampler variable.
  103900. * @param postProcess Post process to get the input texture from.
  103901. */
  103902. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  103903. /**
  103904. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  103905. * 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)
  103906. * @param channel Name of the sampler variable.
  103907. * @param postProcess Post process to get the output texture from.
  103908. */
  103909. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  103910. /** @hidden */
  103911. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  103912. /** @hidden */
  103913. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  103914. /** @hidden */
  103915. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  103916. /** @hidden */
  103917. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  103918. /**
  103919. * Binds a buffer to a uniform.
  103920. * @param buffer Buffer to bind.
  103921. * @param name Name of the uniform variable to bind to.
  103922. */
  103923. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  103924. /**
  103925. * Binds block to a uniform.
  103926. * @param blockName Name of the block to bind.
  103927. * @param index Index to bind.
  103928. */
  103929. bindUniformBlock(blockName: string, index: number): void;
  103930. /**
  103931. * Sets an interger value on a uniform variable.
  103932. * @param uniformName Name of the variable.
  103933. * @param value Value to be set.
  103934. * @returns this effect.
  103935. */
  103936. setInt(uniformName: string, value: number): Effect;
  103937. /**
  103938. * Sets an int array on a uniform variable.
  103939. * @param uniformName Name of the variable.
  103940. * @param array array to be set.
  103941. * @returns this effect.
  103942. */
  103943. setIntArray(uniformName: string, array: Int32Array): Effect;
  103944. /**
  103945. * 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)
  103946. * @param uniformName Name of the variable.
  103947. * @param array array to be set.
  103948. * @returns this effect.
  103949. */
  103950. setIntArray2(uniformName: string, array: Int32Array): Effect;
  103951. /**
  103952. * 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)
  103953. * @param uniformName Name of the variable.
  103954. * @param array array to be set.
  103955. * @returns this effect.
  103956. */
  103957. setIntArray3(uniformName: string, array: Int32Array): Effect;
  103958. /**
  103959. * 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)
  103960. * @param uniformName Name of the variable.
  103961. * @param array array to be set.
  103962. * @returns this effect.
  103963. */
  103964. setIntArray4(uniformName: string, array: Int32Array): Effect;
  103965. /**
  103966. * Sets an float array on a uniform variable.
  103967. * @param uniformName Name of the variable.
  103968. * @param array array to be set.
  103969. * @returns this effect.
  103970. */
  103971. setFloatArray(uniformName: string, array: Float32Array): Effect;
  103972. /**
  103973. * 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)
  103974. * @param uniformName Name of the variable.
  103975. * @param array array to be set.
  103976. * @returns this effect.
  103977. */
  103978. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  103979. /**
  103980. * 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)
  103981. * @param uniformName Name of the variable.
  103982. * @param array array to be set.
  103983. * @returns this effect.
  103984. */
  103985. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  103986. /**
  103987. * 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)
  103988. * @param uniformName Name of the variable.
  103989. * @param array array to be set.
  103990. * @returns this effect.
  103991. */
  103992. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  103993. /**
  103994. * Sets an array on a uniform variable.
  103995. * @param uniformName Name of the variable.
  103996. * @param array array to be set.
  103997. * @returns this effect.
  103998. */
  103999. setArray(uniformName: string, array: number[]): Effect;
  104000. /**
  104001. * 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)
  104002. * @param uniformName Name of the variable.
  104003. * @param array array to be set.
  104004. * @returns this effect.
  104005. */
  104006. setArray2(uniformName: string, array: number[]): Effect;
  104007. /**
  104008. * 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)
  104009. * @param uniformName Name of the variable.
  104010. * @param array array to be set.
  104011. * @returns this effect.
  104012. */
  104013. setArray3(uniformName: string, array: number[]): Effect;
  104014. /**
  104015. * 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)
  104016. * @param uniformName Name of the variable.
  104017. * @param array array to be set.
  104018. * @returns this effect.
  104019. */
  104020. setArray4(uniformName: string, array: number[]): Effect;
  104021. /**
  104022. * Sets matrices on a uniform variable.
  104023. * @param uniformName Name of the variable.
  104024. * @param matrices matrices to be set.
  104025. * @returns this effect.
  104026. */
  104027. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  104028. /**
  104029. * Sets matrix on a uniform variable.
  104030. * @param uniformName Name of the variable.
  104031. * @param matrix matrix to be set.
  104032. * @returns this effect.
  104033. */
  104034. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  104035. /**
  104036. * 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)
  104037. * @param uniformName Name of the variable.
  104038. * @param matrix matrix to be set.
  104039. * @returns this effect.
  104040. */
  104041. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  104042. /**
  104043. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  104044. * @param uniformName Name of the variable.
  104045. * @param matrix matrix to be set.
  104046. * @returns this effect.
  104047. */
  104048. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  104049. /**
  104050. * Sets a float on a uniform variable.
  104051. * @param uniformName Name of the variable.
  104052. * @param value value to be set.
  104053. * @returns this effect.
  104054. */
  104055. setFloat(uniformName: string, value: number): Effect;
  104056. /**
  104057. * Sets a boolean on a uniform variable.
  104058. * @param uniformName Name of the variable.
  104059. * @param bool value to be set.
  104060. * @returns this effect.
  104061. */
  104062. setBool(uniformName: string, bool: boolean): Effect;
  104063. /**
  104064. * Sets a Vector2 on a uniform variable.
  104065. * @param uniformName Name of the variable.
  104066. * @param vector2 vector2 to be set.
  104067. * @returns this effect.
  104068. */
  104069. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  104070. /**
  104071. * Sets a float2 on a uniform variable.
  104072. * @param uniformName Name of the variable.
  104073. * @param x First float in float2.
  104074. * @param y Second float in float2.
  104075. * @returns this effect.
  104076. */
  104077. setFloat2(uniformName: string, x: number, y: number): Effect;
  104078. /**
  104079. * Sets a Vector3 on a uniform variable.
  104080. * @param uniformName Name of the variable.
  104081. * @param vector3 Value to be set.
  104082. * @returns this effect.
  104083. */
  104084. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  104085. /**
  104086. * Sets a float3 on a uniform variable.
  104087. * @param uniformName Name of the variable.
  104088. * @param x First float in float3.
  104089. * @param y Second float in float3.
  104090. * @param z Third float in float3.
  104091. * @returns this effect.
  104092. */
  104093. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  104094. /**
  104095. * Sets a Vector4 on a uniform variable.
  104096. * @param uniformName Name of the variable.
  104097. * @param vector4 Value to be set.
  104098. * @returns this effect.
  104099. */
  104100. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  104101. /**
  104102. * Sets a float4 on a uniform variable.
  104103. * @param uniformName Name of the variable.
  104104. * @param x First float in float4.
  104105. * @param y Second float in float4.
  104106. * @param z Third float in float4.
  104107. * @param w Fourth float in float4.
  104108. * @returns this effect.
  104109. */
  104110. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  104111. /**
  104112. * Sets a Color3 on a uniform variable.
  104113. * @param uniformName Name of the variable.
  104114. * @param color3 Value to be set.
  104115. * @returns this effect.
  104116. */
  104117. setColor3(uniformName: string, color3: IColor3Like): Effect;
  104118. /**
  104119. * Sets a Color4 on a uniform variable.
  104120. * @param uniformName Name of the variable.
  104121. * @param color3 Value to be set.
  104122. * @param alpha Alpha value to be set.
  104123. * @returns this effect.
  104124. */
  104125. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  104126. /**
  104127. * Sets a Color4 on a uniform variable
  104128. * @param uniformName defines the name of the variable
  104129. * @param color4 defines the value to be set
  104130. * @returns this effect.
  104131. */
  104132. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  104133. /** Release all associated resources */
  104134. dispose(): void;
  104135. /**
  104136. * This function will add a new shader to the shader store
  104137. * @param name the name of the shader
  104138. * @param pixelShader optional pixel shader content
  104139. * @param vertexShader optional vertex shader content
  104140. */
  104141. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  104142. /**
  104143. * Store of each shader (The can be looked up using effect.key)
  104144. */
  104145. static ShadersStore: {
  104146. [key: string]: string;
  104147. };
  104148. /**
  104149. * Store of each included file for a shader (The can be looked up using effect.key)
  104150. */
  104151. static IncludesShadersStore: {
  104152. [key: string]: string;
  104153. };
  104154. /**
  104155. * Resets the cache of effects.
  104156. */
  104157. static ResetCache(): void;
  104158. }
  104159. }
  104160. declare module BABYLON {
  104161. /**
  104162. * Interface used to describe the capabilities of the engine relatively to the current browser
  104163. */
  104164. export interface EngineCapabilities {
  104165. /** Maximum textures units per fragment shader */
  104166. maxTexturesImageUnits: number;
  104167. /** Maximum texture units per vertex shader */
  104168. maxVertexTextureImageUnits: number;
  104169. /** Maximum textures units in the entire pipeline */
  104170. maxCombinedTexturesImageUnits: number;
  104171. /** Maximum texture size */
  104172. maxTextureSize: number;
  104173. /** Maximum texture samples */
  104174. maxSamples?: number;
  104175. /** Maximum cube texture size */
  104176. maxCubemapTextureSize: number;
  104177. /** Maximum render texture size */
  104178. maxRenderTextureSize: number;
  104179. /** Maximum number of vertex attributes */
  104180. maxVertexAttribs: number;
  104181. /** Maximum number of varyings */
  104182. maxVaryingVectors: number;
  104183. /** Maximum number of uniforms per vertex shader */
  104184. maxVertexUniformVectors: number;
  104185. /** Maximum number of uniforms per fragment shader */
  104186. maxFragmentUniformVectors: number;
  104187. /** Defines if standard derivates (dx/dy) are supported */
  104188. standardDerivatives: boolean;
  104189. /** Defines if s3tc texture compression is supported */
  104190. s3tc?: WEBGL_compressed_texture_s3tc;
  104191. /** Defines if pvrtc texture compression is supported */
  104192. pvrtc: any;
  104193. /** Defines if etc1 texture compression is supported */
  104194. etc1: any;
  104195. /** Defines if etc2 texture compression is supported */
  104196. etc2: any;
  104197. /** Defines if astc texture compression is supported */
  104198. astc: any;
  104199. /** Defines if float textures are supported */
  104200. textureFloat: boolean;
  104201. /** Defines if vertex array objects are supported */
  104202. vertexArrayObject: boolean;
  104203. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  104204. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  104205. /** Gets the maximum level of anisotropy supported */
  104206. maxAnisotropy: number;
  104207. /** Defines if instancing is supported */
  104208. instancedArrays: boolean;
  104209. /** Defines if 32 bits indices are supported */
  104210. uintIndices: boolean;
  104211. /** Defines if high precision shaders are supported */
  104212. highPrecisionShaderSupported: boolean;
  104213. /** Defines if depth reading in the fragment shader is supported */
  104214. fragmentDepthSupported: boolean;
  104215. /** Defines if float texture linear filtering is supported*/
  104216. textureFloatLinearFiltering: boolean;
  104217. /** Defines if rendering to float textures is supported */
  104218. textureFloatRender: boolean;
  104219. /** Defines if half float textures are supported*/
  104220. textureHalfFloat: boolean;
  104221. /** Defines if half float texture linear filtering is supported*/
  104222. textureHalfFloatLinearFiltering: boolean;
  104223. /** Defines if rendering to half float textures is supported */
  104224. textureHalfFloatRender: boolean;
  104225. /** Defines if textureLOD shader command is supported */
  104226. textureLOD: boolean;
  104227. /** Defines if draw buffers extension is supported */
  104228. drawBuffersExtension: boolean;
  104229. /** Defines if depth textures are supported */
  104230. depthTextureExtension: boolean;
  104231. /** Defines if float color buffer are supported */
  104232. colorBufferFloat: boolean;
  104233. /** Gets disjoint timer query extension (null if not supported) */
  104234. timerQuery?: EXT_disjoint_timer_query;
  104235. /** Defines if timestamp can be used with timer query */
  104236. canUseTimestampForTimerQuery: boolean;
  104237. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  104238. multiview?: any;
  104239. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  104240. oculusMultiview?: any;
  104241. /** Function used to let the system compiles shaders in background */
  104242. parallelShaderCompile?: {
  104243. COMPLETION_STATUS_KHR: number;
  104244. };
  104245. /** Max number of texture samples for MSAA */
  104246. maxMSAASamples: number;
  104247. /** Defines if the blend min max extension is supported */
  104248. blendMinMax: boolean;
  104249. }
  104250. }
  104251. declare module BABYLON {
  104252. /**
  104253. * @hidden
  104254. **/
  104255. export class DepthCullingState {
  104256. private _isDepthTestDirty;
  104257. private _isDepthMaskDirty;
  104258. private _isDepthFuncDirty;
  104259. private _isCullFaceDirty;
  104260. private _isCullDirty;
  104261. private _isZOffsetDirty;
  104262. private _isFrontFaceDirty;
  104263. private _depthTest;
  104264. private _depthMask;
  104265. private _depthFunc;
  104266. private _cull;
  104267. private _cullFace;
  104268. private _zOffset;
  104269. private _frontFace;
  104270. /**
  104271. * Initializes the state.
  104272. */
  104273. constructor();
  104274. get isDirty(): boolean;
  104275. get zOffset(): number;
  104276. set zOffset(value: number);
  104277. get cullFace(): Nullable<number>;
  104278. set cullFace(value: Nullable<number>);
  104279. get cull(): Nullable<boolean>;
  104280. set cull(value: Nullable<boolean>);
  104281. get depthFunc(): Nullable<number>;
  104282. set depthFunc(value: Nullable<number>);
  104283. get depthMask(): boolean;
  104284. set depthMask(value: boolean);
  104285. get depthTest(): boolean;
  104286. set depthTest(value: boolean);
  104287. get frontFace(): Nullable<number>;
  104288. set frontFace(value: Nullable<number>);
  104289. reset(): void;
  104290. apply(gl: WebGLRenderingContext): void;
  104291. }
  104292. }
  104293. declare module BABYLON {
  104294. /**
  104295. * @hidden
  104296. **/
  104297. export class StencilState {
  104298. /** 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 */
  104299. static readonly ALWAYS: number;
  104300. /** Passed to stencilOperation to specify that stencil value must be kept */
  104301. static readonly KEEP: number;
  104302. /** Passed to stencilOperation to specify that stencil value must be replaced */
  104303. static readonly REPLACE: number;
  104304. private _isStencilTestDirty;
  104305. private _isStencilMaskDirty;
  104306. private _isStencilFuncDirty;
  104307. private _isStencilOpDirty;
  104308. private _stencilTest;
  104309. private _stencilMask;
  104310. private _stencilFunc;
  104311. private _stencilFuncRef;
  104312. private _stencilFuncMask;
  104313. private _stencilOpStencilFail;
  104314. private _stencilOpDepthFail;
  104315. private _stencilOpStencilDepthPass;
  104316. get isDirty(): boolean;
  104317. get stencilFunc(): number;
  104318. set stencilFunc(value: number);
  104319. get stencilFuncRef(): number;
  104320. set stencilFuncRef(value: number);
  104321. get stencilFuncMask(): number;
  104322. set stencilFuncMask(value: number);
  104323. get stencilOpStencilFail(): number;
  104324. set stencilOpStencilFail(value: number);
  104325. get stencilOpDepthFail(): number;
  104326. set stencilOpDepthFail(value: number);
  104327. get stencilOpStencilDepthPass(): number;
  104328. set stencilOpStencilDepthPass(value: number);
  104329. get stencilMask(): number;
  104330. set stencilMask(value: number);
  104331. get stencilTest(): boolean;
  104332. set stencilTest(value: boolean);
  104333. constructor();
  104334. reset(): void;
  104335. apply(gl: WebGLRenderingContext): void;
  104336. }
  104337. }
  104338. declare module BABYLON {
  104339. /**
  104340. * @hidden
  104341. **/
  104342. export class AlphaState {
  104343. private _isAlphaBlendDirty;
  104344. private _isBlendFunctionParametersDirty;
  104345. private _isBlendEquationParametersDirty;
  104346. private _isBlendConstantsDirty;
  104347. private _alphaBlend;
  104348. private _blendFunctionParameters;
  104349. private _blendEquationParameters;
  104350. private _blendConstants;
  104351. /**
  104352. * Initializes the state.
  104353. */
  104354. constructor();
  104355. get isDirty(): boolean;
  104356. get alphaBlend(): boolean;
  104357. set alphaBlend(value: boolean);
  104358. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  104359. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  104360. setAlphaEquationParameters(rgb: number, alpha: number): void;
  104361. reset(): void;
  104362. apply(gl: WebGLRenderingContext): void;
  104363. }
  104364. }
  104365. declare module BABYLON {
  104366. /** @hidden */
  104367. export class WebGL2ShaderProcessor implements IShaderProcessor {
  104368. attributeProcessor(attribute: string): string;
  104369. varyingProcessor(varying: string, isFragment: boolean): string;
  104370. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  104371. }
  104372. }
  104373. declare module BABYLON {
  104374. /**
  104375. * Interface for attribute information associated with buffer instanciation
  104376. */
  104377. export interface InstancingAttributeInfo {
  104378. /**
  104379. * Name of the GLSL attribute
  104380. * if attribute index is not specified, this is used to retrieve the index from the effect
  104381. */
  104382. attributeName: string;
  104383. /**
  104384. * Index/offset of the attribute in the vertex shader
  104385. * if not specified, this will be computes from the name.
  104386. */
  104387. index?: number;
  104388. /**
  104389. * size of the attribute, 1, 2, 3 or 4
  104390. */
  104391. attributeSize: number;
  104392. /**
  104393. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  104394. */
  104395. offset: number;
  104396. /**
  104397. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  104398. * default to 1
  104399. */
  104400. divisor?: number;
  104401. /**
  104402. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  104403. * default is FLOAT
  104404. */
  104405. attributeType?: number;
  104406. /**
  104407. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  104408. */
  104409. normalized?: boolean;
  104410. }
  104411. }
  104412. declare module BABYLON {
  104413. interface ThinEngine {
  104414. /**
  104415. * Update a video texture
  104416. * @param texture defines the texture to update
  104417. * @param video defines the video element to use
  104418. * @param invertY defines if data must be stored with Y axis inverted
  104419. */
  104420. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  104421. }
  104422. }
  104423. declare module BABYLON {
  104424. /**
  104425. * Settings for finer control over video usage
  104426. */
  104427. export interface VideoTextureSettings {
  104428. /**
  104429. * Applies `autoplay` to video, if specified
  104430. */
  104431. autoPlay?: boolean;
  104432. /**
  104433. * Applies `loop` to video, if specified
  104434. */
  104435. loop?: boolean;
  104436. /**
  104437. * Automatically updates internal texture from video at every frame in the render loop
  104438. */
  104439. autoUpdateTexture: boolean;
  104440. /**
  104441. * Image src displayed during the video loading or until the user interacts with the video.
  104442. */
  104443. poster?: string;
  104444. }
  104445. /**
  104446. * If you want to display a video in your scene, this is the special texture for that.
  104447. * This special texture works similar to other textures, with the exception of a few parameters.
  104448. * @see https://doc.babylonjs.com/how_to/video_texture
  104449. */
  104450. export class VideoTexture extends Texture {
  104451. /**
  104452. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  104453. */
  104454. readonly autoUpdateTexture: boolean;
  104455. /**
  104456. * The video instance used by the texture internally
  104457. */
  104458. readonly video: HTMLVideoElement;
  104459. private _onUserActionRequestedObservable;
  104460. /**
  104461. * Event triggerd when a dom action is required by the user to play the video.
  104462. * This happens due to recent changes in browser policies preventing video to auto start.
  104463. */
  104464. get onUserActionRequestedObservable(): Observable<Texture>;
  104465. private _generateMipMaps;
  104466. private _engine;
  104467. private _stillImageCaptured;
  104468. private _displayingPosterTexture;
  104469. private _settings;
  104470. private _createInternalTextureOnEvent;
  104471. private _frameId;
  104472. private _currentSrc;
  104473. /**
  104474. * Creates a video texture.
  104475. * If you want to display a video in your scene, this is the special texture for that.
  104476. * This special texture works similar to other textures, with the exception of a few parameters.
  104477. * @see https://doc.babylonjs.com/how_to/video_texture
  104478. * @param name optional name, will detect from video source, if not defined
  104479. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  104480. * @param scene is obviously the current scene.
  104481. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  104482. * @param invertY is false by default but can be used to invert video on Y axis
  104483. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  104484. * @param settings allows finer control over video usage
  104485. */
  104486. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  104487. private _getName;
  104488. private _getVideo;
  104489. private _createInternalTexture;
  104490. private reset;
  104491. /**
  104492. * @hidden Internal method to initiate `update`.
  104493. */
  104494. _rebuild(): void;
  104495. /**
  104496. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  104497. */
  104498. update(): void;
  104499. /**
  104500. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  104501. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  104502. */
  104503. updateTexture(isVisible: boolean): void;
  104504. protected _updateInternalTexture: () => void;
  104505. /**
  104506. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  104507. * @param url New url.
  104508. */
  104509. updateURL(url: string): void;
  104510. /**
  104511. * Clones the texture.
  104512. * @returns the cloned texture
  104513. */
  104514. clone(): VideoTexture;
  104515. /**
  104516. * Dispose the texture and release its associated resources.
  104517. */
  104518. dispose(): void;
  104519. /**
  104520. * Creates a video texture straight from a stream.
  104521. * @param scene Define the scene the texture should be created in
  104522. * @param stream Define the stream the texture should be created from
  104523. * @returns The created video texture as a promise
  104524. */
  104525. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  104526. /**
  104527. * Creates a video texture straight from your WebCam video feed.
  104528. * @param scene Define the scene the texture should be created in
  104529. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  104530. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  104531. * @returns The created video texture as a promise
  104532. */
  104533. static CreateFromWebCamAsync(scene: Scene, constraints: {
  104534. minWidth: number;
  104535. maxWidth: number;
  104536. minHeight: number;
  104537. maxHeight: number;
  104538. deviceId: string;
  104539. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  104540. /**
  104541. * Creates a video texture straight from your WebCam video feed.
  104542. * @param scene Define the scene the texture should be created in
  104543. * @param onReady Define a callback to triggered once the texture will be ready
  104544. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  104545. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  104546. */
  104547. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  104548. minWidth: number;
  104549. maxWidth: number;
  104550. minHeight: number;
  104551. maxHeight: number;
  104552. deviceId: string;
  104553. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  104554. }
  104555. }
  104556. declare module BABYLON {
  104557. /**
  104558. * Defines the interface used by objects working like Scene
  104559. * @hidden
  104560. */
  104561. export interface ISceneLike {
  104562. _addPendingData(data: any): void;
  104563. _removePendingData(data: any): void;
  104564. offlineProvider: IOfflineProvider;
  104565. }
  104566. /** Interface defining initialization parameters for Engine class */
  104567. export interface EngineOptions extends WebGLContextAttributes {
  104568. /**
  104569. * Defines if the engine should no exceed a specified device ratio
  104570. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  104571. */
  104572. limitDeviceRatio?: number;
  104573. /**
  104574. * Defines if webvr should be enabled automatically
  104575. * @see http://doc.babylonjs.com/how_to/webvr_camera
  104576. */
  104577. autoEnableWebVR?: boolean;
  104578. /**
  104579. * Defines if webgl2 should be turned off even if supported
  104580. * @see http://doc.babylonjs.com/features/webgl2
  104581. */
  104582. disableWebGL2Support?: boolean;
  104583. /**
  104584. * Defines if webaudio should be initialized as well
  104585. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104586. */
  104587. audioEngine?: boolean;
  104588. /**
  104589. * Defines if animations should run using a deterministic lock step
  104590. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104591. */
  104592. deterministicLockstep?: boolean;
  104593. /** Defines the maximum steps to use with deterministic lock step mode */
  104594. lockstepMaxSteps?: number;
  104595. /** Defines the seconds between each deterministic lock step */
  104596. timeStep?: number;
  104597. /**
  104598. * Defines that engine should ignore context lost events
  104599. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  104600. */
  104601. doNotHandleContextLost?: boolean;
  104602. /**
  104603. * Defines that engine should ignore modifying touch action attribute and style
  104604. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  104605. */
  104606. doNotHandleTouchAction?: boolean;
  104607. /**
  104608. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  104609. */
  104610. useHighPrecisionFloats?: boolean;
  104611. }
  104612. /**
  104613. * The base engine class (root of all engines)
  104614. */
  104615. export class ThinEngine {
  104616. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  104617. static ExceptionList: ({
  104618. key: string;
  104619. capture: string;
  104620. captureConstraint: number;
  104621. targets: string[];
  104622. } | {
  104623. key: string;
  104624. capture: null;
  104625. captureConstraint: null;
  104626. targets: string[];
  104627. })[];
  104628. /** @hidden */
  104629. static _TextureLoaders: IInternalTextureLoader[];
  104630. /**
  104631. * Returns the current npm package of the sdk
  104632. */
  104633. static get NpmPackage(): string;
  104634. /**
  104635. * Returns the current version of the framework
  104636. */
  104637. static get Version(): string;
  104638. /**
  104639. * Returns a string describing the current engine
  104640. */
  104641. get description(): string;
  104642. /**
  104643. * Gets or sets the epsilon value used by collision engine
  104644. */
  104645. static CollisionsEpsilon: number;
  104646. /**
  104647. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  104648. */
  104649. static get ShadersRepository(): string;
  104650. static set ShadersRepository(value: string);
  104651. /** @hidden */
  104652. _shaderProcessor: IShaderProcessor;
  104653. /**
  104654. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  104655. */
  104656. forcePOTTextures: boolean;
  104657. /**
  104658. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  104659. */
  104660. isFullscreen: boolean;
  104661. /**
  104662. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  104663. */
  104664. cullBackFaces: boolean;
  104665. /**
  104666. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  104667. */
  104668. renderEvenInBackground: boolean;
  104669. /**
  104670. * Gets or sets a boolean indicating that cache can be kept between frames
  104671. */
  104672. preventCacheWipeBetweenFrames: boolean;
  104673. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  104674. validateShaderPrograms: boolean;
  104675. /**
  104676. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  104677. * This can provide greater z depth for distant objects.
  104678. */
  104679. useReverseDepthBuffer: boolean;
  104680. /**
  104681. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  104682. */
  104683. disableUniformBuffers: boolean;
  104684. /** @hidden */
  104685. _uniformBuffers: UniformBuffer[];
  104686. /**
  104687. * Gets a boolean indicating that the engine supports uniform buffers
  104688. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  104689. */
  104690. get supportsUniformBuffers(): boolean;
  104691. /** @hidden */
  104692. _gl: WebGLRenderingContext;
  104693. /** @hidden */
  104694. _webGLVersion: number;
  104695. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  104696. protected _windowIsBackground: boolean;
  104697. protected _creationOptions: EngineOptions;
  104698. protected _highPrecisionShadersAllowed: boolean;
  104699. /** @hidden */
  104700. get _shouldUseHighPrecisionShader(): boolean;
  104701. /**
  104702. * Gets a boolean indicating that only power of 2 textures are supported
  104703. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  104704. */
  104705. get needPOTTextures(): boolean;
  104706. /** @hidden */
  104707. _badOS: boolean;
  104708. /** @hidden */
  104709. _badDesktopOS: boolean;
  104710. private _hardwareScalingLevel;
  104711. /** @hidden */
  104712. _caps: EngineCapabilities;
  104713. private _isStencilEnable;
  104714. private _glVersion;
  104715. private _glRenderer;
  104716. private _glVendor;
  104717. /** @hidden */
  104718. _videoTextureSupported: boolean;
  104719. protected _renderingQueueLaunched: boolean;
  104720. protected _activeRenderLoops: (() => void)[];
  104721. /**
  104722. * Observable signaled when a context lost event is raised
  104723. */
  104724. onContextLostObservable: Observable<ThinEngine>;
  104725. /**
  104726. * Observable signaled when a context restored event is raised
  104727. */
  104728. onContextRestoredObservable: Observable<ThinEngine>;
  104729. private _onContextLost;
  104730. private _onContextRestored;
  104731. protected _contextWasLost: boolean;
  104732. /** @hidden */
  104733. _doNotHandleContextLost: boolean;
  104734. /**
  104735. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  104736. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  104737. */
  104738. get doNotHandleContextLost(): boolean;
  104739. set doNotHandleContextLost(value: boolean);
  104740. /**
  104741. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  104742. */
  104743. disableVertexArrayObjects: boolean;
  104744. /** @hidden */
  104745. protected _colorWrite: boolean;
  104746. /** @hidden */
  104747. protected _colorWriteChanged: boolean;
  104748. /** @hidden */
  104749. protected _depthCullingState: DepthCullingState;
  104750. /** @hidden */
  104751. protected _stencilState: StencilState;
  104752. /** @hidden */
  104753. _alphaState: AlphaState;
  104754. /** @hidden */
  104755. _alphaMode: number;
  104756. /** @hidden */
  104757. _alphaEquation: number;
  104758. /** @hidden */
  104759. _internalTexturesCache: InternalTexture[];
  104760. /** @hidden */
  104761. protected _activeChannel: number;
  104762. private _currentTextureChannel;
  104763. /** @hidden */
  104764. protected _boundTexturesCache: {
  104765. [key: string]: Nullable<InternalTexture>;
  104766. };
  104767. /** @hidden */
  104768. protected _currentEffect: Nullable<Effect>;
  104769. /** @hidden */
  104770. protected _currentProgram: Nullable<WebGLProgram>;
  104771. private _compiledEffects;
  104772. private _vertexAttribArraysEnabled;
  104773. /** @hidden */
  104774. protected _cachedViewport: Nullable<IViewportLike>;
  104775. private _cachedVertexArrayObject;
  104776. /** @hidden */
  104777. protected _cachedVertexBuffers: any;
  104778. /** @hidden */
  104779. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  104780. /** @hidden */
  104781. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  104782. /** @hidden */
  104783. _currentRenderTarget: Nullable<InternalTexture>;
  104784. private _uintIndicesCurrentlySet;
  104785. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  104786. /** @hidden */
  104787. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  104788. private _currentBufferPointers;
  104789. private _currentInstanceLocations;
  104790. private _currentInstanceBuffers;
  104791. private _textureUnits;
  104792. /** @hidden */
  104793. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  104794. /** @hidden */
  104795. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  104796. /** @hidden */
  104797. _boundRenderFunction: any;
  104798. private _vaoRecordInProgress;
  104799. private _mustWipeVertexAttributes;
  104800. private _emptyTexture;
  104801. private _emptyCubeTexture;
  104802. private _emptyTexture3D;
  104803. private _emptyTexture2DArray;
  104804. /** @hidden */
  104805. _frameHandler: number;
  104806. private _nextFreeTextureSlots;
  104807. private _maxSimultaneousTextures;
  104808. private _activeRequests;
  104809. protected _texturesSupported: string[];
  104810. /** @hidden */
  104811. _textureFormatInUse: Nullable<string>;
  104812. protected get _supportsHardwareTextureRescaling(): boolean;
  104813. private _framebufferDimensionsObject;
  104814. /**
  104815. * sets the object from which width and height will be taken from when getting render width and height
  104816. * Will fallback to the gl object
  104817. * @param dimensions the framebuffer width and height that will be used.
  104818. */
  104819. set framebufferDimensionsObject(dimensions: Nullable<{
  104820. framebufferWidth: number;
  104821. framebufferHeight: number;
  104822. }>);
  104823. /**
  104824. * Gets the list of texture formats supported
  104825. */
  104826. get texturesSupported(): Array<string>;
  104827. /**
  104828. * Gets the list of texture formats in use
  104829. */
  104830. get textureFormatInUse(): Nullable<string>;
  104831. /**
  104832. * Gets the current viewport
  104833. */
  104834. get currentViewport(): Nullable<IViewportLike>;
  104835. /**
  104836. * Gets the default empty texture
  104837. */
  104838. get emptyTexture(): InternalTexture;
  104839. /**
  104840. * Gets the default empty 3D texture
  104841. */
  104842. get emptyTexture3D(): InternalTexture;
  104843. /**
  104844. * Gets the default empty 2D array texture
  104845. */
  104846. get emptyTexture2DArray(): InternalTexture;
  104847. /**
  104848. * Gets the default empty cube texture
  104849. */
  104850. get emptyCubeTexture(): InternalTexture;
  104851. /**
  104852. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  104853. */
  104854. readonly premultipliedAlpha: boolean;
  104855. /**
  104856. * Observable event triggered before each texture is initialized
  104857. */
  104858. onBeforeTextureInitObservable: Observable<Texture>;
  104859. /**
  104860. * Creates a new engine
  104861. * @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
  104862. * @param antialias defines enable antialiasing (default: false)
  104863. * @param options defines further options to be sent to the getContext() function
  104864. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  104865. */
  104866. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  104867. private _rebuildInternalTextures;
  104868. private _rebuildEffects;
  104869. /**
  104870. * Gets a boolean indicating if all created effects are ready
  104871. * @returns true if all effects are ready
  104872. */
  104873. areAllEffectsReady(): boolean;
  104874. protected _rebuildBuffers(): void;
  104875. private _initGLContext;
  104876. /**
  104877. * Gets version of the current webGL context
  104878. */
  104879. get webGLVersion(): number;
  104880. /**
  104881. * Gets a string idenfifying the name of the class
  104882. * @returns "Engine" string
  104883. */
  104884. getClassName(): string;
  104885. /**
  104886. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  104887. */
  104888. get isStencilEnable(): boolean;
  104889. /** @hidden */
  104890. _prepareWorkingCanvas(): void;
  104891. /**
  104892. * Reset the texture cache to empty state
  104893. */
  104894. resetTextureCache(): void;
  104895. /**
  104896. * Gets an object containing information about the current webGL context
  104897. * @returns an object containing the vender, the renderer and the version of the current webGL context
  104898. */
  104899. getGlInfo(): {
  104900. vendor: string;
  104901. renderer: string;
  104902. version: string;
  104903. };
  104904. /**
  104905. * Defines the hardware scaling level.
  104906. * By default the hardware scaling level is computed from the window device ratio.
  104907. * 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.
  104908. * @param level defines the level to use
  104909. */
  104910. setHardwareScalingLevel(level: number): void;
  104911. /**
  104912. * Gets the current hardware scaling level.
  104913. * By default the hardware scaling level is computed from the window device ratio.
  104914. * 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.
  104915. * @returns a number indicating the current hardware scaling level
  104916. */
  104917. getHardwareScalingLevel(): number;
  104918. /**
  104919. * Gets the list of loaded textures
  104920. * @returns an array containing all loaded textures
  104921. */
  104922. getLoadedTexturesCache(): InternalTexture[];
  104923. /**
  104924. * Gets the object containing all engine capabilities
  104925. * @returns the EngineCapabilities object
  104926. */
  104927. getCaps(): EngineCapabilities;
  104928. /**
  104929. * stop executing a render loop function and remove it from the execution array
  104930. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  104931. */
  104932. stopRenderLoop(renderFunction?: () => void): void;
  104933. /** @hidden */
  104934. _renderLoop(): void;
  104935. /**
  104936. * Gets the HTML canvas attached with the current webGL context
  104937. * @returns a HTML canvas
  104938. */
  104939. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  104940. /**
  104941. * Gets host window
  104942. * @returns the host window object
  104943. */
  104944. getHostWindow(): Nullable<Window>;
  104945. /**
  104946. * Gets the current render width
  104947. * @param useScreen defines if screen size must be used (or the current render target if any)
  104948. * @returns a number defining the current render width
  104949. */
  104950. getRenderWidth(useScreen?: boolean): number;
  104951. /**
  104952. * Gets the current render height
  104953. * @param useScreen defines if screen size must be used (or the current render target if any)
  104954. * @returns a number defining the current render height
  104955. */
  104956. getRenderHeight(useScreen?: boolean): number;
  104957. /**
  104958. * Can be used to override the current requestAnimationFrame requester.
  104959. * @hidden
  104960. */
  104961. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  104962. /**
  104963. * Register and execute a render loop. The engine can have more than one render function
  104964. * @param renderFunction defines the function to continuously execute
  104965. */
  104966. runRenderLoop(renderFunction: () => void): void;
  104967. /**
  104968. * Clear the current render buffer or the current render target (if any is set up)
  104969. * @param color defines the color to use
  104970. * @param backBuffer defines if the back buffer must be cleared
  104971. * @param depth defines if the depth buffer must be cleared
  104972. * @param stencil defines if the stencil buffer must be cleared
  104973. */
  104974. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  104975. private _viewportCached;
  104976. /** @hidden */
  104977. _viewport(x: number, y: number, width: number, height: number): void;
  104978. /**
  104979. * Set the WebGL's viewport
  104980. * @param viewport defines the viewport element to be used
  104981. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  104982. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  104983. */
  104984. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  104985. /**
  104986. * Begin a new frame
  104987. */
  104988. beginFrame(): void;
  104989. /**
  104990. * Enf the current frame
  104991. */
  104992. endFrame(): void;
  104993. /**
  104994. * Resize the view according to the canvas' size
  104995. */
  104996. resize(): void;
  104997. /**
  104998. * Force a specific size of the canvas
  104999. * @param width defines the new canvas' width
  105000. * @param height defines the new canvas' height
  105001. */
  105002. setSize(width: number, height: number): void;
  105003. /**
  105004. * Binds the frame buffer to the specified texture.
  105005. * @param texture The texture to render to or null for the default canvas
  105006. * @param faceIndex The face of the texture to render to in case of cube texture
  105007. * @param requiredWidth The width of the target to render to
  105008. * @param requiredHeight The height of the target to render to
  105009. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  105010. * @param lodLevel defines the lod level to bind to the frame buffer
  105011. * @param layer defines the 2d array index to bind to frame buffer to
  105012. */
  105013. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  105014. /** @hidden */
  105015. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  105016. /**
  105017. * Unbind the current render target texture from the webGL context
  105018. * @param texture defines the render target texture to unbind
  105019. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  105020. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  105021. */
  105022. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  105023. /**
  105024. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  105025. */
  105026. flushFramebuffer(): void;
  105027. /**
  105028. * Unbind the current render target and bind the default framebuffer
  105029. */
  105030. restoreDefaultFramebuffer(): void;
  105031. /** @hidden */
  105032. protected _resetVertexBufferBinding(): void;
  105033. /**
  105034. * Creates a vertex buffer
  105035. * @param data the data for the vertex buffer
  105036. * @returns the new WebGL static buffer
  105037. */
  105038. createVertexBuffer(data: DataArray): DataBuffer;
  105039. private _createVertexBuffer;
  105040. /**
  105041. * Creates a dynamic vertex buffer
  105042. * @param data the data for the dynamic vertex buffer
  105043. * @returns the new WebGL dynamic buffer
  105044. */
  105045. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  105046. protected _resetIndexBufferBinding(): void;
  105047. /**
  105048. * Creates a new index buffer
  105049. * @param indices defines the content of the index buffer
  105050. * @param updatable defines if the index buffer must be updatable
  105051. * @returns a new webGL buffer
  105052. */
  105053. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  105054. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  105055. /**
  105056. * Bind a webGL buffer to the webGL context
  105057. * @param buffer defines the buffer to bind
  105058. */
  105059. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  105060. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  105061. private bindBuffer;
  105062. /**
  105063. * update the bound buffer with the given data
  105064. * @param data defines the data to update
  105065. */
  105066. updateArrayBuffer(data: Float32Array): void;
  105067. private _vertexAttribPointer;
  105068. /** @hidden */
  105069. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  105070. private _bindVertexBuffersAttributes;
  105071. /**
  105072. * Records a vertex array object
  105073. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  105074. * @param vertexBuffers defines the list of vertex buffers to store
  105075. * @param indexBuffer defines the index buffer to store
  105076. * @param effect defines the effect to store
  105077. * @returns the new vertex array object
  105078. */
  105079. recordVertexArrayObject(vertexBuffers: {
  105080. [key: string]: VertexBuffer;
  105081. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  105082. /**
  105083. * Bind a specific vertex array object
  105084. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  105085. * @param vertexArrayObject defines the vertex array object to bind
  105086. * @param indexBuffer defines the index buffer to bind
  105087. */
  105088. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  105089. /**
  105090. * Bind webGl buffers directly to the webGL context
  105091. * @param vertexBuffer defines the vertex buffer to bind
  105092. * @param indexBuffer defines the index buffer to bind
  105093. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  105094. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  105095. * @param effect defines the effect associated with the vertex buffer
  105096. */
  105097. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  105098. private _unbindVertexArrayObject;
  105099. /**
  105100. * Bind a list of vertex buffers to the webGL context
  105101. * @param vertexBuffers defines the list of vertex buffers to bind
  105102. * @param indexBuffer defines the index buffer to bind
  105103. * @param effect defines the effect associated with the vertex buffers
  105104. */
  105105. bindBuffers(vertexBuffers: {
  105106. [key: string]: Nullable<VertexBuffer>;
  105107. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  105108. /**
  105109. * Unbind all instance attributes
  105110. */
  105111. unbindInstanceAttributes(): void;
  105112. /**
  105113. * Release and free the memory of a vertex array object
  105114. * @param vao defines the vertex array object to delete
  105115. */
  105116. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  105117. /** @hidden */
  105118. _releaseBuffer(buffer: DataBuffer): boolean;
  105119. protected _deleteBuffer(buffer: DataBuffer): void;
  105120. /**
  105121. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  105122. * @param instancesBuffer defines the webGL buffer to update and bind
  105123. * @param data defines the data to store in the buffer
  105124. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  105125. */
  105126. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  105127. /**
  105128. * Bind the content of a webGL buffer used with instantiation
  105129. * @param instancesBuffer defines the webGL buffer to bind
  105130. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  105131. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  105132. */
  105133. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  105134. /**
  105135. * Disable the instance attribute corresponding to the name in parameter
  105136. * @param name defines the name of the attribute to disable
  105137. */
  105138. disableInstanceAttributeByName(name: string): void;
  105139. /**
  105140. * Disable the instance attribute corresponding to the location in parameter
  105141. * @param attributeLocation defines the attribute location of the attribute to disable
  105142. */
  105143. disableInstanceAttribute(attributeLocation: number): void;
  105144. /**
  105145. * Disable the attribute corresponding to the location in parameter
  105146. * @param attributeLocation defines the attribute location of the attribute to disable
  105147. */
  105148. disableAttributeByIndex(attributeLocation: number): void;
  105149. /**
  105150. * Send a draw order
  105151. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  105152. * @param indexStart defines the starting index
  105153. * @param indexCount defines the number of index to draw
  105154. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  105155. */
  105156. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  105157. /**
  105158. * Draw a list of points
  105159. * @param verticesStart defines the index of first vertex to draw
  105160. * @param verticesCount defines the count of vertices to draw
  105161. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  105162. */
  105163. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  105164. /**
  105165. * Draw a list of unindexed primitives
  105166. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  105167. * @param verticesStart defines the index of first vertex to draw
  105168. * @param verticesCount defines the count of vertices to draw
  105169. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  105170. */
  105171. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  105172. /**
  105173. * Draw a list of indexed primitives
  105174. * @param fillMode defines the primitive to use
  105175. * @param indexStart defines the starting index
  105176. * @param indexCount defines the number of index to draw
  105177. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  105178. */
  105179. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  105180. /**
  105181. * Draw a list of unindexed primitives
  105182. * @param fillMode defines the primitive to use
  105183. * @param verticesStart defines the index of first vertex to draw
  105184. * @param verticesCount defines the count of vertices to draw
  105185. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  105186. */
  105187. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  105188. private _drawMode;
  105189. /** @hidden */
  105190. protected _reportDrawCall(): void;
  105191. /** @hidden */
  105192. _releaseEffect(effect: Effect): void;
  105193. /** @hidden */
  105194. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  105195. /**
  105196. * Create a new effect (used to store vertex/fragment shaders)
  105197. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  105198. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  105199. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  105200. * @param samplers defines an array of string used to represent textures
  105201. * @param defines defines the string containing the defines to use to compile the shaders
  105202. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  105203. * @param onCompiled defines a function to call when the effect creation is successful
  105204. * @param onError defines a function to call when the effect creation has failed
  105205. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  105206. * @returns the new Effect
  105207. */
  105208. 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;
  105209. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  105210. private _compileShader;
  105211. private _compileRawShader;
  105212. /** @hidden */
  105213. _getShaderSource(shader: WebGLShader): Nullable<string>;
  105214. /**
  105215. * Directly creates a webGL program
  105216. * @param pipelineContext defines the pipeline context to attach to
  105217. * @param vertexCode defines the vertex shader code to use
  105218. * @param fragmentCode defines the fragment shader code to use
  105219. * @param context defines the webGL context to use (if not set, the current one will be used)
  105220. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  105221. * @returns the new webGL program
  105222. */
  105223. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  105224. /**
  105225. * Creates a webGL program
  105226. * @param pipelineContext defines the pipeline context to attach to
  105227. * @param vertexCode defines the vertex shader code to use
  105228. * @param fragmentCode defines the fragment shader code to use
  105229. * @param defines defines the string containing the defines to use to compile the shaders
  105230. * @param context defines the webGL context to use (if not set, the current one will be used)
  105231. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  105232. * @returns the new webGL program
  105233. */
  105234. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  105235. /**
  105236. * Creates a new pipeline context
  105237. * @returns the new pipeline
  105238. */
  105239. createPipelineContext(): IPipelineContext;
  105240. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  105241. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  105242. /** @hidden */
  105243. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  105244. /** @hidden */
  105245. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  105246. /** @hidden */
  105247. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  105248. /**
  105249. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  105250. * @param pipelineContext defines the pipeline context to use
  105251. * @param uniformsNames defines the list of uniform names
  105252. * @returns an array of webGL uniform locations
  105253. */
  105254. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  105255. /**
  105256. * Gets the lsit of active attributes for a given webGL program
  105257. * @param pipelineContext defines the pipeline context to use
  105258. * @param attributesNames defines the list of attribute names to get
  105259. * @returns an array of indices indicating the offset of each attribute
  105260. */
  105261. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  105262. /**
  105263. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  105264. * @param effect defines the effect to activate
  105265. */
  105266. enableEffect(effect: Nullable<Effect>): void;
  105267. /**
  105268. * Set the value of an uniform to a number (int)
  105269. * @param uniform defines the webGL uniform location where to store the value
  105270. * @param value defines the int number to store
  105271. */
  105272. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  105273. /**
  105274. * Set the value of an uniform to an array of int32
  105275. * @param uniform defines the webGL uniform location where to store the value
  105276. * @param array defines the array of int32 to store
  105277. */
  105278. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  105279. /**
  105280. * Set the value of an uniform to an array of int32 (stored as vec2)
  105281. * @param uniform defines the webGL uniform location where to store the value
  105282. * @param array defines the array of int32 to store
  105283. */
  105284. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  105285. /**
  105286. * Set the value of an uniform to an array of int32 (stored as vec3)
  105287. * @param uniform defines the webGL uniform location where to store the value
  105288. * @param array defines the array of int32 to store
  105289. */
  105290. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  105291. /**
  105292. * Set the value of an uniform to an array of int32 (stored as vec4)
  105293. * @param uniform defines the webGL uniform location where to store the value
  105294. * @param array defines the array of int32 to store
  105295. */
  105296. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  105297. /**
  105298. * Set the value of an uniform to an array of number
  105299. * @param uniform defines the webGL uniform location where to store the value
  105300. * @param array defines the array of number to store
  105301. */
  105302. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  105303. /**
  105304. * Set the value of an uniform to an array of number (stored as vec2)
  105305. * @param uniform defines the webGL uniform location where to store the value
  105306. * @param array defines the array of number to store
  105307. */
  105308. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  105309. /**
  105310. * Set the value of an uniform to an array of number (stored as vec3)
  105311. * @param uniform defines the webGL uniform location where to store the value
  105312. * @param array defines the array of number to store
  105313. */
  105314. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  105315. /**
  105316. * Set the value of an uniform to an array of number (stored as vec4)
  105317. * @param uniform defines the webGL uniform location where to store the value
  105318. * @param array defines the array of number to store
  105319. */
  105320. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  105321. /**
  105322. * Set the value of an uniform to an array of float32 (stored as matrices)
  105323. * @param uniform defines the webGL uniform location where to store the value
  105324. * @param matrices defines the array of float32 to store
  105325. */
  105326. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  105327. /**
  105328. * Set the value of an uniform to a matrix (3x3)
  105329. * @param uniform defines the webGL uniform location where to store the value
  105330. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  105331. */
  105332. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  105333. /**
  105334. * Set the value of an uniform to a matrix (2x2)
  105335. * @param uniform defines the webGL uniform location where to store the value
  105336. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  105337. */
  105338. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  105339. /**
  105340. * Set the value of an uniform to a number (float)
  105341. * @param uniform defines the webGL uniform location where to store the value
  105342. * @param value defines the float number to store
  105343. */
  105344. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  105345. /**
  105346. * Set the value of an uniform to a vec2
  105347. * @param uniform defines the webGL uniform location where to store the value
  105348. * @param x defines the 1st component of the value
  105349. * @param y defines the 2nd component of the value
  105350. */
  105351. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  105352. /**
  105353. * Set the value of an uniform to a vec3
  105354. * @param uniform defines the webGL uniform location where to store the value
  105355. * @param x defines the 1st component of the value
  105356. * @param y defines the 2nd component of the value
  105357. * @param z defines the 3rd component of the value
  105358. */
  105359. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  105360. /**
  105361. * Set the value of an uniform to a vec4
  105362. * @param uniform defines the webGL uniform location where to store the value
  105363. * @param x defines the 1st component of the value
  105364. * @param y defines the 2nd component of the value
  105365. * @param z defines the 3rd component of the value
  105366. * @param w defines the 4th component of the value
  105367. */
  105368. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  105369. /**
  105370. * Apply all cached states (depth, culling, stencil and alpha)
  105371. */
  105372. applyStates(): void;
  105373. /**
  105374. * Enable or disable color writing
  105375. * @param enable defines the state to set
  105376. */
  105377. setColorWrite(enable: boolean): void;
  105378. /**
  105379. * Gets a boolean indicating if color writing is enabled
  105380. * @returns the current color writing state
  105381. */
  105382. getColorWrite(): boolean;
  105383. /**
  105384. * Gets the depth culling state manager
  105385. */
  105386. get depthCullingState(): DepthCullingState;
  105387. /**
  105388. * Gets the alpha state manager
  105389. */
  105390. get alphaState(): AlphaState;
  105391. /**
  105392. * Gets the stencil state manager
  105393. */
  105394. get stencilState(): StencilState;
  105395. /**
  105396. * Clears the list of texture accessible through engine.
  105397. * This can help preventing texture load conflict due to name collision.
  105398. */
  105399. clearInternalTexturesCache(): void;
  105400. /**
  105401. * Force the entire cache to be cleared
  105402. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  105403. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  105404. */
  105405. wipeCaches(bruteForce?: boolean): void;
  105406. /** @hidden */
  105407. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  105408. min: number;
  105409. mag: number;
  105410. };
  105411. /** @hidden */
  105412. _createTexture(): WebGLTexture;
  105413. /**
  105414. * Usually called from Texture.ts.
  105415. * Passed information to create a WebGLTexture
  105416. * @param urlArg defines a value which contains one of the following:
  105417. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  105418. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  105419. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  105420. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  105421. * @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)
  105422. * @param scene needed for loading to the correct scene
  105423. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  105424. * @param onLoad optional callback to be called upon successful completion
  105425. * @param onError optional callback to be called upon failure
  105426. * @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
  105427. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  105428. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  105429. * @param forcedExtension defines the extension to use to pick the right loader
  105430. * @param mimeType defines an optional mime type
  105431. * @returns a InternalTexture for assignment back into BABYLON.Texture
  105432. */
  105433. 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;
  105434. /**
  105435. * Loads an image as an HTMLImageElement.
  105436. * @param input url string, ArrayBuffer, or Blob to load
  105437. * @param onLoad callback called when the image successfully loads
  105438. * @param onError callback called when the image fails to load
  105439. * @param offlineProvider offline provider for caching
  105440. * @param mimeType optional mime type
  105441. * @returns the HTMLImageElement of the loaded image
  105442. * @hidden
  105443. */
  105444. 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>;
  105445. /**
  105446. * @hidden
  105447. */
  105448. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  105449. /**
  105450. * Creates a raw texture
  105451. * @param data defines the data to store in the texture
  105452. * @param width defines the width of the texture
  105453. * @param height defines the height of the texture
  105454. * @param format defines the format of the data
  105455. * @param generateMipMaps defines if the engine should generate the mip levels
  105456. * @param invertY defines if data must be stored with Y axis inverted
  105457. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  105458. * @param compression defines the compression used (null by default)
  105459. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  105460. * @returns the raw texture inside an InternalTexture
  105461. */
  105462. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  105463. /**
  105464. * Creates a new raw cube texture
  105465. * @param data defines the array of data to use to create each face
  105466. * @param size defines the size of the textures
  105467. * @param format defines the format of the data
  105468. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  105469. * @param generateMipMaps defines if the engine should generate the mip levels
  105470. * @param invertY defines if data must be stored with Y axis inverted
  105471. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105472. * @param compression defines the compression used (null by default)
  105473. * @returns the cube texture as an InternalTexture
  105474. */
  105475. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  105476. /**
  105477. * Creates a new raw 3D texture
  105478. * @param data defines the data used to create the texture
  105479. * @param width defines the width of the texture
  105480. * @param height defines the height of the texture
  105481. * @param depth defines the depth of the texture
  105482. * @param format defines the format of the texture
  105483. * @param generateMipMaps defines if the engine must generate mip levels
  105484. * @param invertY defines if data must be stored with Y axis inverted
  105485. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105486. * @param compression defines the compressed used (can be null)
  105487. * @param textureType defines the compressed used (can be null)
  105488. * @returns a new raw 3D texture (stored in an InternalTexture)
  105489. */
  105490. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  105491. /**
  105492. * Creates a new raw 2D array texture
  105493. * @param data defines the data used to create the texture
  105494. * @param width defines the width of the texture
  105495. * @param height defines the height of the texture
  105496. * @param depth defines the number of layers of the texture
  105497. * @param format defines the format of the texture
  105498. * @param generateMipMaps defines if the engine must generate mip levels
  105499. * @param invertY defines if data must be stored with Y axis inverted
  105500. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105501. * @param compression defines the compressed used (can be null)
  105502. * @param textureType defines the compressed used (can be null)
  105503. * @returns a new raw 2D array texture (stored in an InternalTexture)
  105504. */
  105505. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  105506. private _unpackFlipYCached;
  105507. /**
  105508. * In case you are sharing the context with other applications, it might
  105509. * be interested to not cache the unpack flip y state to ensure a consistent
  105510. * value would be set.
  105511. */
  105512. enableUnpackFlipYCached: boolean;
  105513. /** @hidden */
  105514. _unpackFlipY(value: boolean): void;
  105515. /** @hidden */
  105516. _getUnpackAlignement(): number;
  105517. private _getTextureTarget;
  105518. /**
  105519. * Update the sampling mode of a given texture
  105520. * @param samplingMode defines the required sampling mode
  105521. * @param texture defines the texture to update
  105522. * @param generateMipMaps defines whether to generate mipmaps for the texture
  105523. */
  105524. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  105525. /**
  105526. * Update the sampling mode of a given texture
  105527. * @param texture defines the texture to update
  105528. * @param wrapU defines the texture wrap mode of the u coordinates
  105529. * @param wrapV defines the texture wrap mode of the v coordinates
  105530. * @param wrapR defines the texture wrap mode of the r coordinates
  105531. */
  105532. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  105533. /** @hidden */
  105534. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  105535. width: number;
  105536. height: number;
  105537. layers?: number;
  105538. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  105539. /** @hidden */
  105540. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105541. /** @hidden */
  105542. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  105543. /**
  105544. * Update a portion of an internal texture
  105545. * @param texture defines the texture to update
  105546. * @param imageData defines the data to store into the texture
  105547. * @param xOffset defines the x coordinates of the update rectangle
  105548. * @param yOffset defines the y coordinates of the update rectangle
  105549. * @param width defines the width of the update rectangle
  105550. * @param height defines the height of the update rectangle
  105551. * @param faceIndex defines the face index if texture is a cube (0 by default)
  105552. * @param lod defines the lod level to update (0 by default)
  105553. */
  105554. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  105555. /** @hidden */
  105556. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105557. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  105558. private _prepareWebGLTexture;
  105559. /** @hidden */
  105560. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  105561. private _getDepthStencilBuffer;
  105562. /** @hidden */
  105563. _releaseFramebufferObjects(texture: InternalTexture): void;
  105564. /** @hidden */
  105565. _releaseTexture(texture: InternalTexture): void;
  105566. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  105567. protected _setProgram(program: WebGLProgram): void;
  105568. protected _boundUniforms: {
  105569. [key: number]: WebGLUniformLocation;
  105570. };
  105571. /**
  105572. * Binds an effect to the webGL context
  105573. * @param effect defines the effect to bind
  105574. */
  105575. bindSamplers(effect: Effect): void;
  105576. private _activateCurrentTexture;
  105577. /** @hidden */
  105578. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  105579. /** @hidden */
  105580. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  105581. /**
  105582. * Unbind all textures from the webGL context
  105583. */
  105584. unbindAllTextures(): void;
  105585. /**
  105586. * Sets a texture to the according uniform.
  105587. * @param channel The texture channel
  105588. * @param uniform The uniform to set
  105589. * @param texture The texture to apply
  105590. */
  105591. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  105592. private _bindSamplerUniformToChannel;
  105593. private _getTextureWrapMode;
  105594. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  105595. /**
  105596. * Sets an array of texture to the webGL context
  105597. * @param channel defines the channel where the texture array must be set
  105598. * @param uniform defines the associated uniform location
  105599. * @param textures defines the array of textures to bind
  105600. */
  105601. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  105602. /** @hidden */
  105603. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  105604. private _setTextureParameterFloat;
  105605. private _setTextureParameterInteger;
  105606. /**
  105607. * Unbind all vertex attributes from the webGL context
  105608. */
  105609. unbindAllAttributes(): void;
  105610. /**
  105611. * 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
  105612. */
  105613. releaseEffects(): void;
  105614. /**
  105615. * Dispose and release all associated resources
  105616. */
  105617. dispose(): void;
  105618. /**
  105619. * Attach a new callback raised when context lost event is fired
  105620. * @param callback defines the callback to call
  105621. */
  105622. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  105623. /**
  105624. * Attach a new callback raised when context restored event is fired
  105625. * @param callback defines the callback to call
  105626. */
  105627. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  105628. /**
  105629. * Get the current error code of the webGL context
  105630. * @returns the error code
  105631. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  105632. */
  105633. getError(): number;
  105634. private _canRenderToFloatFramebuffer;
  105635. private _canRenderToHalfFloatFramebuffer;
  105636. private _canRenderToFramebuffer;
  105637. /** @hidden */
  105638. _getWebGLTextureType(type: number): number;
  105639. /** @hidden */
  105640. _getInternalFormat(format: number): number;
  105641. /** @hidden */
  105642. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  105643. /** @hidden */
  105644. _getRGBAMultiSampleBufferFormat(type: number): number;
  105645. /** @hidden */
  105646. _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;
  105647. /**
  105648. * Loads a file from a url
  105649. * @param url url to load
  105650. * @param onSuccess callback called when the file successfully loads
  105651. * @param onProgress callback called while file is loading (if the server supports this mode)
  105652. * @param offlineProvider defines the offline provider for caching
  105653. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  105654. * @param onError callback called when the file fails to load
  105655. * @returns a file request object
  105656. * @hidden
  105657. */
  105658. 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;
  105659. /**
  105660. * Reads pixels from the current frame buffer. Please note that this function can be slow
  105661. * @param x defines the x coordinate of the rectangle where pixels must be read
  105662. * @param y defines the y coordinate of the rectangle where pixels must be read
  105663. * @param width defines the width of the rectangle where pixels must be read
  105664. * @param height defines the height of the rectangle where pixels must be read
  105665. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  105666. * @returns a Uint8Array containing RGBA colors
  105667. */
  105668. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  105669. private static _isSupported;
  105670. /**
  105671. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  105672. * @returns true if the engine can be created
  105673. * @ignorenaming
  105674. */
  105675. static isSupported(): boolean;
  105676. /**
  105677. * Find the next highest power of two.
  105678. * @param x Number to start search from.
  105679. * @return Next highest power of two.
  105680. */
  105681. static CeilingPOT(x: number): number;
  105682. /**
  105683. * Find the next lowest power of two.
  105684. * @param x Number to start search from.
  105685. * @return Next lowest power of two.
  105686. */
  105687. static FloorPOT(x: number): number;
  105688. /**
  105689. * Find the nearest power of two.
  105690. * @param x Number to start search from.
  105691. * @return Next nearest power of two.
  105692. */
  105693. static NearestPOT(x: number): number;
  105694. /**
  105695. * Get the closest exponent of two
  105696. * @param value defines the value to approximate
  105697. * @param max defines the maximum value to return
  105698. * @param mode defines how to define the closest value
  105699. * @returns closest exponent of two of the given value
  105700. */
  105701. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  105702. /**
  105703. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  105704. * @param func - the function to be called
  105705. * @param requester - the object that will request the next frame. Falls back to window.
  105706. * @returns frame number
  105707. */
  105708. static QueueNewFrame(func: () => void, requester?: any): number;
  105709. /**
  105710. * Gets host document
  105711. * @returns the host document object
  105712. */
  105713. getHostDocument(): Nullable<Document>;
  105714. }
  105715. }
  105716. declare module BABYLON {
  105717. /**
  105718. * Class representing spherical harmonics coefficients to the 3rd degree
  105719. */
  105720. export class SphericalHarmonics {
  105721. /**
  105722. * Defines whether or not the harmonics have been prescaled for rendering.
  105723. */
  105724. preScaled: boolean;
  105725. /**
  105726. * The l0,0 coefficients of the spherical harmonics
  105727. */
  105728. l00: Vector3;
  105729. /**
  105730. * The l1,-1 coefficients of the spherical harmonics
  105731. */
  105732. l1_1: Vector3;
  105733. /**
  105734. * The l1,0 coefficients of the spherical harmonics
  105735. */
  105736. l10: Vector3;
  105737. /**
  105738. * The l1,1 coefficients of the spherical harmonics
  105739. */
  105740. l11: Vector3;
  105741. /**
  105742. * The l2,-2 coefficients of the spherical harmonics
  105743. */
  105744. l2_2: Vector3;
  105745. /**
  105746. * The l2,-1 coefficients of the spherical harmonics
  105747. */
  105748. l2_1: Vector3;
  105749. /**
  105750. * The l2,0 coefficients of the spherical harmonics
  105751. */
  105752. l20: Vector3;
  105753. /**
  105754. * The l2,1 coefficients of the spherical harmonics
  105755. */
  105756. l21: Vector3;
  105757. /**
  105758. * The l2,2 coefficients of the spherical harmonics
  105759. */
  105760. l22: Vector3;
  105761. /**
  105762. * Adds a light to the spherical harmonics
  105763. * @param direction the direction of the light
  105764. * @param color the color of the light
  105765. * @param deltaSolidAngle the delta solid angle of the light
  105766. */
  105767. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  105768. /**
  105769. * Scales the spherical harmonics by the given amount
  105770. * @param scale the amount to scale
  105771. */
  105772. scaleInPlace(scale: number): void;
  105773. /**
  105774. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  105775. *
  105776. * ```
  105777. * E_lm = A_l * L_lm
  105778. * ```
  105779. *
  105780. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  105781. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  105782. * the scaling factors are given in equation 9.
  105783. */
  105784. convertIncidentRadianceToIrradiance(): void;
  105785. /**
  105786. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  105787. *
  105788. * ```
  105789. * L = (1/pi) * E * rho
  105790. * ```
  105791. *
  105792. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  105793. */
  105794. convertIrradianceToLambertianRadiance(): void;
  105795. /**
  105796. * Integrates the reconstruction coefficients directly in to the SH preventing further
  105797. * required operations at run time.
  105798. *
  105799. * This is simply done by scaling back the SH with Ylm constants parameter.
  105800. * The trigonometric part being applied by the shader at run time.
  105801. */
  105802. preScaleForRendering(): void;
  105803. /**
  105804. * Constructs a spherical harmonics from an array.
  105805. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  105806. * @returns the spherical harmonics
  105807. */
  105808. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  105809. /**
  105810. * Gets the spherical harmonics from polynomial
  105811. * @param polynomial the spherical polynomial
  105812. * @returns the spherical harmonics
  105813. */
  105814. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  105815. }
  105816. /**
  105817. * Class representing spherical polynomial coefficients to the 3rd degree
  105818. */
  105819. export class SphericalPolynomial {
  105820. private _harmonics;
  105821. /**
  105822. * The spherical harmonics used to create the polynomials.
  105823. */
  105824. get preScaledHarmonics(): SphericalHarmonics;
  105825. /**
  105826. * The x coefficients of the spherical polynomial
  105827. */
  105828. x: Vector3;
  105829. /**
  105830. * The y coefficients of the spherical polynomial
  105831. */
  105832. y: Vector3;
  105833. /**
  105834. * The z coefficients of the spherical polynomial
  105835. */
  105836. z: Vector3;
  105837. /**
  105838. * The xx coefficients of the spherical polynomial
  105839. */
  105840. xx: Vector3;
  105841. /**
  105842. * The yy coefficients of the spherical polynomial
  105843. */
  105844. yy: Vector3;
  105845. /**
  105846. * The zz coefficients of the spherical polynomial
  105847. */
  105848. zz: Vector3;
  105849. /**
  105850. * The xy coefficients of the spherical polynomial
  105851. */
  105852. xy: Vector3;
  105853. /**
  105854. * The yz coefficients of the spherical polynomial
  105855. */
  105856. yz: Vector3;
  105857. /**
  105858. * The zx coefficients of the spherical polynomial
  105859. */
  105860. zx: Vector3;
  105861. /**
  105862. * Adds an ambient color to the spherical polynomial
  105863. * @param color the color to add
  105864. */
  105865. addAmbient(color: Color3): void;
  105866. /**
  105867. * Scales the spherical polynomial by the given amount
  105868. * @param scale the amount to scale
  105869. */
  105870. scaleInPlace(scale: number): void;
  105871. /**
  105872. * Gets the spherical polynomial from harmonics
  105873. * @param harmonics the spherical harmonics
  105874. * @returns the spherical polynomial
  105875. */
  105876. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  105877. /**
  105878. * Constructs a spherical polynomial from an array.
  105879. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  105880. * @returns the spherical polynomial
  105881. */
  105882. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  105883. }
  105884. }
  105885. declare module BABYLON {
  105886. /**
  105887. * Defines the source of the internal texture
  105888. */
  105889. export enum InternalTextureSource {
  105890. /**
  105891. * The source of the texture data is unknown
  105892. */
  105893. Unknown = 0,
  105894. /**
  105895. * Texture data comes from an URL
  105896. */
  105897. Url = 1,
  105898. /**
  105899. * Texture data is only used for temporary storage
  105900. */
  105901. Temp = 2,
  105902. /**
  105903. * Texture data comes from raw data (ArrayBuffer)
  105904. */
  105905. Raw = 3,
  105906. /**
  105907. * Texture content is dynamic (video or dynamic texture)
  105908. */
  105909. Dynamic = 4,
  105910. /**
  105911. * Texture content is generated by rendering to it
  105912. */
  105913. RenderTarget = 5,
  105914. /**
  105915. * Texture content is part of a multi render target process
  105916. */
  105917. MultiRenderTarget = 6,
  105918. /**
  105919. * Texture data comes from a cube data file
  105920. */
  105921. Cube = 7,
  105922. /**
  105923. * Texture data comes from a raw cube data
  105924. */
  105925. CubeRaw = 8,
  105926. /**
  105927. * Texture data come from a prefiltered cube data file
  105928. */
  105929. CubePrefiltered = 9,
  105930. /**
  105931. * Texture content is raw 3D data
  105932. */
  105933. Raw3D = 10,
  105934. /**
  105935. * Texture content is raw 2D array data
  105936. */
  105937. Raw2DArray = 11,
  105938. /**
  105939. * Texture content is a depth texture
  105940. */
  105941. Depth = 12,
  105942. /**
  105943. * Texture data comes from a raw cube data encoded with RGBD
  105944. */
  105945. CubeRawRGBD = 13
  105946. }
  105947. /**
  105948. * Class used to store data associated with WebGL texture data for the engine
  105949. * This class should not be used directly
  105950. */
  105951. export class InternalTexture {
  105952. /** @hidden */
  105953. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  105954. /**
  105955. * Defines if the texture is ready
  105956. */
  105957. isReady: boolean;
  105958. /**
  105959. * Defines if the texture is a cube texture
  105960. */
  105961. isCube: boolean;
  105962. /**
  105963. * Defines if the texture contains 3D data
  105964. */
  105965. is3D: boolean;
  105966. /**
  105967. * Defines if the texture contains 2D array data
  105968. */
  105969. is2DArray: boolean;
  105970. /**
  105971. * Defines if the texture contains multiview data
  105972. */
  105973. isMultiview: boolean;
  105974. /**
  105975. * Gets the URL used to load this texture
  105976. */
  105977. url: string;
  105978. /**
  105979. * Gets the sampling mode of the texture
  105980. */
  105981. samplingMode: number;
  105982. /**
  105983. * Gets a boolean indicating if the texture needs mipmaps generation
  105984. */
  105985. generateMipMaps: boolean;
  105986. /**
  105987. * Gets the number of samples used by the texture (WebGL2+ only)
  105988. */
  105989. samples: number;
  105990. /**
  105991. * Gets the type of the texture (int, float...)
  105992. */
  105993. type: number;
  105994. /**
  105995. * Gets the format of the texture (RGB, RGBA...)
  105996. */
  105997. format: number;
  105998. /**
  105999. * Observable called when the texture is loaded
  106000. */
  106001. onLoadedObservable: Observable<InternalTexture>;
  106002. /**
  106003. * Gets the width of the texture
  106004. */
  106005. width: number;
  106006. /**
  106007. * Gets the height of the texture
  106008. */
  106009. height: number;
  106010. /**
  106011. * Gets the depth of the texture
  106012. */
  106013. depth: number;
  106014. /**
  106015. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  106016. */
  106017. baseWidth: number;
  106018. /**
  106019. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  106020. */
  106021. baseHeight: number;
  106022. /**
  106023. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  106024. */
  106025. baseDepth: number;
  106026. /**
  106027. * Gets a boolean indicating if the texture is inverted on Y axis
  106028. */
  106029. invertY: boolean;
  106030. /** @hidden */
  106031. _invertVScale: boolean;
  106032. /** @hidden */
  106033. _associatedChannel: number;
  106034. /** @hidden */
  106035. _source: InternalTextureSource;
  106036. /** @hidden */
  106037. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  106038. /** @hidden */
  106039. _bufferView: Nullable<ArrayBufferView>;
  106040. /** @hidden */
  106041. _bufferViewArray: Nullable<ArrayBufferView[]>;
  106042. /** @hidden */
  106043. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  106044. /** @hidden */
  106045. _size: number;
  106046. /** @hidden */
  106047. _extension: string;
  106048. /** @hidden */
  106049. _files: Nullable<string[]>;
  106050. /** @hidden */
  106051. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  106052. /** @hidden */
  106053. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  106054. /** @hidden */
  106055. _framebuffer: Nullable<WebGLFramebuffer>;
  106056. /** @hidden */
  106057. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  106058. /** @hidden */
  106059. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  106060. /** @hidden */
  106061. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  106062. /** @hidden */
  106063. _attachments: Nullable<number[]>;
  106064. /** @hidden */
  106065. _cachedCoordinatesMode: Nullable<number>;
  106066. /** @hidden */
  106067. _cachedWrapU: Nullable<number>;
  106068. /** @hidden */
  106069. _cachedWrapV: Nullable<number>;
  106070. /** @hidden */
  106071. _cachedWrapR: Nullable<number>;
  106072. /** @hidden */
  106073. _cachedAnisotropicFilteringLevel: Nullable<number>;
  106074. /** @hidden */
  106075. _isDisabled: boolean;
  106076. /** @hidden */
  106077. _compression: Nullable<string>;
  106078. /** @hidden */
  106079. _generateStencilBuffer: boolean;
  106080. /** @hidden */
  106081. _generateDepthBuffer: boolean;
  106082. /** @hidden */
  106083. _comparisonFunction: number;
  106084. /** @hidden */
  106085. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  106086. /** @hidden */
  106087. _lodGenerationScale: number;
  106088. /** @hidden */
  106089. _lodGenerationOffset: number;
  106090. /** @hidden */
  106091. _depthStencilTexture: Nullable<InternalTexture>;
  106092. /** @hidden */
  106093. _colorTextureArray: Nullable<WebGLTexture>;
  106094. /** @hidden */
  106095. _depthStencilTextureArray: Nullable<WebGLTexture>;
  106096. /** @hidden */
  106097. _lodTextureHigh: Nullable<BaseTexture>;
  106098. /** @hidden */
  106099. _lodTextureMid: Nullable<BaseTexture>;
  106100. /** @hidden */
  106101. _lodTextureLow: Nullable<BaseTexture>;
  106102. /** @hidden */
  106103. _isRGBD: boolean;
  106104. /** @hidden */
  106105. _linearSpecularLOD: boolean;
  106106. /** @hidden */
  106107. _irradianceTexture: Nullable<BaseTexture>;
  106108. /** @hidden */
  106109. _webGLTexture: Nullable<WebGLTexture>;
  106110. /** @hidden */
  106111. _references: number;
  106112. private _engine;
  106113. /**
  106114. * Gets the Engine the texture belongs to.
  106115. * @returns The babylon engine
  106116. */
  106117. getEngine(): ThinEngine;
  106118. /**
  106119. * Gets the data source type of the texture
  106120. */
  106121. get source(): InternalTextureSource;
  106122. /**
  106123. * Creates a new InternalTexture
  106124. * @param engine defines the engine to use
  106125. * @param source defines the type of data that will be used
  106126. * @param delayAllocation if the texture allocation should be delayed (default: false)
  106127. */
  106128. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  106129. /**
  106130. * Increments the number of references (ie. the number of Texture that point to it)
  106131. */
  106132. incrementReferences(): void;
  106133. /**
  106134. * Change the size of the texture (not the size of the content)
  106135. * @param width defines the new width
  106136. * @param height defines the new height
  106137. * @param depth defines the new depth (1 by default)
  106138. */
  106139. updateSize(width: int, height: int, depth?: int): void;
  106140. /** @hidden */
  106141. _rebuild(): void;
  106142. /** @hidden */
  106143. _swapAndDie(target: InternalTexture): void;
  106144. /**
  106145. * Dispose the current allocated resources
  106146. */
  106147. dispose(): void;
  106148. }
  106149. }
  106150. declare module BABYLON {
  106151. /**
  106152. * Class used to work with sound analyzer using fast fourier transform (FFT)
  106153. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106154. */
  106155. export class Analyser {
  106156. /**
  106157. * Gets or sets the smoothing
  106158. * @ignorenaming
  106159. */
  106160. SMOOTHING: number;
  106161. /**
  106162. * Gets or sets the FFT table size
  106163. * @ignorenaming
  106164. */
  106165. FFT_SIZE: number;
  106166. /**
  106167. * Gets or sets the bar graph amplitude
  106168. * @ignorenaming
  106169. */
  106170. BARGRAPHAMPLITUDE: number;
  106171. /**
  106172. * Gets or sets the position of the debug canvas
  106173. * @ignorenaming
  106174. */
  106175. DEBUGCANVASPOS: {
  106176. x: number;
  106177. y: number;
  106178. };
  106179. /**
  106180. * Gets or sets the debug canvas size
  106181. * @ignorenaming
  106182. */
  106183. DEBUGCANVASSIZE: {
  106184. width: number;
  106185. height: number;
  106186. };
  106187. private _byteFreqs;
  106188. private _byteTime;
  106189. private _floatFreqs;
  106190. private _webAudioAnalyser;
  106191. private _debugCanvas;
  106192. private _debugCanvasContext;
  106193. private _scene;
  106194. private _registerFunc;
  106195. private _audioEngine;
  106196. /**
  106197. * Creates a new analyser
  106198. * @param scene defines hosting scene
  106199. */
  106200. constructor(scene: Scene);
  106201. /**
  106202. * Get the number of data values you will have to play with for the visualization
  106203. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  106204. * @returns a number
  106205. */
  106206. getFrequencyBinCount(): number;
  106207. /**
  106208. * Gets the current frequency data as a byte array
  106209. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  106210. * @returns a Uint8Array
  106211. */
  106212. getByteFrequencyData(): Uint8Array;
  106213. /**
  106214. * Gets the current waveform as a byte array
  106215. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  106216. * @returns a Uint8Array
  106217. */
  106218. getByteTimeDomainData(): Uint8Array;
  106219. /**
  106220. * Gets the current frequency data as a float array
  106221. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  106222. * @returns a Float32Array
  106223. */
  106224. getFloatFrequencyData(): Float32Array;
  106225. /**
  106226. * Renders the debug canvas
  106227. */
  106228. drawDebugCanvas(): void;
  106229. /**
  106230. * Stops rendering the debug canvas and removes it
  106231. */
  106232. stopDebugCanvas(): void;
  106233. /**
  106234. * Connects two audio nodes
  106235. * @param inputAudioNode defines first node to connect
  106236. * @param outputAudioNode defines second node to connect
  106237. */
  106238. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  106239. /**
  106240. * Releases all associated resources
  106241. */
  106242. dispose(): void;
  106243. }
  106244. }
  106245. declare module BABYLON {
  106246. /**
  106247. * This represents an audio engine and it is responsible
  106248. * to play, synchronize and analyse sounds throughout the application.
  106249. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106250. */
  106251. export interface IAudioEngine extends IDisposable {
  106252. /**
  106253. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  106254. */
  106255. readonly canUseWebAudio: boolean;
  106256. /**
  106257. * Gets the current AudioContext if available.
  106258. */
  106259. readonly audioContext: Nullable<AudioContext>;
  106260. /**
  106261. * The master gain node defines the global audio volume of your audio engine.
  106262. */
  106263. readonly masterGain: GainNode;
  106264. /**
  106265. * Gets whether or not mp3 are supported by your browser.
  106266. */
  106267. readonly isMP3supported: boolean;
  106268. /**
  106269. * Gets whether or not ogg are supported by your browser.
  106270. */
  106271. readonly isOGGsupported: boolean;
  106272. /**
  106273. * Defines if Babylon should emit a warning if WebAudio is not supported.
  106274. * @ignoreNaming
  106275. */
  106276. WarnedWebAudioUnsupported: boolean;
  106277. /**
  106278. * Defines if the audio engine relies on a custom unlocked button.
  106279. * In this case, the embedded button will not be displayed.
  106280. */
  106281. useCustomUnlockedButton: boolean;
  106282. /**
  106283. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  106284. */
  106285. readonly unlocked: boolean;
  106286. /**
  106287. * Event raised when audio has been unlocked on the browser.
  106288. */
  106289. onAudioUnlockedObservable: Observable<AudioEngine>;
  106290. /**
  106291. * Event raised when audio has been locked on the browser.
  106292. */
  106293. onAudioLockedObservable: Observable<AudioEngine>;
  106294. /**
  106295. * Flags the audio engine in Locked state.
  106296. * This happens due to new browser policies preventing audio to autoplay.
  106297. */
  106298. lock(): void;
  106299. /**
  106300. * Unlocks the audio engine once a user action has been done on the dom.
  106301. * This is helpful to resume play once browser policies have been satisfied.
  106302. */
  106303. unlock(): void;
  106304. /**
  106305. * Gets the global volume sets on the master gain.
  106306. * @returns the global volume if set or -1 otherwise
  106307. */
  106308. getGlobalVolume(): number;
  106309. /**
  106310. * Sets the global volume of your experience (sets on the master gain).
  106311. * @param newVolume Defines the new global volume of the application
  106312. */
  106313. setGlobalVolume(newVolume: number): void;
  106314. /**
  106315. * Connect the audio engine to an audio analyser allowing some amazing
  106316. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  106317. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  106318. * @param analyser The analyser to connect to the engine
  106319. */
  106320. connectToAnalyser(analyser: Analyser): void;
  106321. }
  106322. /**
  106323. * This represents the default audio engine used in babylon.
  106324. * It is responsible to play, synchronize and analyse sounds throughout the application.
  106325. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106326. */
  106327. export class AudioEngine implements IAudioEngine {
  106328. private _audioContext;
  106329. private _audioContextInitialized;
  106330. private _muteButton;
  106331. private _hostElement;
  106332. /**
  106333. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  106334. */
  106335. canUseWebAudio: boolean;
  106336. /**
  106337. * The master gain node defines the global audio volume of your audio engine.
  106338. */
  106339. masterGain: GainNode;
  106340. /**
  106341. * Defines if Babylon should emit a warning if WebAudio is not supported.
  106342. * @ignoreNaming
  106343. */
  106344. WarnedWebAudioUnsupported: boolean;
  106345. /**
  106346. * Gets whether or not mp3 are supported by your browser.
  106347. */
  106348. isMP3supported: boolean;
  106349. /**
  106350. * Gets whether or not ogg are supported by your browser.
  106351. */
  106352. isOGGsupported: boolean;
  106353. /**
  106354. * Gets whether audio has been unlocked on the device.
  106355. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  106356. * a user interaction has happened.
  106357. */
  106358. unlocked: boolean;
  106359. /**
  106360. * Defines if the audio engine relies on a custom unlocked button.
  106361. * In this case, the embedded button will not be displayed.
  106362. */
  106363. useCustomUnlockedButton: boolean;
  106364. /**
  106365. * Event raised when audio has been unlocked on the browser.
  106366. */
  106367. onAudioUnlockedObservable: Observable<AudioEngine>;
  106368. /**
  106369. * Event raised when audio has been locked on the browser.
  106370. */
  106371. onAudioLockedObservable: Observable<AudioEngine>;
  106372. /**
  106373. * Gets the current AudioContext if available.
  106374. */
  106375. get audioContext(): Nullable<AudioContext>;
  106376. private _connectedAnalyser;
  106377. /**
  106378. * Instantiates a new audio engine.
  106379. *
  106380. * There should be only one per page as some browsers restrict the number
  106381. * of audio contexts you can create.
  106382. * @param hostElement defines the host element where to display the mute icon if necessary
  106383. */
  106384. constructor(hostElement?: Nullable<HTMLElement>);
  106385. /**
  106386. * Flags the audio engine in Locked state.
  106387. * This happens due to new browser policies preventing audio to autoplay.
  106388. */
  106389. lock(): void;
  106390. /**
  106391. * Unlocks the audio engine once a user action has been done on the dom.
  106392. * This is helpful to resume play once browser policies have been satisfied.
  106393. */
  106394. unlock(): void;
  106395. private _resumeAudioContext;
  106396. private _initializeAudioContext;
  106397. private _tryToRun;
  106398. private _triggerRunningState;
  106399. private _triggerSuspendedState;
  106400. private _displayMuteButton;
  106401. private _moveButtonToTopLeft;
  106402. private _onResize;
  106403. private _hideMuteButton;
  106404. /**
  106405. * Destroy and release the resources associated with the audio ccontext.
  106406. */
  106407. dispose(): void;
  106408. /**
  106409. * Gets the global volume sets on the master gain.
  106410. * @returns the global volume if set or -1 otherwise
  106411. */
  106412. getGlobalVolume(): number;
  106413. /**
  106414. * Sets the global volume of your experience (sets on the master gain).
  106415. * @param newVolume Defines the new global volume of the application
  106416. */
  106417. setGlobalVolume(newVolume: number): void;
  106418. /**
  106419. * Connect the audio engine to an audio analyser allowing some amazing
  106420. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  106421. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  106422. * @param analyser The analyser to connect to the engine
  106423. */
  106424. connectToAnalyser(analyser: Analyser): void;
  106425. }
  106426. }
  106427. declare module BABYLON {
  106428. /**
  106429. * Interface used to present a loading screen while loading a scene
  106430. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106431. */
  106432. export interface ILoadingScreen {
  106433. /**
  106434. * Function called to display the loading screen
  106435. */
  106436. displayLoadingUI: () => void;
  106437. /**
  106438. * Function called to hide the loading screen
  106439. */
  106440. hideLoadingUI: () => void;
  106441. /**
  106442. * Gets or sets the color to use for the background
  106443. */
  106444. loadingUIBackgroundColor: string;
  106445. /**
  106446. * Gets or sets the text to display while loading
  106447. */
  106448. loadingUIText: string;
  106449. }
  106450. /**
  106451. * Class used for the default loading screen
  106452. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106453. */
  106454. export class DefaultLoadingScreen implements ILoadingScreen {
  106455. private _renderingCanvas;
  106456. private _loadingText;
  106457. private _loadingDivBackgroundColor;
  106458. private _loadingDiv;
  106459. private _loadingTextDiv;
  106460. /** Gets or sets the logo url to use for the default loading screen */
  106461. static DefaultLogoUrl: string;
  106462. /** Gets or sets the spinner url to use for the default loading screen */
  106463. static DefaultSpinnerUrl: string;
  106464. /**
  106465. * Creates a new default loading screen
  106466. * @param _renderingCanvas defines the canvas used to render the scene
  106467. * @param _loadingText defines the default text to display
  106468. * @param _loadingDivBackgroundColor defines the default background color
  106469. */
  106470. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  106471. /**
  106472. * Function called to display the loading screen
  106473. */
  106474. displayLoadingUI(): void;
  106475. /**
  106476. * Function called to hide the loading screen
  106477. */
  106478. hideLoadingUI(): void;
  106479. /**
  106480. * Gets or sets the text to display while loading
  106481. */
  106482. set loadingUIText(text: string);
  106483. get loadingUIText(): string;
  106484. /**
  106485. * Gets or sets the color to use for the background
  106486. */
  106487. get loadingUIBackgroundColor(): string;
  106488. set loadingUIBackgroundColor(color: string);
  106489. private _resizeLoadingUI;
  106490. }
  106491. }
  106492. declare module BABYLON {
  106493. /**
  106494. * Interface for any object that can request an animation frame
  106495. */
  106496. export interface ICustomAnimationFrameRequester {
  106497. /**
  106498. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  106499. */
  106500. renderFunction?: Function;
  106501. /**
  106502. * Called to request the next frame to render to
  106503. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  106504. */
  106505. requestAnimationFrame: Function;
  106506. /**
  106507. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  106508. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  106509. */
  106510. requestID?: number;
  106511. }
  106512. }
  106513. declare module BABYLON {
  106514. /**
  106515. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  106516. */
  106517. export class PerformanceMonitor {
  106518. private _enabled;
  106519. private _rollingFrameTime;
  106520. private _lastFrameTimeMs;
  106521. /**
  106522. * constructor
  106523. * @param frameSampleSize The number of samples required to saturate the sliding window
  106524. */
  106525. constructor(frameSampleSize?: number);
  106526. /**
  106527. * Samples current frame
  106528. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  106529. */
  106530. sampleFrame(timeMs?: number): void;
  106531. /**
  106532. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  106533. */
  106534. get averageFrameTime(): number;
  106535. /**
  106536. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  106537. */
  106538. get averageFrameTimeVariance(): number;
  106539. /**
  106540. * Returns the frame time of the most recent frame
  106541. */
  106542. get instantaneousFrameTime(): number;
  106543. /**
  106544. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  106545. */
  106546. get averageFPS(): number;
  106547. /**
  106548. * Returns the average framerate in frames per second using the most recent frame time
  106549. */
  106550. get instantaneousFPS(): number;
  106551. /**
  106552. * Returns true if enough samples have been taken to completely fill the sliding window
  106553. */
  106554. get isSaturated(): boolean;
  106555. /**
  106556. * Enables contributions to the sliding window sample set
  106557. */
  106558. enable(): void;
  106559. /**
  106560. * Disables contributions to the sliding window sample set
  106561. * Samples will not be interpolated over the disabled period
  106562. */
  106563. disable(): void;
  106564. /**
  106565. * Returns true if sampling is enabled
  106566. */
  106567. get isEnabled(): boolean;
  106568. /**
  106569. * Resets performance monitor
  106570. */
  106571. reset(): void;
  106572. }
  106573. /**
  106574. * RollingAverage
  106575. *
  106576. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  106577. */
  106578. export class RollingAverage {
  106579. /**
  106580. * Current average
  106581. */
  106582. average: number;
  106583. /**
  106584. * Current variance
  106585. */
  106586. variance: number;
  106587. protected _samples: Array<number>;
  106588. protected _sampleCount: number;
  106589. protected _pos: number;
  106590. protected _m2: number;
  106591. /**
  106592. * constructor
  106593. * @param length The number of samples required to saturate the sliding window
  106594. */
  106595. constructor(length: number);
  106596. /**
  106597. * Adds a sample to the sample set
  106598. * @param v The sample value
  106599. */
  106600. add(v: number): void;
  106601. /**
  106602. * Returns previously added values or null if outside of history or outside the sliding window domain
  106603. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  106604. * @return Value previously recorded with add() or null if outside of range
  106605. */
  106606. history(i: number): number;
  106607. /**
  106608. * Returns true if enough samples have been taken to completely fill the sliding window
  106609. * @return true if sample-set saturated
  106610. */
  106611. isSaturated(): boolean;
  106612. /**
  106613. * Resets the rolling average (equivalent to 0 samples taken so far)
  106614. */
  106615. reset(): void;
  106616. /**
  106617. * Wraps a value around the sample range boundaries
  106618. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  106619. * @return Wrapped position in sample range
  106620. */
  106621. protected _wrapPosition(i: number): number;
  106622. }
  106623. }
  106624. declare module BABYLON {
  106625. /**
  106626. * This class is used to track a performance counter which is number based.
  106627. * The user has access to many properties which give statistics of different nature.
  106628. *
  106629. * The implementer can track two kinds of Performance Counter: time and count.
  106630. * 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.
  106631. * 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.
  106632. */
  106633. export class PerfCounter {
  106634. /**
  106635. * Gets or sets a global boolean to turn on and off all the counters
  106636. */
  106637. static Enabled: boolean;
  106638. /**
  106639. * Returns the smallest value ever
  106640. */
  106641. get min(): number;
  106642. /**
  106643. * Returns the biggest value ever
  106644. */
  106645. get max(): number;
  106646. /**
  106647. * Returns the average value since the performance counter is running
  106648. */
  106649. get average(): number;
  106650. /**
  106651. * Returns the average value of the last second the counter was monitored
  106652. */
  106653. get lastSecAverage(): number;
  106654. /**
  106655. * Returns the current value
  106656. */
  106657. get current(): number;
  106658. /**
  106659. * Gets the accumulated total
  106660. */
  106661. get total(): number;
  106662. /**
  106663. * Gets the total value count
  106664. */
  106665. get count(): number;
  106666. /**
  106667. * Creates a new counter
  106668. */
  106669. constructor();
  106670. /**
  106671. * Call this method to start monitoring a new frame.
  106672. * 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.
  106673. */
  106674. fetchNewFrame(): void;
  106675. /**
  106676. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  106677. * @param newCount the count value to add to the monitored count
  106678. * @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.
  106679. */
  106680. addCount(newCount: number, fetchResult: boolean): void;
  106681. /**
  106682. * Start monitoring this performance counter
  106683. */
  106684. beginMonitoring(): void;
  106685. /**
  106686. * Compute the time lapsed since the previous beginMonitoring() call.
  106687. * @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
  106688. */
  106689. endMonitoring(newFrame?: boolean): void;
  106690. private _fetchResult;
  106691. private _startMonitoringTime;
  106692. private _min;
  106693. private _max;
  106694. private _average;
  106695. private _current;
  106696. private _totalValueCount;
  106697. private _totalAccumulated;
  106698. private _lastSecAverage;
  106699. private _lastSecAccumulated;
  106700. private _lastSecTime;
  106701. private _lastSecValueCount;
  106702. }
  106703. }
  106704. declare module BABYLON {
  106705. interface ThinEngine {
  106706. /**
  106707. * Sets alpha constants used by some alpha blending modes
  106708. * @param r defines the red component
  106709. * @param g defines the green component
  106710. * @param b defines the blue component
  106711. * @param a defines the alpha component
  106712. */
  106713. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  106714. /**
  106715. * Sets the current alpha mode
  106716. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  106717. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  106718. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  106719. */
  106720. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  106721. /**
  106722. * Gets the current alpha mode
  106723. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  106724. * @returns the current alpha mode
  106725. */
  106726. getAlphaMode(): number;
  106727. /**
  106728. * Sets the current alpha equation
  106729. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  106730. */
  106731. setAlphaEquation(equation: number): void;
  106732. /**
  106733. * Gets the current alpha equation.
  106734. * @returns the current alpha equation
  106735. */
  106736. getAlphaEquation(): number;
  106737. }
  106738. }
  106739. declare module BABYLON {
  106740. /**
  106741. * Defines the interface used by display changed events
  106742. */
  106743. export interface IDisplayChangedEventArgs {
  106744. /** Gets the vrDisplay object (if any) */
  106745. vrDisplay: Nullable<any>;
  106746. /** Gets a boolean indicating if webVR is supported */
  106747. vrSupported: boolean;
  106748. }
  106749. /**
  106750. * Defines the interface used by objects containing a viewport (like a camera)
  106751. */
  106752. interface IViewportOwnerLike {
  106753. /**
  106754. * Gets or sets the viewport
  106755. */
  106756. viewport: IViewportLike;
  106757. }
  106758. /**
  106759. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  106760. */
  106761. export class Engine extends ThinEngine {
  106762. /** Defines that alpha blending is disabled */
  106763. static readonly ALPHA_DISABLE: number;
  106764. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  106765. static readonly ALPHA_ADD: number;
  106766. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  106767. static readonly ALPHA_COMBINE: number;
  106768. /** Defines that alpha blending to DEST - SRC * DEST */
  106769. static readonly ALPHA_SUBTRACT: number;
  106770. /** Defines that alpha blending to SRC * DEST */
  106771. static readonly ALPHA_MULTIPLY: number;
  106772. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  106773. static readonly ALPHA_MAXIMIZED: number;
  106774. /** Defines that alpha blending to SRC + DEST */
  106775. static readonly ALPHA_ONEONE: number;
  106776. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  106777. static readonly ALPHA_PREMULTIPLIED: number;
  106778. /**
  106779. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  106780. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  106781. */
  106782. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  106783. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  106784. static readonly ALPHA_INTERPOLATE: number;
  106785. /**
  106786. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  106787. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  106788. */
  106789. static readonly ALPHA_SCREENMODE: number;
  106790. /** Defines that the ressource is not delayed*/
  106791. static readonly DELAYLOADSTATE_NONE: number;
  106792. /** Defines that the ressource was successfully delay loaded */
  106793. static readonly DELAYLOADSTATE_LOADED: number;
  106794. /** Defines that the ressource is currently delay loading */
  106795. static readonly DELAYLOADSTATE_LOADING: number;
  106796. /** Defines that the ressource is delayed and has not started loading */
  106797. static readonly DELAYLOADSTATE_NOTLOADED: number;
  106798. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  106799. static readonly NEVER: number;
  106800. /** 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 */
  106801. static readonly ALWAYS: number;
  106802. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  106803. static readonly LESS: number;
  106804. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  106805. static readonly EQUAL: number;
  106806. /** 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 */
  106807. static readonly LEQUAL: number;
  106808. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  106809. static readonly GREATER: number;
  106810. /** 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 */
  106811. static readonly GEQUAL: number;
  106812. /** 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 */
  106813. static readonly NOTEQUAL: number;
  106814. /** Passed to stencilOperation to specify that stencil value must be kept */
  106815. static readonly KEEP: number;
  106816. /** Passed to stencilOperation to specify that stencil value must be replaced */
  106817. static readonly REPLACE: number;
  106818. /** Passed to stencilOperation to specify that stencil value must be incremented */
  106819. static readonly INCR: number;
  106820. /** Passed to stencilOperation to specify that stencil value must be decremented */
  106821. static readonly DECR: number;
  106822. /** Passed to stencilOperation to specify that stencil value must be inverted */
  106823. static readonly INVERT: number;
  106824. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  106825. static readonly INCR_WRAP: number;
  106826. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  106827. static readonly DECR_WRAP: number;
  106828. /** Texture is not repeating outside of 0..1 UVs */
  106829. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  106830. /** Texture is repeating outside of 0..1 UVs */
  106831. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  106832. /** Texture is repeating and mirrored */
  106833. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  106834. /** ALPHA */
  106835. static readonly TEXTUREFORMAT_ALPHA: number;
  106836. /** LUMINANCE */
  106837. static readonly TEXTUREFORMAT_LUMINANCE: number;
  106838. /** LUMINANCE_ALPHA */
  106839. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  106840. /** RGB */
  106841. static readonly TEXTUREFORMAT_RGB: number;
  106842. /** RGBA */
  106843. static readonly TEXTUREFORMAT_RGBA: number;
  106844. /** RED */
  106845. static readonly TEXTUREFORMAT_RED: number;
  106846. /** RED (2nd reference) */
  106847. static readonly TEXTUREFORMAT_R: number;
  106848. /** RG */
  106849. static readonly TEXTUREFORMAT_RG: number;
  106850. /** RED_INTEGER */
  106851. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  106852. /** RED_INTEGER (2nd reference) */
  106853. static readonly TEXTUREFORMAT_R_INTEGER: number;
  106854. /** RG_INTEGER */
  106855. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  106856. /** RGB_INTEGER */
  106857. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  106858. /** RGBA_INTEGER */
  106859. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  106860. /** UNSIGNED_BYTE */
  106861. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  106862. /** UNSIGNED_BYTE (2nd reference) */
  106863. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  106864. /** FLOAT */
  106865. static readonly TEXTURETYPE_FLOAT: number;
  106866. /** HALF_FLOAT */
  106867. static readonly TEXTURETYPE_HALF_FLOAT: number;
  106868. /** BYTE */
  106869. static readonly TEXTURETYPE_BYTE: number;
  106870. /** SHORT */
  106871. static readonly TEXTURETYPE_SHORT: number;
  106872. /** UNSIGNED_SHORT */
  106873. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  106874. /** INT */
  106875. static readonly TEXTURETYPE_INT: number;
  106876. /** UNSIGNED_INT */
  106877. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  106878. /** UNSIGNED_SHORT_4_4_4_4 */
  106879. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  106880. /** UNSIGNED_SHORT_5_5_5_1 */
  106881. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  106882. /** UNSIGNED_SHORT_5_6_5 */
  106883. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  106884. /** UNSIGNED_INT_2_10_10_10_REV */
  106885. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  106886. /** UNSIGNED_INT_24_8 */
  106887. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  106888. /** UNSIGNED_INT_10F_11F_11F_REV */
  106889. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  106890. /** UNSIGNED_INT_5_9_9_9_REV */
  106891. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  106892. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  106893. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  106894. /** nearest is mag = nearest and min = nearest and mip = linear */
  106895. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  106896. /** Bilinear is mag = linear and min = linear and mip = nearest */
  106897. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  106898. /** Trilinear is mag = linear and min = linear and mip = linear */
  106899. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  106900. /** nearest is mag = nearest and min = nearest and mip = linear */
  106901. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  106902. /** Bilinear is mag = linear and min = linear and mip = nearest */
  106903. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  106904. /** Trilinear is mag = linear and min = linear and mip = linear */
  106905. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  106906. /** mag = nearest and min = nearest and mip = nearest */
  106907. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  106908. /** mag = nearest and min = linear and mip = nearest */
  106909. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  106910. /** mag = nearest and min = linear and mip = linear */
  106911. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  106912. /** mag = nearest and min = linear and mip = none */
  106913. static readonly TEXTURE_NEAREST_LINEAR: number;
  106914. /** mag = nearest and min = nearest and mip = none */
  106915. static readonly TEXTURE_NEAREST_NEAREST: number;
  106916. /** mag = linear and min = nearest and mip = nearest */
  106917. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  106918. /** mag = linear and min = nearest and mip = linear */
  106919. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  106920. /** mag = linear and min = linear and mip = none */
  106921. static readonly TEXTURE_LINEAR_LINEAR: number;
  106922. /** mag = linear and min = nearest and mip = none */
  106923. static readonly TEXTURE_LINEAR_NEAREST: number;
  106924. /** Explicit coordinates mode */
  106925. static readonly TEXTURE_EXPLICIT_MODE: number;
  106926. /** Spherical coordinates mode */
  106927. static readonly TEXTURE_SPHERICAL_MODE: number;
  106928. /** Planar coordinates mode */
  106929. static readonly TEXTURE_PLANAR_MODE: number;
  106930. /** Cubic coordinates mode */
  106931. static readonly TEXTURE_CUBIC_MODE: number;
  106932. /** Projection coordinates mode */
  106933. static readonly TEXTURE_PROJECTION_MODE: number;
  106934. /** Skybox coordinates mode */
  106935. static readonly TEXTURE_SKYBOX_MODE: number;
  106936. /** Inverse Cubic coordinates mode */
  106937. static readonly TEXTURE_INVCUBIC_MODE: number;
  106938. /** Equirectangular coordinates mode */
  106939. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  106940. /** Equirectangular Fixed coordinates mode */
  106941. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  106942. /** Equirectangular Fixed Mirrored coordinates mode */
  106943. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  106944. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  106945. static readonly SCALEMODE_FLOOR: number;
  106946. /** Defines that texture rescaling will look for the nearest power of 2 size */
  106947. static readonly SCALEMODE_NEAREST: number;
  106948. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  106949. static readonly SCALEMODE_CEILING: number;
  106950. /**
  106951. * Returns the current npm package of the sdk
  106952. */
  106953. static get NpmPackage(): string;
  106954. /**
  106955. * Returns the current version of the framework
  106956. */
  106957. static get Version(): string;
  106958. /** Gets the list of created engines */
  106959. static get Instances(): Engine[];
  106960. /**
  106961. * Gets the latest created engine
  106962. */
  106963. static get LastCreatedEngine(): Nullable<Engine>;
  106964. /**
  106965. * Gets the latest created scene
  106966. */
  106967. static get LastCreatedScene(): Nullable<Scene>;
  106968. /**
  106969. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  106970. * @param flag defines which part of the materials must be marked as dirty
  106971. * @param predicate defines a predicate used to filter which materials should be affected
  106972. */
  106973. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  106974. /**
  106975. * Method called to create the default loading screen.
  106976. * This can be overriden in your own app.
  106977. * @param canvas The rendering canvas element
  106978. * @returns The loading screen
  106979. */
  106980. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  106981. /**
  106982. * Method called to create the default rescale post process on each engine.
  106983. */
  106984. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  106985. /**
  106986. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  106987. **/
  106988. enableOfflineSupport: boolean;
  106989. /**
  106990. * 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)
  106991. **/
  106992. disableManifestCheck: boolean;
  106993. /**
  106994. * Gets the list of created scenes
  106995. */
  106996. scenes: Scene[];
  106997. /**
  106998. * Event raised when a new scene is created
  106999. */
  107000. onNewSceneAddedObservable: Observable<Scene>;
  107001. /**
  107002. * Gets the list of created postprocesses
  107003. */
  107004. postProcesses: PostProcess[];
  107005. /**
  107006. * Gets a boolean indicating if the pointer is currently locked
  107007. */
  107008. isPointerLock: boolean;
  107009. /**
  107010. * Observable event triggered each time the rendering canvas is resized
  107011. */
  107012. onResizeObservable: Observable<Engine>;
  107013. /**
  107014. * Observable event triggered each time the canvas loses focus
  107015. */
  107016. onCanvasBlurObservable: Observable<Engine>;
  107017. /**
  107018. * Observable event triggered each time the canvas gains focus
  107019. */
  107020. onCanvasFocusObservable: Observable<Engine>;
  107021. /**
  107022. * Observable event triggered each time the canvas receives pointerout event
  107023. */
  107024. onCanvasPointerOutObservable: Observable<PointerEvent>;
  107025. /**
  107026. * Observable raised when the engine begins a new frame
  107027. */
  107028. onBeginFrameObservable: Observable<Engine>;
  107029. /**
  107030. * If set, will be used to request the next animation frame for the render loop
  107031. */
  107032. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  107033. /**
  107034. * Observable raised when the engine ends the current frame
  107035. */
  107036. onEndFrameObservable: Observable<Engine>;
  107037. /**
  107038. * Observable raised when the engine is about to compile a shader
  107039. */
  107040. onBeforeShaderCompilationObservable: Observable<Engine>;
  107041. /**
  107042. * Observable raised when the engine has jsut compiled a shader
  107043. */
  107044. onAfterShaderCompilationObservable: Observable<Engine>;
  107045. /**
  107046. * Gets the audio engine
  107047. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107048. * @ignorenaming
  107049. */
  107050. static audioEngine: IAudioEngine;
  107051. /**
  107052. * Default AudioEngine factory responsible of creating the Audio Engine.
  107053. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  107054. */
  107055. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  107056. /**
  107057. * Default offline support factory responsible of creating a tool used to store data locally.
  107058. * By default, this will create a Database object if the workload has been embedded.
  107059. */
  107060. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  107061. private _loadingScreen;
  107062. private _pointerLockRequested;
  107063. private _dummyFramebuffer;
  107064. private _rescalePostProcess;
  107065. private _deterministicLockstep;
  107066. private _lockstepMaxSteps;
  107067. private _timeStep;
  107068. protected get _supportsHardwareTextureRescaling(): boolean;
  107069. private _fps;
  107070. private _deltaTime;
  107071. /** @hidden */
  107072. _drawCalls: PerfCounter;
  107073. /** 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 */
  107074. canvasTabIndex: number;
  107075. /**
  107076. * Turn this value on if you want to pause FPS computation when in background
  107077. */
  107078. disablePerformanceMonitorInBackground: boolean;
  107079. private _performanceMonitor;
  107080. /**
  107081. * Gets the performance monitor attached to this engine
  107082. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  107083. */
  107084. get performanceMonitor(): PerformanceMonitor;
  107085. private _onFocus;
  107086. private _onBlur;
  107087. private _onCanvasPointerOut;
  107088. private _onCanvasBlur;
  107089. private _onCanvasFocus;
  107090. private _onFullscreenChange;
  107091. private _onPointerLockChange;
  107092. /**
  107093. * Gets the HTML element used to attach event listeners
  107094. * @returns a HTML element
  107095. */
  107096. getInputElement(): Nullable<HTMLElement>;
  107097. /**
  107098. * Creates a new engine
  107099. * @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
  107100. * @param antialias defines enable antialiasing (default: false)
  107101. * @param options defines further options to be sent to the getContext() function
  107102. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  107103. */
  107104. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  107105. /**
  107106. * Gets current aspect ratio
  107107. * @param viewportOwner defines the camera to use to get the aspect ratio
  107108. * @param useScreen defines if screen size must be used (or the current render target if any)
  107109. * @returns a number defining the aspect ratio
  107110. */
  107111. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  107112. /**
  107113. * Gets current screen aspect ratio
  107114. * @returns a number defining the aspect ratio
  107115. */
  107116. getScreenAspectRatio(): number;
  107117. /**
  107118. * Gets the client rect of the HTML canvas attached with the current webGL context
  107119. * @returns a client rectanglee
  107120. */
  107121. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  107122. /**
  107123. * Gets the client rect of the HTML element used for events
  107124. * @returns a client rectanglee
  107125. */
  107126. getInputElementClientRect(): Nullable<ClientRect>;
  107127. /**
  107128. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  107129. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107130. * @returns true if engine is in deterministic lock step mode
  107131. */
  107132. isDeterministicLockStep(): boolean;
  107133. /**
  107134. * Gets the max steps when engine is running in deterministic lock step
  107135. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107136. * @returns the max steps
  107137. */
  107138. getLockstepMaxSteps(): number;
  107139. /**
  107140. * Returns the time in ms between steps when using deterministic lock step.
  107141. * @returns time step in (ms)
  107142. */
  107143. getTimeStep(): number;
  107144. /**
  107145. * Force the mipmap generation for the given render target texture
  107146. * @param texture defines the render target texture to use
  107147. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  107148. */
  107149. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  107150. /** States */
  107151. /**
  107152. * Set various states to the webGL context
  107153. * @param culling defines backface culling state
  107154. * @param zOffset defines the value to apply to zOffset (0 by default)
  107155. * @param force defines if states must be applied even if cache is up to date
  107156. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  107157. */
  107158. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  107159. /**
  107160. * Set the z offset to apply to current rendering
  107161. * @param value defines the offset to apply
  107162. */
  107163. setZOffset(value: number): void;
  107164. /**
  107165. * Gets the current value of the zOffset
  107166. * @returns the current zOffset state
  107167. */
  107168. getZOffset(): number;
  107169. /**
  107170. * Enable or disable depth buffering
  107171. * @param enable defines the state to set
  107172. */
  107173. setDepthBuffer(enable: boolean): void;
  107174. /**
  107175. * Gets a boolean indicating if depth writing is enabled
  107176. * @returns the current depth writing state
  107177. */
  107178. getDepthWrite(): boolean;
  107179. /**
  107180. * Enable or disable depth writing
  107181. * @param enable defines the state to set
  107182. */
  107183. setDepthWrite(enable: boolean): void;
  107184. /**
  107185. * Gets a boolean indicating if stencil buffer is enabled
  107186. * @returns the current stencil buffer state
  107187. */
  107188. getStencilBuffer(): boolean;
  107189. /**
  107190. * Enable or disable the stencil buffer
  107191. * @param enable defines if the stencil buffer must be enabled or disabled
  107192. */
  107193. setStencilBuffer(enable: boolean): void;
  107194. /**
  107195. * Gets the current stencil mask
  107196. * @returns a number defining the new stencil mask to use
  107197. */
  107198. getStencilMask(): number;
  107199. /**
  107200. * Sets the current stencil mask
  107201. * @param mask defines the new stencil mask to use
  107202. */
  107203. setStencilMask(mask: number): void;
  107204. /**
  107205. * Gets the current stencil function
  107206. * @returns a number defining the stencil function to use
  107207. */
  107208. getStencilFunction(): number;
  107209. /**
  107210. * Gets the current stencil reference value
  107211. * @returns a number defining the stencil reference value to use
  107212. */
  107213. getStencilFunctionReference(): number;
  107214. /**
  107215. * Gets the current stencil mask
  107216. * @returns a number defining the stencil mask to use
  107217. */
  107218. getStencilFunctionMask(): number;
  107219. /**
  107220. * Sets the current stencil function
  107221. * @param stencilFunc defines the new stencil function to use
  107222. */
  107223. setStencilFunction(stencilFunc: number): void;
  107224. /**
  107225. * Sets the current stencil reference
  107226. * @param reference defines the new stencil reference to use
  107227. */
  107228. setStencilFunctionReference(reference: number): void;
  107229. /**
  107230. * Sets the current stencil mask
  107231. * @param mask defines the new stencil mask to use
  107232. */
  107233. setStencilFunctionMask(mask: number): void;
  107234. /**
  107235. * Gets the current stencil operation when stencil fails
  107236. * @returns a number defining stencil operation to use when stencil fails
  107237. */
  107238. getStencilOperationFail(): number;
  107239. /**
  107240. * Gets the current stencil operation when depth fails
  107241. * @returns a number defining stencil operation to use when depth fails
  107242. */
  107243. getStencilOperationDepthFail(): number;
  107244. /**
  107245. * Gets the current stencil operation when stencil passes
  107246. * @returns a number defining stencil operation to use when stencil passes
  107247. */
  107248. getStencilOperationPass(): number;
  107249. /**
  107250. * Sets the stencil operation to use when stencil fails
  107251. * @param operation defines the stencil operation to use when stencil fails
  107252. */
  107253. setStencilOperationFail(operation: number): void;
  107254. /**
  107255. * Sets the stencil operation to use when depth fails
  107256. * @param operation defines the stencil operation to use when depth fails
  107257. */
  107258. setStencilOperationDepthFail(operation: number): void;
  107259. /**
  107260. * Sets the stencil operation to use when stencil passes
  107261. * @param operation defines the stencil operation to use when stencil passes
  107262. */
  107263. setStencilOperationPass(operation: number): void;
  107264. /**
  107265. * Sets a boolean indicating if the dithering state is enabled or disabled
  107266. * @param value defines the dithering state
  107267. */
  107268. setDitheringState(value: boolean): void;
  107269. /**
  107270. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  107271. * @param value defines the rasterizer state
  107272. */
  107273. setRasterizerState(value: boolean): void;
  107274. /**
  107275. * Gets the current depth function
  107276. * @returns a number defining the depth function
  107277. */
  107278. getDepthFunction(): Nullable<number>;
  107279. /**
  107280. * Sets the current depth function
  107281. * @param depthFunc defines the function to use
  107282. */
  107283. setDepthFunction(depthFunc: number): void;
  107284. /**
  107285. * Sets the current depth function to GREATER
  107286. */
  107287. setDepthFunctionToGreater(): void;
  107288. /**
  107289. * Sets the current depth function to GEQUAL
  107290. */
  107291. setDepthFunctionToGreaterOrEqual(): void;
  107292. /**
  107293. * Sets the current depth function to LESS
  107294. */
  107295. setDepthFunctionToLess(): void;
  107296. /**
  107297. * Sets the current depth function to LEQUAL
  107298. */
  107299. setDepthFunctionToLessOrEqual(): void;
  107300. private _cachedStencilBuffer;
  107301. private _cachedStencilFunction;
  107302. private _cachedStencilMask;
  107303. private _cachedStencilOperationPass;
  107304. private _cachedStencilOperationFail;
  107305. private _cachedStencilOperationDepthFail;
  107306. private _cachedStencilReference;
  107307. /**
  107308. * Caches the the state of the stencil buffer
  107309. */
  107310. cacheStencilState(): void;
  107311. /**
  107312. * Restores the state of the stencil buffer
  107313. */
  107314. restoreStencilState(): void;
  107315. /**
  107316. * Directly set the WebGL Viewport
  107317. * @param x defines the x coordinate of the viewport (in screen space)
  107318. * @param y defines the y coordinate of the viewport (in screen space)
  107319. * @param width defines the width of the viewport (in screen space)
  107320. * @param height defines the height of the viewport (in screen space)
  107321. * @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
  107322. */
  107323. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  107324. /**
  107325. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  107326. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  107327. * @param y defines the y-coordinate of the corner of the clear rectangle
  107328. * @param width defines the width of the clear rectangle
  107329. * @param height defines the height of the clear rectangle
  107330. * @param clearColor defines the clear color
  107331. */
  107332. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  107333. /**
  107334. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  107335. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  107336. * @param y defines the y-coordinate of the corner of the clear rectangle
  107337. * @param width defines the width of the clear rectangle
  107338. * @param height defines the height of the clear rectangle
  107339. */
  107340. enableScissor(x: number, y: number, width: number, height: number): void;
  107341. /**
  107342. * Disable previously set scissor test rectangle
  107343. */
  107344. disableScissor(): void;
  107345. protected _reportDrawCall(): void;
  107346. /**
  107347. * Initializes a webVR display and starts listening to display change events
  107348. * The onVRDisplayChangedObservable will be notified upon these changes
  107349. * @returns The onVRDisplayChangedObservable
  107350. */
  107351. initWebVR(): Observable<IDisplayChangedEventArgs>;
  107352. /** @hidden */
  107353. _prepareVRComponent(): void;
  107354. /** @hidden */
  107355. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  107356. /** @hidden */
  107357. _submitVRFrame(): void;
  107358. /**
  107359. * Call this function to leave webVR mode
  107360. * Will do nothing if webVR is not supported or if there is no webVR device
  107361. * @see http://doc.babylonjs.com/how_to/webvr_camera
  107362. */
  107363. disableVR(): void;
  107364. /**
  107365. * Gets a boolean indicating that the system is in VR mode and is presenting
  107366. * @returns true if VR mode is engaged
  107367. */
  107368. isVRPresenting(): boolean;
  107369. /** @hidden */
  107370. _requestVRFrame(): void;
  107371. /** @hidden */
  107372. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  107373. /**
  107374. * Gets the source code of the vertex shader associated with a specific webGL program
  107375. * @param program defines the program to use
  107376. * @returns a string containing the source code of the vertex shader associated with the program
  107377. */
  107378. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  107379. /**
  107380. * Gets the source code of the fragment shader associated with a specific webGL program
  107381. * @param program defines the program to use
  107382. * @returns a string containing the source code of the fragment shader associated with the program
  107383. */
  107384. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  107385. /**
  107386. * Sets a depth stencil texture from a render target to the according uniform.
  107387. * @param channel The texture channel
  107388. * @param uniform The uniform to set
  107389. * @param texture The render target texture containing the depth stencil texture to apply
  107390. */
  107391. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  107392. /**
  107393. * Sets a texture to the webGL context from a postprocess
  107394. * @param channel defines the channel to use
  107395. * @param postProcess defines the source postprocess
  107396. */
  107397. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  107398. /**
  107399. * Binds the output of the passed in post process to the texture channel specified
  107400. * @param channel The channel the texture should be bound to
  107401. * @param postProcess The post process which's output should be bound
  107402. */
  107403. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  107404. /** @hidden */
  107405. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  107406. protected _rebuildBuffers(): void;
  107407. /** @hidden */
  107408. _renderFrame(): void;
  107409. _renderLoop(): void;
  107410. /** @hidden */
  107411. _renderViews(): boolean;
  107412. /**
  107413. * Toggle full screen mode
  107414. * @param requestPointerLock defines if a pointer lock should be requested from the user
  107415. */
  107416. switchFullscreen(requestPointerLock: boolean): void;
  107417. /**
  107418. * Enters full screen mode
  107419. * @param requestPointerLock defines if a pointer lock should be requested from the user
  107420. */
  107421. enterFullscreen(requestPointerLock: boolean): void;
  107422. /**
  107423. * Exits full screen mode
  107424. */
  107425. exitFullscreen(): void;
  107426. /**
  107427. * Enters Pointerlock mode
  107428. */
  107429. enterPointerlock(): void;
  107430. /**
  107431. * Exits Pointerlock mode
  107432. */
  107433. exitPointerlock(): void;
  107434. /**
  107435. * Begin a new frame
  107436. */
  107437. beginFrame(): void;
  107438. /**
  107439. * Enf the current frame
  107440. */
  107441. endFrame(): void;
  107442. resize(): void;
  107443. /**
  107444. * Force a specific size of the canvas
  107445. * @param width defines the new canvas' width
  107446. * @param height defines the new canvas' height
  107447. */
  107448. setSize(width: number, height: number): void;
  107449. /**
  107450. * Updates a dynamic vertex buffer.
  107451. * @param vertexBuffer the vertex buffer to update
  107452. * @param data the data used to update the vertex buffer
  107453. * @param byteOffset the byte offset of the data
  107454. * @param byteLength the byte length of the data
  107455. */
  107456. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  107457. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  107458. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  107459. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  107460. _releaseTexture(texture: InternalTexture): void;
  107461. /**
  107462. * @hidden
  107463. * Rescales a texture
  107464. * @param source input texutre
  107465. * @param destination destination texture
  107466. * @param scene scene to use to render the resize
  107467. * @param internalFormat format to use when resizing
  107468. * @param onComplete callback to be called when resize has completed
  107469. */
  107470. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  107471. /**
  107472. * Gets the current framerate
  107473. * @returns a number representing the framerate
  107474. */
  107475. getFps(): number;
  107476. /**
  107477. * Gets the time spent between current and previous frame
  107478. * @returns a number representing the delta time in ms
  107479. */
  107480. getDeltaTime(): number;
  107481. private _measureFps;
  107482. /** @hidden */
  107483. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  107484. /**
  107485. * Update a dynamic index buffer
  107486. * @param indexBuffer defines the target index buffer
  107487. * @param indices defines the data to update
  107488. * @param offset defines the offset in the target index buffer where update should start
  107489. */
  107490. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  107491. /**
  107492. * Updates the sample count of a render target texture
  107493. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  107494. * @param texture defines the texture to update
  107495. * @param samples defines the sample count to set
  107496. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  107497. */
  107498. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  107499. /**
  107500. * Updates a depth texture Comparison Mode and Function.
  107501. * If the comparison Function is equal to 0, the mode will be set to none.
  107502. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  107503. * @param texture The texture to set the comparison function for
  107504. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  107505. */
  107506. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  107507. /**
  107508. * Creates a webGL buffer to use with instanciation
  107509. * @param capacity defines the size of the buffer
  107510. * @returns the webGL buffer
  107511. */
  107512. createInstancesBuffer(capacity: number): DataBuffer;
  107513. /**
  107514. * Delete a webGL buffer used with instanciation
  107515. * @param buffer defines the webGL buffer to delete
  107516. */
  107517. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  107518. private _clientWaitAsync;
  107519. /** @hidden */
  107520. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  107521. /** @hidden */
  107522. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  107523. dispose(): void;
  107524. private _disableTouchAction;
  107525. /**
  107526. * Display the loading screen
  107527. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107528. */
  107529. displayLoadingUI(): void;
  107530. /**
  107531. * Hide the loading screen
  107532. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107533. */
  107534. hideLoadingUI(): void;
  107535. /**
  107536. * Gets the current loading screen object
  107537. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107538. */
  107539. get loadingScreen(): ILoadingScreen;
  107540. /**
  107541. * Sets the current loading screen object
  107542. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107543. */
  107544. set loadingScreen(loadingScreen: ILoadingScreen);
  107545. /**
  107546. * Sets the current loading screen text
  107547. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107548. */
  107549. set loadingUIText(text: string);
  107550. /**
  107551. * Sets the current loading screen background color
  107552. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107553. */
  107554. set loadingUIBackgroundColor(color: string);
  107555. /** Pointerlock and fullscreen */
  107556. /**
  107557. * Ask the browser to promote the current element to pointerlock mode
  107558. * @param element defines the DOM element to promote
  107559. */
  107560. static _RequestPointerlock(element: HTMLElement): void;
  107561. /**
  107562. * Asks the browser to exit pointerlock mode
  107563. */
  107564. static _ExitPointerlock(): void;
  107565. /**
  107566. * Ask the browser to promote the current element to fullscreen rendering mode
  107567. * @param element defines the DOM element to promote
  107568. */
  107569. static _RequestFullscreen(element: HTMLElement): void;
  107570. /**
  107571. * Asks the browser to exit fullscreen mode
  107572. */
  107573. static _ExitFullscreen(): void;
  107574. }
  107575. }
  107576. declare module BABYLON {
  107577. /**
  107578. * The engine store class is responsible to hold all the instances of Engine and Scene created
  107579. * during the life time of the application.
  107580. */
  107581. export class EngineStore {
  107582. /** Gets the list of created engines */
  107583. static Instances: Engine[];
  107584. /** @hidden */
  107585. static _LastCreatedScene: Nullable<Scene>;
  107586. /**
  107587. * Gets the latest created engine
  107588. */
  107589. static get LastCreatedEngine(): Nullable<Engine>;
  107590. /**
  107591. * Gets the latest created scene
  107592. */
  107593. static get LastCreatedScene(): Nullable<Scene>;
  107594. /**
  107595. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  107596. * @ignorenaming
  107597. */
  107598. static UseFallbackTexture: boolean;
  107599. /**
  107600. * Texture content used if a texture cannot loaded
  107601. * @ignorenaming
  107602. */
  107603. static FallbackTexture: string;
  107604. }
  107605. }
  107606. declare module BABYLON {
  107607. /**
  107608. * Helper class that provides a small promise polyfill
  107609. */
  107610. export class PromisePolyfill {
  107611. /**
  107612. * Static function used to check if the polyfill is required
  107613. * If this is the case then the function will inject the polyfill to window.Promise
  107614. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  107615. */
  107616. static Apply(force?: boolean): void;
  107617. }
  107618. }
  107619. declare module BABYLON {
  107620. /**
  107621. * Interface for screenshot methods with describe argument called `size` as object with options
  107622. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  107623. */
  107624. export interface IScreenshotSize {
  107625. /**
  107626. * number in pixels for canvas height
  107627. */
  107628. height?: number;
  107629. /**
  107630. * multiplier allowing render at a higher or lower resolution
  107631. * If value is defined then height and width will be ignored and taken from camera
  107632. */
  107633. precision?: number;
  107634. /**
  107635. * number in pixels for canvas width
  107636. */
  107637. width?: number;
  107638. }
  107639. }
  107640. declare module BABYLON {
  107641. interface IColor4Like {
  107642. r: float;
  107643. g: float;
  107644. b: float;
  107645. a: float;
  107646. }
  107647. /**
  107648. * Class containing a set of static utilities functions
  107649. */
  107650. export class Tools {
  107651. /**
  107652. * Gets or sets the base URL to use to load assets
  107653. */
  107654. static get BaseUrl(): string;
  107655. static set BaseUrl(value: string);
  107656. /**
  107657. * Enable/Disable Custom HTTP Request Headers globally.
  107658. * default = false
  107659. * @see CustomRequestHeaders
  107660. */
  107661. static UseCustomRequestHeaders: boolean;
  107662. /**
  107663. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  107664. * i.e. when loading files, where the server/service expects an Authorization header
  107665. */
  107666. static CustomRequestHeaders: {
  107667. [key: string]: string;
  107668. };
  107669. /**
  107670. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  107671. */
  107672. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  107673. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  107674. /**
  107675. * Default behaviour for cors in the application.
  107676. * It can be a string if the expected behavior is identical in the entire app.
  107677. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  107678. */
  107679. static get CorsBehavior(): string | ((url: string | string[]) => string);
  107680. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  107681. /**
  107682. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  107683. * @ignorenaming
  107684. */
  107685. static get UseFallbackTexture(): boolean;
  107686. static set UseFallbackTexture(value: boolean);
  107687. /**
  107688. * Use this object to register external classes like custom textures or material
  107689. * to allow the laoders to instantiate them
  107690. */
  107691. static get RegisteredExternalClasses(): {
  107692. [key: string]: Object;
  107693. };
  107694. static set RegisteredExternalClasses(classes: {
  107695. [key: string]: Object;
  107696. });
  107697. /**
  107698. * Texture content used if a texture cannot loaded
  107699. * @ignorenaming
  107700. */
  107701. static get fallbackTexture(): string;
  107702. static set fallbackTexture(value: string);
  107703. /**
  107704. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  107705. * @param u defines the coordinate on X axis
  107706. * @param v defines the coordinate on Y axis
  107707. * @param width defines the width of the source data
  107708. * @param height defines the height of the source data
  107709. * @param pixels defines the source byte array
  107710. * @param color defines the output color
  107711. */
  107712. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  107713. /**
  107714. * Interpolates between a and b via alpha
  107715. * @param a The lower value (returned when alpha = 0)
  107716. * @param b The upper value (returned when alpha = 1)
  107717. * @param alpha The interpolation-factor
  107718. * @return The mixed value
  107719. */
  107720. static Mix(a: number, b: number, alpha: number): number;
  107721. /**
  107722. * Tries to instantiate a new object from a given class name
  107723. * @param className defines the class name to instantiate
  107724. * @returns the new object or null if the system was not able to do the instantiation
  107725. */
  107726. static Instantiate(className: string): any;
  107727. /**
  107728. * Provides a slice function that will work even on IE
  107729. * @param data defines the array to slice
  107730. * @param start defines the start of the data (optional)
  107731. * @param end defines the end of the data (optional)
  107732. * @returns the new sliced array
  107733. */
  107734. static Slice<T>(data: T, start?: number, end?: number): T;
  107735. /**
  107736. * Polyfill for setImmediate
  107737. * @param action defines the action to execute after the current execution block
  107738. */
  107739. static SetImmediate(action: () => void): void;
  107740. /**
  107741. * Function indicating if a number is an exponent of 2
  107742. * @param value defines the value to test
  107743. * @returns true if the value is an exponent of 2
  107744. */
  107745. static IsExponentOfTwo(value: number): boolean;
  107746. private static _tmpFloatArray;
  107747. /**
  107748. * Returns the nearest 32-bit single precision float representation of a Number
  107749. * @param value A Number. If the parameter is of a different type, it will get converted
  107750. * to a number or to NaN if it cannot be converted
  107751. * @returns number
  107752. */
  107753. static FloatRound(value: number): number;
  107754. /**
  107755. * Extracts the filename from a path
  107756. * @param path defines the path to use
  107757. * @returns the filename
  107758. */
  107759. static GetFilename(path: string): string;
  107760. /**
  107761. * Extracts the "folder" part of a path (everything before the filename).
  107762. * @param uri The URI to extract the info from
  107763. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  107764. * @returns The "folder" part of the path
  107765. */
  107766. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  107767. /**
  107768. * Extracts text content from a DOM element hierarchy
  107769. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  107770. */
  107771. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  107772. /**
  107773. * Convert an angle in radians to degrees
  107774. * @param angle defines the angle to convert
  107775. * @returns the angle in degrees
  107776. */
  107777. static ToDegrees(angle: number): number;
  107778. /**
  107779. * Convert an angle in degrees to radians
  107780. * @param angle defines the angle to convert
  107781. * @returns the angle in radians
  107782. */
  107783. static ToRadians(angle: number): number;
  107784. /**
  107785. * Returns an array if obj is not an array
  107786. * @param obj defines the object to evaluate as an array
  107787. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  107788. * @returns either obj directly if obj is an array or a new array containing obj
  107789. */
  107790. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  107791. /**
  107792. * Gets the pointer prefix to use
  107793. * @returns "pointer" if touch is enabled. Else returns "mouse"
  107794. */
  107795. static GetPointerPrefix(): string;
  107796. /**
  107797. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  107798. * @param url define the url we are trying
  107799. * @param element define the dom element where to configure the cors policy
  107800. */
  107801. static SetCorsBehavior(url: string | string[], element: {
  107802. crossOrigin: string | null;
  107803. }): void;
  107804. /**
  107805. * Removes unwanted characters from an url
  107806. * @param url defines the url to clean
  107807. * @returns the cleaned url
  107808. */
  107809. static CleanUrl(url: string): string;
  107810. /**
  107811. * Gets or sets a function used to pre-process url before using them to load assets
  107812. */
  107813. static get PreprocessUrl(): (url: string) => string;
  107814. static set PreprocessUrl(processor: (url: string) => string);
  107815. /**
  107816. * Loads an image as an HTMLImageElement.
  107817. * @param input url string, ArrayBuffer, or Blob to load
  107818. * @param onLoad callback called when the image successfully loads
  107819. * @param onError callback called when the image fails to load
  107820. * @param offlineProvider offline provider for caching
  107821. * @param mimeType optional mime type
  107822. * @returns the HTMLImageElement of the loaded image
  107823. */
  107824. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  107825. /**
  107826. * Loads a file from a url
  107827. * @param url url string, ArrayBuffer, or Blob to load
  107828. * @param onSuccess callback called when the file successfully loads
  107829. * @param onProgress callback called while file is loading (if the server supports this mode)
  107830. * @param offlineProvider defines the offline provider for caching
  107831. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  107832. * @param onError callback called when the file fails to load
  107833. * @returns a file request object
  107834. */
  107835. 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;
  107836. /**
  107837. * Loads a file from a url
  107838. * @param url the file url to load
  107839. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  107840. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  107841. */
  107842. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  107843. /**
  107844. * Load a script (identified by an url). When the url returns, the
  107845. * content of this file is added into a new script element, attached to the DOM (body element)
  107846. * @param scriptUrl defines the url of the script to laod
  107847. * @param onSuccess defines the callback called when the script is loaded
  107848. * @param onError defines the callback to call if an error occurs
  107849. * @param scriptId defines the id of the script element
  107850. */
  107851. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  107852. /**
  107853. * Load an asynchronous script (identified by an url). When the url returns, the
  107854. * content of this file is added into a new script element, attached to the DOM (body element)
  107855. * @param scriptUrl defines the url of the script to laod
  107856. * @param scriptId defines the id of the script element
  107857. * @returns a promise request object
  107858. */
  107859. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  107860. /**
  107861. * Loads a file from a blob
  107862. * @param fileToLoad defines the blob to use
  107863. * @param callback defines the callback to call when data is loaded
  107864. * @param progressCallback defines the callback to call during loading process
  107865. * @returns a file request object
  107866. */
  107867. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  107868. /**
  107869. * Reads a file from a File object
  107870. * @param file defines the file to load
  107871. * @param onSuccess defines the callback to call when data is loaded
  107872. * @param onProgress defines the callback to call during loading process
  107873. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  107874. * @param onError defines the callback to call when an error occurs
  107875. * @returns a file request object
  107876. */
  107877. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  107878. /**
  107879. * Creates a data url from a given string content
  107880. * @param content defines the content to convert
  107881. * @returns the new data url link
  107882. */
  107883. static FileAsURL(content: string): string;
  107884. /**
  107885. * Format the given number to a specific decimal format
  107886. * @param value defines the number to format
  107887. * @param decimals defines the number of decimals to use
  107888. * @returns the formatted string
  107889. */
  107890. static Format(value: number, decimals?: number): string;
  107891. /**
  107892. * Tries to copy an object by duplicating every property
  107893. * @param source defines the source object
  107894. * @param destination defines the target object
  107895. * @param doNotCopyList defines a list of properties to avoid
  107896. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  107897. */
  107898. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  107899. /**
  107900. * Gets a boolean indicating if the given object has no own property
  107901. * @param obj defines the object to test
  107902. * @returns true if object has no own property
  107903. */
  107904. static IsEmpty(obj: any): boolean;
  107905. /**
  107906. * Function used to register events at window level
  107907. * @param windowElement defines the Window object to use
  107908. * @param events defines the events to register
  107909. */
  107910. static RegisterTopRootEvents(windowElement: Window, events: {
  107911. name: string;
  107912. handler: Nullable<(e: FocusEvent) => any>;
  107913. }[]): void;
  107914. /**
  107915. * Function used to unregister events from window level
  107916. * @param windowElement defines the Window object to use
  107917. * @param events defines the events to unregister
  107918. */
  107919. static UnregisterTopRootEvents(windowElement: Window, events: {
  107920. name: string;
  107921. handler: Nullable<(e: FocusEvent) => any>;
  107922. }[]): void;
  107923. /**
  107924. * @ignore
  107925. */
  107926. static _ScreenshotCanvas: HTMLCanvasElement;
  107927. /**
  107928. * Dumps the current bound framebuffer
  107929. * @param width defines the rendering width
  107930. * @param height defines the rendering height
  107931. * @param engine defines the hosting engine
  107932. * @param successCallback defines the callback triggered once the data are available
  107933. * @param mimeType defines the mime type of the result
  107934. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  107935. */
  107936. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107937. /**
  107938. * Converts the canvas data to blob.
  107939. * This acts as a polyfill for browsers not supporting the to blob function.
  107940. * @param canvas Defines the canvas to extract the data from
  107941. * @param successCallback Defines the callback triggered once the data are available
  107942. * @param mimeType Defines the mime type of the result
  107943. */
  107944. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  107945. /**
  107946. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  107947. * @param successCallback defines the callback triggered once the data are available
  107948. * @param mimeType defines the mime type of the result
  107949. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  107950. */
  107951. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107952. /**
  107953. * Downloads a blob in the browser
  107954. * @param blob defines the blob to download
  107955. * @param fileName defines the name of the downloaded file
  107956. */
  107957. static Download(blob: Blob, fileName: string): void;
  107958. /**
  107959. * Captures a screenshot of the current rendering
  107960. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107961. * @param engine defines the rendering engine
  107962. * @param camera defines the source camera
  107963. * @param size This parameter can be set to a single number or to an object with the
  107964. * following (optional) properties: precision, width, height. If a single number is passed,
  107965. * it will be used for both width and height. If an object is passed, the screenshot size
  107966. * will be derived from the parameters. The precision property is a multiplier allowing
  107967. * rendering at a higher or lower resolution
  107968. * @param successCallback defines the callback receives a single parameter which contains the
  107969. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  107970. * src parameter of an <img> to display it
  107971. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  107972. * Check your browser for supported MIME types
  107973. */
  107974. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  107975. /**
  107976. * Captures a screenshot of the current rendering
  107977. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107978. * @param engine defines the rendering engine
  107979. * @param camera defines the source camera
  107980. * @param size This parameter can be set to a single number or to an object with the
  107981. * following (optional) properties: precision, width, height. If a single number is passed,
  107982. * it will be used for both width and height. If an object is passed, the screenshot size
  107983. * will be derived from the parameters. The precision property is a multiplier allowing
  107984. * rendering at a higher or lower resolution
  107985. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  107986. * Check your browser for supported MIME types
  107987. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  107988. * to the src parameter of an <img> to display it
  107989. */
  107990. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  107991. /**
  107992. * Generates an image screenshot from the specified camera.
  107993. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107994. * @param engine The engine to use for rendering
  107995. * @param camera The camera to use for rendering
  107996. * @param size This parameter can be set to a single number or to an object with the
  107997. * following (optional) properties: precision, width, height. If a single number is passed,
  107998. * it will be used for both width and height. If an object is passed, the screenshot size
  107999. * will be derived from the parameters. The precision property is a multiplier allowing
  108000. * rendering at a higher or lower resolution
  108001. * @param successCallback The callback receives a single parameter which contains the
  108002. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  108003. * src parameter of an <img> to display it
  108004. * @param mimeType The MIME type of the screenshot image (default: image/png).
  108005. * Check your browser for supported MIME types
  108006. * @param samples Texture samples (default: 1)
  108007. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  108008. * @param fileName A name for for the downloaded file.
  108009. */
  108010. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  108011. /**
  108012. * Generates an image screenshot from the specified camera.
  108013. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  108014. * @param engine The engine to use for rendering
  108015. * @param camera The camera to use for rendering
  108016. * @param size This parameter can be set to a single number or to an object with the
  108017. * following (optional) properties: precision, width, height. If a single number is passed,
  108018. * it will be used for both width and height. If an object is passed, the screenshot size
  108019. * will be derived from the parameters. The precision property is a multiplier allowing
  108020. * rendering at a higher or lower resolution
  108021. * @param mimeType The MIME type of the screenshot image (default: image/png).
  108022. * Check your browser for supported MIME types
  108023. * @param samples Texture samples (default: 1)
  108024. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  108025. * @param fileName A name for for the downloaded file.
  108026. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  108027. * to the src parameter of an <img> to display it
  108028. */
  108029. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  108030. /**
  108031. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  108032. * Be aware Math.random() could cause collisions, but:
  108033. * "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"
  108034. * @returns a pseudo random id
  108035. */
  108036. static RandomId(): string;
  108037. /**
  108038. * Test if the given uri is a base64 string
  108039. * @param uri The uri to test
  108040. * @return True if the uri is a base64 string or false otherwise
  108041. */
  108042. static IsBase64(uri: string): boolean;
  108043. /**
  108044. * Decode the given base64 uri.
  108045. * @param uri The uri to decode
  108046. * @return The decoded base64 data.
  108047. */
  108048. static DecodeBase64(uri: string): ArrayBuffer;
  108049. /**
  108050. * Gets the absolute url.
  108051. * @param url the input url
  108052. * @return the absolute url
  108053. */
  108054. static GetAbsoluteUrl(url: string): string;
  108055. /**
  108056. * No log
  108057. */
  108058. static readonly NoneLogLevel: number;
  108059. /**
  108060. * Only message logs
  108061. */
  108062. static readonly MessageLogLevel: number;
  108063. /**
  108064. * Only warning logs
  108065. */
  108066. static readonly WarningLogLevel: number;
  108067. /**
  108068. * Only error logs
  108069. */
  108070. static readonly ErrorLogLevel: number;
  108071. /**
  108072. * All logs
  108073. */
  108074. static readonly AllLogLevel: number;
  108075. /**
  108076. * Gets a value indicating the number of loading errors
  108077. * @ignorenaming
  108078. */
  108079. static get errorsCount(): number;
  108080. /**
  108081. * Callback called when a new log is added
  108082. */
  108083. static OnNewCacheEntry: (entry: string) => void;
  108084. /**
  108085. * Log a message to the console
  108086. * @param message defines the message to log
  108087. */
  108088. static Log(message: string): void;
  108089. /**
  108090. * Write a warning message to the console
  108091. * @param message defines the message to log
  108092. */
  108093. static Warn(message: string): void;
  108094. /**
  108095. * Write an error message to the console
  108096. * @param message defines the message to log
  108097. */
  108098. static Error(message: string): void;
  108099. /**
  108100. * Gets current log cache (list of logs)
  108101. */
  108102. static get LogCache(): string;
  108103. /**
  108104. * Clears the log cache
  108105. */
  108106. static ClearLogCache(): void;
  108107. /**
  108108. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  108109. */
  108110. static set LogLevels(level: number);
  108111. /**
  108112. * Checks if the window object exists
  108113. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  108114. */
  108115. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  108116. /**
  108117. * No performance log
  108118. */
  108119. static readonly PerformanceNoneLogLevel: number;
  108120. /**
  108121. * Use user marks to log performance
  108122. */
  108123. static readonly PerformanceUserMarkLogLevel: number;
  108124. /**
  108125. * Log performance to the console
  108126. */
  108127. static readonly PerformanceConsoleLogLevel: number;
  108128. private static _performance;
  108129. /**
  108130. * Sets the current performance log level
  108131. */
  108132. static set PerformanceLogLevel(level: number);
  108133. private static _StartPerformanceCounterDisabled;
  108134. private static _EndPerformanceCounterDisabled;
  108135. private static _StartUserMark;
  108136. private static _EndUserMark;
  108137. private static _StartPerformanceConsole;
  108138. private static _EndPerformanceConsole;
  108139. /**
  108140. * Starts a performance counter
  108141. */
  108142. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  108143. /**
  108144. * Ends a specific performance coutner
  108145. */
  108146. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  108147. /**
  108148. * Gets either window.performance.now() if supported or Date.now() else
  108149. */
  108150. static get Now(): number;
  108151. /**
  108152. * This method will return the name of the class used to create the instance of the given object.
  108153. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  108154. * @param object the object to get the class name from
  108155. * @param isType defines if the object is actually a type
  108156. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  108157. */
  108158. static GetClassName(object: any, isType?: boolean): string;
  108159. /**
  108160. * Gets the first element of an array satisfying a given predicate
  108161. * @param array defines the array to browse
  108162. * @param predicate defines the predicate to use
  108163. * @returns null if not found or the element
  108164. */
  108165. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  108166. /**
  108167. * This method will return the name of the full name of the class, including its owning module (if any).
  108168. * 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).
  108169. * @param object the object to get the class name from
  108170. * @param isType defines if the object is actually a type
  108171. * @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.
  108172. * @ignorenaming
  108173. */
  108174. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  108175. /**
  108176. * Returns a promise that resolves after the given amount of time.
  108177. * @param delay Number of milliseconds to delay
  108178. * @returns Promise that resolves after the given amount of time
  108179. */
  108180. static DelayAsync(delay: number): Promise<void>;
  108181. /**
  108182. * Utility function to detect if the current user agent is Safari
  108183. * @returns whether or not the current user agent is safari
  108184. */
  108185. static IsSafari(): boolean;
  108186. }
  108187. /**
  108188. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  108189. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  108190. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  108191. * @param name The name of the class, case should be preserved
  108192. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  108193. */
  108194. export function className(name: string, module?: string): (target: Object) => void;
  108195. /**
  108196. * An implementation of a loop for asynchronous functions.
  108197. */
  108198. export class AsyncLoop {
  108199. /**
  108200. * Defines the number of iterations for the loop
  108201. */
  108202. iterations: number;
  108203. /**
  108204. * Defines the current index of the loop.
  108205. */
  108206. index: number;
  108207. private _done;
  108208. private _fn;
  108209. private _successCallback;
  108210. /**
  108211. * Constructor.
  108212. * @param iterations the number of iterations.
  108213. * @param func the function to run each iteration
  108214. * @param successCallback the callback that will be called upon succesful execution
  108215. * @param offset starting offset.
  108216. */
  108217. constructor(
  108218. /**
  108219. * Defines the number of iterations for the loop
  108220. */
  108221. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  108222. /**
  108223. * Execute the next iteration. Must be called after the last iteration was finished.
  108224. */
  108225. executeNext(): void;
  108226. /**
  108227. * Break the loop and run the success callback.
  108228. */
  108229. breakLoop(): void;
  108230. /**
  108231. * Create and run an async loop.
  108232. * @param iterations the number of iterations.
  108233. * @param fn the function to run each iteration
  108234. * @param successCallback the callback that will be called upon succesful execution
  108235. * @param offset starting offset.
  108236. * @returns the created async loop object
  108237. */
  108238. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  108239. /**
  108240. * A for-loop that will run a given number of iterations synchronous and the rest async.
  108241. * @param iterations total number of iterations
  108242. * @param syncedIterations number of synchronous iterations in each async iteration.
  108243. * @param fn the function to call each iteration.
  108244. * @param callback a success call back that will be called when iterating stops.
  108245. * @param breakFunction a break condition (optional)
  108246. * @param timeout timeout settings for the setTimeout function. default - 0.
  108247. * @returns the created async loop object
  108248. */
  108249. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  108250. }
  108251. }
  108252. declare module BABYLON {
  108253. /**
  108254. * This class implement a typical dictionary using a string as key and the generic type T as value.
  108255. * The underlying implementation relies on an associative array to ensure the best performances.
  108256. * The value can be anything including 'null' but except 'undefined'
  108257. */
  108258. export class StringDictionary<T> {
  108259. /**
  108260. * This will clear this dictionary and copy the content from the 'source' one.
  108261. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  108262. * @param source the dictionary to take the content from and copy to this dictionary
  108263. */
  108264. copyFrom(source: StringDictionary<T>): void;
  108265. /**
  108266. * Get a value based from its key
  108267. * @param key the given key to get the matching value from
  108268. * @return the value if found, otherwise undefined is returned
  108269. */
  108270. get(key: string): T | undefined;
  108271. /**
  108272. * Get a value from its key or add it if it doesn't exist.
  108273. * This method will ensure you that a given key/data will be present in the dictionary.
  108274. * @param key the given key to get the matching value from
  108275. * @param factory the factory that will create the value if the key is not present in the dictionary.
  108276. * The factory will only be invoked if there's no data for the given key.
  108277. * @return the value corresponding to the key.
  108278. */
  108279. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  108280. /**
  108281. * Get a value from its key if present in the dictionary otherwise add it
  108282. * @param key the key to get the value from
  108283. * @param val if there's no such key/value pair in the dictionary add it with this value
  108284. * @return the value corresponding to the key
  108285. */
  108286. getOrAdd(key: string, val: T): T;
  108287. /**
  108288. * Check if there's a given key in the dictionary
  108289. * @param key the key to check for
  108290. * @return true if the key is present, false otherwise
  108291. */
  108292. contains(key: string): boolean;
  108293. /**
  108294. * Add a new key and its corresponding value
  108295. * @param key the key to add
  108296. * @param value the value corresponding to the key
  108297. * @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
  108298. */
  108299. add(key: string, value: T): boolean;
  108300. /**
  108301. * Update a specific value associated to a key
  108302. * @param key defines the key to use
  108303. * @param value defines the value to store
  108304. * @returns true if the value was updated (or false if the key was not found)
  108305. */
  108306. set(key: string, value: T): boolean;
  108307. /**
  108308. * Get the element of the given key and remove it from the dictionary
  108309. * @param key defines the key to search
  108310. * @returns the value associated with the key or null if not found
  108311. */
  108312. getAndRemove(key: string): Nullable<T>;
  108313. /**
  108314. * Remove a key/value from the dictionary.
  108315. * @param key the key to remove
  108316. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  108317. */
  108318. remove(key: string): boolean;
  108319. /**
  108320. * Clear the whole content of the dictionary
  108321. */
  108322. clear(): void;
  108323. /**
  108324. * Gets the current count
  108325. */
  108326. get count(): number;
  108327. /**
  108328. * Execute a callback on each key/val of the dictionary.
  108329. * Note that you can remove any element in this dictionary in the callback implementation
  108330. * @param callback the callback to execute on a given key/value pair
  108331. */
  108332. forEach(callback: (key: string, val: T) => void): void;
  108333. /**
  108334. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  108335. * If the callback returns null or undefined the method will iterate to the next key/value pair
  108336. * Note that you can remove any element in this dictionary in the callback implementation
  108337. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  108338. * @returns the first item
  108339. */
  108340. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  108341. private _count;
  108342. private _data;
  108343. }
  108344. }
  108345. declare module BABYLON {
  108346. /** @hidden */
  108347. export interface ICollisionCoordinator {
  108348. createCollider(): Collider;
  108349. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  108350. init(scene: Scene): void;
  108351. }
  108352. /** @hidden */
  108353. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  108354. private _scene;
  108355. private _scaledPosition;
  108356. private _scaledVelocity;
  108357. private _finalPosition;
  108358. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  108359. createCollider(): Collider;
  108360. init(scene: Scene): void;
  108361. private _collideWithWorld;
  108362. }
  108363. }
  108364. declare module BABYLON {
  108365. /**
  108366. * Class used to manage all inputs for the scene.
  108367. */
  108368. export class InputManager {
  108369. /** The distance in pixel that you have to move to prevent some events */
  108370. static DragMovementThreshold: number;
  108371. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  108372. static LongPressDelay: number;
  108373. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  108374. static DoubleClickDelay: number;
  108375. /** If you need to check double click without raising a single click at first click, enable this flag */
  108376. static ExclusiveDoubleClickMode: boolean;
  108377. private _wheelEventName;
  108378. private _onPointerMove;
  108379. private _onPointerDown;
  108380. private _onPointerUp;
  108381. private _initClickEvent;
  108382. private _initActionManager;
  108383. private _delayedSimpleClick;
  108384. private _delayedSimpleClickTimeout;
  108385. private _previousDelayedSimpleClickTimeout;
  108386. private _meshPickProceed;
  108387. private _previousButtonPressed;
  108388. private _currentPickResult;
  108389. private _previousPickResult;
  108390. private _totalPointersPressed;
  108391. private _doubleClickOccured;
  108392. private _pointerOverMesh;
  108393. private _pickedDownMesh;
  108394. private _pickedUpMesh;
  108395. private _pointerX;
  108396. private _pointerY;
  108397. private _unTranslatedPointerX;
  108398. private _unTranslatedPointerY;
  108399. private _startingPointerPosition;
  108400. private _previousStartingPointerPosition;
  108401. private _startingPointerTime;
  108402. private _previousStartingPointerTime;
  108403. private _pointerCaptures;
  108404. private _onKeyDown;
  108405. private _onKeyUp;
  108406. private _onCanvasFocusObserver;
  108407. private _onCanvasBlurObserver;
  108408. private _scene;
  108409. /**
  108410. * Creates a new InputManager
  108411. * @param scene defines the hosting scene
  108412. */
  108413. constructor(scene: Scene);
  108414. /**
  108415. * Gets the mesh that is currently under the pointer
  108416. */
  108417. get meshUnderPointer(): Nullable<AbstractMesh>;
  108418. /**
  108419. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  108420. */
  108421. get unTranslatedPointer(): Vector2;
  108422. /**
  108423. * Gets or sets the current on-screen X position of the pointer
  108424. */
  108425. get pointerX(): number;
  108426. set pointerX(value: number);
  108427. /**
  108428. * Gets or sets the current on-screen Y position of the pointer
  108429. */
  108430. get pointerY(): number;
  108431. set pointerY(value: number);
  108432. private _updatePointerPosition;
  108433. private _processPointerMove;
  108434. private _setRayOnPointerInfo;
  108435. private _checkPrePointerObservable;
  108436. /**
  108437. * Use this method to simulate a pointer move on a mesh
  108438. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108439. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108440. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108441. */
  108442. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  108443. /**
  108444. * Use this method to simulate a pointer down on a mesh
  108445. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108446. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108447. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108448. */
  108449. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  108450. private _processPointerDown;
  108451. /** @hidden */
  108452. _isPointerSwiping(): boolean;
  108453. /**
  108454. * Use this method to simulate a pointer up on a mesh
  108455. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108456. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108457. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108458. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  108459. */
  108460. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  108461. private _processPointerUp;
  108462. /**
  108463. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  108464. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  108465. * @returns true if the pointer was captured
  108466. */
  108467. isPointerCaptured(pointerId?: number): boolean;
  108468. /**
  108469. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  108470. * @param attachUp defines if you want to attach events to pointerup
  108471. * @param attachDown defines if you want to attach events to pointerdown
  108472. * @param attachMove defines if you want to attach events to pointermove
  108473. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  108474. */
  108475. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  108476. /**
  108477. * Detaches all event handlers
  108478. */
  108479. detachControl(): void;
  108480. /**
  108481. * Force the value of meshUnderPointer
  108482. * @param mesh defines the mesh to use
  108483. */
  108484. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  108485. /**
  108486. * Gets the mesh under the pointer
  108487. * @returns a Mesh or null if no mesh is under the pointer
  108488. */
  108489. getPointerOverMesh(): Nullable<AbstractMesh>;
  108490. }
  108491. }
  108492. declare module BABYLON {
  108493. /**
  108494. * Helper class used to generate session unique ID
  108495. */
  108496. export class UniqueIdGenerator {
  108497. private static _UniqueIdCounter;
  108498. /**
  108499. * Gets an unique (relatively to the current scene) Id
  108500. */
  108501. static get UniqueId(): number;
  108502. }
  108503. }
  108504. declare module BABYLON {
  108505. /**
  108506. * This class defines the direct association between an animation and a target
  108507. */
  108508. export class TargetedAnimation {
  108509. /**
  108510. * Animation to perform
  108511. */
  108512. animation: Animation;
  108513. /**
  108514. * Target to animate
  108515. */
  108516. target: any;
  108517. /**
  108518. * Serialize the object
  108519. * @returns the JSON object representing the current entity
  108520. */
  108521. serialize(): any;
  108522. }
  108523. /**
  108524. * Use this class to create coordinated animations on multiple targets
  108525. */
  108526. export class AnimationGroup implements IDisposable {
  108527. /** The name of the animation group */
  108528. name: string;
  108529. private _scene;
  108530. private _targetedAnimations;
  108531. private _animatables;
  108532. private _from;
  108533. private _to;
  108534. private _isStarted;
  108535. private _isPaused;
  108536. private _speedRatio;
  108537. private _loopAnimation;
  108538. /**
  108539. * Gets or sets the unique id of the node
  108540. */
  108541. uniqueId: number;
  108542. /**
  108543. * This observable will notify when one animation have ended
  108544. */
  108545. onAnimationEndObservable: Observable<TargetedAnimation>;
  108546. /**
  108547. * Observer raised when one animation loops
  108548. */
  108549. onAnimationLoopObservable: Observable<TargetedAnimation>;
  108550. /**
  108551. * Observer raised when all animations have looped
  108552. */
  108553. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  108554. /**
  108555. * This observable will notify when all animations have ended.
  108556. */
  108557. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  108558. /**
  108559. * This observable will notify when all animations have paused.
  108560. */
  108561. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  108562. /**
  108563. * This observable will notify when all animations are playing.
  108564. */
  108565. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  108566. /**
  108567. * Gets the first frame
  108568. */
  108569. get from(): number;
  108570. /**
  108571. * Gets the last frame
  108572. */
  108573. get to(): number;
  108574. /**
  108575. * Define if the animations are started
  108576. */
  108577. get isStarted(): boolean;
  108578. /**
  108579. * Gets a value indicating that the current group is playing
  108580. */
  108581. get isPlaying(): boolean;
  108582. /**
  108583. * Gets or sets the speed ratio to use for all animations
  108584. */
  108585. get speedRatio(): number;
  108586. /**
  108587. * Gets or sets the speed ratio to use for all animations
  108588. */
  108589. set speedRatio(value: number);
  108590. /**
  108591. * Gets or sets if all animations should loop or not
  108592. */
  108593. get loopAnimation(): boolean;
  108594. set loopAnimation(value: boolean);
  108595. /**
  108596. * Gets the targeted animations for this animation group
  108597. */
  108598. get targetedAnimations(): Array<TargetedAnimation>;
  108599. /**
  108600. * returning the list of animatables controlled by this animation group.
  108601. */
  108602. get animatables(): Array<Animatable>;
  108603. /**
  108604. * Instantiates a new Animation Group.
  108605. * This helps managing several animations at once.
  108606. * @see http://doc.babylonjs.com/how_to/group
  108607. * @param name Defines the name of the group
  108608. * @param scene Defines the scene the group belongs to
  108609. */
  108610. constructor(
  108611. /** The name of the animation group */
  108612. name: string, scene?: Nullable<Scene>);
  108613. /**
  108614. * Add an animation (with its target) in the group
  108615. * @param animation defines the animation we want to add
  108616. * @param target defines the target of the animation
  108617. * @returns the TargetedAnimation object
  108618. */
  108619. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  108620. /**
  108621. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  108622. * It can add constant keys at begin or end
  108623. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  108624. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  108625. * @returns the animation group
  108626. */
  108627. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  108628. private _animationLoopCount;
  108629. private _animationLoopFlags;
  108630. private _processLoop;
  108631. /**
  108632. * Start all animations on given targets
  108633. * @param loop defines if animations must loop
  108634. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  108635. * @param from defines the from key (optional)
  108636. * @param to defines the to key (optional)
  108637. * @returns the current animation group
  108638. */
  108639. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  108640. /**
  108641. * Pause all animations
  108642. * @returns the animation group
  108643. */
  108644. pause(): AnimationGroup;
  108645. /**
  108646. * Play all animations to initial state
  108647. * This function will start() the animations if they were not started or will restart() them if they were paused
  108648. * @param loop defines if animations must loop
  108649. * @returns the animation group
  108650. */
  108651. play(loop?: boolean): AnimationGroup;
  108652. /**
  108653. * Reset all animations to initial state
  108654. * @returns the animation group
  108655. */
  108656. reset(): AnimationGroup;
  108657. /**
  108658. * Restart animations from key 0
  108659. * @returns the animation group
  108660. */
  108661. restart(): AnimationGroup;
  108662. /**
  108663. * Stop all animations
  108664. * @returns the animation group
  108665. */
  108666. stop(): AnimationGroup;
  108667. /**
  108668. * Set animation weight for all animatables
  108669. * @param weight defines the weight to use
  108670. * @return the animationGroup
  108671. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  108672. */
  108673. setWeightForAllAnimatables(weight: number): AnimationGroup;
  108674. /**
  108675. * Synchronize and normalize all animatables with a source animatable
  108676. * @param root defines the root animatable to synchronize with
  108677. * @return the animationGroup
  108678. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  108679. */
  108680. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  108681. /**
  108682. * Goes to a specific frame in this animation group
  108683. * @param frame the frame number to go to
  108684. * @return the animationGroup
  108685. */
  108686. goToFrame(frame: number): AnimationGroup;
  108687. /**
  108688. * Dispose all associated resources
  108689. */
  108690. dispose(): void;
  108691. private _checkAnimationGroupEnded;
  108692. /**
  108693. * Clone the current animation group and returns a copy
  108694. * @param newName defines the name of the new group
  108695. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  108696. * @returns the new aniamtion group
  108697. */
  108698. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  108699. /**
  108700. * Serializes the animationGroup to an object
  108701. * @returns Serialized object
  108702. */
  108703. serialize(): any;
  108704. /**
  108705. * Returns a new AnimationGroup object parsed from the source provided.
  108706. * @param parsedAnimationGroup defines the source
  108707. * @param scene defines the scene that will receive the animationGroup
  108708. * @returns a new AnimationGroup
  108709. */
  108710. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  108711. /**
  108712. * Returns the string "AnimationGroup"
  108713. * @returns "AnimationGroup"
  108714. */
  108715. getClassName(): string;
  108716. /**
  108717. * Creates a detailled string about the object
  108718. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  108719. * @returns a string representing the object
  108720. */
  108721. toString(fullDetails?: boolean): string;
  108722. }
  108723. }
  108724. declare module BABYLON {
  108725. /**
  108726. * Define an interface for all classes that will hold resources
  108727. */
  108728. export interface IDisposable {
  108729. /**
  108730. * Releases all held resources
  108731. */
  108732. dispose(): void;
  108733. }
  108734. /** Interface defining initialization parameters for Scene class */
  108735. export interface SceneOptions {
  108736. /**
  108737. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  108738. * It will improve performance when the number of geometries becomes important.
  108739. */
  108740. useGeometryUniqueIdsMap?: boolean;
  108741. /**
  108742. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  108743. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  108744. */
  108745. useMaterialMeshMap?: boolean;
  108746. /**
  108747. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  108748. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  108749. */
  108750. useClonedMeshMap?: boolean;
  108751. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  108752. virtual?: boolean;
  108753. }
  108754. /**
  108755. * Represents a scene to be rendered by the engine.
  108756. * @see http://doc.babylonjs.com/features/scene
  108757. */
  108758. export class Scene extends AbstractScene implements IAnimatable {
  108759. /** The fog is deactivated */
  108760. static readonly FOGMODE_NONE: number;
  108761. /** The fog density is following an exponential function */
  108762. static readonly FOGMODE_EXP: number;
  108763. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  108764. static readonly FOGMODE_EXP2: number;
  108765. /** The fog density is following a linear function. */
  108766. static readonly FOGMODE_LINEAR: number;
  108767. /**
  108768. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  108769. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108770. */
  108771. static MinDeltaTime: number;
  108772. /**
  108773. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  108774. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108775. */
  108776. static MaxDeltaTime: number;
  108777. /**
  108778. * Factory used to create the default material.
  108779. * @param name The name of the material to create
  108780. * @param scene The scene to create the material for
  108781. * @returns The default material
  108782. */
  108783. static DefaultMaterialFactory(scene: Scene): Material;
  108784. /**
  108785. * Factory used to create the a collision coordinator.
  108786. * @returns The collision coordinator
  108787. */
  108788. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  108789. /** @hidden */
  108790. _inputManager: InputManager;
  108791. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  108792. cameraToUseForPointers: Nullable<Camera>;
  108793. /** @hidden */
  108794. readonly _isScene: boolean;
  108795. /** @hidden */
  108796. _blockEntityCollection: boolean;
  108797. /**
  108798. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  108799. */
  108800. autoClear: boolean;
  108801. /**
  108802. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  108803. */
  108804. autoClearDepthAndStencil: boolean;
  108805. /**
  108806. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  108807. */
  108808. clearColor: Color4;
  108809. /**
  108810. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  108811. */
  108812. ambientColor: Color3;
  108813. /**
  108814. * This is use to store the default BRDF lookup for PBR materials in your scene.
  108815. * It should only be one of the following (if not the default embedded one):
  108816. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  108817. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  108818. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  108819. * The material properties need to be setup according to the type of texture in use.
  108820. */
  108821. environmentBRDFTexture: BaseTexture;
  108822. /** @hidden */
  108823. protected _environmentTexture: Nullable<BaseTexture>;
  108824. /**
  108825. * Texture used in all pbr material as the reflection texture.
  108826. * As in the majority of the scene they are the same (exception for multi room and so on),
  108827. * this is easier to reference from here than from all the materials.
  108828. */
  108829. get environmentTexture(): Nullable<BaseTexture>;
  108830. /**
  108831. * Texture used in all pbr material as the reflection texture.
  108832. * As in the majority of the scene they are the same (exception for multi room and so on),
  108833. * this is easier to set here than in all the materials.
  108834. */
  108835. set environmentTexture(value: Nullable<BaseTexture>);
  108836. /** @hidden */
  108837. protected _environmentIntensity: number;
  108838. /**
  108839. * Intensity of the environment in all pbr material.
  108840. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  108841. * As in the majority of the scene they are the same (exception for multi room and so on),
  108842. * this is easier to reference from here than from all the materials.
  108843. */
  108844. get environmentIntensity(): number;
  108845. /**
  108846. * Intensity of the environment in all pbr material.
  108847. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  108848. * As in the majority of the scene they are the same (exception for multi room and so on),
  108849. * this is easier to set here than in all the materials.
  108850. */
  108851. set environmentIntensity(value: number);
  108852. /** @hidden */
  108853. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108854. /**
  108855. * Default image processing configuration used either in the rendering
  108856. * Forward main pass or through the imageProcessingPostProcess if present.
  108857. * As in the majority of the scene they are the same (exception for multi camera),
  108858. * this is easier to reference from here than from all the materials and post process.
  108859. *
  108860. * No setter as we it is a shared configuration, you can set the values instead.
  108861. */
  108862. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  108863. private _forceWireframe;
  108864. /**
  108865. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  108866. */
  108867. set forceWireframe(value: boolean);
  108868. get forceWireframe(): boolean;
  108869. private _skipFrustumClipping;
  108870. /**
  108871. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  108872. */
  108873. set skipFrustumClipping(value: boolean);
  108874. get skipFrustumClipping(): boolean;
  108875. private _forcePointsCloud;
  108876. /**
  108877. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  108878. */
  108879. set forcePointsCloud(value: boolean);
  108880. get forcePointsCloud(): boolean;
  108881. /**
  108882. * Gets or sets the active clipplane 1
  108883. */
  108884. clipPlane: Nullable<Plane>;
  108885. /**
  108886. * Gets or sets the active clipplane 2
  108887. */
  108888. clipPlane2: Nullable<Plane>;
  108889. /**
  108890. * Gets or sets the active clipplane 3
  108891. */
  108892. clipPlane3: Nullable<Plane>;
  108893. /**
  108894. * Gets or sets the active clipplane 4
  108895. */
  108896. clipPlane4: Nullable<Plane>;
  108897. /**
  108898. * Gets or sets the active clipplane 5
  108899. */
  108900. clipPlane5: Nullable<Plane>;
  108901. /**
  108902. * Gets or sets the active clipplane 6
  108903. */
  108904. clipPlane6: Nullable<Plane>;
  108905. /**
  108906. * Gets or sets a boolean indicating if animations are enabled
  108907. */
  108908. animationsEnabled: boolean;
  108909. private _animationPropertiesOverride;
  108910. /**
  108911. * Gets or sets the animation properties override
  108912. */
  108913. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  108914. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  108915. /**
  108916. * Gets or sets a boolean indicating if a constant deltatime has to be used
  108917. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  108918. */
  108919. useConstantAnimationDeltaTime: boolean;
  108920. /**
  108921. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  108922. * Please note that it requires to run a ray cast through the scene on every frame
  108923. */
  108924. constantlyUpdateMeshUnderPointer: boolean;
  108925. /**
  108926. * Defines the HTML cursor to use when hovering over interactive elements
  108927. */
  108928. hoverCursor: string;
  108929. /**
  108930. * Defines the HTML default cursor to use (empty by default)
  108931. */
  108932. defaultCursor: string;
  108933. /**
  108934. * Defines whether cursors are handled by the scene.
  108935. */
  108936. doNotHandleCursors: boolean;
  108937. /**
  108938. * This is used to call preventDefault() on pointer down
  108939. * in order to block unwanted artifacts like system double clicks
  108940. */
  108941. preventDefaultOnPointerDown: boolean;
  108942. /**
  108943. * This is used to call preventDefault() on pointer up
  108944. * in order to block unwanted artifacts like system double clicks
  108945. */
  108946. preventDefaultOnPointerUp: boolean;
  108947. /**
  108948. * Gets or sets user defined metadata
  108949. */
  108950. metadata: any;
  108951. /**
  108952. * For internal use only. Please do not use.
  108953. */
  108954. reservedDataStore: any;
  108955. /**
  108956. * Gets the name of the plugin used to load this scene (null by default)
  108957. */
  108958. loadingPluginName: string;
  108959. /**
  108960. * Use this array to add regular expressions used to disable offline support for specific urls
  108961. */
  108962. disableOfflineSupportExceptionRules: RegExp[];
  108963. /**
  108964. * An event triggered when the scene is disposed.
  108965. */
  108966. onDisposeObservable: Observable<Scene>;
  108967. private _onDisposeObserver;
  108968. /** Sets a function to be executed when this scene is disposed. */
  108969. set onDispose(callback: () => void);
  108970. /**
  108971. * An event triggered before rendering the scene (right after animations and physics)
  108972. */
  108973. onBeforeRenderObservable: Observable<Scene>;
  108974. private _onBeforeRenderObserver;
  108975. /** Sets a function to be executed before rendering this scene */
  108976. set beforeRender(callback: Nullable<() => void>);
  108977. /**
  108978. * An event triggered after rendering the scene
  108979. */
  108980. onAfterRenderObservable: Observable<Scene>;
  108981. /**
  108982. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  108983. */
  108984. onAfterRenderCameraObservable: Observable<Camera>;
  108985. private _onAfterRenderObserver;
  108986. /** Sets a function to be executed after rendering this scene */
  108987. set afterRender(callback: Nullable<() => void>);
  108988. /**
  108989. * An event triggered before animating the scene
  108990. */
  108991. onBeforeAnimationsObservable: Observable<Scene>;
  108992. /**
  108993. * An event triggered after animations processing
  108994. */
  108995. onAfterAnimationsObservable: Observable<Scene>;
  108996. /**
  108997. * An event triggered before draw calls are ready to be sent
  108998. */
  108999. onBeforeDrawPhaseObservable: Observable<Scene>;
  109000. /**
  109001. * An event triggered after draw calls have been sent
  109002. */
  109003. onAfterDrawPhaseObservable: Observable<Scene>;
  109004. /**
  109005. * An event triggered when the scene is ready
  109006. */
  109007. onReadyObservable: Observable<Scene>;
  109008. /**
  109009. * An event triggered before rendering a camera
  109010. */
  109011. onBeforeCameraRenderObservable: Observable<Camera>;
  109012. private _onBeforeCameraRenderObserver;
  109013. /** Sets a function to be executed before rendering a camera*/
  109014. set beforeCameraRender(callback: () => void);
  109015. /**
  109016. * An event triggered after rendering a camera
  109017. */
  109018. onAfterCameraRenderObservable: Observable<Camera>;
  109019. private _onAfterCameraRenderObserver;
  109020. /** Sets a function to be executed after rendering a camera*/
  109021. set afterCameraRender(callback: () => void);
  109022. /**
  109023. * An event triggered when active meshes evaluation is about to start
  109024. */
  109025. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  109026. /**
  109027. * An event triggered when active meshes evaluation is done
  109028. */
  109029. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  109030. /**
  109031. * An event triggered when particles rendering is about to start
  109032. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  109033. */
  109034. onBeforeParticlesRenderingObservable: Observable<Scene>;
  109035. /**
  109036. * An event triggered when particles rendering is done
  109037. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  109038. */
  109039. onAfterParticlesRenderingObservable: Observable<Scene>;
  109040. /**
  109041. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  109042. */
  109043. onDataLoadedObservable: Observable<Scene>;
  109044. /**
  109045. * An event triggered when a camera is created
  109046. */
  109047. onNewCameraAddedObservable: Observable<Camera>;
  109048. /**
  109049. * An event triggered when a camera is removed
  109050. */
  109051. onCameraRemovedObservable: Observable<Camera>;
  109052. /**
  109053. * An event triggered when a light is created
  109054. */
  109055. onNewLightAddedObservable: Observable<Light>;
  109056. /**
  109057. * An event triggered when a light is removed
  109058. */
  109059. onLightRemovedObservable: Observable<Light>;
  109060. /**
  109061. * An event triggered when a geometry is created
  109062. */
  109063. onNewGeometryAddedObservable: Observable<Geometry>;
  109064. /**
  109065. * An event triggered when a geometry is removed
  109066. */
  109067. onGeometryRemovedObservable: Observable<Geometry>;
  109068. /**
  109069. * An event triggered when a transform node is created
  109070. */
  109071. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  109072. /**
  109073. * An event triggered when a transform node is removed
  109074. */
  109075. onTransformNodeRemovedObservable: Observable<TransformNode>;
  109076. /**
  109077. * An event triggered when a mesh is created
  109078. */
  109079. onNewMeshAddedObservable: Observable<AbstractMesh>;
  109080. /**
  109081. * An event triggered when a mesh is removed
  109082. */
  109083. onMeshRemovedObservable: Observable<AbstractMesh>;
  109084. /**
  109085. * An event triggered when a skeleton is created
  109086. */
  109087. onNewSkeletonAddedObservable: Observable<Skeleton>;
  109088. /**
  109089. * An event triggered when a skeleton is removed
  109090. */
  109091. onSkeletonRemovedObservable: Observable<Skeleton>;
  109092. /**
  109093. * An event triggered when a material is created
  109094. */
  109095. onNewMaterialAddedObservable: Observable<Material>;
  109096. /**
  109097. * An event triggered when a material is removed
  109098. */
  109099. onMaterialRemovedObservable: Observable<Material>;
  109100. /**
  109101. * An event triggered when a texture is created
  109102. */
  109103. onNewTextureAddedObservable: Observable<BaseTexture>;
  109104. /**
  109105. * An event triggered when a texture is removed
  109106. */
  109107. onTextureRemovedObservable: Observable<BaseTexture>;
  109108. /**
  109109. * An event triggered when render targets are about to be rendered
  109110. * Can happen multiple times per frame.
  109111. */
  109112. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  109113. /**
  109114. * An event triggered when render targets were rendered.
  109115. * Can happen multiple times per frame.
  109116. */
  109117. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  109118. /**
  109119. * An event triggered before calculating deterministic simulation step
  109120. */
  109121. onBeforeStepObservable: Observable<Scene>;
  109122. /**
  109123. * An event triggered after calculating deterministic simulation step
  109124. */
  109125. onAfterStepObservable: Observable<Scene>;
  109126. /**
  109127. * An event triggered when the activeCamera property is updated
  109128. */
  109129. onActiveCameraChanged: Observable<Scene>;
  109130. /**
  109131. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  109132. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  109133. * 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)
  109134. */
  109135. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  109136. /**
  109137. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  109138. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  109139. * 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)
  109140. */
  109141. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  109142. /**
  109143. * This Observable will when a mesh has been imported into the scene.
  109144. */
  109145. onMeshImportedObservable: Observable<AbstractMesh>;
  109146. /**
  109147. * This Observable will when an animation file has been imported into the scene.
  109148. */
  109149. onAnimationFileImportedObservable: Observable<Scene>;
  109150. /**
  109151. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  109152. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  109153. */
  109154. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  109155. /** @hidden */
  109156. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  109157. /**
  109158. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  109159. */
  109160. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  109161. /**
  109162. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  109163. */
  109164. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  109165. /**
  109166. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  109167. */
  109168. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  109169. /** Callback called when a pointer move is detected */
  109170. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  109171. /** Callback called when a pointer down is detected */
  109172. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  109173. /** Callback called when a pointer up is detected */
  109174. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  109175. /** Callback called when a pointer pick is detected */
  109176. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  109177. /**
  109178. * 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).
  109179. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  109180. */
  109181. onPrePointerObservable: Observable<PointerInfoPre>;
  109182. /**
  109183. * Observable event triggered each time an input event is received from the rendering canvas
  109184. */
  109185. onPointerObservable: Observable<PointerInfo>;
  109186. /**
  109187. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  109188. */
  109189. get unTranslatedPointer(): Vector2;
  109190. /**
  109191. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  109192. */
  109193. static get DragMovementThreshold(): number;
  109194. static set DragMovementThreshold(value: number);
  109195. /**
  109196. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  109197. */
  109198. static get LongPressDelay(): number;
  109199. static set LongPressDelay(value: number);
  109200. /**
  109201. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  109202. */
  109203. static get DoubleClickDelay(): number;
  109204. static set DoubleClickDelay(value: number);
  109205. /** If you need to check double click without raising a single click at first click, enable this flag */
  109206. static get ExclusiveDoubleClickMode(): boolean;
  109207. static set ExclusiveDoubleClickMode(value: boolean);
  109208. /** @hidden */
  109209. _mirroredCameraPosition: Nullable<Vector3>;
  109210. /**
  109211. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  109212. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  109213. */
  109214. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  109215. /**
  109216. * Observable event triggered each time an keyboard event is received from the hosting window
  109217. */
  109218. onKeyboardObservable: Observable<KeyboardInfo>;
  109219. private _useRightHandedSystem;
  109220. /**
  109221. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  109222. */
  109223. set useRightHandedSystem(value: boolean);
  109224. get useRightHandedSystem(): boolean;
  109225. private _timeAccumulator;
  109226. private _currentStepId;
  109227. private _currentInternalStep;
  109228. /**
  109229. * Sets the step Id used by deterministic lock step
  109230. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109231. * @param newStepId defines the step Id
  109232. */
  109233. setStepId(newStepId: number): void;
  109234. /**
  109235. * Gets the step Id used by deterministic lock step
  109236. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109237. * @returns the step Id
  109238. */
  109239. getStepId(): number;
  109240. /**
  109241. * Gets the internal step used by deterministic lock step
  109242. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109243. * @returns the internal step
  109244. */
  109245. getInternalStep(): number;
  109246. private _fogEnabled;
  109247. /**
  109248. * Gets or sets a boolean indicating if fog is enabled on this scene
  109249. * @see http://doc.babylonjs.com/babylon101/environment#fog
  109250. * (Default is true)
  109251. */
  109252. set fogEnabled(value: boolean);
  109253. get fogEnabled(): boolean;
  109254. private _fogMode;
  109255. /**
  109256. * Gets or sets the fog mode to use
  109257. * @see http://doc.babylonjs.com/babylon101/environment#fog
  109258. * | mode | value |
  109259. * | --- | --- |
  109260. * | FOGMODE_NONE | 0 |
  109261. * | FOGMODE_EXP | 1 |
  109262. * | FOGMODE_EXP2 | 2 |
  109263. * | FOGMODE_LINEAR | 3 |
  109264. */
  109265. set fogMode(value: number);
  109266. get fogMode(): number;
  109267. /**
  109268. * Gets or sets the fog color to use
  109269. * @see http://doc.babylonjs.com/babylon101/environment#fog
  109270. * (Default is Color3(0.2, 0.2, 0.3))
  109271. */
  109272. fogColor: Color3;
  109273. /**
  109274. * Gets or sets the fog density to use
  109275. * @see http://doc.babylonjs.com/babylon101/environment#fog
  109276. * (Default is 0.1)
  109277. */
  109278. fogDensity: number;
  109279. /**
  109280. * Gets or sets the fog start distance to use
  109281. * @see http://doc.babylonjs.com/babylon101/environment#fog
  109282. * (Default is 0)
  109283. */
  109284. fogStart: number;
  109285. /**
  109286. * Gets or sets the fog end distance to use
  109287. * @see http://doc.babylonjs.com/babylon101/environment#fog
  109288. * (Default is 1000)
  109289. */
  109290. fogEnd: number;
  109291. private _shadowsEnabled;
  109292. /**
  109293. * Gets or sets a boolean indicating if shadows are enabled on this scene
  109294. */
  109295. set shadowsEnabled(value: boolean);
  109296. get shadowsEnabled(): boolean;
  109297. private _lightsEnabled;
  109298. /**
  109299. * Gets or sets a boolean indicating if lights are enabled on this scene
  109300. */
  109301. set lightsEnabled(value: boolean);
  109302. get lightsEnabled(): boolean;
  109303. /** All of the active cameras added to this scene. */
  109304. activeCameras: Camera[];
  109305. /** @hidden */
  109306. _activeCamera: Nullable<Camera>;
  109307. /** Gets or sets the current active camera */
  109308. get activeCamera(): Nullable<Camera>;
  109309. set activeCamera(value: Nullable<Camera>);
  109310. private _defaultMaterial;
  109311. /** The default material used on meshes when no material is affected */
  109312. get defaultMaterial(): Material;
  109313. /** The default material used on meshes when no material is affected */
  109314. set defaultMaterial(value: Material);
  109315. private _texturesEnabled;
  109316. /**
  109317. * Gets or sets a boolean indicating if textures are enabled on this scene
  109318. */
  109319. set texturesEnabled(value: boolean);
  109320. get texturesEnabled(): boolean;
  109321. /**
  109322. * Gets or sets a boolean indicating if particles are enabled on this scene
  109323. */
  109324. particlesEnabled: boolean;
  109325. /**
  109326. * Gets or sets a boolean indicating if sprites are enabled on this scene
  109327. */
  109328. spritesEnabled: boolean;
  109329. private _skeletonsEnabled;
  109330. /**
  109331. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  109332. */
  109333. set skeletonsEnabled(value: boolean);
  109334. get skeletonsEnabled(): boolean;
  109335. /**
  109336. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  109337. */
  109338. lensFlaresEnabled: boolean;
  109339. /**
  109340. * Gets or sets a boolean indicating if collisions are enabled on this scene
  109341. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109342. */
  109343. collisionsEnabled: boolean;
  109344. private _collisionCoordinator;
  109345. /** @hidden */
  109346. get collisionCoordinator(): ICollisionCoordinator;
  109347. /**
  109348. * Defines the gravity applied to this scene (used only for collisions)
  109349. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109350. */
  109351. gravity: Vector3;
  109352. /**
  109353. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  109354. */
  109355. postProcessesEnabled: boolean;
  109356. /**
  109357. * The list of postprocesses added to the scene
  109358. */
  109359. postProcesses: PostProcess[];
  109360. /**
  109361. * Gets the current postprocess manager
  109362. */
  109363. postProcessManager: PostProcessManager;
  109364. /**
  109365. * Gets or sets a boolean indicating if render targets are enabled on this scene
  109366. */
  109367. renderTargetsEnabled: boolean;
  109368. /**
  109369. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  109370. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  109371. */
  109372. dumpNextRenderTargets: boolean;
  109373. /**
  109374. * The list of user defined render targets added to the scene
  109375. */
  109376. customRenderTargets: RenderTargetTexture[];
  109377. /**
  109378. * Defines if texture loading must be delayed
  109379. * If true, textures will only be loaded when they need to be rendered
  109380. */
  109381. useDelayedTextureLoading: boolean;
  109382. /**
  109383. * Gets the list of meshes imported to the scene through SceneLoader
  109384. */
  109385. importedMeshesFiles: String[];
  109386. /**
  109387. * Gets or sets a boolean indicating if probes are enabled on this scene
  109388. */
  109389. probesEnabled: boolean;
  109390. /**
  109391. * Gets or sets the current offline provider to use to store scene data
  109392. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  109393. */
  109394. offlineProvider: IOfflineProvider;
  109395. /**
  109396. * Gets or sets the action manager associated with the scene
  109397. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  109398. */
  109399. actionManager: AbstractActionManager;
  109400. private _meshesForIntersections;
  109401. /**
  109402. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  109403. */
  109404. proceduralTexturesEnabled: boolean;
  109405. private _engine;
  109406. private _totalVertices;
  109407. /** @hidden */
  109408. _activeIndices: PerfCounter;
  109409. /** @hidden */
  109410. _activeParticles: PerfCounter;
  109411. /** @hidden */
  109412. _activeBones: PerfCounter;
  109413. private _animationRatio;
  109414. /** @hidden */
  109415. _animationTimeLast: number;
  109416. /** @hidden */
  109417. _animationTime: number;
  109418. /**
  109419. * Gets or sets a general scale for animation speed
  109420. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  109421. */
  109422. animationTimeScale: number;
  109423. /** @hidden */
  109424. _cachedMaterial: Nullable<Material>;
  109425. /** @hidden */
  109426. _cachedEffect: Nullable<Effect>;
  109427. /** @hidden */
  109428. _cachedVisibility: Nullable<number>;
  109429. private _renderId;
  109430. private _frameId;
  109431. private _executeWhenReadyTimeoutId;
  109432. private _intermediateRendering;
  109433. private _viewUpdateFlag;
  109434. private _projectionUpdateFlag;
  109435. /** @hidden */
  109436. _toBeDisposed: Nullable<IDisposable>[];
  109437. private _activeRequests;
  109438. /** @hidden */
  109439. _pendingData: any[];
  109440. private _isDisposed;
  109441. /**
  109442. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  109443. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  109444. */
  109445. dispatchAllSubMeshesOfActiveMeshes: boolean;
  109446. private _activeMeshes;
  109447. private _processedMaterials;
  109448. private _renderTargets;
  109449. /** @hidden */
  109450. _activeParticleSystems: SmartArray<IParticleSystem>;
  109451. private _activeSkeletons;
  109452. private _softwareSkinnedMeshes;
  109453. private _renderingManager;
  109454. /** @hidden */
  109455. _activeAnimatables: Animatable[];
  109456. private _transformMatrix;
  109457. private _sceneUbo;
  109458. /** @hidden */
  109459. _viewMatrix: Matrix;
  109460. private _projectionMatrix;
  109461. /** @hidden */
  109462. _forcedViewPosition: Nullable<Vector3>;
  109463. /** @hidden */
  109464. _frustumPlanes: Plane[];
  109465. /**
  109466. * Gets the list of frustum planes (built from the active camera)
  109467. */
  109468. get frustumPlanes(): Plane[];
  109469. /**
  109470. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  109471. * This is useful if there are more lights that the maximum simulteanous authorized
  109472. */
  109473. requireLightSorting: boolean;
  109474. /** @hidden */
  109475. readonly useMaterialMeshMap: boolean;
  109476. /** @hidden */
  109477. readonly useClonedMeshMap: boolean;
  109478. private _externalData;
  109479. private _uid;
  109480. /**
  109481. * @hidden
  109482. * Backing store of defined scene components.
  109483. */
  109484. _components: ISceneComponent[];
  109485. /**
  109486. * @hidden
  109487. * Backing store of defined scene components.
  109488. */
  109489. _serializableComponents: ISceneSerializableComponent[];
  109490. /**
  109491. * List of components to register on the next registration step.
  109492. */
  109493. private _transientComponents;
  109494. /**
  109495. * Registers the transient components if needed.
  109496. */
  109497. private _registerTransientComponents;
  109498. /**
  109499. * @hidden
  109500. * Add a component to the scene.
  109501. * Note that the ccomponent could be registered on th next frame if this is called after
  109502. * the register component stage.
  109503. * @param component Defines the component to add to the scene
  109504. */
  109505. _addComponent(component: ISceneComponent): void;
  109506. /**
  109507. * @hidden
  109508. * Gets a component from the scene.
  109509. * @param name defines the name of the component to retrieve
  109510. * @returns the component or null if not present
  109511. */
  109512. _getComponent(name: string): Nullable<ISceneComponent>;
  109513. /**
  109514. * @hidden
  109515. * Defines the actions happening before camera updates.
  109516. */
  109517. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  109518. /**
  109519. * @hidden
  109520. * Defines the actions happening before clear the canvas.
  109521. */
  109522. _beforeClearStage: Stage<SimpleStageAction>;
  109523. /**
  109524. * @hidden
  109525. * Defines the actions when collecting render targets for the frame.
  109526. */
  109527. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  109528. /**
  109529. * @hidden
  109530. * Defines the actions happening for one camera in the frame.
  109531. */
  109532. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  109533. /**
  109534. * @hidden
  109535. * Defines the actions happening during the per mesh ready checks.
  109536. */
  109537. _isReadyForMeshStage: Stage<MeshStageAction>;
  109538. /**
  109539. * @hidden
  109540. * Defines the actions happening before evaluate active mesh checks.
  109541. */
  109542. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  109543. /**
  109544. * @hidden
  109545. * Defines the actions happening during the evaluate sub mesh checks.
  109546. */
  109547. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  109548. /**
  109549. * @hidden
  109550. * Defines the actions happening during the active mesh stage.
  109551. */
  109552. _activeMeshStage: Stage<ActiveMeshStageAction>;
  109553. /**
  109554. * @hidden
  109555. * Defines the actions happening during the per camera render target step.
  109556. */
  109557. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  109558. /**
  109559. * @hidden
  109560. * Defines the actions happening just before the active camera is drawing.
  109561. */
  109562. _beforeCameraDrawStage: Stage<CameraStageAction>;
  109563. /**
  109564. * @hidden
  109565. * Defines the actions happening just before a render target is drawing.
  109566. */
  109567. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  109568. /**
  109569. * @hidden
  109570. * Defines the actions happening just before a rendering group is drawing.
  109571. */
  109572. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  109573. /**
  109574. * @hidden
  109575. * Defines the actions happening just before a mesh is drawing.
  109576. */
  109577. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  109578. /**
  109579. * @hidden
  109580. * Defines the actions happening just after a mesh has been drawn.
  109581. */
  109582. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  109583. /**
  109584. * @hidden
  109585. * Defines the actions happening just after a rendering group has been drawn.
  109586. */
  109587. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  109588. /**
  109589. * @hidden
  109590. * Defines the actions happening just after the active camera has been drawn.
  109591. */
  109592. _afterCameraDrawStage: Stage<CameraStageAction>;
  109593. /**
  109594. * @hidden
  109595. * Defines the actions happening just after a render target has been drawn.
  109596. */
  109597. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  109598. /**
  109599. * @hidden
  109600. * Defines the actions happening just after rendering all cameras and computing intersections.
  109601. */
  109602. _afterRenderStage: Stage<SimpleStageAction>;
  109603. /**
  109604. * @hidden
  109605. * Defines the actions happening when a pointer move event happens.
  109606. */
  109607. _pointerMoveStage: Stage<PointerMoveStageAction>;
  109608. /**
  109609. * @hidden
  109610. * Defines the actions happening when a pointer down event happens.
  109611. */
  109612. _pointerDownStage: Stage<PointerUpDownStageAction>;
  109613. /**
  109614. * @hidden
  109615. * Defines the actions happening when a pointer up event happens.
  109616. */
  109617. _pointerUpStage: Stage<PointerUpDownStageAction>;
  109618. /**
  109619. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  109620. */
  109621. private geometriesByUniqueId;
  109622. /**
  109623. * Creates a new Scene
  109624. * @param engine defines the engine to use to render this scene
  109625. * @param options defines the scene options
  109626. */
  109627. constructor(engine: Engine, options?: SceneOptions);
  109628. /**
  109629. * Gets a string idenfifying the name of the class
  109630. * @returns "Scene" string
  109631. */
  109632. getClassName(): string;
  109633. private _defaultMeshCandidates;
  109634. /**
  109635. * @hidden
  109636. */
  109637. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  109638. private _defaultSubMeshCandidates;
  109639. /**
  109640. * @hidden
  109641. */
  109642. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  109643. /**
  109644. * Sets the default candidate providers for the scene.
  109645. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  109646. * and getCollidingSubMeshCandidates to their default function
  109647. */
  109648. setDefaultCandidateProviders(): void;
  109649. /**
  109650. * Gets the mesh that is currently under the pointer
  109651. */
  109652. get meshUnderPointer(): Nullable<AbstractMesh>;
  109653. /**
  109654. * Gets or sets the current on-screen X position of the pointer
  109655. */
  109656. get pointerX(): number;
  109657. set pointerX(value: number);
  109658. /**
  109659. * Gets or sets the current on-screen Y position of the pointer
  109660. */
  109661. get pointerY(): number;
  109662. set pointerY(value: number);
  109663. /**
  109664. * Gets the cached material (ie. the latest rendered one)
  109665. * @returns the cached material
  109666. */
  109667. getCachedMaterial(): Nullable<Material>;
  109668. /**
  109669. * Gets the cached effect (ie. the latest rendered one)
  109670. * @returns the cached effect
  109671. */
  109672. getCachedEffect(): Nullable<Effect>;
  109673. /**
  109674. * Gets the cached visibility state (ie. the latest rendered one)
  109675. * @returns the cached visibility state
  109676. */
  109677. getCachedVisibility(): Nullable<number>;
  109678. /**
  109679. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  109680. * @param material defines the current material
  109681. * @param effect defines the current effect
  109682. * @param visibility defines the current visibility state
  109683. * @returns true if one parameter is not cached
  109684. */
  109685. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  109686. /**
  109687. * Gets the engine associated with the scene
  109688. * @returns an Engine
  109689. */
  109690. getEngine(): Engine;
  109691. /**
  109692. * Gets the total number of vertices rendered per frame
  109693. * @returns the total number of vertices rendered per frame
  109694. */
  109695. getTotalVertices(): number;
  109696. /**
  109697. * Gets the performance counter for total vertices
  109698. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109699. */
  109700. get totalVerticesPerfCounter(): PerfCounter;
  109701. /**
  109702. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  109703. * @returns the total number of active indices rendered per frame
  109704. */
  109705. getActiveIndices(): number;
  109706. /**
  109707. * Gets the performance counter for active indices
  109708. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109709. */
  109710. get totalActiveIndicesPerfCounter(): PerfCounter;
  109711. /**
  109712. * Gets the total number of active particles rendered per frame
  109713. * @returns the total number of active particles rendered per frame
  109714. */
  109715. getActiveParticles(): number;
  109716. /**
  109717. * Gets the performance counter for active particles
  109718. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109719. */
  109720. get activeParticlesPerfCounter(): PerfCounter;
  109721. /**
  109722. * Gets the total number of active bones rendered per frame
  109723. * @returns the total number of active bones rendered per frame
  109724. */
  109725. getActiveBones(): number;
  109726. /**
  109727. * Gets the performance counter for active bones
  109728. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109729. */
  109730. get activeBonesPerfCounter(): PerfCounter;
  109731. /**
  109732. * Gets the array of active meshes
  109733. * @returns an array of AbstractMesh
  109734. */
  109735. getActiveMeshes(): SmartArray<AbstractMesh>;
  109736. /**
  109737. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  109738. * @returns a number
  109739. */
  109740. getAnimationRatio(): number;
  109741. /**
  109742. * Gets an unique Id for the current render phase
  109743. * @returns a number
  109744. */
  109745. getRenderId(): number;
  109746. /**
  109747. * Gets an unique Id for the current frame
  109748. * @returns a number
  109749. */
  109750. getFrameId(): number;
  109751. /** Call this function if you want to manually increment the render Id*/
  109752. incrementRenderId(): void;
  109753. private _createUbo;
  109754. /**
  109755. * Use this method to simulate a pointer move on a mesh
  109756. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109757. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109758. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109759. * @returns the current scene
  109760. */
  109761. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  109762. /**
  109763. * Use this method to simulate a pointer down on a mesh
  109764. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109765. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109766. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109767. * @returns the current scene
  109768. */
  109769. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  109770. /**
  109771. * Use this method to simulate a pointer up on a mesh
  109772. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109773. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109774. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109775. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  109776. * @returns the current scene
  109777. */
  109778. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  109779. /**
  109780. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  109781. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  109782. * @returns true if the pointer was captured
  109783. */
  109784. isPointerCaptured(pointerId?: number): boolean;
  109785. /**
  109786. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  109787. * @param attachUp defines if you want to attach events to pointerup
  109788. * @param attachDown defines if you want to attach events to pointerdown
  109789. * @param attachMove defines if you want to attach events to pointermove
  109790. */
  109791. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  109792. /** Detaches all event handlers*/
  109793. detachControl(): void;
  109794. /**
  109795. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  109796. * Delay loaded resources are not taking in account
  109797. * @return true if all required resources are ready
  109798. */
  109799. isReady(): boolean;
  109800. /** Resets all cached information relative to material (including effect and visibility) */
  109801. resetCachedMaterial(): void;
  109802. /**
  109803. * Registers a function to be called before every frame render
  109804. * @param func defines the function to register
  109805. */
  109806. registerBeforeRender(func: () => void): void;
  109807. /**
  109808. * Unregisters a function called before every frame render
  109809. * @param func defines the function to unregister
  109810. */
  109811. unregisterBeforeRender(func: () => void): void;
  109812. /**
  109813. * Registers a function to be called after every frame render
  109814. * @param func defines the function to register
  109815. */
  109816. registerAfterRender(func: () => void): void;
  109817. /**
  109818. * Unregisters a function called after every frame render
  109819. * @param func defines the function to unregister
  109820. */
  109821. unregisterAfterRender(func: () => void): void;
  109822. private _executeOnceBeforeRender;
  109823. /**
  109824. * The provided function will run before render once and will be disposed afterwards.
  109825. * A timeout delay can be provided so that the function will be executed in N ms.
  109826. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  109827. * @param func The function to be executed.
  109828. * @param timeout optional delay in ms
  109829. */
  109830. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  109831. /** @hidden */
  109832. _addPendingData(data: any): void;
  109833. /** @hidden */
  109834. _removePendingData(data: any): void;
  109835. /**
  109836. * Returns the number of items waiting to be loaded
  109837. * @returns the number of items waiting to be loaded
  109838. */
  109839. getWaitingItemsCount(): number;
  109840. /**
  109841. * Returns a boolean indicating if the scene is still loading data
  109842. */
  109843. get isLoading(): boolean;
  109844. /**
  109845. * Registers a function to be executed when the scene is ready
  109846. * @param {Function} func - the function to be executed
  109847. */
  109848. executeWhenReady(func: () => void): void;
  109849. /**
  109850. * Returns a promise that resolves when the scene is ready
  109851. * @returns A promise that resolves when the scene is ready
  109852. */
  109853. whenReadyAsync(): Promise<void>;
  109854. /** @hidden */
  109855. _checkIsReady(): void;
  109856. /**
  109857. * Gets all animatable attached to the scene
  109858. */
  109859. get animatables(): Animatable[];
  109860. /**
  109861. * Resets the last animation time frame.
  109862. * Useful to override when animations start running when loading a scene for the first time.
  109863. */
  109864. resetLastAnimationTimeFrame(): void;
  109865. /**
  109866. * Gets the current view matrix
  109867. * @returns a Matrix
  109868. */
  109869. getViewMatrix(): Matrix;
  109870. /**
  109871. * Gets the current projection matrix
  109872. * @returns a Matrix
  109873. */
  109874. getProjectionMatrix(): Matrix;
  109875. /**
  109876. * Gets the current transform matrix
  109877. * @returns a Matrix made of View * Projection
  109878. */
  109879. getTransformMatrix(): Matrix;
  109880. /**
  109881. * Sets the current transform matrix
  109882. * @param viewL defines the View matrix to use
  109883. * @param projectionL defines the Projection matrix to use
  109884. * @param viewR defines the right View matrix to use (if provided)
  109885. * @param projectionR defines the right Projection matrix to use (if provided)
  109886. */
  109887. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  109888. /**
  109889. * Gets the uniform buffer used to store scene data
  109890. * @returns a UniformBuffer
  109891. */
  109892. getSceneUniformBuffer(): UniformBuffer;
  109893. /**
  109894. * Gets an unique (relatively to the current scene) Id
  109895. * @returns an unique number for the scene
  109896. */
  109897. getUniqueId(): number;
  109898. /**
  109899. * Add a mesh to the list of scene's meshes
  109900. * @param newMesh defines the mesh to add
  109901. * @param recursive if all child meshes should also be added to the scene
  109902. */
  109903. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  109904. /**
  109905. * Remove a mesh for the list of scene's meshes
  109906. * @param toRemove defines the mesh to remove
  109907. * @param recursive if all child meshes should also be removed from the scene
  109908. * @returns the index where the mesh was in the mesh list
  109909. */
  109910. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  109911. /**
  109912. * Add a transform node to the list of scene's transform nodes
  109913. * @param newTransformNode defines the transform node to add
  109914. */
  109915. addTransformNode(newTransformNode: TransformNode): void;
  109916. /**
  109917. * Remove a transform node for the list of scene's transform nodes
  109918. * @param toRemove defines the transform node to remove
  109919. * @returns the index where the transform node was in the transform node list
  109920. */
  109921. removeTransformNode(toRemove: TransformNode): number;
  109922. /**
  109923. * Remove a skeleton for the list of scene's skeletons
  109924. * @param toRemove defines the skeleton to remove
  109925. * @returns the index where the skeleton was in the skeleton list
  109926. */
  109927. removeSkeleton(toRemove: Skeleton): number;
  109928. /**
  109929. * Remove a morph target for the list of scene's morph targets
  109930. * @param toRemove defines the morph target to remove
  109931. * @returns the index where the morph target was in the morph target list
  109932. */
  109933. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  109934. /**
  109935. * Remove a light for the list of scene's lights
  109936. * @param toRemove defines the light to remove
  109937. * @returns the index where the light was in the light list
  109938. */
  109939. removeLight(toRemove: Light): number;
  109940. /**
  109941. * Remove a camera for the list of scene's cameras
  109942. * @param toRemove defines the camera to remove
  109943. * @returns the index where the camera was in the camera list
  109944. */
  109945. removeCamera(toRemove: Camera): number;
  109946. /**
  109947. * Remove a particle system for the list of scene's particle systems
  109948. * @param toRemove defines the particle system to remove
  109949. * @returns the index where the particle system was in the particle system list
  109950. */
  109951. removeParticleSystem(toRemove: IParticleSystem): number;
  109952. /**
  109953. * Remove a animation for the list of scene's animations
  109954. * @param toRemove defines the animation to remove
  109955. * @returns the index where the animation was in the animation list
  109956. */
  109957. removeAnimation(toRemove: Animation): number;
  109958. /**
  109959. * Will stop the animation of the given target
  109960. * @param target - the target
  109961. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  109962. * @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)
  109963. */
  109964. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  109965. /**
  109966. * Removes the given animation group from this scene.
  109967. * @param toRemove The animation group to remove
  109968. * @returns The index of the removed animation group
  109969. */
  109970. removeAnimationGroup(toRemove: AnimationGroup): number;
  109971. /**
  109972. * Removes the given multi-material from this scene.
  109973. * @param toRemove The multi-material to remove
  109974. * @returns The index of the removed multi-material
  109975. */
  109976. removeMultiMaterial(toRemove: MultiMaterial): number;
  109977. /**
  109978. * Removes the given material from this scene.
  109979. * @param toRemove The material to remove
  109980. * @returns The index of the removed material
  109981. */
  109982. removeMaterial(toRemove: Material): number;
  109983. /**
  109984. * Removes the given action manager from this scene.
  109985. * @param toRemove The action manager to remove
  109986. * @returns The index of the removed action manager
  109987. */
  109988. removeActionManager(toRemove: AbstractActionManager): number;
  109989. /**
  109990. * Removes the given texture from this scene.
  109991. * @param toRemove The texture to remove
  109992. * @returns The index of the removed texture
  109993. */
  109994. removeTexture(toRemove: BaseTexture): number;
  109995. /**
  109996. * Adds the given light to this scene
  109997. * @param newLight The light to add
  109998. */
  109999. addLight(newLight: Light): void;
  110000. /**
  110001. * Sorts the list list based on light priorities
  110002. */
  110003. sortLightsByPriority(): void;
  110004. /**
  110005. * Adds the given camera to this scene
  110006. * @param newCamera The camera to add
  110007. */
  110008. addCamera(newCamera: Camera): void;
  110009. /**
  110010. * Adds the given skeleton to this scene
  110011. * @param newSkeleton The skeleton to add
  110012. */
  110013. addSkeleton(newSkeleton: Skeleton): void;
  110014. /**
  110015. * Adds the given particle system to this scene
  110016. * @param newParticleSystem The particle system to add
  110017. */
  110018. addParticleSystem(newParticleSystem: IParticleSystem): void;
  110019. /**
  110020. * Adds the given animation to this scene
  110021. * @param newAnimation The animation to add
  110022. */
  110023. addAnimation(newAnimation: Animation): void;
  110024. /**
  110025. * Adds the given animation group to this scene.
  110026. * @param newAnimationGroup The animation group to add
  110027. */
  110028. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  110029. /**
  110030. * Adds the given multi-material to this scene
  110031. * @param newMultiMaterial The multi-material to add
  110032. */
  110033. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  110034. /**
  110035. * Adds the given material to this scene
  110036. * @param newMaterial The material to add
  110037. */
  110038. addMaterial(newMaterial: Material): void;
  110039. /**
  110040. * Adds the given morph target to this scene
  110041. * @param newMorphTargetManager The morph target to add
  110042. */
  110043. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  110044. /**
  110045. * Adds the given geometry to this scene
  110046. * @param newGeometry The geometry to add
  110047. */
  110048. addGeometry(newGeometry: Geometry): void;
  110049. /**
  110050. * Adds the given action manager to this scene
  110051. * @param newActionManager The action manager to add
  110052. */
  110053. addActionManager(newActionManager: AbstractActionManager): void;
  110054. /**
  110055. * Adds the given texture to this scene.
  110056. * @param newTexture The texture to add
  110057. */
  110058. addTexture(newTexture: BaseTexture): void;
  110059. /**
  110060. * Switch active camera
  110061. * @param newCamera defines the new active camera
  110062. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  110063. */
  110064. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  110065. /**
  110066. * sets the active camera of the scene using its ID
  110067. * @param id defines the camera's ID
  110068. * @return the new active camera or null if none found.
  110069. */
  110070. setActiveCameraByID(id: string): Nullable<Camera>;
  110071. /**
  110072. * sets the active camera of the scene using its name
  110073. * @param name defines the camera's name
  110074. * @returns the new active camera or null if none found.
  110075. */
  110076. setActiveCameraByName(name: string): Nullable<Camera>;
  110077. /**
  110078. * get an animation group using its name
  110079. * @param name defines the material's name
  110080. * @return the animation group or null if none found.
  110081. */
  110082. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  110083. /**
  110084. * Get a material using its unique id
  110085. * @param uniqueId defines the material's unique id
  110086. * @return the material or null if none found.
  110087. */
  110088. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  110089. /**
  110090. * get a material using its id
  110091. * @param id defines the material's ID
  110092. * @return the material or null if none found.
  110093. */
  110094. getMaterialByID(id: string): Nullable<Material>;
  110095. /**
  110096. * Gets a the last added material using a given id
  110097. * @param id defines the material's ID
  110098. * @return the last material with the given id or null if none found.
  110099. */
  110100. getLastMaterialByID(id: string): Nullable<Material>;
  110101. /**
  110102. * Gets a material using its name
  110103. * @param name defines the material's name
  110104. * @return the material or null if none found.
  110105. */
  110106. getMaterialByName(name: string): Nullable<Material>;
  110107. /**
  110108. * Get a texture using its unique id
  110109. * @param uniqueId defines the texture's unique id
  110110. * @return the texture or null if none found.
  110111. */
  110112. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  110113. /**
  110114. * Gets a camera using its id
  110115. * @param id defines the id to look for
  110116. * @returns the camera or null if not found
  110117. */
  110118. getCameraByID(id: string): Nullable<Camera>;
  110119. /**
  110120. * Gets a camera using its unique id
  110121. * @param uniqueId defines the unique id to look for
  110122. * @returns the camera or null if not found
  110123. */
  110124. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  110125. /**
  110126. * Gets a camera using its name
  110127. * @param name defines the camera's name
  110128. * @return the camera or null if none found.
  110129. */
  110130. getCameraByName(name: string): Nullable<Camera>;
  110131. /**
  110132. * Gets a bone using its id
  110133. * @param id defines the bone's id
  110134. * @return the bone or null if not found
  110135. */
  110136. getBoneByID(id: string): Nullable<Bone>;
  110137. /**
  110138. * Gets a bone using its id
  110139. * @param name defines the bone's name
  110140. * @return the bone or null if not found
  110141. */
  110142. getBoneByName(name: string): Nullable<Bone>;
  110143. /**
  110144. * Gets a light node using its name
  110145. * @param name defines the the light's name
  110146. * @return the light or null if none found.
  110147. */
  110148. getLightByName(name: string): Nullable<Light>;
  110149. /**
  110150. * Gets a light node using its id
  110151. * @param id defines the light's id
  110152. * @return the light or null if none found.
  110153. */
  110154. getLightByID(id: string): Nullable<Light>;
  110155. /**
  110156. * Gets a light node using its scene-generated unique ID
  110157. * @param uniqueId defines the light's unique id
  110158. * @return the light or null if none found.
  110159. */
  110160. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  110161. /**
  110162. * Gets a particle system by id
  110163. * @param id defines the particle system id
  110164. * @return the corresponding system or null if none found
  110165. */
  110166. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  110167. /**
  110168. * Gets a geometry using its ID
  110169. * @param id defines the geometry's id
  110170. * @return the geometry or null if none found.
  110171. */
  110172. getGeometryByID(id: string): Nullable<Geometry>;
  110173. private _getGeometryByUniqueID;
  110174. /**
  110175. * Add a new geometry to this scene
  110176. * @param geometry defines the geometry to be added to the scene.
  110177. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  110178. * @return a boolean defining if the geometry was added or not
  110179. */
  110180. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  110181. /**
  110182. * Removes an existing geometry
  110183. * @param geometry defines the geometry to be removed from the scene
  110184. * @return a boolean defining if the geometry was removed or not
  110185. */
  110186. removeGeometry(geometry: Geometry): boolean;
  110187. /**
  110188. * Gets the list of geometries attached to the scene
  110189. * @returns an array of Geometry
  110190. */
  110191. getGeometries(): Geometry[];
  110192. /**
  110193. * Gets the first added mesh found of a given ID
  110194. * @param id defines the id to search for
  110195. * @return the mesh found or null if not found at all
  110196. */
  110197. getMeshByID(id: string): Nullable<AbstractMesh>;
  110198. /**
  110199. * Gets a list of meshes using their id
  110200. * @param id defines the id to search for
  110201. * @returns a list of meshes
  110202. */
  110203. getMeshesByID(id: string): Array<AbstractMesh>;
  110204. /**
  110205. * Gets the first added transform node found of a given ID
  110206. * @param id defines the id to search for
  110207. * @return the found transform node or null if not found at all.
  110208. */
  110209. getTransformNodeByID(id: string): Nullable<TransformNode>;
  110210. /**
  110211. * Gets a transform node with its auto-generated unique id
  110212. * @param uniqueId efines the unique id to search for
  110213. * @return the found transform node or null if not found at all.
  110214. */
  110215. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  110216. /**
  110217. * Gets a list of transform nodes using their id
  110218. * @param id defines the id to search for
  110219. * @returns a list of transform nodes
  110220. */
  110221. getTransformNodesByID(id: string): Array<TransformNode>;
  110222. /**
  110223. * Gets a mesh with its auto-generated unique id
  110224. * @param uniqueId defines the unique id to search for
  110225. * @return the found mesh or null if not found at all.
  110226. */
  110227. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  110228. /**
  110229. * Gets a the last added mesh using a given id
  110230. * @param id defines the id to search for
  110231. * @return the found mesh or null if not found at all.
  110232. */
  110233. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  110234. /**
  110235. * Gets a the last added node (Mesh, Camera, Light) using a given id
  110236. * @param id defines the id to search for
  110237. * @return the found node or null if not found at all
  110238. */
  110239. getLastEntryByID(id: string): Nullable<Node>;
  110240. /**
  110241. * Gets a node (Mesh, Camera, Light) using a given id
  110242. * @param id defines the id to search for
  110243. * @return the found node or null if not found at all
  110244. */
  110245. getNodeByID(id: string): Nullable<Node>;
  110246. /**
  110247. * Gets a node (Mesh, Camera, Light) using a given name
  110248. * @param name defines the name to search for
  110249. * @return the found node or null if not found at all.
  110250. */
  110251. getNodeByName(name: string): Nullable<Node>;
  110252. /**
  110253. * Gets a mesh using a given name
  110254. * @param name defines the name to search for
  110255. * @return the found mesh or null if not found at all.
  110256. */
  110257. getMeshByName(name: string): Nullable<AbstractMesh>;
  110258. /**
  110259. * Gets a transform node using a given name
  110260. * @param name defines the name to search for
  110261. * @return the found transform node or null if not found at all.
  110262. */
  110263. getTransformNodeByName(name: string): Nullable<TransformNode>;
  110264. /**
  110265. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  110266. * @param id defines the id to search for
  110267. * @return the found skeleton or null if not found at all.
  110268. */
  110269. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  110270. /**
  110271. * Gets a skeleton using a given auto generated unique id
  110272. * @param uniqueId defines the unique id to search for
  110273. * @return the found skeleton or null if not found at all.
  110274. */
  110275. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  110276. /**
  110277. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  110278. * @param id defines the id to search for
  110279. * @return the found skeleton or null if not found at all.
  110280. */
  110281. getSkeletonById(id: string): Nullable<Skeleton>;
  110282. /**
  110283. * Gets a skeleton using a given name
  110284. * @param name defines the name to search for
  110285. * @return the found skeleton or null if not found at all.
  110286. */
  110287. getSkeletonByName(name: string): Nullable<Skeleton>;
  110288. /**
  110289. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  110290. * @param id defines the id to search for
  110291. * @return the found morph target manager or null if not found at all.
  110292. */
  110293. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  110294. /**
  110295. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  110296. * @param id defines the id to search for
  110297. * @return the found morph target or null if not found at all.
  110298. */
  110299. getMorphTargetById(id: string): Nullable<MorphTarget>;
  110300. /**
  110301. * Gets a boolean indicating if the given mesh is active
  110302. * @param mesh defines the mesh to look for
  110303. * @returns true if the mesh is in the active list
  110304. */
  110305. isActiveMesh(mesh: AbstractMesh): boolean;
  110306. /**
  110307. * Return a unique id as a string which can serve as an identifier for the scene
  110308. */
  110309. get uid(): string;
  110310. /**
  110311. * Add an externaly attached data from its key.
  110312. * This method call will fail and return false, if such key already exists.
  110313. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  110314. * @param key the unique key that identifies the data
  110315. * @param data the data object to associate to the key for this Engine instance
  110316. * @return true if no such key were already present and the data was added successfully, false otherwise
  110317. */
  110318. addExternalData<T>(key: string, data: T): boolean;
  110319. /**
  110320. * Get an externaly attached data from its key
  110321. * @param key the unique key that identifies the data
  110322. * @return the associated data, if present (can be null), or undefined if not present
  110323. */
  110324. getExternalData<T>(key: string): Nullable<T>;
  110325. /**
  110326. * Get an externaly attached data from its key, create it using a factory if it's not already present
  110327. * @param key the unique key that identifies the data
  110328. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  110329. * @return the associated data, can be null if the factory returned null.
  110330. */
  110331. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  110332. /**
  110333. * Remove an externaly attached data from the Engine instance
  110334. * @param key the unique key that identifies the data
  110335. * @return true if the data was successfully removed, false if it doesn't exist
  110336. */
  110337. removeExternalData(key: string): boolean;
  110338. private _evaluateSubMesh;
  110339. /**
  110340. * Clear the processed materials smart array preventing retention point in material dispose.
  110341. */
  110342. freeProcessedMaterials(): void;
  110343. private _preventFreeActiveMeshesAndRenderingGroups;
  110344. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  110345. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  110346. * when disposing several meshes in a row or a hierarchy of meshes.
  110347. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  110348. */
  110349. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  110350. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  110351. /**
  110352. * Clear the active meshes smart array preventing retention point in mesh dispose.
  110353. */
  110354. freeActiveMeshes(): void;
  110355. /**
  110356. * Clear the info related to rendering groups preventing retention points during dispose.
  110357. */
  110358. freeRenderingGroups(): void;
  110359. /** @hidden */
  110360. _isInIntermediateRendering(): boolean;
  110361. /**
  110362. * Lambda returning the list of potentially active meshes.
  110363. */
  110364. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  110365. /**
  110366. * Lambda returning the list of potentially active sub meshes.
  110367. */
  110368. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  110369. /**
  110370. * Lambda returning the list of potentially intersecting sub meshes.
  110371. */
  110372. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  110373. /**
  110374. * Lambda returning the list of potentially colliding sub meshes.
  110375. */
  110376. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  110377. private _activeMeshesFrozen;
  110378. private _skipEvaluateActiveMeshesCompletely;
  110379. /**
  110380. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  110381. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  110382. * @returns the current scene
  110383. */
  110384. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  110385. /**
  110386. * Use this function to restart evaluating active meshes on every frame
  110387. * @returns the current scene
  110388. */
  110389. unfreezeActiveMeshes(): Scene;
  110390. private _evaluateActiveMeshes;
  110391. private _activeMesh;
  110392. /**
  110393. * Update the transform matrix to update from the current active camera
  110394. * @param force defines a boolean used to force the update even if cache is up to date
  110395. */
  110396. updateTransformMatrix(force?: boolean): void;
  110397. private _bindFrameBuffer;
  110398. /** @hidden */
  110399. _allowPostProcessClearColor: boolean;
  110400. /** @hidden */
  110401. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  110402. private _processSubCameras;
  110403. private _checkIntersections;
  110404. /** @hidden */
  110405. _advancePhysicsEngineStep(step: number): void;
  110406. /**
  110407. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  110408. */
  110409. getDeterministicFrameTime: () => number;
  110410. /** @hidden */
  110411. _animate(): void;
  110412. /** Execute all animations (for a frame) */
  110413. animate(): void;
  110414. /**
  110415. * Render the scene
  110416. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  110417. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  110418. */
  110419. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  110420. /**
  110421. * Freeze all materials
  110422. * A frozen material will not be updatable but should be faster to render
  110423. */
  110424. freezeMaterials(): void;
  110425. /**
  110426. * Unfreeze all materials
  110427. * A frozen material will not be updatable but should be faster to render
  110428. */
  110429. unfreezeMaterials(): void;
  110430. /**
  110431. * Releases all held ressources
  110432. */
  110433. dispose(): void;
  110434. /**
  110435. * Gets if the scene is already disposed
  110436. */
  110437. get isDisposed(): boolean;
  110438. /**
  110439. * Call this function to reduce memory footprint of the scene.
  110440. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  110441. */
  110442. clearCachedVertexData(): void;
  110443. /**
  110444. * This function will remove the local cached buffer data from texture.
  110445. * It will save memory but will prevent the texture from being rebuilt
  110446. */
  110447. cleanCachedTextureBuffer(): void;
  110448. /**
  110449. * Get the world extend vectors with an optional filter
  110450. *
  110451. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  110452. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  110453. */
  110454. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  110455. min: Vector3;
  110456. max: Vector3;
  110457. };
  110458. /**
  110459. * Creates a ray that can be used to pick in the scene
  110460. * @param x defines the x coordinate of the origin (on-screen)
  110461. * @param y defines the y coordinate of the origin (on-screen)
  110462. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  110463. * @param camera defines the camera to use for the picking
  110464. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  110465. * @returns a Ray
  110466. */
  110467. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  110468. /**
  110469. * Creates a ray that can be used to pick in the scene
  110470. * @param x defines the x coordinate of the origin (on-screen)
  110471. * @param y defines the y coordinate of the origin (on-screen)
  110472. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  110473. * @param result defines the ray where to store the picking ray
  110474. * @param camera defines the camera to use for the picking
  110475. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  110476. * @returns the current scene
  110477. */
  110478. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  110479. /**
  110480. * Creates a ray that can be used to pick in the scene
  110481. * @param x defines the x coordinate of the origin (on-screen)
  110482. * @param y defines the y coordinate of the origin (on-screen)
  110483. * @param camera defines the camera to use for the picking
  110484. * @returns a Ray
  110485. */
  110486. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  110487. /**
  110488. * Creates a ray that can be used to pick in the scene
  110489. * @param x defines the x coordinate of the origin (on-screen)
  110490. * @param y defines the y coordinate of the origin (on-screen)
  110491. * @param result defines the ray where to store the picking ray
  110492. * @param camera defines the camera to use for the picking
  110493. * @returns the current scene
  110494. */
  110495. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  110496. /** Launch a ray to try to pick a mesh in the scene
  110497. * @param x position on screen
  110498. * @param y position on screen
  110499. * @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
  110500. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  110501. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  110502. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110503. * @returns a PickingInfo
  110504. */
  110505. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  110506. /** Use the given ray to pick a mesh in the scene
  110507. * @param ray The ray to use to pick meshes
  110508. * @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
  110509. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  110510. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110511. * @returns a PickingInfo
  110512. */
  110513. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  110514. /**
  110515. * Launch a ray to try to pick a mesh in the scene
  110516. * @param x X position on screen
  110517. * @param y Y position on screen
  110518. * @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
  110519. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  110520. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110521. * @returns an array of PickingInfo
  110522. */
  110523. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  110524. /**
  110525. * Launch a ray to try to pick a mesh in the scene
  110526. * @param ray Ray to use
  110527. * @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
  110528. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110529. * @returns an array of PickingInfo
  110530. */
  110531. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  110532. /**
  110533. * Force the value of meshUnderPointer
  110534. * @param mesh defines the mesh to use
  110535. */
  110536. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  110537. /**
  110538. * Gets the mesh under the pointer
  110539. * @returns a Mesh or null if no mesh is under the pointer
  110540. */
  110541. getPointerOverMesh(): Nullable<AbstractMesh>;
  110542. /** @hidden */
  110543. _rebuildGeometries(): void;
  110544. /** @hidden */
  110545. _rebuildTextures(): void;
  110546. private _getByTags;
  110547. /**
  110548. * Get a list of meshes by tags
  110549. * @param tagsQuery defines the tags query to use
  110550. * @param forEach defines a predicate used to filter results
  110551. * @returns an array of Mesh
  110552. */
  110553. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  110554. /**
  110555. * Get a list of cameras by tags
  110556. * @param tagsQuery defines the tags query to use
  110557. * @param forEach defines a predicate used to filter results
  110558. * @returns an array of Camera
  110559. */
  110560. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  110561. /**
  110562. * Get a list of lights by tags
  110563. * @param tagsQuery defines the tags query to use
  110564. * @param forEach defines a predicate used to filter results
  110565. * @returns an array of Light
  110566. */
  110567. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  110568. /**
  110569. * Get a list of materials by tags
  110570. * @param tagsQuery defines the tags query to use
  110571. * @param forEach defines a predicate used to filter results
  110572. * @returns an array of Material
  110573. */
  110574. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  110575. /**
  110576. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  110577. * This allowed control for front to back rendering or reversly depending of the special needs.
  110578. *
  110579. * @param renderingGroupId The rendering group id corresponding to its index
  110580. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  110581. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  110582. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  110583. */
  110584. 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;
  110585. /**
  110586. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  110587. *
  110588. * @param renderingGroupId The rendering group id corresponding to its index
  110589. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  110590. * @param depth Automatically clears depth between groups if true and autoClear is true.
  110591. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  110592. */
  110593. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  110594. /**
  110595. * Gets the current auto clear configuration for one rendering group of the rendering
  110596. * manager.
  110597. * @param index the rendering group index to get the information for
  110598. * @returns The auto clear setup for the requested rendering group
  110599. */
  110600. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  110601. private _blockMaterialDirtyMechanism;
  110602. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  110603. get blockMaterialDirtyMechanism(): boolean;
  110604. set blockMaterialDirtyMechanism(value: boolean);
  110605. /**
  110606. * Will flag all materials as dirty to trigger new shader compilation
  110607. * @param flag defines the flag used to specify which material part must be marked as dirty
  110608. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  110609. */
  110610. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  110611. /** @hidden */
  110612. _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;
  110613. /** @hidden */
  110614. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110615. /** @hidden */
  110616. _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;
  110617. /** @hidden */
  110618. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  110619. /** @hidden */
  110620. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  110621. /** @hidden */
  110622. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110623. }
  110624. }
  110625. declare module BABYLON {
  110626. /**
  110627. * Set of assets to keep when moving a scene into an asset container.
  110628. */
  110629. export class KeepAssets extends AbstractScene {
  110630. }
  110631. /**
  110632. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  110633. */
  110634. export class InstantiatedEntries {
  110635. /**
  110636. * List of new root nodes (eg. nodes with no parent)
  110637. */
  110638. rootNodes: TransformNode[];
  110639. /**
  110640. * List of new skeletons
  110641. */
  110642. skeletons: Skeleton[];
  110643. /**
  110644. * List of new animation groups
  110645. */
  110646. animationGroups: AnimationGroup[];
  110647. }
  110648. /**
  110649. * Container with a set of assets that can be added or removed from a scene.
  110650. */
  110651. export class AssetContainer extends AbstractScene {
  110652. private _wasAddedToScene;
  110653. /**
  110654. * The scene the AssetContainer belongs to.
  110655. */
  110656. scene: Scene;
  110657. /**
  110658. * Instantiates an AssetContainer.
  110659. * @param scene The scene the AssetContainer belongs to.
  110660. */
  110661. constructor(scene: Scene);
  110662. /**
  110663. * Instantiate or clone all meshes and add the new ones to the scene.
  110664. * Skeletons and animation groups will all be cloned
  110665. * @param nameFunction defines an optional function used to get new names for clones
  110666. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  110667. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  110668. */
  110669. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  110670. /**
  110671. * Adds all the assets from the container to the scene.
  110672. */
  110673. addAllToScene(): void;
  110674. /**
  110675. * Removes all the assets in the container from the scene
  110676. */
  110677. removeAllFromScene(): void;
  110678. /**
  110679. * Disposes all the assets in the container
  110680. */
  110681. dispose(): void;
  110682. private _moveAssets;
  110683. /**
  110684. * Removes all the assets contained in the scene and adds them to the container.
  110685. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  110686. */
  110687. moveAllFromScene(keepAssets?: KeepAssets): void;
  110688. /**
  110689. * 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.
  110690. * @returns the root mesh
  110691. */
  110692. createRootMesh(): Mesh;
  110693. /**
  110694. * Merge animations from this asset container into a scene
  110695. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  110696. * @param animatables set of animatables to retarget to a node from the scene
  110697. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  110698. */
  110699. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  110700. }
  110701. }
  110702. declare module BABYLON {
  110703. /**
  110704. * Defines how the parser contract is defined.
  110705. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  110706. */
  110707. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  110708. /**
  110709. * Defines how the individual parser contract is defined.
  110710. * These parser can parse an individual asset
  110711. */
  110712. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  110713. /**
  110714. * Base class of the scene acting as a container for the different elements composing a scene.
  110715. * This class is dynamically extended by the different components of the scene increasing
  110716. * flexibility and reducing coupling
  110717. */
  110718. export abstract class AbstractScene {
  110719. /**
  110720. * Stores the list of available parsers in the application.
  110721. */
  110722. private static _BabylonFileParsers;
  110723. /**
  110724. * Stores the list of available individual parsers in the application.
  110725. */
  110726. private static _IndividualBabylonFileParsers;
  110727. /**
  110728. * Adds a parser in the list of available ones
  110729. * @param name Defines the name of the parser
  110730. * @param parser Defines the parser to add
  110731. */
  110732. static AddParser(name: string, parser: BabylonFileParser): void;
  110733. /**
  110734. * Gets a general parser from the list of avaialble ones
  110735. * @param name Defines the name of the parser
  110736. * @returns the requested parser or null
  110737. */
  110738. static GetParser(name: string): Nullable<BabylonFileParser>;
  110739. /**
  110740. * Adds n individual parser in the list of available ones
  110741. * @param name Defines the name of the parser
  110742. * @param parser Defines the parser to add
  110743. */
  110744. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  110745. /**
  110746. * Gets an individual parser from the list of avaialble ones
  110747. * @param name Defines the name of the parser
  110748. * @returns the requested parser or null
  110749. */
  110750. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  110751. /**
  110752. * Parser json data and populate both a scene and its associated container object
  110753. * @param jsonData Defines the data to parse
  110754. * @param scene Defines the scene to parse the data for
  110755. * @param container Defines the container attached to the parsing sequence
  110756. * @param rootUrl Defines the root url of the data
  110757. */
  110758. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  110759. /**
  110760. * Gets the list of root nodes (ie. nodes with no parent)
  110761. */
  110762. rootNodes: Node[];
  110763. /** All of the cameras added to this scene
  110764. * @see http://doc.babylonjs.com/babylon101/cameras
  110765. */
  110766. cameras: Camera[];
  110767. /**
  110768. * All of the lights added to this scene
  110769. * @see http://doc.babylonjs.com/babylon101/lights
  110770. */
  110771. lights: Light[];
  110772. /**
  110773. * All of the (abstract) meshes added to this scene
  110774. */
  110775. meshes: AbstractMesh[];
  110776. /**
  110777. * The list of skeletons added to the scene
  110778. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  110779. */
  110780. skeletons: Skeleton[];
  110781. /**
  110782. * All of the particle systems added to this scene
  110783. * @see http://doc.babylonjs.com/babylon101/particles
  110784. */
  110785. particleSystems: IParticleSystem[];
  110786. /**
  110787. * Gets a list of Animations associated with the scene
  110788. */
  110789. animations: Animation[];
  110790. /**
  110791. * All of the animation groups added to this scene
  110792. * @see http://doc.babylonjs.com/how_to/group
  110793. */
  110794. animationGroups: AnimationGroup[];
  110795. /**
  110796. * All of the multi-materials added to this scene
  110797. * @see http://doc.babylonjs.com/how_to/multi_materials
  110798. */
  110799. multiMaterials: MultiMaterial[];
  110800. /**
  110801. * All of the materials added to this scene
  110802. * In the context of a Scene, it is not supposed to be modified manually.
  110803. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  110804. * Note also that the order of the Material within the array is not significant and might change.
  110805. * @see http://doc.babylonjs.com/babylon101/materials
  110806. */
  110807. materials: Material[];
  110808. /**
  110809. * The list of morph target managers added to the scene
  110810. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  110811. */
  110812. morphTargetManagers: MorphTargetManager[];
  110813. /**
  110814. * The list of geometries used in the scene.
  110815. */
  110816. geometries: Geometry[];
  110817. /**
  110818. * All of the tranform nodes added to this scene
  110819. * In the context of a Scene, it is not supposed to be modified manually.
  110820. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  110821. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  110822. * @see http://doc.babylonjs.com/how_to/transformnode
  110823. */
  110824. transformNodes: TransformNode[];
  110825. /**
  110826. * ActionManagers available on the scene.
  110827. */
  110828. actionManagers: AbstractActionManager[];
  110829. /**
  110830. * Textures to keep.
  110831. */
  110832. textures: BaseTexture[];
  110833. /**
  110834. * Environment texture for the scene
  110835. */
  110836. environmentTexture: Nullable<BaseTexture>;
  110837. /**
  110838. * @returns all meshes, lights, cameras, transformNodes and bones
  110839. */
  110840. getNodes(): Array<Node>;
  110841. }
  110842. }
  110843. declare module BABYLON {
  110844. /**
  110845. * Interface used to define options for Sound class
  110846. */
  110847. export interface ISoundOptions {
  110848. /**
  110849. * Does the sound autoplay once loaded.
  110850. */
  110851. autoplay?: boolean;
  110852. /**
  110853. * Does the sound loop after it finishes playing once.
  110854. */
  110855. loop?: boolean;
  110856. /**
  110857. * Sound's volume
  110858. */
  110859. volume?: number;
  110860. /**
  110861. * Is it a spatial sound?
  110862. */
  110863. spatialSound?: boolean;
  110864. /**
  110865. * Maximum distance to hear that sound
  110866. */
  110867. maxDistance?: number;
  110868. /**
  110869. * Uses user defined attenuation function
  110870. */
  110871. useCustomAttenuation?: boolean;
  110872. /**
  110873. * Define the roll off factor of spatial sounds.
  110874. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110875. */
  110876. rolloffFactor?: number;
  110877. /**
  110878. * Define the reference distance the sound should be heard perfectly.
  110879. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110880. */
  110881. refDistance?: number;
  110882. /**
  110883. * Define the distance attenuation model the sound will follow.
  110884. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110885. */
  110886. distanceModel?: string;
  110887. /**
  110888. * Defines the playback speed (1 by default)
  110889. */
  110890. playbackRate?: number;
  110891. /**
  110892. * Defines if the sound is from a streaming source
  110893. */
  110894. streaming?: boolean;
  110895. /**
  110896. * Defines an optional length (in seconds) inside the sound file
  110897. */
  110898. length?: number;
  110899. /**
  110900. * Defines an optional offset (in seconds) inside the sound file
  110901. */
  110902. offset?: number;
  110903. /**
  110904. * If true, URLs will not be required to state the audio file codec to use.
  110905. */
  110906. skipCodecCheck?: boolean;
  110907. }
  110908. /**
  110909. * Defines a sound that can be played in the application.
  110910. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  110911. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110912. */
  110913. export class Sound {
  110914. /**
  110915. * The name of the sound in the scene.
  110916. */
  110917. name: string;
  110918. /**
  110919. * Does the sound autoplay once loaded.
  110920. */
  110921. autoplay: boolean;
  110922. /**
  110923. * Does the sound loop after it finishes playing once.
  110924. */
  110925. loop: boolean;
  110926. /**
  110927. * Does the sound use a custom attenuation curve to simulate the falloff
  110928. * happening when the source gets further away from the camera.
  110929. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  110930. */
  110931. useCustomAttenuation: boolean;
  110932. /**
  110933. * The sound track id this sound belongs to.
  110934. */
  110935. soundTrackId: number;
  110936. /**
  110937. * Is this sound currently played.
  110938. */
  110939. isPlaying: boolean;
  110940. /**
  110941. * Is this sound currently paused.
  110942. */
  110943. isPaused: boolean;
  110944. /**
  110945. * Does this sound enables spatial sound.
  110946. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110947. */
  110948. spatialSound: boolean;
  110949. /**
  110950. * Define the reference distance the sound should be heard perfectly.
  110951. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110952. */
  110953. refDistance: number;
  110954. /**
  110955. * Define the roll off factor of spatial sounds.
  110956. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110957. */
  110958. rolloffFactor: number;
  110959. /**
  110960. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  110961. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110962. */
  110963. maxDistance: number;
  110964. /**
  110965. * Define the distance attenuation model the sound will follow.
  110966. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110967. */
  110968. distanceModel: string;
  110969. /**
  110970. * @hidden
  110971. * Back Compat
  110972. **/
  110973. onended: () => any;
  110974. /**
  110975. * Observable event when the current playing sound finishes.
  110976. */
  110977. onEndedObservable: Observable<Sound>;
  110978. private _panningModel;
  110979. private _playbackRate;
  110980. private _streaming;
  110981. private _startTime;
  110982. private _startOffset;
  110983. private _position;
  110984. /** @hidden */
  110985. _positionInEmitterSpace: boolean;
  110986. private _localDirection;
  110987. private _volume;
  110988. private _isReadyToPlay;
  110989. private _isDirectional;
  110990. private _readyToPlayCallback;
  110991. private _audioBuffer;
  110992. private _soundSource;
  110993. private _streamingSource;
  110994. private _soundPanner;
  110995. private _soundGain;
  110996. private _inputAudioNode;
  110997. private _outputAudioNode;
  110998. private _coneInnerAngle;
  110999. private _coneOuterAngle;
  111000. private _coneOuterGain;
  111001. private _scene;
  111002. private _connectedTransformNode;
  111003. private _customAttenuationFunction;
  111004. private _registerFunc;
  111005. private _isOutputConnected;
  111006. private _htmlAudioElement;
  111007. private _urlType;
  111008. private _length?;
  111009. private _offset?;
  111010. /** @hidden */
  111011. static _SceneComponentInitialization: (scene: Scene) => void;
  111012. /**
  111013. * Create a sound and attach it to a scene
  111014. * @param name Name of your sound
  111015. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  111016. * @param scene defines the scene the sound belongs to
  111017. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  111018. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  111019. */
  111020. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  111021. /**
  111022. * Release the sound and its associated resources
  111023. */
  111024. dispose(): void;
  111025. /**
  111026. * Gets if the sounds is ready to be played or not.
  111027. * @returns true if ready, otherwise false
  111028. */
  111029. isReady(): boolean;
  111030. private _soundLoaded;
  111031. /**
  111032. * Sets the data of the sound from an audiobuffer
  111033. * @param audioBuffer The audioBuffer containing the data
  111034. */
  111035. setAudioBuffer(audioBuffer: AudioBuffer): void;
  111036. /**
  111037. * Updates the current sounds options such as maxdistance, loop...
  111038. * @param options A JSON object containing values named as the object properties
  111039. */
  111040. updateOptions(options: ISoundOptions): void;
  111041. private _createSpatialParameters;
  111042. private _updateSpatialParameters;
  111043. /**
  111044. * Switch the panning model to HRTF:
  111045. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  111046. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111047. */
  111048. switchPanningModelToHRTF(): void;
  111049. /**
  111050. * Switch the panning model to Equal Power:
  111051. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  111052. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111053. */
  111054. switchPanningModelToEqualPower(): void;
  111055. private _switchPanningModel;
  111056. /**
  111057. * Connect this sound to a sound track audio node like gain...
  111058. * @param soundTrackAudioNode the sound track audio node to connect to
  111059. */
  111060. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  111061. /**
  111062. * Transform this sound into a directional source
  111063. * @param coneInnerAngle Size of the inner cone in degree
  111064. * @param coneOuterAngle Size of the outer cone in degree
  111065. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  111066. */
  111067. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  111068. /**
  111069. * Gets or sets the inner angle for the directional cone.
  111070. */
  111071. get directionalConeInnerAngle(): number;
  111072. /**
  111073. * Gets or sets the inner angle for the directional cone.
  111074. */
  111075. set directionalConeInnerAngle(value: number);
  111076. /**
  111077. * Gets or sets the outer angle for the directional cone.
  111078. */
  111079. get directionalConeOuterAngle(): number;
  111080. /**
  111081. * Gets or sets the outer angle for the directional cone.
  111082. */
  111083. set directionalConeOuterAngle(value: number);
  111084. /**
  111085. * Sets the position of the emitter if spatial sound is enabled
  111086. * @param newPosition Defines the new posisiton
  111087. */
  111088. setPosition(newPosition: Vector3): void;
  111089. /**
  111090. * Sets the local direction of the emitter if spatial sound is enabled
  111091. * @param newLocalDirection Defines the new local direction
  111092. */
  111093. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  111094. private _updateDirection;
  111095. /** @hidden */
  111096. updateDistanceFromListener(): void;
  111097. /**
  111098. * Sets a new custom attenuation function for the sound.
  111099. * @param callback Defines the function used for the attenuation
  111100. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  111101. */
  111102. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  111103. /**
  111104. * Play the sound
  111105. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  111106. * @param offset (optional) Start the sound at a specific time in seconds
  111107. * @param length (optional) Sound duration (in seconds)
  111108. */
  111109. play(time?: number, offset?: number, length?: number): void;
  111110. private _onended;
  111111. /**
  111112. * Stop the sound
  111113. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  111114. */
  111115. stop(time?: number): void;
  111116. /**
  111117. * Put the sound in pause
  111118. */
  111119. pause(): void;
  111120. /**
  111121. * Sets a dedicated volume for this sounds
  111122. * @param newVolume Define the new volume of the sound
  111123. * @param time Define time for gradual change to new volume
  111124. */
  111125. setVolume(newVolume: number, time?: number): void;
  111126. /**
  111127. * Set the sound play back rate
  111128. * @param newPlaybackRate Define the playback rate the sound should be played at
  111129. */
  111130. setPlaybackRate(newPlaybackRate: number): void;
  111131. /**
  111132. * Gets the volume of the sound.
  111133. * @returns the volume of the sound
  111134. */
  111135. getVolume(): number;
  111136. /**
  111137. * Attach the sound to a dedicated mesh
  111138. * @param transformNode The transform node to connect the sound with
  111139. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  111140. */
  111141. attachToMesh(transformNode: TransformNode): void;
  111142. /**
  111143. * Detach the sound from the previously attached mesh
  111144. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  111145. */
  111146. detachFromMesh(): void;
  111147. private _onRegisterAfterWorldMatrixUpdate;
  111148. /**
  111149. * Clone the current sound in the scene.
  111150. * @returns the new sound clone
  111151. */
  111152. clone(): Nullable<Sound>;
  111153. /**
  111154. * Gets the current underlying audio buffer containing the data
  111155. * @returns the audio buffer
  111156. */
  111157. getAudioBuffer(): Nullable<AudioBuffer>;
  111158. /**
  111159. * Serializes the Sound in a JSON representation
  111160. * @returns the JSON representation of the sound
  111161. */
  111162. serialize(): any;
  111163. /**
  111164. * Parse a JSON representation of a sound to innstantiate in a given scene
  111165. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  111166. * @param scene Define the scene the new parsed sound should be created in
  111167. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  111168. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  111169. * @returns the newly parsed sound
  111170. */
  111171. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  111172. }
  111173. }
  111174. declare module BABYLON {
  111175. /**
  111176. * This defines an action helpful to play a defined sound on a triggered action.
  111177. */
  111178. export class PlaySoundAction extends Action {
  111179. private _sound;
  111180. /**
  111181. * Instantiate the action
  111182. * @param triggerOptions defines the trigger options
  111183. * @param sound defines the sound to play
  111184. * @param condition defines the trigger related conditions
  111185. */
  111186. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  111187. /** @hidden */
  111188. _prepare(): void;
  111189. /**
  111190. * Execute the action and play the sound.
  111191. */
  111192. execute(): void;
  111193. /**
  111194. * Serializes the actions and its related information.
  111195. * @param parent defines the object to serialize in
  111196. * @returns the serialized object
  111197. */
  111198. serialize(parent: any): any;
  111199. }
  111200. /**
  111201. * This defines an action helpful to stop a defined sound on a triggered action.
  111202. */
  111203. export class StopSoundAction extends Action {
  111204. private _sound;
  111205. /**
  111206. * Instantiate the action
  111207. * @param triggerOptions defines the trigger options
  111208. * @param sound defines the sound to stop
  111209. * @param condition defines the trigger related conditions
  111210. */
  111211. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  111212. /** @hidden */
  111213. _prepare(): void;
  111214. /**
  111215. * Execute the action and stop the sound.
  111216. */
  111217. execute(): void;
  111218. /**
  111219. * Serializes the actions and its related information.
  111220. * @param parent defines the object to serialize in
  111221. * @returns the serialized object
  111222. */
  111223. serialize(parent: any): any;
  111224. }
  111225. }
  111226. declare module BABYLON {
  111227. /**
  111228. * This defines an action responsible to change the value of a property
  111229. * by interpolating between its current value and the newly set one once triggered.
  111230. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  111231. */
  111232. export class InterpolateValueAction extends Action {
  111233. /**
  111234. * Defines the path of the property where the value should be interpolated
  111235. */
  111236. propertyPath: string;
  111237. /**
  111238. * Defines the target value at the end of the interpolation.
  111239. */
  111240. value: any;
  111241. /**
  111242. * Defines the time it will take for the property to interpolate to the value.
  111243. */
  111244. duration: number;
  111245. /**
  111246. * Defines if the other scene animations should be stopped when the action has been triggered
  111247. */
  111248. stopOtherAnimations?: boolean;
  111249. /**
  111250. * Defines a callback raised once the interpolation animation has been done.
  111251. */
  111252. onInterpolationDone?: () => void;
  111253. /**
  111254. * Observable triggered once the interpolation animation has been done.
  111255. */
  111256. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  111257. private _target;
  111258. private _effectiveTarget;
  111259. private _property;
  111260. /**
  111261. * Instantiate the action
  111262. * @param triggerOptions defines the trigger options
  111263. * @param target defines the object containing the value to interpolate
  111264. * @param propertyPath defines the path to the property in the target object
  111265. * @param value defines the target value at the end of the interpolation
  111266. * @param duration deines the time it will take for the property to interpolate to the value.
  111267. * @param condition defines the trigger related conditions
  111268. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  111269. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  111270. */
  111271. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  111272. /** @hidden */
  111273. _prepare(): void;
  111274. /**
  111275. * Execute the action starts the value interpolation.
  111276. */
  111277. execute(): void;
  111278. /**
  111279. * Serializes the actions and its related information.
  111280. * @param parent defines the object to serialize in
  111281. * @returns the serialized object
  111282. */
  111283. serialize(parent: any): any;
  111284. }
  111285. }
  111286. declare module BABYLON {
  111287. /**
  111288. * Options allowed during the creation of a sound track.
  111289. */
  111290. export interface ISoundTrackOptions {
  111291. /**
  111292. * The volume the sound track should take during creation
  111293. */
  111294. volume?: number;
  111295. /**
  111296. * Define if the sound track is the main sound track of the scene
  111297. */
  111298. mainTrack?: boolean;
  111299. }
  111300. /**
  111301. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  111302. * It will be also used in a future release to apply effects on a specific track.
  111303. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  111304. */
  111305. export class SoundTrack {
  111306. /**
  111307. * The unique identifier of the sound track in the scene.
  111308. */
  111309. id: number;
  111310. /**
  111311. * The list of sounds included in the sound track.
  111312. */
  111313. soundCollection: Array<Sound>;
  111314. private _outputAudioNode;
  111315. private _scene;
  111316. private _connectedAnalyser;
  111317. private _options;
  111318. private _isInitialized;
  111319. /**
  111320. * Creates a new sound track.
  111321. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  111322. * @param scene Define the scene the sound track belongs to
  111323. * @param options
  111324. */
  111325. constructor(scene: Scene, options?: ISoundTrackOptions);
  111326. private _initializeSoundTrackAudioGraph;
  111327. /**
  111328. * Release the sound track and its associated resources
  111329. */
  111330. dispose(): void;
  111331. /**
  111332. * Adds a sound to this sound track
  111333. * @param sound define the cound to add
  111334. * @ignoreNaming
  111335. */
  111336. AddSound(sound: Sound): void;
  111337. /**
  111338. * Removes a sound to this sound track
  111339. * @param sound define the cound to remove
  111340. * @ignoreNaming
  111341. */
  111342. RemoveSound(sound: Sound): void;
  111343. /**
  111344. * Set a global volume for the full sound track.
  111345. * @param newVolume Define the new volume of the sound track
  111346. */
  111347. setVolume(newVolume: number): void;
  111348. /**
  111349. * Switch the panning model to HRTF:
  111350. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  111351. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111352. */
  111353. switchPanningModelToHRTF(): void;
  111354. /**
  111355. * Switch the panning model to Equal Power:
  111356. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  111357. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111358. */
  111359. switchPanningModelToEqualPower(): void;
  111360. /**
  111361. * Connect the sound track to an audio analyser allowing some amazing
  111362. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  111363. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  111364. * @param analyser The analyser to connect to the engine
  111365. */
  111366. connectToAnalyser(analyser: Analyser): void;
  111367. }
  111368. }
  111369. declare module BABYLON {
  111370. interface AbstractScene {
  111371. /**
  111372. * The list of sounds used in the scene.
  111373. */
  111374. sounds: Nullable<Array<Sound>>;
  111375. }
  111376. interface Scene {
  111377. /**
  111378. * @hidden
  111379. * Backing field
  111380. */
  111381. _mainSoundTrack: SoundTrack;
  111382. /**
  111383. * The main sound track played by the scene.
  111384. * It cotains your primary collection of sounds.
  111385. */
  111386. mainSoundTrack: SoundTrack;
  111387. /**
  111388. * The list of sound tracks added to the scene
  111389. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111390. */
  111391. soundTracks: Nullable<Array<SoundTrack>>;
  111392. /**
  111393. * Gets a sound using a given name
  111394. * @param name defines the name to search for
  111395. * @return the found sound or null if not found at all.
  111396. */
  111397. getSoundByName(name: string): Nullable<Sound>;
  111398. /**
  111399. * Gets or sets if audio support is enabled
  111400. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111401. */
  111402. audioEnabled: boolean;
  111403. /**
  111404. * Gets or sets if audio will be output to headphones
  111405. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111406. */
  111407. headphone: boolean;
  111408. /**
  111409. * Gets or sets custom audio listener position provider
  111410. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111411. */
  111412. audioListenerPositionProvider: Nullable<() => Vector3>;
  111413. /**
  111414. * Gets or sets a refresh rate when using 3D audio positioning
  111415. */
  111416. audioPositioningRefreshRate: number;
  111417. }
  111418. /**
  111419. * Defines the sound scene component responsible to manage any sounds
  111420. * in a given scene.
  111421. */
  111422. export class AudioSceneComponent implements ISceneSerializableComponent {
  111423. /**
  111424. * The component name helpfull to identify the component in the list of scene components.
  111425. */
  111426. readonly name: string;
  111427. /**
  111428. * The scene the component belongs to.
  111429. */
  111430. scene: Scene;
  111431. private _audioEnabled;
  111432. /**
  111433. * Gets whether audio is enabled or not.
  111434. * Please use related enable/disable method to switch state.
  111435. */
  111436. get audioEnabled(): boolean;
  111437. private _headphone;
  111438. /**
  111439. * Gets whether audio is outputing to headphone or not.
  111440. * Please use the according Switch methods to change output.
  111441. */
  111442. get headphone(): boolean;
  111443. /**
  111444. * Gets or sets a refresh rate when using 3D audio positioning
  111445. */
  111446. audioPositioningRefreshRate: number;
  111447. private _audioListenerPositionProvider;
  111448. /**
  111449. * Gets the current audio listener position provider
  111450. */
  111451. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  111452. /**
  111453. * Sets a custom listener position for all sounds in the scene
  111454. * By default, this is the position of the first active camera
  111455. */
  111456. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  111457. /**
  111458. * Creates a new instance of the component for the given scene
  111459. * @param scene Defines the scene to register the component in
  111460. */
  111461. constructor(scene: Scene);
  111462. /**
  111463. * Registers the component in a given scene
  111464. */
  111465. register(): void;
  111466. /**
  111467. * Rebuilds the elements related to this component in case of
  111468. * context lost for instance.
  111469. */
  111470. rebuild(): void;
  111471. /**
  111472. * Serializes the component data to the specified json object
  111473. * @param serializationObject The object to serialize to
  111474. */
  111475. serialize(serializationObject: any): void;
  111476. /**
  111477. * Adds all the elements from the container to the scene
  111478. * @param container the container holding the elements
  111479. */
  111480. addFromContainer(container: AbstractScene): void;
  111481. /**
  111482. * Removes all the elements in the container from the scene
  111483. * @param container contains the elements to remove
  111484. * @param dispose if the removed element should be disposed (default: false)
  111485. */
  111486. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111487. /**
  111488. * Disposes the component and the associated ressources.
  111489. */
  111490. dispose(): void;
  111491. /**
  111492. * Disables audio in the associated scene.
  111493. */
  111494. disableAudio(): void;
  111495. /**
  111496. * Enables audio in the associated scene.
  111497. */
  111498. enableAudio(): void;
  111499. /**
  111500. * Switch audio to headphone output.
  111501. */
  111502. switchAudioModeForHeadphones(): void;
  111503. /**
  111504. * Switch audio to normal speakers.
  111505. */
  111506. switchAudioModeForNormalSpeakers(): void;
  111507. private _cachedCameraDirection;
  111508. private _cachedCameraPosition;
  111509. private _lastCheck;
  111510. private _afterRender;
  111511. }
  111512. }
  111513. declare module BABYLON {
  111514. /**
  111515. * Wraps one or more Sound objects and selects one with random weight for playback.
  111516. */
  111517. export class WeightedSound {
  111518. /** When true a Sound will be selected and played when the current playing Sound completes. */
  111519. loop: boolean;
  111520. private _coneInnerAngle;
  111521. private _coneOuterAngle;
  111522. private _volume;
  111523. /** A Sound is currently playing. */
  111524. isPlaying: boolean;
  111525. /** A Sound is currently paused. */
  111526. isPaused: boolean;
  111527. private _sounds;
  111528. private _weights;
  111529. private _currentIndex?;
  111530. /**
  111531. * Creates a new WeightedSound from the list of sounds given.
  111532. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  111533. * @param sounds Array of Sounds that will be selected from.
  111534. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  111535. */
  111536. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  111537. /**
  111538. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  111539. */
  111540. get directionalConeInnerAngle(): number;
  111541. /**
  111542. * The size of cone in degress for a directional sound in which there will be no attenuation.
  111543. */
  111544. set directionalConeInnerAngle(value: number);
  111545. /**
  111546. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  111547. * Listener angles between innerAngle and outerAngle will falloff linearly.
  111548. */
  111549. get directionalConeOuterAngle(): number;
  111550. /**
  111551. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  111552. * Listener angles between innerAngle and outerAngle will falloff linearly.
  111553. */
  111554. set directionalConeOuterAngle(value: number);
  111555. /**
  111556. * Playback volume.
  111557. */
  111558. get volume(): number;
  111559. /**
  111560. * Playback volume.
  111561. */
  111562. set volume(value: number);
  111563. private _onended;
  111564. /**
  111565. * Suspend playback
  111566. */
  111567. pause(): void;
  111568. /**
  111569. * Stop playback
  111570. */
  111571. stop(): void;
  111572. /**
  111573. * Start playback.
  111574. * @param startOffset Position the clip head at a specific time in seconds.
  111575. */
  111576. play(startOffset?: number): void;
  111577. }
  111578. }
  111579. declare module BABYLON {
  111580. /**
  111581. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  111582. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111583. */
  111584. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  111585. /**
  111586. * Gets the name of the behavior.
  111587. */
  111588. get name(): string;
  111589. /**
  111590. * The easing function used by animations
  111591. */
  111592. static EasingFunction: BackEase;
  111593. /**
  111594. * The easing mode used by animations
  111595. */
  111596. static EasingMode: number;
  111597. /**
  111598. * The duration of the animation, in milliseconds
  111599. */
  111600. transitionDuration: number;
  111601. /**
  111602. * Length of the distance animated by the transition when lower radius is reached
  111603. */
  111604. lowerRadiusTransitionRange: number;
  111605. /**
  111606. * Length of the distance animated by the transition when upper radius is reached
  111607. */
  111608. upperRadiusTransitionRange: number;
  111609. private _autoTransitionRange;
  111610. /**
  111611. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  111612. */
  111613. get autoTransitionRange(): boolean;
  111614. /**
  111615. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  111616. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  111617. */
  111618. set autoTransitionRange(value: boolean);
  111619. private _attachedCamera;
  111620. private _onAfterCheckInputsObserver;
  111621. private _onMeshTargetChangedObserver;
  111622. /**
  111623. * Initializes the behavior.
  111624. */
  111625. init(): void;
  111626. /**
  111627. * Attaches the behavior to its arc rotate camera.
  111628. * @param camera Defines the camera to attach the behavior to
  111629. */
  111630. attach(camera: ArcRotateCamera): void;
  111631. /**
  111632. * Detaches the behavior from its current arc rotate camera.
  111633. */
  111634. detach(): void;
  111635. private _radiusIsAnimating;
  111636. private _radiusBounceTransition;
  111637. private _animatables;
  111638. private _cachedWheelPrecision;
  111639. /**
  111640. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  111641. * @param radiusLimit The limit to check against.
  111642. * @return Bool to indicate if at limit.
  111643. */
  111644. private _isRadiusAtLimit;
  111645. /**
  111646. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  111647. * @param radiusDelta The delta by which to animate to. Can be negative.
  111648. */
  111649. private _applyBoundRadiusAnimation;
  111650. /**
  111651. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  111652. */
  111653. protected _clearAnimationLocks(): void;
  111654. /**
  111655. * Stops and removes all animations that have been applied to the camera
  111656. */
  111657. stopAllAnimations(): void;
  111658. }
  111659. }
  111660. declare module BABYLON {
  111661. /**
  111662. * 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.
  111663. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  111664. */
  111665. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  111666. /**
  111667. * Gets the name of the behavior.
  111668. */
  111669. get name(): string;
  111670. private _mode;
  111671. private _radiusScale;
  111672. private _positionScale;
  111673. private _defaultElevation;
  111674. private _elevationReturnTime;
  111675. private _elevationReturnWaitTime;
  111676. private _zoomStopsAnimation;
  111677. private _framingTime;
  111678. /**
  111679. * The easing function used by animations
  111680. */
  111681. static EasingFunction: ExponentialEase;
  111682. /**
  111683. * The easing mode used by animations
  111684. */
  111685. static EasingMode: number;
  111686. /**
  111687. * Sets the current mode used by the behavior
  111688. */
  111689. set mode(mode: number);
  111690. /**
  111691. * Gets current mode used by the behavior.
  111692. */
  111693. get mode(): number;
  111694. /**
  111695. * Sets the scale applied to the radius (1 by default)
  111696. */
  111697. set radiusScale(radius: number);
  111698. /**
  111699. * Gets the scale applied to the radius
  111700. */
  111701. get radiusScale(): number;
  111702. /**
  111703. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  111704. */
  111705. set positionScale(scale: number);
  111706. /**
  111707. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  111708. */
  111709. get positionScale(): number;
  111710. /**
  111711. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  111712. * behaviour is triggered, in radians.
  111713. */
  111714. set defaultElevation(elevation: number);
  111715. /**
  111716. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  111717. * behaviour is triggered, in radians.
  111718. */
  111719. get defaultElevation(): number;
  111720. /**
  111721. * Sets the time (in milliseconds) taken to return to the default beta position.
  111722. * Negative value indicates camera should not return to default.
  111723. */
  111724. set elevationReturnTime(speed: number);
  111725. /**
  111726. * Gets the time (in milliseconds) taken to return to the default beta position.
  111727. * Negative value indicates camera should not return to default.
  111728. */
  111729. get elevationReturnTime(): number;
  111730. /**
  111731. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  111732. */
  111733. set elevationReturnWaitTime(time: number);
  111734. /**
  111735. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  111736. */
  111737. get elevationReturnWaitTime(): number;
  111738. /**
  111739. * Sets the flag that indicates if user zooming should stop animation.
  111740. */
  111741. set zoomStopsAnimation(flag: boolean);
  111742. /**
  111743. * Gets the flag that indicates if user zooming should stop animation.
  111744. */
  111745. get zoomStopsAnimation(): boolean;
  111746. /**
  111747. * Sets the transition time when framing the mesh, in milliseconds
  111748. */
  111749. set framingTime(time: number);
  111750. /**
  111751. * Gets the transition time when framing the mesh, in milliseconds
  111752. */
  111753. get framingTime(): number;
  111754. /**
  111755. * Define if the behavior should automatically change the configured
  111756. * camera limits and sensibilities.
  111757. */
  111758. autoCorrectCameraLimitsAndSensibility: boolean;
  111759. private _onPrePointerObservableObserver;
  111760. private _onAfterCheckInputsObserver;
  111761. private _onMeshTargetChangedObserver;
  111762. private _attachedCamera;
  111763. private _isPointerDown;
  111764. private _lastInteractionTime;
  111765. /**
  111766. * Initializes the behavior.
  111767. */
  111768. init(): void;
  111769. /**
  111770. * Attaches the behavior to its arc rotate camera.
  111771. * @param camera Defines the camera to attach the behavior to
  111772. */
  111773. attach(camera: ArcRotateCamera): void;
  111774. /**
  111775. * Detaches the behavior from its current arc rotate camera.
  111776. */
  111777. detach(): void;
  111778. private _animatables;
  111779. private _betaIsAnimating;
  111780. private _betaTransition;
  111781. private _radiusTransition;
  111782. private _vectorTransition;
  111783. /**
  111784. * Targets the given mesh and updates zoom level accordingly.
  111785. * @param mesh The mesh to target.
  111786. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111787. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111788. */
  111789. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111790. /**
  111791. * Targets the given mesh with its children and updates zoom level accordingly.
  111792. * @param mesh The mesh to target.
  111793. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111794. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111795. */
  111796. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111797. /**
  111798. * Targets the given meshes with their children and updates zoom level accordingly.
  111799. * @param meshes The mesh to target.
  111800. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111801. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111802. */
  111803. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111804. /**
  111805. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  111806. * @param minimumWorld Determines the smaller position of the bounding box extend
  111807. * @param maximumWorld Determines the bigger position of the bounding box extend
  111808. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111809. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111810. */
  111811. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111812. /**
  111813. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  111814. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  111815. * frustum width.
  111816. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  111817. * to fully enclose the mesh in the viewing frustum.
  111818. */
  111819. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  111820. /**
  111821. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  111822. * is automatically returned to its default position (expected to be above ground plane).
  111823. */
  111824. private _maintainCameraAboveGround;
  111825. /**
  111826. * Returns the frustum slope based on the canvas ratio and camera FOV
  111827. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  111828. */
  111829. private _getFrustumSlope;
  111830. /**
  111831. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  111832. */
  111833. private _clearAnimationLocks;
  111834. /**
  111835. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  111836. */
  111837. private _applyUserInteraction;
  111838. /**
  111839. * Stops and removes all animations that have been applied to the camera
  111840. */
  111841. stopAllAnimations(): void;
  111842. /**
  111843. * Gets a value indicating if the user is moving the camera
  111844. */
  111845. get isUserIsMoving(): boolean;
  111846. /**
  111847. * The camera can move all the way towards the mesh.
  111848. */
  111849. static IgnoreBoundsSizeMode: number;
  111850. /**
  111851. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  111852. */
  111853. static FitFrustumSidesMode: number;
  111854. }
  111855. }
  111856. declare module BABYLON {
  111857. /**
  111858. * Base class for Camera Pointer Inputs.
  111859. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  111860. * for example usage.
  111861. */
  111862. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  111863. /**
  111864. * Defines the camera the input is attached to.
  111865. */
  111866. abstract camera: Camera;
  111867. /**
  111868. * Whether keyboard modifier keys are pressed at time of last mouse event.
  111869. */
  111870. protected _altKey: boolean;
  111871. protected _ctrlKey: boolean;
  111872. protected _metaKey: boolean;
  111873. protected _shiftKey: boolean;
  111874. /**
  111875. * Which mouse buttons were pressed at time of last mouse event.
  111876. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  111877. */
  111878. protected _buttonsPressed: number;
  111879. /**
  111880. * Defines the buttons associated with the input to handle camera move.
  111881. */
  111882. buttons: number[];
  111883. /**
  111884. * Attach the input controls to a specific dom element to get the input from.
  111885. * @param element Defines the element the controls should be listened from
  111886. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111887. */
  111888. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111889. /**
  111890. * Detach the current controls from the specified dom element.
  111891. * @param element Defines the element to stop listening the inputs from
  111892. */
  111893. detachControl(element: Nullable<HTMLElement>): void;
  111894. /**
  111895. * Gets the class name of the current input.
  111896. * @returns the class name
  111897. */
  111898. getClassName(): string;
  111899. /**
  111900. * Get the friendly name associated with the input class.
  111901. * @returns the input friendly name
  111902. */
  111903. getSimpleName(): string;
  111904. /**
  111905. * Called on pointer POINTERDOUBLETAP event.
  111906. * Override this method to provide functionality on POINTERDOUBLETAP event.
  111907. */
  111908. protected onDoubleTap(type: string): void;
  111909. /**
  111910. * Called on pointer POINTERMOVE event if only a single touch is active.
  111911. * Override this method to provide functionality.
  111912. */
  111913. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111914. /**
  111915. * Called on pointer POINTERMOVE event if multiple touches are active.
  111916. * Override this method to provide functionality.
  111917. */
  111918. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111919. /**
  111920. * Called on JS contextmenu event.
  111921. * Override this method to provide functionality.
  111922. */
  111923. protected onContextMenu(evt: PointerEvent): void;
  111924. /**
  111925. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  111926. * press.
  111927. * Override this method to provide functionality.
  111928. */
  111929. protected onButtonDown(evt: PointerEvent): void;
  111930. /**
  111931. * Called each time a new POINTERUP event occurs. Ie, for each button
  111932. * release.
  111933. * Override this method to provide functionality.
  111934. */
  111935. protected onButtonUp(evt: PointerEvent): void;
  111936. /**
  111937. * Called when window becomes inactive.
  111938. * Override this method to provide functionality.
  111939. */
  111940. protected onLostFocus(): void;
  111941. private _pointerInput;
  111942. private _observer;
  111943. private _onLostFocus;
  111944. private pointA;
  111945. private pointB;
  111946. }
  111947. }
  111948. declare module BABYLON {
  111949. /**
  111950. * Manage the pointers inputs to control an arc rotate camera.
  111951. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111952. */
  111953. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  111954. /**
  111955. * Defines the camera the input is attached to.
  111956. */
  111957. camera: ArcRotateCamera;
  111958. /**
  111959. * Gets the class name of the current input.
  111960. * @returns the class name
  111961. */
  111962. getClassName(): string;
  111963. /**
  111964. * Defines the buttons associated with the input to handle camera move.
  111965. */
  111966. buttons: number[];
  111967. /**
  111968. * Defines the pointer angular sensibility along the X axis or how fast is
  111969. * the camera rotating.
  111970. */
  111971. angularSensibilityX: number;
  111972. /**
  111973. * Defines the pointer angular sensibility along the Y axis or how fast is
  111974. * the camera rotating.
  111975. */
  111976. angularSensibilityY: number;
  111977. /**
  111978. * Defines the pointer pinch precision or how fast is the camera zooming.
  111979. */
  111980. pinchPrecision: number;
  111981. /**
  111982. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  111983. * from 0.
  111984. * It defines the percentage of current camera.radius to use as delta when
  111985. * pinch zoom is used.
  111986. */
  111987. pinchDeltaPercentage: number;
  111988. /**
  111989. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  111990. * that any object in the plane at the camera's target point will scale
  111991. * perfectly with finger motion.
  111992. * Overrides pinchDeltaPercentage and pinchPrecision.
  111993. */
  111994. useNaturalPinchZoom: boolean;
  111995. /**
  111996. * Defines the pointer panning sensibility or how fast is the camera moving.
  111997. */
  111998. panningSensibility: number;
  111999. /**
  112000. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  112001. */
  112002. multiTouchPanning: boolean;
  112003. /**
  112004. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  112005. * zoom (pinch) through multitouch.
  112006. */
  112007. multiTouchPanAndZoom: boolean;
  112008. /**
  112009. * Revers pinch action direction.
  112010. */
  112011. pinchInwards: boolean;
  112012. private _isPanClick;
  112013. private _twoFingerActivityCount;
  112014. private _isPinching;
  112015. /**
  112016. * Called on pointer POINTERMOVE event if only a single touch is active.
  112017. */
  112018. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  112019. /**
  112020. * Called on pointer POINTERDOUBLETAP event.
  112021. */
  112022. protected onDoubleTap(type: string): void;
  112023. /**
  112024. * Called on pointer POINTERMOVE event if multiple touches are active.
  112025. */
  112026. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  112027. /**
  112028. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  112029. * press.
  112030. */
  112031. protected onButtonDown(evt: PointerEvent): void;
  112032. /**
  112033. * Called each time a new POINTERUP event occurs. Ie, for each button
  112034. * release.
  112035. */
  112036. protected onButtonUp(evt: PointerEvent): void;
  112037. /**
  112038. * Called when window becomes inactive.
  112039. */
  112040. protected onLostFocus(): void;
  112041. }
  112042. }
  112043. declare module BABYLON {
  112044. /**
  112045. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  112046. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112047. */
  112048. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  112049. /**
  112050. * Defines the camera the input is attached to.
  112051. */
  112052. camera: ArcRotateCamera;
  112053. /**
  112054. * Defines the list of key codes associated with the up action (increase alpha)
  112055. */
  112056. keysUp: number[];
  112057. /**
  112058. * Defines the list of key codes associated with the down action (decrease alpha)
  112059. */
  112060. keysDown: number[];
  112061. /**
  112062. * Defines the list of key codes associated with the left action (increase beta)
  112063. */
  112064. keysLeft: number[];
  112065. /**
  112066. * Defines the list of key codes associated with the right action (decrease beta)
  112067. */
  112068. keysRight: number[];
  112069. /**
  112070. * Defines the list of key codes associated with the reset action.
  112071. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  112072. */
  112073. keysReset: number[];
  112074. /**
  112075. * Defines the panning sensibility of the inputs.
  112076. * (How fast is the camera panning)
  112077. */
  112078. panningSensibility: number;
  112079. /**
  112080. * Defines the zooming sensibility of the inputs.
  112081. * (How fast is the camera zooming)
  112082. */
  112083. zoomingSensibility: number;
  112084. /**
  112085. * Defines whether maintaining the alt key down switch the movement mode from
  112086. * orientation to zoom.
  112087. */
  112088. useAltToZoom: boolean;
  112089. /**
  112090. * Rotation speed of the camera
  112091. */
  112092. angularSpeed: number;
  112093. private _keys;
  112094. private _ctrlPressed;
  112095. private _altPressed;
  112096. private _onCanvasBlurObserver;
  112097. private _onKeyboardObserver;
  112098. private _engine;
  112099. private _scene;
  112100. /**
  112101. * Attach the input controls to a specific dom element to get the input from.
  112102. * @param element Defines the element the controls should be listened from
  112103. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112104. */
  112105. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112106. /**
  112107. * Detach the current controls from the specified dom element.
  112108. * @param element Defines the element to stop listening the inputs from
  112109. */
  112110. detachControl(element: Nullable<HTMLElement>): void;
  112111. /**
  112112. * Update the current camera state depending on the inputs that have been used this frame.
  112113. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112114. */
  112115. checkInputs(): void;
  112116. /**
  112117. * Gets the class name of the current intput.
  112118. * @returns the class name
  112119. */
  112120. getClassName(): string;
  112121. /**
  112122. * Get the friendly name associated with the input class.
  112123. * @returns the input friendly name
  112124. */
  112125. getSimpleName(): string;
  112126. }
  112127. }
  112128. declare module BABYLON {
  112129. /**
  112130. * Manage the mouse wheel inputs to control an arc rotate camera.
  112131. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112132. */
  112133. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  112134. /**
  112135. * Defines the camera the input is attached to.
  112136. */
  112137. camera: ArcRotateCamera;
  112138. /**
  112139. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  112140. */
  112141. wheelPrecision: number;
  112142. /**
  112143. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  112144. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  112145. */
  112146. wheelDeltaPercentage: number;
  112147. private _wheel;
  112148. private _observer;
  112149. private computeDeltaFromMouseWheelLegacyEvent;
  112150. /**
  112151. * Attach the input controls to a specific dom element to get the input from.
  112152. * @param element Defines the element the controls should be listened from
  112153. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112154. */
  112155. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112156. /**
  112157. * Detach the current controls from the specified dom element.
  112158. * @param element Defines the element to stop listening the inputs from
  112159. */
  112160. detachControl(element: Nullable<HTMLElement>): void;
  112161. /**
  112162. * Gets the class name of the current intput.
  112163. * @returns the class name
  112164. */
  112165. getClassName(): string;
  112166. /**
  112167. * Get the friendly name associated with the input class.
  112168. * @returns the input friendly name
  112169. */
  112170. getSimpleName(): string;
  112171. }
  112172. }
  112173. declare module BABYLON {
  112174. /**
  112175. * Default Inputs manager for the ArcRotateCamera.
  112176. * It groups all the default supported inputs for ease of use.
  112177. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112178. */
  112179. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  112180. /**
  112181. * Instantiates a new ArcRotateCameraInputsManager.
  112182. * @param camera Defines the camera the inputs belong to
  112183. */
  112184. constructor(camera: ArcRotateCamera);
  112185. /**
  112186. * Add mouse wheel input support to the input manager.
  112187. * @returns the current input manager
  112188. */
  112189. addMouseWheel(): ArcRotateCameraInputsManager;
  112190. /**
  112191. * Add pointers input support to the input manager.
  112192. * @returns the current input manager
  112193. */
  112194. addPointers(): ArcRotateCameraInputsManager;
  112195. /**
  112196. * Add keyboard input support to the input manager.
  112197. * @returns the current input manager
  112198. */
  112199. addKeyboard(): ArcRotateCameraInputsManager;
  112200. }
  112201. }
  112202. declare module BABYLON {
  112203. /**
  112204. * This represents an orbital type of camera.
  112205. *
  112206. * 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.
  112207. * 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.
  112208. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  112209. */
  112210. export class ArcRotateCamera extends TargetCamera {
  112211. /**
  112212. * Defines the rotation angle of the camera along the longitudinal axis.
  112213. */
  112214. alpha: number;
  112215. /**
  112216. * Defines the rotation angle of the camera along the latitudinal axis.
  112217. */
  112218. beta: number;
  112219. /**
  112220. * Defines the radius of the camera from it s target point.
  112221. */
  112222. radius: number;
  112223. protected _target: Vector3;
  112224. protected _targetHost: Nullable<AbstractMesh>;
  112225. /**
  112226. * Defines the target point of the camera.
  112227. * The camera looks towards it form the radius distance.
  112228. */
  112229. get target(): Vector3;
  112230. set target(value: Vector3);
  112231. /**
  112232. * Define the current local position of the camera in the scene
  112233. */
  112234. get position(): Vector3;
  112235. set position(newPosition: Vector3);
  112236. protected _upVector: Vector3;
  112237. protected _upToYMatrix: Matrix;
  112238. protected _YToUpMatrix: Matrix;
  112239. /**
  112240. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  112241. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  112242. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  112243. */
  112244. set upVector(vec: Vector3);
  112245. get upVector(): Vector3;
  112246. /**
  112247. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  112248. */
  112249. setMatUp(): void;
  112250. /**
  112251. * Current inertia value on the longitudinal axis.
  112252. * The bigger this number the longer it will take for the camera to stop.
  112253. */
  112254. inertialAlphaOffset: number;
  112255. /**
  112256. * Current inertia value on the latitudinal axis.
  112257. * The bigger this number the longer it will take for the camera to stop.
  112258. */
  112259. inertialBetaOffset: number;
  112260. /**
  112261. * Current inertia value on the radius axis.
  112262. * The bigger this number the longer it will take for the camera to stop.
  112263. */
  112264. inertialRadiusOffset: number;
  112265. /**
  112266. * Minimum allowed angle on the longitudinal axis.
  112267. * This can help limiting how the Camera is able to move in the scene.
  112268. */
  112269. lowerAlphaLimit: Nullable<number>;
  112270. /**
  112271. * Maximum allowed angle on the longitudinal axis.
  112272. * This can help limiting how the Camera is able to move in the scene.
  112273. */
  112274. upperAlphaLimit: Nullable<number>;
  112275. /**
  112276. * Minimum allowed angle on the latitudinal axis.
  112277. * This can help limiting how the Camera is able to move in the scene.
  112278. */
  112279. lowerBetaLimit: number;
  112280. /**
  112281. * Maximum allowed angle on the latitudinal axis.
  112282. * This can help limiting how the Camera is able to move in the scene.
  112283. */
  112284. upperBetaLimit: number;
  112285. /**
  112286. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  112287. * This can help limiting how the Camera is able to move in the scene.
  112288. */
  112289. lowerRadiusLimit: Nullable<number>;
  112290. /**
  112291. * Maximum allowed distance of the camera to the target (The camera can not get further).
  112292. * This can help limiting how the Camera is able to move in the scene.
  112293. */
  112294. upperRadiusLimit: Nullable<number>;
  112295. /**
  112296. * Defines the current inertia value used during panning of the camera along the X axis.
  112297. */
  112298. inertialPanningX: number;
  112299. /**
  112300. * Defines the current inertia value used during panning of the camera along the Y axis.
  112301. */
  112302. inertialPanningY: number;
  112303. /**
  112304. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  112305. * Basically if your fingers moves away from more than this distance you will be considered
  112306. * in pinch mode.
  112307. */
  112308. pinchToPanMaxDistance: number;
  112309. /**
  112310. * Defines the maximum distance the camera can pan.
  112311. * This could help keeping the cammera always in your scene.
  112312. */
  112313. panningDistanceLimit: Nullable<number>;
  112314. /**
  112315. * Defines the target of the camera before paning.
  112316. */
  112317. panningOriginTarget: Vector3;
  112318. /**
  112319. * Defines the value of the inertia used during panning.
  112320. * 0 would mean stop inertia and one would mean no decelleration at all.
  112321. */
  112322. panningInertia: number;
  112323. /**
  112324. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  112325. */
  112326. get angularSensibilityX(): number;
  112327. set angularSensibilityX(value: number);
  112328. /**
  112329. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  112330. */
  112331. get angularSensibilityY(): number;
  112332. set angularSensibilityY(value: number);
  112333. /**
  112334. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  112335. */
  112336. get pinchPrecision(): number;
  112337. set pinchPrecision(value: number);
  112338. /**
  112339. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  112340. * It will be used instead of pinchDeltaPrecision if different from 0.
  112341. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  112342. */
  112343. get pinchDeltaPercentage(): number;
  112344. set pinchDeltaPercentage(value: number);
  112345. /**
  112346. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  112347. * and pinch delta percentage.
  112348. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  112349. * that any object in the plane at the camera's target point will scale
  112350. * perfectly with finger motion.
  112351. */
  112352. get useNaturalPinchZoom(): boolean;
  112353. set useNaturalPinchZoom(value: boolean);
  112354. /**
  112355. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  112356. */
  112357. get panningSensibility(): number;
  112358. set panningSensibility(value: number);
  112359. /**
  112360. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  112361. */
  112362. get keysUp(): number[];
  112363. set keysUp(value: number[]);
  112364. /**
  112365. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  112366. */
  112367. get keysDown(): number[];
  112368. set keysDown(value: number[]);
  112369. /**
  112370. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  112371. */
  112372. get keysLeft(): number[];
  112373. set keysLeft(value: number[]);
  112374. /**
  112375. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  112376. */
  112377. get keysRight(): number[];
  112378. set keysRight(value: number[]);
  112379. /**
  112380. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  112381. */
  112382. get wheelPrecision(): number;
  112383. set wheelPrecision(value: number);
  112384. /**
  112385. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  112386. * It will be used instead of pinchDeltaPrecision if different from 0.
  112387. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  112388. */
  112389. get wheelDeltaPercentage(): number;
  112390. set wheelDeltaPercentage(value: number);
  112391. /**
  112392. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  112393. */
  112394. zoomOnFactor: number;
  112395. /**
  112396. * Defines a screen offset for the camera position.
  112397. */
  112398. targetScreenOffset: Vector2;
  112399. /**
  112400. * Allows the camera to be completely reversed.
  112401. * If false the camera can not arrive upside down.
  112402. */
  112403. allowUpsideDown: boolean;
  112404. /**
  112405. * Define if double tap/click is used to restore the previously saved state of the camera.
  112406. */
  112407. useInputToRestoreState: boolean;
  112408. /** @hidden */
  112409. _viewMatrix: Matrix;
  112410. /** @hidden */
  112411. _useCtrlForPanning: boolean;
  112412. /** @hidden */
  112413. _panningMouseButton: number;
  112414. /**
  112415. * Defines the input associated to the camera.
  112416. */
  112417. inputs: ArcRotateCameraInputsManager;
  112418. /** @hidden */
  112419. _reset: () => void;
  112420. /**
  112421. * Defines the allowed panning axis.
  112422. */
  112423. panningAxis: Vector3;
  112424. protected _localDirection: Vector3;
  112425. protected _transformedDirection: Vector3;
  112426. private _bouncingBehavior;
  112427. /**
  112428. * Gets the bouncing behavior of the camera if it has been enabled.
  112429. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  112430. */
  112431. get bouncingBehavior(): Nullable<BouncingBehavior>;
  112432. /**
  112433. * Defines if the bouncing behavior of the camera is enabled on the camera.
  112434. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  112435. */
  112436. get useBouncingBehavior(): boolean;
  112437. set useBouncingBehavior(value: boolean);
  112438. private _framingBehavior;
  112439. /**
  112440. * Gets the framing behavior of the camera if it has been enabled.
  112441. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  112442. */
  112443. get framingBehavior(): Nullable<FramingBehavior>;
  112444. /**
  112445. * Defines if the framing behavior of the camera is enabled on the camera.
  112446. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  112447. */
  112448. get useFramingBehavior(): boolean;
  112449. set useFramingBehavior(value: boolean);
  112450. private _autoRotationBehavior;
  112451. /**
  112452. * Gets the auto rotation behavior of the camera if it has been enabled.
  112453. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112454. */
  112455. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  112456. /**
  112457. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  112458. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112459. */
  112460. get useAutoRotationBehavior(): boolean;
  112461. set useAutoRotationBehavior(value: boolean);
  112462. /**
  112463. * Observable triggered when the mesh target has been changed on the camera.
  112464. */
  112465. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  112466. /**
  112467. * Event raised when the camera is colliding with a mesh.
  112468. */
  112469. onCollide: (collidedMesh: AbstractMesh) => void;
  112470. /**
  112471. * Defines whether the camera should check collision with the objects oh the scene.
  112472. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  112473. */
  112474. checkCollisions: boolean;
  112475. /**
  112476. * Defines the collision radius of the camera.
  112477. * This simulates a sphere around the camera.
  112478. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  112479. */
  112480. collisionRadius: Vector3;
  112481. protected _collider: Collider;
  112482. protected _previousPosition: Vector3;
  112483. protected _collisionVelocity: Vector3;
  112484. protected _newPosition: Vector3;
  112485. protected _previousAlpha: number;
  112486. protected _previousBeta: number;
  112487. protected _previousRadius: number;
  112488. protected _collisionTriggered: boolean;
  112489. protected _targetBoundingCenter: Nullable<Vector3>;
  112490. private _computationVector;
  112491. /**
  112492. * Instantiates a new ArcRotateCamera in a given scene
  112493. * @param name Defines the name of the camera
  112494. * @param alpha Defines the camera rotation along the logitudinal axis
  112495. * @param beta Defines the camera rotation along the latitudinal axis
  112496. * @param radius Defines the camera distance from its target
  112497. * @param target Defines the camera target
  112498. * @param scene Defines the scene the camera belongs to
  112499. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  112500. */
  112501. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  112502. /** @hidden */
  112503. _initCache(): void;
  112504. /** @hidden */
  112505. _updateCache(ignoreParentClass?: boolean): void;
  112506. protected _getTargetPosition(): Vector3;
  112507. private _storedAlpha;
  112508. private _storedBeta;
  112509. private _storedRadius;
  112510. private _storedTarget;
  112511. private _storedTargetScreenOffset;
  112512. /**
  112513. * Stores the current state of the camera (alpha, beta, radius and target)
  112514. * @returns the camera itself
  112515. */
  112516. storeState(): Camera;
  112517. /**
  112518. * @hidden
  112519. * Restored camera state. You must call storeState() first
  112520. */
  112521. _restoreStateValues(): boolean;
  112522. /** @hidden */
  112523. _isSynchronizedViewMatrix(): boolean;
  112524. /**
  112525. * Attached controls to the current camera.
  112526. * @param element Defines the element the controls should be listened from
  112527. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112528. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  112529. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  112530. */
  112531. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  112532. /**
  112533. * Detach the current controls from the camera.
  112534. * The camera will stop reacting to inputs.
  112535. * @param element Defines the element to stop listening the inputs from
  112536. */
  112537. detachControl(element: HTMLElement): void;
  112538. /** @hidden */
  112539. _checkInputs(): void;
  112540. protected _checkLimits(): void;
  112541. /**
  112542. * Rebuilds angles (alpha, beta) and radius from the give position and target
  112543. */
  112544. rebuildAnglesAndRadius(): void;
  112545. /**
  112546. * Use a position to define the current camera related information like alpha, beta and radius
  112547. * @param position Defines the position to set the camera at
  112548. */
  112549. setPosition(position: Vector3): void;
  112550. /**
  112551. * Defines the target the camera should look at.
  112552. * This will automatically adapt alpha beta and radius to fit within the new target.
  112553. * @param target Defines the new target as a Vector or a mesh
  112554. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  112555. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  112556. */
  112557. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  112558. /** @hidden */
  112559. _getViewMatrix(): Matrix;
  112560. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  112561. /**
  112562. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  112563. * @param meshes Defines the mesh to zoom on
  112564. * @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)
  112565. */
  112566. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  112567. /**
  112568. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  112569. * The target will be changed but the radius
  112570. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  112571. * @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)
  112572. */
  112573. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  112574. min: Vector3;
  112575. max: Vector3;
  112576. distance: number;
  112577. }, doNotUpdateMaxZ?: boolean): void;
  112578. /**
  112579. * @override
  112580. * Override Camera.createRigCamera
  112581. */
  112582. createRigCamera(name: string, cameraIndex: number): Camera;
  112583. /**
  112584. * @hidden
  112585. * @override
  112586. * Override Camera._updateRigCameras
  112587. */
  112588. _updateRigCameras(): void;
  112589. /**
  112590. * Destroy the camera and release the current resources hold by it.
  112591. */
  112592. dispose(): void;
  112593. /**
  112594. * Gets the current object class name.
  112595. * @return the class name
  112596. */
  112597. getClassName(): string;
  112598. }
  112599. }
  112600. declare module BABYLON {
  112601. /**
  112602. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  112603. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112604. */
  112605. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  112606. /**
  112607. * Gets the name of the behavior.
  112608. */
  112609. get name(): string;
  112610. private _zoomStopsAnimation;
  112611. private _idleRotationSpeed;
  112612. private _idleRotationWaitTime;
  112613. private _idleRotationSpinupTime;
  112614. /**
  112615. * Sets the flag that indicates if user zooming should stop animation.
  112616. */
  112617. set zoomStopsAnimation(flag: boolean);
  112618. /**
  112619. * Gets the flag that indicates if user zooming should stop animation.
  112620. */
  112621. get zoomStopsAnimation(): boolean;
  112622. /**
  112623. * Sets the default speed at which the camera rotates around the model.
  112624. */
  112625. set idleRotationSpeed(speed: number);
  112626. /**
  112627. * Gets the default speed at which the camera rotates around the model.
  112628. */
  112629. get idleRotationSpeed(): number;
  112630. /**
  112631. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  112632. */
  112633. set idleRotationWaitTime(time: number);
  112634. /**
  112635. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  112636. */
  112637. get idleRotationWaitTime(): number;
  112638. /**
  112639. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  112640. */
  112641. set idleRotationSpinupTime(time: number);
  112642. /**
  112643. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  112644. */
  112645. get idleRotationSpinupTime(): number;
  112646. /**
  112647. * Gets a value indicating if the camera is currently rotating because of this behavior
  112648. */
  112649. get rotationInProgress(): boolean;
  112650. private _onPrePointerObservableObserver;
  112651. private _onAfterCheckInputsObserver;
  112652. private _attachedCamera;
  112653. private _isPointerDown;
  112654. private _lastFrameTime;
  112655. private _lastInteractionTime;
  112656. private _cameraRotationSpeed;
  112657. /**
  112658. * Initializes the behavior.
  112659. */
  112660. init(): void;
  112661. /**
  112662. * Attaches the behavior to its arc rotate camera.
  112663. * @param camera Defines the camera to attach the behavior to
  112664. */
  112665. attach(camera: ArcRotateCamera): void;
  112666. /**
  112667. * Detaches the behavior from its current arc rotate camera.
  112668. */
  112669. detach(): void;
  112670. /**
  112671. * Returns true if user is scrolling.
  112672. * @return true if user is scrolling.
  112673. */
  112674. private _userIsZooming;
  112675. private _lastFrameRadius;
  112676. private _shouldAnimationStopForInteraction;
  112677. /**
  112678. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  112679. */
  112680. private _applyUserInteraction;
  112681. private _userIsMoving;
  112682. }
  112683. }
  112684. declare module BABYLON {
  112685. /**
  112686. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  112687. */
  112688. export class AttachToBoxBehavior implements Behavior<Mesh> {
  112689. private ui;
  112690. /**
  112691. * The name of the behavior
  112692. */
  112693. name: string;
  112694. /**
  112695. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  112696. */
  112697. distanceAwayFromFace: number;
  112698. /**
  112699. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  112700. */
  112701. distanceAwayFromBottomOfFace: number;
  112702. private _faceVectors;
  112703. private _target;
  112704. private _scene;
  112705. private _onRenderObserver;
  112706. private _tmpMatrix;
  112707. private _tmpVector;
  112708. /**
  112709. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  112710. * @param ui The transform node that should be attched to the mesh
  112711. */
  112712. constructor(ui: TransformNode);
  112713. /**
  112714. * Initializes the behavior
  112715. */
  112716. init(): void;
  112717. private _closestFace;
  112718. private _zeroVector;
  112719. private _lookAtTmpMatrix;
  112720. private _lookAtToRef;
  112721. /**
  112722. * Attaches the AttachToBoxBehavior to the passed in mesh
  112723. * @param target The mesh that the specified node will be attached to
  112724. */
  112725. attach(target: Mesh): void;
  112726. /**
  112727. * Detaches the behavior from the mesh
  112728. */
  112729. detach(): void;
  112730. }
  112731. }
  112732. declare module BABYLON {
  112733. /**
  112734. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  112735. */
  112736. export class FadeInOutBehavior implements Behavior<Mesh> {
  112737. /**
  112738. * Time in milliseconds to delay before fading in (Default: 0)
  112739. */
  112740. delay: number;
  112741. /**
  112742. * Time in milliseconds for the mesh to fade in (Default: 300)
  112743. */
  112744. fadeInTime: number;
  112745. private _millisecondsPerFrame;
  112746. private _hovered;
  112747. private _hoverValue;
  112748. private _ownerNode;
  112749. /**
  112750. * Instatiates the FadeInOutBehavior
  112751. */
  112752. constructor();
  112753. /**
  112754. * The name of the behavior
  112755. */
  112756. get name(): string;
  112757. /**
  112758. * Initializes the behavior
  112759. */
  112760. init(): void;
  112761. /**
  112762. * Attaches the fade behavior on the passed in mesh
  112763. * @param ownerNode The mesh that will be faded in/out once attached
  112764. */
  112765. attach(ownerNode: Mesh): void;
  112766. /**
  112767. * Detaches the behavior from the mesh
  112768. */
  112769. detach(): void;
  112770. /**
  112771. * Triggers the mesh to begin fading in or out
  112772. * @param value if the object should fade in or out (true to fade in)
  112773. */
  112774. fadeIn(value: boolean): void;
  112775. private _update;
  112776. private _setAllVisibility;
  112777. }
  112778. }
  112779. declare module BABYLON {
  112780. /**
  112781. * Class containing a set of static utilities functions for managing Pivots
  112782. * @hidden
  112783. */
  112784. export class PivotTools {
  112785. private static _PivotCached;
  112786. private static _OldPivotPoint;
  112787. private static _PivotTranslation;
  112788. private static _PivotTmpVector;
  112789. /** @hidden */
  112790. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  112791. /** @hidden */
  112792. static _RestorePivotPoint(mesh: AbstractMesh): void;
  112793. }
  112794. }
  112795. declare module BABYLON {
  112796. /**
  112797. * Class containing static functions to help procedurally build meshes
  112798. */
  112799. export class PlaneBuilder {
  112800. /**
  112801. * Creates a plane mesh
  112802. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  112803. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  112804. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  112805. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112806. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112807. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112808. * @param name defines the name of the mesh
  112809. * @param options defines the options used to create the mesh
  112810. * @param scene defines the hosting scene
  112811. * @returns the plane mesh
  112812. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  112813. */
  112814. static CreatePlane(name: string, options: {
  112815. size?: number;
  112816. width?: number;
  112817. height?: number;
  112818. sideOrientation?: number;
  112819. frontUVs?: Vector4;
  112820. backUVs?: Vector4;
  112821. updatable?: boolean;
  112822. sourcePlane?: Plane;
  112823. }, scene?: Nullable<Scene>): Mesh;
  112824. }
  112825. }
  112826. declare module BABYLON {
  112827. /**
  112828. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  112829. */
  112830. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  112831. private static _AnyMouseID;
  112832. /**
  112833. * Abstract mesh the behavior is set on
  112834. */
  112835. attachedNode: AbstractMesh;
  112836. private _dragPlane;
  112837. private _scene;
  112838. private _pointerObserver;
  112839. private _beforeRenderObserver;
  112840. private static _planeScene;
  112841. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  112842. /**
  112843. * 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)
  112844. */
  112845. maxDragAngle: number;
  112846. /**
  112847. * @hidden
  112848. */
  112849. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  112850. /**
  112851. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  112852. */
  112853. currentDraggingPointerID: number;
  112854. /**
  112855. * The last position where the pointer hit the drag plane in world space
  112856. */
  112857. lastDragPosition: Vector3;
  112858. /**
  112859. * If the behavior is currently in a dragging state
  112860. */
  112861. dragging: boolean;
  112862. /**
  112863. * 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)
  112864. */
  112865. dragDeltaRatio: number;
  112866. /**
  112867. * If the drag plane orientation should be updated during the dragging (Default: true)
  112868. */
  112869. updateDragPlane: boolean;
  112870. private _debugMode;
  112871. private _moving;
  112872. /**
  112873. * Fires each time the attached mesh is dragged with the pointer
  112874. * * delta between last drag position and current drag position in world space
  112875. * * dragDistance along the drag axis
  112876. * * dragPlaneNormal normal of the current drag plane used during the drag
  112877. * * dragPlanePoint in world space where the drag intersects the drag plane
  112878. */
  112879. onDragObservable: Observable<{
  112880. delta: Vector3;
  112881. dragPlanePoint: Vector3;
  112882. dragPlaneNormal: Vector3;
  112883. dragDistance: number;
  112884. pointerId: number;
  112885. }>;
  112886. /**
  112887. * Fires each time a drag begins (eg. mouse down on mesh)
  112888. */
  112889. onDragStartObservable: Observable<{
  112890. dragPlanePoint: Vector3;
  112891. pointerId: number;
  112892. }>;
  112893. /**
  112894. * Fires each time a drag ends (eg. mouse release after drag)
  112895. */
  112896. onDragEndObservable: Observable<{
  112897. dragPlanePoint: Vector3;
  112898. pointerId: number;
  112899. }>;
  112900. /**
  112901. * If the attached mesh should be moved when dragged
  112902. */
  112903. moveAttached: boolean;
  112904. /**
  112905. * If the drag behavior will react to drag events (Default: true)
  112906. */
  112907. enabled: boolean;
  112908. /**
  112909. * If pointer events should start and release the drag (Default: true)
  112910. */
  112911. startAndReleaseDragOnPointerEvents: boolean;
  112912. /**
  112913. * If camera controls should be detached during the drag
  112914. */
  112915. detachCameraControls: boolean;
  112916. /**
  112917. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  112918. */
  112919. useObjectOrientationForDragging: boolean;
  112920. private _options;
  112921. /**
  112922. * Gets the options used by the behavior
  112923. */
  112924. get options(): {
  112925. dragAxis?: Vector3;
  112926. dragPlaneNormal?: Vector3;
  112927. };
  112928. /**
  112929. * Sets the options used by the behavior
  112930. */
  112931. set options(options: {
  112932. dragAxis?: Vector3;
  112933. dragPlaneNormal?: Vector3;
  112934. });
  112935. /**
  112936. * Creates a pointer drag behavior that can be attached to a mesh
  112937. * @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)
  112938. */
  112939. constructor(options?: {
  112940. dragAxis?: Vector3;
  112941. dragPlaneNormal?: Vector3;
  112942. });
  112943. /**
  112944. * Predicate to determine if it is valid to move the object to a new position when it is moved
  112945. */
  112946. validateDrag: (targetPosition: Vector3) => boolean;
  112947. /**
  112948. * The name of the behavior
  112949. */
  112950. get name(): string;
  112951. /**
  112952. * Initializes the behavior
  112953. */
  112954. init(): void;
  112955. private _tmpVector;
  112956. private _alternatePickedPoint;
  112957. private _worldDragAxis;
  112958. private _targetPosition;
  112959. private _attachedElement;
  112960. /**
  112961. * Attaches the drag behavior the passed in mesh
  112962. * @param ownerNode The mesh that will be dragged around once attached
  112963. * @param predicate Predicate to use for pick filtering
  112964. */
  112965. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  112966. /**
  112967. * Force relase the drag action by code.
  112968. */
  112969. releaseDrag(): void;
  112970. private _startDragRay;
  112971. private _lastPointerRay;
  112972. /**
  112973. * Simulates the start of a pointer drag event on the behavior
  112974. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  112975. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  112976. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  112977. */
  112978. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  112979. private _startDrag;
  112980. private _dragDelta;
  112981. private _moveDrag;
  112982. private _pickWithRayOnDragPlane;
  112983. private _pointA;
  112984. private _pointB;
  112985. private _pointC;
  112986. private _lineA;
  112987. private _lineB;
  112988. private _localAxis;
  112989. private _lookAt;
  112990. private _updateDragPlanePosition;
  112991. /**
  112992. * Detaches the behavior from the mesh
  112993. */
  112994. detach(): void;
  112995. }
  112996. }
  112997. declare module BABYLON {
  112998. /**
  112999. * A behavior that when attached to a mesh will allow the mesh to be scaled
  113000. */
  113001. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  113002. private _dragBehaviorA;
  113003. private _dragBehaviorB;
  113004. private _startDistance;
  113005. private _initialScale;
  113006. private _targetScale;
  113007. private _ownerNode;
  113008. private _sceneRenderObserver;
  113009. /**
  113010. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  113011. */
  113012. constructor();
  113013. /**
  113014. * The name of the behavior
  113015. */
  113016. get name(): string;
  113017. /**
  113018. * Initializes the behavior
  113019. */
  113020. init(): void;
  113021. private _getCurrentDistance;
  113022. /**
  113023. * Attaches the scale behavior the passed in mesh
  113024. * @param ownerNode The mesh that will be scaled around once attached
  113025. */
  113026. attach(ownerNode: Mesh): void;
  113027. /**
  113028. * Detaches the behavior from the mesh
  113029. */
  113030. detach(): void;
  113031. }
  113032. }
  113033. declare module BABYLON {
  113034. /**
  113035. * 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
  113036. */
  113037. export class SixDofDragBehavior implements Behavior<Mesh> {
  113038. private static _virtualScene;
  113039. private _ownerNode;
  113040. private _sceneRenderObserver;
  113041. private _scene;
  113042. private _targetPosition;
  113043. private _virtualOriginMesh;
  113044. private _virtualDragMesh;
  113045. private _pointerObserver;
  113046. private _moving;
  113047. private _startingOrientation;
  113048. /**
  113049. * 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)
  113050. */
  113051. private zDragFactor;
  113052. /**
  113053. * If the object should rotate to face the drag origin
  113054. */
  113055. rotateDraggedObject: boolean;
  113056. /**
  113057. * If the behavior is currently in a dragging state
  113058. */
  113059. dragging: boolean;
  113060. /**
  113061. * 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)
  113062. */
  113063. dragDeltaRatio: number;
  113064. /**
  113065. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  113066. */
  113067. currentDraggingPointerID: number;
  113068. /**
  113069. * If camera controls should be detached during the drag
  113070. */
  113071. detachCameraControls: boolean;
  113072. /**
  113073. * Fires each time a drag starts
  113074. */
  113075. onDragStartObservable: Observable<{}>;
  113076. /**
  113077. * Fires each time a drag ends (eg. mouse release after drag)
  113078. */
  113079. onDragEndObservable: Observable<{}>;
  113080. /**
  113081. * 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
  113082. */
  113083. constructor();
  113084. /**
  113085. * The name of the behavior
  113086. */
  113087. get name(): string;
  113088. /**
  113089. * Initializes the behavior
  113090. */
  113091. init(): void;
  113092. /**
  113093. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  113094. */
  113095. private get _pointerCamera();
  113096. /**
  113097. * Attaches the scale behavior the passed in mesh
  113098. * @param ownerNode The mesh that will be scaled around once attached
  113099. */
  113100. attach(ownerNode: Mesh): void;
  113101. /**
  113102. * Detaches the behavior from the mesh
  113103. */
  113104. detach(): void;
  113105. }
  113106. }
  113107. declare module BABYLON {
  113108. /**
  113109. * Class used to apply inverse kinematics to bones
  113110. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  113111. */
  113112. export class BoneIKController {
  113113. private static _tmpVecs;
  113114. private static _tmpQuat;
  113115. private static _tmpMats;
  113116. /**
  113117. * Gets or sets the target mesh
  113118. */
  113119. targetMesh: AbstractMesh;
  113120. /** Gets or sets the mesh used as pole */
  113121. poleTargetMesh: AbstractMesh;
  113122. /**
  113123. * Gets or sets the bone used as pole
  113124. */
  113125. poleTargetBone: Nullable<Bone>;
  113126. /**
  113127. * Gets or sets the target position
  113128. */
  113129. targetPosition: Vector3;
  113130. /**
  113131. * Gets or sets the pole target position
  113132. */
  113133. poleTargetPosition: Vector3;
  113134. /**
  113135. * Gets or sets the pole target local offset
  113136. */
  113137. poleTargetLocalOffset: Vector3;
  113138. /**
  113139. * Gets or sets the pole angle
  113140. */
  113141. poleAngle: number;
  113142. /**
  113143. * Gets or sets the mesh associated with the controller
  113144. */
  113145. mesh: AbstractMesh;
  113146. /**
  113147. * 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)
  113148. */
  113149. slerpAmount: number;
  113150. private _bone1Quat;
  113151. private _bone1Mat;
  113152. private _bone2Ang;
  113153. private _bone1;
  113154. private _bone2;
  113155. private _bone1Length;
  113156. private _bone2Length;
  113157. private _maxAngle;
  113158. private _maxReach;
  113159. private _rightHandedSystem;
  113160. private _bendAxis;
  113161. private _slerping;
  113162. private _adjustRoll;
  113163. /**
  113164. * Gets or sets maximum allowed angle
  113165. */
  113166. get maxAngle(): number;
  113167. set maxAngle(value: number);
  113168. /**
  113169. * Creates a new BoneIKController
  113170. * @param mesh defines the mesh to control
  113171. * @param bone defines the bone to control
  113172. * @param options defines options to set up the controller
  113173. */
  113174. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  113175. targetMesh?: AbstractMesh;
  113176. poleTargetMesh?: AbstractMesh;
  113177. poleTargetBone?: Bone;
  113178. poleTargetLocalOffset?: Vector3;
  113179. poleAngle?: number;
  113180. bendAxis?: Vector3;
  113181. maxAngle?: number;
  113182. slerpAmount?: number;
  113183. });
  113184. private _setMaxAngle;
  113185. /**
  113186. * Force the controller to update the bones
  113187. */
  113188. update(): void;
  113189. }
  113190. }
  113191. declare module BABYLON {
  113192. /**
  113193. * Class used to make a bone look toward a point in space
  113194. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  113195. */
  113196. export class BoneLookController {
  113197. private static _tmpVecs;
  113198. private static _tmpQuat;
  113199. private static _tmpMats;
  113200. /**
  113201. * The target Vector3 that the bone will look at
  113202. */
  113203. target: Vector3;
  113204. /**
  113205. * The mesh that the bone is attached to
  113206. */
  113207. mesh: AbstractMesh;
  113208. /**
  113209. * The bone that will be looking to the target
  113210. */
  113211. bone: Bone;
  113212. /**
  113213. * The up axis of the coordinate system that is used when the bone is rotated
  113214. */
  113215. upAxis: Vector3;
  113216. /**
  113217. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  113218. */
  113219. upAxisSpace: Space;
  113220. /**
  113221. * Used to make an adjustment to the yaw of the bone
  113222. */
  113223. adjustYaw: number;
  113224. /**
  113225. * Used to make an adjustment to the pitch of the bone
  113226. */
  113227. adjustPitch: number;
  113228. /**
  113229. * Used to make an adjustment to the roll of the bone
  113230. */
  113231. adjustRoll: number;
  113232. /**
  113233. * 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)
  113234. */
  113235. slerpAmount: number;
  113236. private _minYaw;
  113237. private _maxYaw;
  113238. private _minPitch;
  113239. private _maxPitch;
  113240. private _minYawSin;
  113241. private _minYawCos;
  113242. private _maxYawSin;
  113243. private _maxYawCos;
  113244. private _midYawConstraint;
  113245. private _minPitchTan;
  113246. private _maxPitchTan;
  113247. private _boneQuat;
  113248. private _slerping;
  113249. private _transformYawPitch;
  113250. private _transformYawPitchInv;
  113251. private _firstFrameSkipped;
  113252. private _yawRange;
  113253. private _fowardAxis;
  113254. /**
  113255. * Gets or sets the minimum yaw angle that the bone can look to
  113256. */
  113257. get minYaw(): number;
  113258. set minYaw(value: number);
  113259. /**
  113260. * Gets or sets the maximum yaw angle that the bone can look to
  113261. */
  113262. get maxYaw(): number;
  113263. set maxYaw(value: number);
  113264. /**
  113265. * Gets or sets the minimum pitch angle that the bone can look to
  113266. */
  113267. get minPitch(): number;
  113268. set minPitch(value: number);
  113269. /**
  113270. * Gets or sets the maximum pitch angle that the bone can look to
  113271. */
  113272. get maxPitch(): number;
  113273. set maxPitch(value: number);
  113274. /**
  113275. * Create a BoneLookController
  113276. * @param mesh the mesh that the bone belongs to
  113277. * @param bone the bone that will be looking to the target
  113278. * @param target the target Vector3 to look at
  113279. * @param options optional settings:
  113280. * * maxYaw: the maximum angle the bone will yaw to
  113281. * * minYaw: the minimum angle the bone will yaw to
  113282. * * maxPitch: the maximum angle the bone will pitch to
  113283. * * minPitch: the minimum angle the bone will yaw to
  113284. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  113285. * * upAxis: the up axis of the coordinate system
  113286. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  113287. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  113288. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  113289. * * adjustYaw: used to make an adjustment to the yaw of the bone
  113290. * * adjustPitch: used to make an adjustment to the pitch of the bone
  113291. * * adjustRoll: used to make an adjustment to the roll of the bone
  113292. **/
  113293. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  113294. maxYaw?: number;
  113295. minYaw?: number;
  113296. maxPitch?: number;
  113297. minPitch?: number;
  113298. slerpAmount?: number;
  113299. upAxis?: Vector3;
  113300. upAxisSpace?: Space;
  113301. yawAxis?: Vector3;
  113302. pitchAxis?: Vector3;
  113303. adjustYaw?: number;
  113304. adjustPitch?: number;
  113305. adjustRoll?: number;
  113306. });
  113307. /**
  113308. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  113309. */
  113310. update(): void;
  113311. private _getAngleDiff;
  113312. private _getAngleBetween;
  113313. private _isAngleBetween;
  113314. }
  113315. }
  113316. declare module BABYLON {
  113317. /**
  113318. * Manage the gamepad inputs to control an arc rotate camera.
  113319. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113320. */
  113321. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  113322. /**
  113323. * Defines the camera the input is attached to.
  113324. */
  113325. camera: ArcRotateCamera;
  113326. /**
  113327. * Defines the gamepad the input is gathering event from.
  113328. */
  113329. gamepad: Nullable<Gamepad>;
  113330. /**
  113331. * Defines the gamepad rotation sensiblity.
  113332. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  113333. */
  113334. gamepadRotationSensibility: number;
  113335. /**
  113336. * Defines the gamepad move sensiblity.
  113337. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  113338. */
  113339. gamepadMoveSensibility: number;
  113340. private _yAxisScale;
  113341. /**
  113342. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  113343. */
  113344. get invertYAxis(): boolean;
  113345. set invertYAxis(value: boolean);
  113346. private _onGamepadConnectedObserver;
  113347. private _onGamepadDisconnectedObserver;
  113348. /**
  113349. * Attach the input controls to a specific dom element to get the input from.
  113350. * @param element Defines the element the controls should be listened from
  113351. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113352. */
  113353. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113354. /**
  113355. * Detach the current controls from the specified dom element.
  113356. * @param element Defines the element to stop listening the inputs from
  113357. */
  113358. detachControl(element: Nullable<HTMLElement>): void;
  113359. /**
  113360. * Update the current camera state depending on the inputs that have been used this frame.
  113361. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113362. */
  113363. checkInputs(): void;
  113364. /**
  113365. * Gets the class name of the current intput.
  113366. * @returns the class name
  113367. */
  113368. getClassName(): string;
  113369. /**
  113370. * Get the friendly name associated with the input class.
  113371. * @returns the input friendly name
  113372. */
  113373. getSimpleName(): string;
  113374. }
  113375. }
  113376. declare module BABYLON {
  113377. interface ArcRotateCameraInputsManager {
  113378. /**
  113379. * Add orientation input support to the input manager.
  113380. * @returns the current input manager
  113381. */
  113382. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  113383. }
  113384. /**
  113385. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  113386. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113387. */
  113388. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  113389. /**
  113390. * Defines the camera the input is attached to.
  113391. */
  113392. camera: ArcRotateCamera;
  113393. /**
  113394. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  113395. */
  113396. alphaCorrection: number;
  113397. /**
  113398. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  113399. */
  113400. gammaCorrection: number;
  113401. private _alpha;
  113402. private _gamma;
  113403. private _dirty;
  113404. private _deviceOrientationHandler;
  113405. /**
  113406. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  113407. */
  113408. constructor();
  113409. /**
  113410. * Attach the input controls to a specific dom element to get the input from.
  113411. * @param element Defines the element the controls should be listened from
  113412. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113413. */
  113414. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113415. /** @hidden */
  113416. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  113417. /**
  113418. * Update the current camera state depending on the inputs that have been used this frame.
  113419. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113420. */
  113421. checkInputs(): void;
  113422. /**
  113423. * Detach the current controls from the specified dom element.
  113424. * @param element Defines the element to stop listening the inputs from
  113425. */
  113426. detachControl(element: Nullable<HTMLElement>): void;
  113427. /**
  113428. * Gets the class name of the current intput.
  113429. * @returns the class name
  113430. */
  113431. getClassName(): string;
  113432. /**
  113433. * Get the friendly name associated with the input class.
  113434. * @returns the input friendly name
  113435. */
  113436. getSimpleName(): string;
  113437. }
  113438. }
  113439. declare module BABYLON {
  113440. /**
  113441. * Listen to mouse events to control the camera.
  113442. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113443. */
  113444. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  113445. /**
  113446. * Defines the camera the input is attached to.
  113447. */
  113448. camera: FlyCamera;
  113449. /**
  113450. * Defines if touch is enabled. (Default is true.)
  113451. */
  113452. touchEnabled: boolean;
  113453. /**
  113454. * Defines the buttons associated with the input to handle camera rotation.
  113455. */
  113456. buttons: number[];
  113457. /**
  113458. * Assign buttons for Yaw control.
  113459. */
  113460. buttonsYaw: number[];
  113461. /**
  113462. * Assign buttons for Pitch control.
  113463. */
  113464. buttonsPitch: number[];
  113465. /**
  113466. * Assign buttons for Roll control.
  113467. */
  113468. buttonsRoll: number[];
  113469. /**
  113470. * Detect if any button is being pressed while mouse is moved.
  113471. * -1 = Mouse locked.
  113472. * 0 = Left button.
  113473. * 1 = Middle Button.
  113474. * 2 = Right Button.
  113475. */
  113476. activeButton: number;
  113477. /**
  113478. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  113479. * Higher values reduce its sensitivity.
  113480. */
  113481. angularSensibility: number;
  113482. private _mousemoveCallback;
  113483. private _observer;
  113484. private _rollObserver;
  113485. private previousPosition;
  113486. private noPreventDefault;
  113487. private element;
  113488. /**
  113489. * Listen to mouse events to control the camera.
  113490. * @param touchEnabled Define if touch is enabled. (Default is true.)
  113491. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113492. */
  113493. constructor(touchEnabled?: boolean);
  113494. /**
  113495. * Attach the mouse control to the HTML DOM element.
  113496. * @param element Defines the element that listens to the input events.
  113497. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  113498. */
  113499. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113500. /**
  113501. * Detach the current controls from the specified dom element.
  113502. * @param element Defines the element to stop listening the inputs from
  113503. */
  113504. detachControl(element: Nullable<HTMLElement>): void;
  113505. /**
  113506. * Gets the class name of the current input.
  113507. * @returns the class name.
  113508. */
  113509. getClassName(): string;
  113510. /**
  113511. * Get the friendly name associated with the input class.
  113512. * @returns the input's friendly name.
  113513. */
  113514. getSimpleName(): string;
  113515. private _pointerInput;
  113516. private _onMouseMove;
  113517. /**
  113518. * Rotate camera by mouse offset.
  113519. */
  113520. private rotateCamera;
  113521. }
  113522. }
  113523. declare module BABYLON {
  113524. /**
  113525. * Default Inputs manager for the FlyCamera.
  113526. * It groups all the default supported inputs for ease of use.
  113527. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113528. */
  113529. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  113530. /**
  113531. * Instantiates a new FlyCameraInputsManager.
  113532. * @param camera Defines the camera the inputs belong to.
  113533. */
  113534. constructor(camera: FlyCamera);
  113535. /**
  113536. * Add keyboard input support to the input manager.
  113537. * @returns the new FlyCameraKeyboardMoveInput().
  113538. */
  113539. addKeyboard(): FlyCameraInputsManager;
  113540. /**
  113541. * Add mouse input support to the input manager.
  113542. * @param touchEnabled Enable touch screen support.
  113543. * @returns the new FlyCameraMouseInput().
  113544. */
  113545. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  113546. }
  113547. }
  113548. declare module BABYLON {
  113549. /**
  113550. * This is a flying camera, designed for 3D movement and rotation in all directions,
  113551. * such as in a 3D Space Shooter or a Flight Simulator.
  113552. */
  113553. export class FlyCamera extends TargetCamera {
  113554. /**
  113555. * Define the collision ellipsoid of the camera.
  113556. * This is helpful for simulating a camera body, like a player's body.
  113557. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  113558. */
  113559. ellipsoid: Vector3;
  113560. /**
  113561. * Define an offset for the position of the ellipsoid around the camera.
  113562. * This can be helpful if the camera is attached away from the player's body center,
  113563. * such as at its head.
  113564. */
  113565. ellipsoidOffset: Vector3;
  113566. /**
  113567. * Enable or disable collisions of the camera with the rest of the scene objects.
  113568. */
  113569. checkCollisions: boolean;
  113570. /**
  113571. * Enable or disable gravity on the camera.
  113572. */
  113573. applyGravity: boolean;
  113574. /**
  113575. * Define the current direction the camera is moving to.
  113576. */
  113577. cameraDirection: Vector3;
  113578. /**
  113579. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  113580. * This overrides and empties cameraRotation.
  113581. */
  113582. rotationQuaternion: Quaternion;
  113583. /**
  113584. * Track Roll to maintain the wanted Rolling when looking around.
  113585. */
  113586. _trackRoll: number;
  113587. /**
  113588. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  113589. */
  113590. rollCorrect: number;
  113591. /**
  113592. * Mimic a banked turn, Rolling the camera when Yawing.
  113593. * It's recommended to use rollCorrect = 10 for faster banking correction.
  113594. */
  113595. bankedTurn: boolean;
  113596. /**
  113597. * Limit in radians for how much Roll banking will add. (Default: 90°)
  113598. */
  113599. bankedTurnLimit: number;
  113600. /**
  113601. * Value of 0 disables the banked Roll.
  113602. * Value of 1 is equal to the Yaw angle in radians.
  113603. */
  113604. bankedTurnMultiplier: number;
  113605. /**
  113606. * The inputs manager loads all the input sources, such as keyboard and mouse.
  113607. */
  113608. inputs: FlyCameraInputsManager;
  113609. /**
  113610. * Gets the input sensibility for mouse input.
  113611. * Higher values reduce sensitivity.
  113612. */
  113613. get angularSensibility(): number;
  113614. /**
  113615. * Sets the input sensibility for a mouse input.
  113616. * Higher values reduce sensitivity.
  113617. */
  113618. set angularSensibility(value: number);
  113619. /**
  113620. * Get the keys for camera movement forward.
  113621. */
  113622. get keysForward(): number[];
  113623. /**
  113624. * Set the keys for camera movement forward.
  113625. */
  113626. set keysForward(value: number[]);
  113627. /**
  113628. * Get the keys for camera movement backward.
  113629. */
  113630. get keysBackward(): number[];
  113631. set keysBackward(value: number[]);
  113632. /**
  113633. * Get the keys for camera movement up.
  113634. */
  113635. get keysUp(): number[];
  113636. /**
  113637. * Set the keys for camera movement up.
  113638. */
  113639. set keysUp(value: number[]);
  113640. /**
  113641. * Get the keys for camera movement down.
  113642. */
  113643. get keysDown(): number[];
  113644. /**
  113645. * Set the keys for camera movement down.
  113646. */
  113647. set keysDown(value: number[]);
  113648. /**
  113649. * Get the keys for camera movement left.
  113650. */
  113651. get keysLeft(): number[];
  113652. /**
  113653. * Set the keys for camera movement left.
  113654. */
  113655. set keysLeft(value: number[]);
  113656. /**
  113657. * Set the keys for camera movement right.
  113658. */
  113659. get keysRight(): number[];
  113660. /**
  113661. * Set the keys for camera movement right.
  113662. */
  113663. set keysRight(value: number[]);
  113664. /**
  113665. * Event raised when the camera collides with a mesh in the scene.
  113666. */
  113667. onCollide: (collidedMesh: AbstractMesh) => void;
  113668. private _collider;
  113669. private _needMoveForGravity;
  113670. private _oldPosition;
  113671. private _diffPosition;
  113672. private _newPosition;
  113673. /** @hidden */
  113674. _localDirection: Vector3;
  113675. /** @hidden */
  113676. _transformedDirection: Vector3;
  113677. /**
  113678. * Instantiates a FlyCamera.
  113679. * This is a flying camera, designed for 3D movement and rotation in all directions,
  113680. * such as in a 3D Space Shooter or a Flight Simulator.
  113681. * @param name Define the name of the camera in the scene.
  113682. * @param position Define the starting position of the camera in the scene.
  113683. * @param scene Define the scene the camera belongs to.
  113684. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  113685. */
  113686. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  113687. /**
  113688. * Attach a control to the HTML DOM element.
  113689. * @param element Defines the element that listens to the input events.
  113690. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  113691. */
  113692. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113693. /**
  113694. * Detach a control from the HTML DOM element.
  113695. * The camera will stop reacting to that input.
  113696. * @param element Defines the element that listens to the input events.
  113697. */
  113698. detachControl(element: HTMLElement): void;
  113699. private _collisionMask;
  113700. /**
  113701. * Get the mask that the camera ignores in collision events.
  113702. */
  113703. get collisionMask(): number;
  113704. /**
  113705. * Set the mask that the camera ignores in collision events.
  113706. */
  113707. set collisionMask(mask: number);
  113708. /** @hidden */
  113709. _collideWithWorld(displacement: Vector3): void;
  113710. /** @hidden */
  113711. private _onCollisionPositionChange;
  113712. /** @hidden */
  113713. _checkInputs(): void;
  113714. /** @hidden */
  113715. _decideIfNeedsToMove(): boolean;
  113716. /** @hidden */
  113717. _updatePosition(): void;
  113718. /**
  113719. * Restore the Roll to its target value at the rate specified.
  113720. * @param rate - Higher means slower restoring.
  113721. * @hidden
  113722. */
  113723. restoreRoll(rate: number): void;
  113724. /**
  113725. * Destroy the camera and release the current resources held by it.
  113726. */
  113727. dispose(): void;
  113728. /**
  113729. * Get the current object class name.
  113730. * @returns the class name.
  113731. */
  113732. getClassName(): string;
  113733. }
  113734. }
  113735. declare module BABYLON {
  113736. /**
  113737. * Listen to keyboard events to control the camera.
  113738. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113739. */
  113740. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  113741. /**
  113742. * Defines the camera the input is attached to.
  113743. */
  113744. camera: FlyCamera;
  113745. /**
  113746. * The list of keyboard keys used to control the forward move of the camera.
  113747. */
  113748. keysForward: number[];
  113749. /**
  113750. * The list of keyboard keys used to control the backward move of the camera.
  113751. */
  113752. keysBackward: number[];
  113753. /**
  113754. * The list of keyboard keys used to control the forward move of the camera.
  113755. */
  113756. keysUp: number[];
  113757. /**
  113758. * The list of keyboard keys used to control the backward move of the camera.
  113759. */
  113760. keysDown: number[];
  113761. /**
  113762. * The list of keyboard keys used to control the right strafe move of the camera.
  113763. */
  113764. keysRight: number[];
  113765. /**
  113766. * The list of keyboard keys used to control the left strafe move of the camera.
  113767. */
  113768. keysLeft: number[];
  113769. private _keys;
  113770. private _onCanvasBlurObserver;
  113771. private _onKeyboardObserver;
  113772. private _engine;
  113773. private _scene;
  113774. /**
  113775. * Attach the input controls to a specific dom element to get the input from.
  113776. * @param element Defines the element the controls should be listened from
  113777. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113778. */
  113779. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113780. /**
  113781. * Detach the current controls from the specified dom element.
  113782. * @param element Defines the element to stop listening the inputs from
  113783. */
  113784. detachControl(element: Nullable<HTMLElement>): void;
  113785. /**
  113786. * Gets the class name of the current intput.
  113787. * @returns the class name
  113788. */
  113789. getClassName(): string;
  113790. /** @hidden */
  113791. _onLostFocus(e: FocusEvent): void;
  113792. /**
  113793. * Get the friendly name associated with the input class.
  113794. * @returns the input friendly name
  113795. */
  113796. getSimpleName(): string;
  113797. /**
  113798. * Update the current camera state depending on the inputs that have been used this frame.
  113799. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113800. */
  113801. checkInputs(): void;
  113802. }
  113803. }
  113804. declare module BABYLON {
  113805. /**
  113806. * Manage the mouse wheel inputs to control a follow camera.
  113807. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113808. */
  113809. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  113810. /**
  113811. * Defines the camera the input is attached to.
  113812. */
  113813. camera: FollowCamera;
  113814. /**
  113815. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  113816. */
  113817. axisControlRadius: boolean;
  113818. /**
  113819. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  113820. */
  113821. axisControlHeight: boolean;
  113822. /**
  113823. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  113824. */
  113825. axisControlRotation: boolean;
  113826. /**
  113827. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  113828. * relation to mouseWheel events.
  113829. */
  113830. wheelPrecision: number;
  113831. /**
  113832. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  113833. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  113834. */
  113835. wheelDeltaPercentage: number;
  113836. private _wheel;
  113837. private _observer;
  113838. /**
  113839. * Attach the input controls to a specific dom element to get the input from.
  113840. * @param element Defines the element the controls should be listened from
  113841. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113842. */
  113843. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113844. /**
  113845. * Detach the current controls from the specified dom element.
  113846. * @param element Defines the element to stop listening the inputs from
  113847. */
  113848. detachControl(element: Nullable<HTMLElement>): void;
  113849. /**
  113850. * Gets the class name of the current intput.
  113851. * @returns the class name
  113852. */
  113853. getClassName(): string;
  113854. /**
  113855. * Get the friendly name associated with the input class.
  113856. * @returns the input friendly name
  113857. */
  113858. getSimpleName(): string;
  113859. }
  113860. }
  113861. declare module BABYLON {
  113862. /**
  113863. * Manage the pointers inputs to control an follow camera.
  113864. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113865. */
  113866. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  113867. /**
  113868. * Defines the camera the input is attached to.
  113869. */
  113870. camera: FollowCamera;
  113871. /**
  113872. * Gets the class name of the current input.
  113873. * @returns the class name
  113874. */
  113875. getClassName(): string;
  113876. /**
  113877. * Defines the pointer angular sensibility along the X axis or how fast is
  113878. * the camera rotating.
  113879. * A negative number will reverse the axis direction.
  113880. */
  113881. angularSensibilityX: number;
  113882. /**
  113883. * Defines the pointer angular sensibility along the Y axis or how fast is
  113884. * the camera rotating.
  113885. * A negative number will reverse the axis direction.
  113886. */
  113887. angularSensibilityY: number;
  113888. /**
  113889. * Defines the pointer pinch precision or how fast is the camera zooming.
  113890. * A negative number will reverse the axis direction.
  113891. */
  113892. pinchPrecision: number;
  113893. /**
  113894. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  113895. * from 0.
  113896. * It defines the percentage of current camera.radius to use as delta when
  113897. * pinch zoom is used.
  113898. */
  113899. pinchDeltaPercentage: number;
  113900. /**
  113901. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  113902. */
  113903. axisXControlRadius: boolean;
  113904. /**
  113905. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  113906. */
  113907. axisXControlHeight: boolean;
  113908. /**
  113909. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  113910. */
  113911. axisXControlRotation: boolean;
  113912. /**
  113913. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  113914. */
  113915. axisYControlRadius: boolean;
  113916. /**
  113917. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  113918. */
  113919. axisYControlHeight: boolean;
  113920. /**
  113921. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  113922. */
  113923. axisYControlRotation: boolean;
  113924. /**
  113925. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  113926. */
  113927. axisPinchControlRadius: boolean;
  113928. /**
  113929. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  113930. */
  113931. axisPinchControlHeight: boolean;
  113932. /**
  113933. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  113934. */
  113935. axisPinchControlRotation: boolean;
  113936. /**
  113937. * Log error messages if basic misconfiguration has occurred.
  113938. */
  113939. warningEnable: boolean;
  113940. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  113941. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  113942. private _warningCounter;
  113943. private _warning;
  113944. }
  113945. }
  113946. declare module BABYLON {
  113947. /**
  113948. * Default Inputs manager for the FollowCamera.
  113949. * It groups all the default supported inputs for ease of use.
  113950. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113951. */
  113952. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  113953. /**
  113954. * Instantiates a new FollowCameraInputsManager.
  113955. * @param camera Defines the camera the inputs belong to
  113956. */
  113957. constructor(camera: FollowCamera);
  113958. /**
  113959. * Add keyboard input support to the input manager.
  113960. * @returns the current input manager
  113961. */
  113962. addKeyboard(): FollowCameraInputsManager;
  113963. /**
  113964. * Add mouse wheel input support to the input manager.
  113965. * @returns the current input manager
  113966. */
  113967. addMouseWheel(): FollowCameraInputsManager;
  113968. /**
  113969. * Add pointers input support to the input manager.
  113970. * @returns the current input manager
  113971. */
  113972. addPointers(): FollowCameraInputsManager;
  113973. /**
  113974. * Add orientation input support to the input manager.
  113975. * @returns the current input manager
  113976. */
  113977. addVRDeviceOrientation(): FollowCameraInputsManager;
  113978. }
  113979. }
  113980. declare module BABYLON {
  113981. /**
  113982. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  113983. * an arc rotate version arcFollowCamera are available.
  113984. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113985. */
  113986. export class FollowCamera extends TargetCamera {
  113987. /**
  113988. * Distance the follow camera should follow an object at
  113989. */
  113990. radius: number;
  113991. /**
  113992. * Minimum allowed distance of the camera to the axis of rotation
  113993. * (The camera can not get closer).
  113994. * This can help limiting how the Camera is able to move in the scene.
  113995. */
  113996. lowerRadiusLimit: Nullable<number>;
  113997. /**
  113998. * Maximum allowed distance of the camera to the axis of rotation
  113999. * (The camera can not get further).
  114000. * This can help limiting how the Camera is able to move in the scene.
  114001. */
  114002. upperRadiusLimit: Nullable<number>;
  114003. /**
  114004. * Define a rotation offset between the camera and the object it follows
  114005. */
  114006. rotationOffset: number;
  114007. /**
  114008. * Minimum allowed angle to camera position relative to target object.
  114009. * This can help limiting how the Camera is able to move in the scene.
  114010. */
  114011. lowerRotationOffsetLimit: Nullable<number>;
  114012. /**
  114013. * Maximum allowed angle to camera position relative to target object.
  114014. * This can help limiting how the Camera is able to move in the scene.
  114015. */
  114016. upperRotationOffsetLimit: Nullable<number>;
  114017. /**
  114018. * Define a height offset between the camera and the object it follows.
  114019. * It can help following an object from the top (like a car chaing a plane)
  114020. */
  114021. heightOffset: number;
  114022. /**
  114023. * Minimum allowed height of camera position relative to target object.
  114024. * This can help limiting how the Camera is able to move in the scene.
  114025. */
  114026. lowerHeightOffsetLimit: Nullable<number>;
  114027. /**
  114028. * Maximum allowed height of camera position relative to target object.
  114029. * This can help limiting how the Camera is able to move in the scene.
  114030. */
  114031. upperHeightOffsetLimit: Nullable<number>;
  114032. /**
  114033. * Define how fast the camera can accelerate to follow it s target.
  114034. */
  114035. cameraAcceleration: number;
  114036. /**
  114037. * Define the speed limit of the camera following an object.
  114038. */
  114039. maxCameraSpeed: number;
  114040. /**
  114041. * Define the target of the camera.
  114042. */
  114043. lockedTarget: Nullable<AbstractMesh>;
  114044. /**
  114045. * Defines the input associated with the camera.
  114046. */
  114047. inputs: FollowCameraInputsManager;
  114048. /**
  114049. * Instantiates the follow camera.
  114050. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  114051. * @param name Define the name of the camera in the scene
  114052. * @param position Define the position of the camera
  114053. * @param scene Define the scene the camera belong to
  114054. * @param lockedTarget Define the target of the camera
  114055. */
  114056. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  114057. private _follow;
  114058. /**
  114059. * Attached controls to the current camera.
  114060. * @param element Defines the element the controls should be listened from
  114061. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114062. */
  114063. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114064. /**
  114065. * Detach the current controls from the camera.
  114066. * The camera will stop reacting to inputs.
  114067. * @param element Defines the element to stop listening the inputs from
  114068. */
  114069. detachControl(element: HTMLElement): void;
  114070. /** @hidden */
  114071. _checkInputs(): void;
  114072. private _checkLimits;
  114073. /**
  114074. * Gets the camera class name.
  114075. * @returns the class name
  114076. */
  114077. getClassName(): string;
  114078. }
  114079. /**
  114080. * Arc Rotate version of the follow camera.
  114081. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  114082. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  114083. */
  114084. export class ArcFollowCamera extends TargetCamera {
  114085. /** The longitudinal angle of the camera */
  114086. alpha: number;
  114087. /** The latitudinal angle of the camera */
  114088. beta: number;
  114089. /** The radius of the camera from its target */
  114090. radius: number;
  114091. /** Define the camera target (the messh it should follow) */
  114092. target: Nullable<AbstractMesh>;
  114093. private _cartesianCoordinates;
  114094. /**
  114095. * Instantiates a new ArcFollowCamera
  114096. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  114097. * @param name Define the name of the camera
  114098. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  114099. * @param beta Define the rotation angle of the camera around the elevation axis
  114100. * @param radius Define the radius of the camera from its target point
  114101. * @param target Define the target of the camera
  114102. * @param scene Define the scene the camera belongs to
  114103. */
  114104. constructor(name: string,
  114105. /** The longitudinal angle of the camera */
  114106. alpha: number,
  114107. /** The latitudinal angle of the camera */
  114108. beta: number,
  114109. /** The radius of the camera from its target */
  114110. radius: number,
  114111. /** Define the camera target (the messh it should follow) */
  114112. target: Nullable<AbstractMesh>, scene: Scene);
  114113. private _follow;
  114114. /** @hidden */
  114115. _checkInputs(): void;
  114116. /**
  114117. * Returns the class name of the object.
  114118. * It is mostly used internally for serialization purposes.
  114119. */
  114120. getClassName(): string;
  114121. }
  114122. }
  114123. declare module BABYLON {
  114124. /**
  114125. * Manage the keyboard inputs to control the movement of a follow camera.
  114126. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114127. */
  114128. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  114129. /**
  114130. * Defines the camera the input is attached to.
  114131. */
  114132. camera: FollowCamera;
  114133. /**
  114134. * Defines the list of key codes associated with the up action (increase heightOffset)
  114135. */
  114136. keysHeightOffsetIncr: number[];
  114137. /**
  114138. * Defines the list of key codes associated with the down action (decrease heightOffset)
  114139. */
  114140. keysHeightOffsetDecr: number[];
  114141. /**
  114142. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  114143. */
  114144. keysHeightOffsetModifierAlt: boolean;
  114145. /**
  114146. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  114147. */
  114148. keysHeightOffsetModifierCtrl: boolean;
  114149. /**
  114150. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  114151. */
  114152. keysHeightOffsetModifierShift: boolean;
  114153. /**
  114154. * Defines the list of key codes associated with the left action (increase rotationOffset)
  114155. */
  114156. keysRotationOffsetIncr: number[];
  114157. /**
  114158. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  114159. */
  114160. keysRotationOffsetDecr: number[];
  114161. /**
  114162. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  114163. */
  114164. keysRotationOffsetModifierAlt: boolean;
  114165. /**
  114166. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  114167. */
  114168. keysRotationOffsetModifierCtrl: boolean;
  114169. /**
  114170. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  114171. */
  114172. keysRotationOffsetModifierShift: boolean;
  114173. /**
  114174. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  114175. */
  114176. keysRadiusIncr: number[];
  114177. /**
  114178. * Defines the list of key codes associated with the zoom-out action (increase radius)
  114179. */
  114180. keysRadiusDecr: number[];
  114181. /**
  114182. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  114183. */
  114184. keysRadiusModifierAlt: boolean;
  114185. /**
  114186. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  114187. */
  114188. keysRadiusModifierCtrl: boolean;
  114189. /**
  114190. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  114191. */
  114192. keysRadiusModifierShift: boolean;
  114193. /**
  114194. * Defines the rate of change of heightOffset.
  114195. */
  114196. heightSensibility: number;
  114197. /**
  114198. * Defines the rate of change of rotationOffset.
  114199. */
  114200. rotationSensibility: number;
  114201. /**
  114202. * Defines the rate of change of radius.
  114203. */
  114204. radiusSensibility: number;
  114205. private _keys;
  114206. private _ctrlPressed;
  114207. private _altPressed;
  114208. private _shiftPressed;
  114209. private _onCanvasBlurObserver;
  114210. private _onKeyboardObserver;
  114211. private _engine;
  114212. private _scene;
  114213. /**
  114214. * Attach the input controls to a specific dom element to get the input from.
  114215. * @param element Defines the element the controls should be listened from
  114216. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114217. */
  114218. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114219. /**
  114220. * Detach the current controls from the specified dom element.
  114221. * @param element Defines the element to stop listening the inputs from
  114222. */
  114223. detachControl(element: Nullable<HTMLElement>): void;
  114224. /**
  114225. * Update the current camera state depending on the inputs that have been used this frame.
  114226. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114227. */
  114228. checkInputs(): void;
  114229. /**
  114230. * Gets the class name of the current input.
  114231. * @returns the class name
  114232. */
  114233. getClassName(): string;
  114234. /**
  114235. * Get the friendly name associated with the input class.
  114236. * @returns the input friendly name
  114237. */
  114238. getSimpleName(): string;
  114239. /**
  114240. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  114241. * allow modification of the heightOffset value.
  114242. */
  114243. private _modifierHeightOffset;
  114244. /**
  114245. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  114246. * allow modification of the rotationOffset value.
  114247. */
  114248. private _modifierRotationOffset;
  114249. /**
  114250. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  114251. * allow modification of the radius value.
  114252. */
  114253. private _modifierRadius;
  114254. }
  114255. }
  114256. declare module BABYLON {
  114257. interface FreeCameraInputsManager {
  114258. /**
  114259. * @hidden
  114260. */
  114261. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  114262. /**
  114263. * Add orientation input support to the input manager.
  114264. * @returns the current input manager
  114265. */
  114266. addDeviceOrientation(): FreeCameraInputsManager;
  114267. }
  114268. /**
  114269. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  114270. * Screen rotation is taken into account.
  114271. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114272. */
  114273. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  114274. private _camera;
  114275. private _screenOrientationAngle;
  114276. private _constantTranform;
  114277. private _screenQuaternion;
  114278. private _alpha;
  114279. private _beta;
  114280. private _gamma;
  114281. /**
  114282. * Can be used to detect if a device orientation sensor is available on a device
  114283. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  114284. * @returns a promise that will resolve on orientation change
  114285. */
  114286. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  114287. /**
  114288. * @hidden
  114289. */
  114290. _onDeviceOrientationChangedObservable: Observable<void>;
  114291. /**
  114292. * Instantiates a new input
  114293. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114294. */
  114295. constructor();
  114296. /**
  114297. * Define the camera controlled by the input.
  114298. */
  114299. get camera(): FreeCamera;
  114300. set camera(camera: FreeCamera);
  114301. /**
  114302. * Attach the input controls to a specific dom element to get the input from.
  114303. * @param element Defines the element the controls should be listened from
  114304. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114305. */
  114306. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114307. private _orientationChanged;
  114308. private _deviceOrientation;
  114309. /**
  114310. * Detach the current controls from the specified dom element.
  114311. * @param element Defines the element to stop listening the inputs from
  114312. */
  114313. detachControl(element: Nullable<HTMLElement>): void;
  114314. /**
  114315. * Update the current camera state depending on the inputs that have been used this frame.
  114316. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114317. */
  114318. checkInputs(): void;
  114319. /**
  114320. * Gets the class name of the current intput.
  114321. * @returns the class name
  114322. */
  114323. getClassName(): string;
  114324. /**
  114325. * Get the friendly name associated with the input class.
  114326. * @returns the input friendly name
  114327. */
  114328. getSimpleName(): string;
  114329. }
  114330. }
  114331. declare module BABYLON {
  114332. /**
  114333. * Manage the gamepad inputs to control a free camera.
  114334. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114335. */
  114336. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  114337. /**
  114338. * Define the camera the input is attached to.
  114339. */
  114340. camera: FreeCamera;
  114341. /**
  114342. * Define the Gamepad controlling the input
  114343. */
  114344. gamepad: Nullable<Gamepad>;
  114345. /**
  114346. * Defines the gamepad rotation sensiblity.
  114347. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  114348. */
  114349. gamepadAngularSensibility: number;
  114350. /**
  114351. * Defines the gamepad move sensiblity.
  114352. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  114353. */
  114354. gamepadMoveSensibility: number;
  114355. private _yAxisScale;
  114356. /**
  114357. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  114358. */
  114359. get invertYAxis(): boolean;
  114360. set invertYAxis(value: boolean);
  114361. private _onGamepadConnectedObserver;
  114362. private _onGamepadDisconnectedObserver;
  114363. private _cameraTransform;
  114364. private _deltaTransform;
  114365. private _vector3;
  114366. private _vector2;
  114367. /**
  114368. * Attach the input controls to a specific dom element to get the input from.
  114369. * @param element Defines the element the controls should be listened from
  114370. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114371. */
  114372. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114373. /**
  114374. * Detach the current controls from the specified dom element.
  114375. * @param element Defines the element to stop listening the inputs from
  114376. */
  114377. detachControl(element: Nullable<HTMLElement>): void;
  114378. /**
  114379. * Update the current camera state depending on the inputs that have been used this frame.
  114380. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114381. */
  114382. checkInputs(): void;
  114383. /**
  114384. * Gets the class name of the current intput.
  114385. * @returns the class name
  114386. */
  114387. getClassName(): string;
  114388. /**
  114389. * Get the friendly name associated with the input class.
  114390. * @returns the input friendly name
  114391. */
  114392. getSimpleName(): string;
  114393. }
  114394. }
  114395. declare module BABYLON {
  114396. /**
  114397. * Defines the potential axis of a Joystick
  114398. */
  114399. export enum JoystickAxis {
  114400. /** X axis */
  114401. X = 0,
  114402. /** Y axis */
  114403. Y = 1,
  114404. /** Z axis */
  114405. Z = 2
  114406. }
  114407. /**
  114408. * Class used to define virtual joystick (used in touch mode)
  114409. */
  114410. export class VirtualJoystick {
  114411. /**
  114412. * Gets or sets a boolean indicating that left and right values must be inverted
  114413. */
  114414. reverseLeftRight: boolean;
  114415. /**
  114416. * Gets or sets a boolean indicating that up and down values must be inverted
  114417. */
  114418. reverseUpDown: boolean;
  114419. /**
  114420. * Gets the offset value for the position (ie. the change of the position value)
  114421. */
  114422. deltaPosition: Vector3;
  114423. /**
  114424. * Gets a boolean indicating if the virtual joystick was pressed
  114425. */
  114426. pressed: boolean;
  114427. /**
  114428. * Canvas the virtual joystick will render onto, default z-index of this is 5
  114429. */
  114430. static Canvas: Nullable<HTMLCanvasElement>;
  114431. private static _globalJoystickIndex;
  114432. private static vjCanvasContext;
  114433. private static vjCanvasWidth;
  114434. private static vjCanvasHeight;
  114435. private static halfWidth;
  114436. private _action;
  114437. private _axisTargetedByLeftAndRight;
  114438. private _axisTargetedByUpAndDown;
  114439. private _joystickSensibility;
  114440. private _inversedSensibility;
  114441. private _joystickPointerID;
  114442. private _joystickColor;
  114443. private _joystickPointerPos;
  114444. private _joystickPreviousPointerPos;
  114445. private _joystickPointerStartPos;
  114446. private _deltaJoystickVector;
  114447. private _leftJoystick;
  114448. private _touches;
  114449. private _onPointerDownHandlerRef;
  114450. private _onPointerMoveHandlerRef;
  114451. private _onPointerUpHandlerRef;
  114452. private _onResize;
  114453. /**
  114454. * Creates a new virtual joystick
  114455. * @param leftJoystick defines that the joystick is for left hand (false by default)
  114456. */
  114457. constructor(leftJoystick?: boolean);
  114458. /**
  114459. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  114460. * @param newJoystickSensibility defines the new sensibility
  114461. */
  114462. setJoystickSensibility(newJoystickSensibility: number): void;
  114463. private _onPointerDown;
  114464. private _onPointerMove;
  114465. private _onPointerUp;
  114466. /**
  114467. * Change the color of the virtual joystick
  114468. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  114469. */
  114470. setJoystickColor(newColor: string): void;
  114471. /**
  114472. * Defines a callback to call when the joystick is touched
  114473. * @param action defines the callback
  114474. */
  114475. setActionOnTouch(action: () => any): void;
  114476. /**
  114477. * Defines which axis you'd like to control for left & right
  114478. * @param axis defines the axis to use
  114479. */
  114480. setAxisForLeftRight(axis: JoystickAxis): void;
  114481. /**
  114482. * Defines which axis you'd like to control for up & down
  114483. * @param axis defines the axis to use
  114484. */
  114485. setAxisForUpDown(axis: JoystickAxis): void;
  114486. private _drawVirtualJoystick;
  114487. /**
  114488. * Release internal HTML canvas
  114489. */
  114490. releaseCanvas(): void;
  114491. }
  114492. }
  114493. declare module BABYLON {
  114494. interface FreeCameraInputsManager {
  114495. /**
  114496. * Add virtual joystick input support to the input manager.
  114497. * @returns the current input manager
  114498. */
  114499. addVirtualJoystick(): FreeCameraInputsManager;
  114500. }
  114501. /**
  114502. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  114503. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114504. */
  114505. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  114506. /**
  114507. * Defines the camera the input is attached to.
  114508. */
  114509. camera: FreeCamera;
  114510. private _leftjoystick;
  114511. private _rightjoystick;
  114512. /**
  114513. * Gets the left stick of the virtual joystick.
  114514. * @returns The virtual Joystick
  114515. */
  114516. getLeftJoystick(): VirtualJoystick;
  114517. /**
  114518. * Gets the right stick of the virtual joystick.
  114519. * @returns The virtual Joystick
  114520. */
  114521. getRightJoystick(): VirtualJoystick;
  114522. /**
  114523. * Update the current camera state depending on the inputs that have been used this frame.
  114524. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114525. */
  114526. checkInputs(): void;
  114527. /**
  114528. * Attach the input controls to a specific dom element to get the input from.
  114529. * @param element Defines the element the controls should be listened from
  114530. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114531. */
  114532. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114533. /**
  114534. * Detach the current controls from the specified dom element.
  114535. * @param element Defines the element to stop listening the inputs from
  114536. */
  114537. detachControl(element: Nullable<HTMLElement>): void;
  114538. /**
  114539. * Gets the class name of the current intput.
  114540. * @returns the class name
  114541. */
  114542. getClassName(): string;
  114543. /**
  114544. * Get the friendly name associated with the input class.
  114545. * @returns the input friendly name
  114546. */
  114547. getSimpleName(): string;
  114548. }
  114549. }
  114550. declare module BABYLON {
  114551. /**
  114552. * This represents a FPS type of camera controlled by touch.
  114553. * This is like a universal camera minus the Gamepad controls.
  114554. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114555. */
  114556. export class TouchCamera extends FreeCamera {
  114557. /**
  114558. * Defines the touch sensibility for rotation.
  114559. * The higher the faster.
  114560. */
  114561. get touchAngularSensibility(): number;
  114562. set touchAngularSensibility(value: number);
  114563. /**
  114564. * Defines the touch sensibility for move.
  114565. * The higher the faster.
  114566. */
  114567. get touchMoveSensibility(): number;
  114568. set touchMoveSensibility(value: number);
  114569. /**
  114570. * Instantiates a new touch camera.
  114571. * This represents a FPS type of camera controlled by touch.
  114572. * This is like a universal camera minus the Gamepad controls.
  114573. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114574. * @param name Define the name of the camera in the scene
  114575. * @param position Define the start position of the camera in the scene
  114576. * @param scene Define the scene the camera belongs to
  114577. */
  114578. constructor(name: string, position: Vector3, scene: Scene);
  114579. /**
  114580. * Gets the current object class name.
  114581. * @return the class name
  114582. */
  114583. getClassName(): string;
  114584. /** @hidden */
  114585. _setupInputs(): void;
  114586. }
  114587. }
  114588. declare module BABYLON {
  114589. /**
  114590. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  114591. * being tilted forward or back and left or right.
  114592. */
  114593. export class DeviceOrientationCamera extends FreeCamera {
  114594. private _initialQuaternion;
  114595. private _quaternionCache;
  114596. private _tmpDragQuaternion;
  114597. private _disablePointerInputWhenUsingDeviceOrientation;
  114598. /**
  114599. * Creates a new device orientation camera
  114600. * @param name The name of the camera
  114601. * @param position The start position camera
  114602. * @param scene The scene the camera belongs to
  114603. */
  114604. constructor(name: string, position: Vector3, scene: Scene);
  114605. /**
  114606. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  114607. */
  114608. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  114609. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  114610. private _dragFactor;
  114611. /**
  114612. * Enabled turning on the y axis when the orientation sensor is active
  114613. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  114614. */
  114615. enableHorizontalDragging(dragFactor?: number): void;
  114616. /**
  114617. * Gets the current instance class name ("DeviceOrientationCamera").
  114618. * This helps avoiding instanceof at run time.
  114619. * @returns the class name
  114620. */
  114621. getClassName(): string;
  114622. /**
  114623. * @hidden
  114624. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  114625. */
  114626. _checkInputs(): void;
  114627. /**
  114628. * Reset the camera to its default orientation on the specified axis only.
  114629. * @param axis The axis to reset
  114630. */
  114631. resetToCurrentRotation(axis?: Axis): void;
  114632. }
  114633. }
  114634. declare module BABYLON {
  114635. /**
  114636. * Defines supported buttons for XBox360 compatible gamepads
  114637. */
  114638. export enum Xbox360Button {
  114639. /** A */
  114640. A = 0,
  114641. /** B */
  114642. B = 1,
  114643. /** X */
  114644. X = 2,
  114645. /** Y */
  114646. Y = 3,
  114647. /** Left button */
  114648. LB = 4,
  114649. /** Right button */
  114650. RB = 5,
  114651. /** Back */
  114652. Back = 8,
  114653. /** Start */
  114654. Start = 9,
  114655. /** Left stick */
  114656. LeftStick = 10,
  114657. /** Right stick */
  114658. RightStick = 11
  114659. }
  114660. /** Defines values for XBox360 DPad */
  114661. export enum Xbox360Dpad {
  114662. /** Up */
  114663. Up = 12,
  114664. /** Down */
  114665. Down = 13,
  114666. /** Left */
  114667. Left = 14,
  114668. /** Right */
  114669. Right = 15
  114670. }
  114671. /**
  114672. * Defines a XBox360 gamepad
  114673. */
  114674. export class Xbox360Pad extends Gamepad {
  114675. private _leftTrigger;
  114676. private _rightTrigger;
  114677. private _onlefttriggerchanged;
  114678. private _onrighttriggerchanged;
  114679. private _onbuttondown;
  114680. private _onbuttonup;
  114681. private _ondpaddown;
  114682. private _ondpadup;
  114683. /** Observable raised when a button is pressed */
  114684. onButtonDownObservable: Observable<Xbox360Button>;
  114685. /** Observable raised when a button is released */
  114686. onButtonUpObservable: Observable<Xbox360Button>;
  114687. /** Observable raised when a pad is pressed */
  114688. onPadDownObservable: Observable<Xbox360Dpad>;
  114689. /** Observable raised when a pad is released */
  114690. onPadUpObservable: Observable<Xbox360Dpad>;
  114691. private _buttonA;
  114692. private _buttonB;
  114693. private _buttonX;
  114694. private _buttonY;
  114695. private _buttonBack;
  114696. private _buttonStart;
  114697. private _buttonLB;
  114698. private _buttonRB;
  114699. private _buttonLeftStick;
  114700. private _buttonRightStick;
  114701. private _dPadUp;
  114702. private _dPadDown;
  114703. private _dPadLeft;
  114704. private _dPadRight;
  114705. private _isXboxOnePad;
  114706. /**
  114707. * Creates a new XBox360 gamepad object
  114708. * @param id defines the id of this gamepad
  114709. * @param index defines its index
  114710. * @param gamepad defines the internal HTML gamepad object
  114711. * @param xboxOne defines if it is a XBox One gamepad
  114712. */
  114713. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  114714. /**
  114715. * Defines the callback to call when left trigger is pressed
  114716. * @param callback defines the callback to use
  114717. */
  114718. onlefttriggerchanged(callback: (value: number) => void): void;
  114719. /**
  114720. * Defines the callback to call when right trigger is pressed
  114721. * @param callback defines the callback to use
  114722. */
  114723. onrighttriggerchanged(callback: (value: number) => void): void;
  114724. /**
  114725. * Gets the left trigger value
  114726. */
  114727. get leftTrigger(): number;
  114728. /**
  114729. * Sets the left trigger value
  114730. */
  114731. set leftTrigger(newValue: number);
  114732. /**
  114733. * Gets the right trigger value
  114734. */
  114735. get rightTrigger(): number;
  114736. /**
  114737. * Sets the right trigger value
  114738. */
  114739. set rightTrigger(newValue: number);
  114740. /**
  114741. * Defines the callback to call when a button is pressed
  114742. * @param callback defines the callback to use
  114743. */
  114744. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  114745. /**
  114746. * Defines the callback to call when a button is released
  114747. * @param callback defines the callback to use
  114748. */
  114749. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  114750. /**
  114751. * Defines the callback to call when a pad is pressed
  114752. * @param callback defines the callback to use
  114753. */
  114754. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  114755. /**
  114756. * Defines the callback to call when a pad is released
  114757. * @param callback defines the callback to use
  114758. */
  114759. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  114760. private _setButtonValue;
  114761. private _setDPadValue;
  114762. /**
  114763. * Gets the value of the `A` button
  114764. */
  114765. get buttonA(): number;
  114766. /**
  114767. * Sets the value of the `A` button
  114768. */
  114769. set buttonA(value: number);
  114770. /**
  114771. * Gets the value of the `B` button
  114772. */
  114773. get buttonB(): number;
  114774. /**
  114775. * Sets the value of the `B` button
  114776. */
  114777. set buttonB(value: number);
  114778. /**
  114779. * Gets the value of the `X` button
  114780. */
  114781. get buttonX(): number;
  114782. /**
  114783. * Sets the value of the `X` button
  114784. */
  114785. set buttonX(value: number);
  114786. /**
  114787. * Gets the value of the `Y` button
  114788. */
  114789. get buttonY(): number;
  114790. /**
  114791. * Sets the value of the `Y` button
  114792. */
  114793. set buttonY(value: number);
  114794. /**
  114795. * Gets the value of the `Start` button
  114796. */
  114797. get buttonStart(): number;
  114798. /**
  114799. * Sets the value of the `Start` button
  114800. */
  114801. set buttonStart(value: number);
  114802. /**
  114803. * Gets the value of the `Back` button
  114804. */
  114805. get buttonBack(): number;
  114806. /**
  114807. * Sets the value of the `Back` button
  114808. */
  114809. set buttonBack(value: number);
  114810. /**
  114811. * Gets the value of the `Left` button
  114812. */
  114813. get buttonLB(): number;
  114814. /**
  114815. * Sets the value of the `Left` button
  114816. */
  114817. set buttonLB(value: number);
  114818. /**
  114819. * Gets the value of the `Right` button
  114820. */
  114821. get buttonRB(): number;
  114822. /**
  114823. * Sets the value of the `Right` button
  114824. */
  114825. set buttonRB(value: number);
  114826. /**
  114827. * Gets the value of the Left joystick
  114828. */
  114829. get buttonLeftStick(): number;
  114830. /**
  114831. * Sets the value of the Left joystick
  114832. */
  114833. set buttonLeftStick(value: number);
  114834. /**
  114835. * Gets the value of the Right joystick
  114836. */
  114837. get buttonRightStick(): number;
  114838. /**
  114839. * Sets the value of the Right joystick
  114840. */
  114841. set buttonRightStick(value: number);
  114842. /**
  114843. * Gets the value of D-pad up
  114844. */
  114845. get dPadUp(): number;
  114846. /**
  114847. * Sets the value of D-pad up
  114848. */
  114849. set dPadUp(value: number);
  114850. /**
  114851. * Gets the value of D-pad down
  114852. */
  114853. get dPadDown(): number;
  114854. /**
  114855. * Sets the value of D-pad down
  114856. */
  114857. set dPadDown(value: number);
  114858. /**
  114859. * Gets the value of D-pad left
  114860. */
  114861. get dPadLeft(): number;
  114862. /**
  114863. * Sets the value of D-pad left
  114864. */
  114865. set dPadLeft(value: number);
  114866. /**
  114867. * Gets the value of D-pad right
  114868. */
  114869. get dPadRight(): number;
  114870. /**
  114871. * Sets the value of D-pad right
  114872. */
  114873. set dPadRight(value: number);
  114874. /**
  114875. * Force the gamepad to synchronize with device values
  114876. */
  114877. update(): void;
  114878. /**
  114879. * Disposes the gamepad
  114880. */
  114881. dispose(): void;
  114882. }
  114883. }
  114884. declare module BABYLON {
  114885. /**
  114886. * Defines supported buttons for DualShock compatible gamepads
  114887. */
  114888. export enum DualShockButton {
  114889. /** Cross */
  114890. Cross = 0,
  114891. /** Circle */
  114892. Circle = 1,
  114893. /** Square */
  114894. Square = 2,
  114895. /** Triangle */
  114896. Triangle = 3,
  114897. /** L1 */
  114898. L1 = 4,
  114899. /** R1 */
  114900. R1 = 5,
  114901. /** Share */
  114902. Share = 8,
  114903. /** Options */
  114904. Options = 9,
  114905. /** Left stick */
  114906. LeftStick = 10,
  114907. /** Right stick */
  114908. RightStick = 11
  114909. }
  114910. /** Defines values for DualShock DPad */
  114911. export enum DualShockDpad {
  114912. /** Up */
  114913. Up = 12,
  114914. /** Down */
  114915. Down = 13,
  114916. /** Left */
  114917. Left = 14,
  114918. /** Right */
  114919. Right = 15
  114920. }
  114921. /**
  114922. * Defines a DualShock gamepad
  114923. */
  114924. export class DualShockPad extends Gamepad {
  114925. private _leftTrigger;
  114926. private _rightTrigger;
  114927. private _onlefttriggerchanged;
  114928. private _onrighttriggerchanged;
  114929. private _onbuttondown;
  114930. private _onbuttonup;
  114931. private _ondpaddown;
  114932. private _ondpadup;
  114933. /** Observable raised when a button is pressed */
  114934. onButtonDownObservable: Observable<DualShockButton>;
  114935. /** Observable raised when a button is released */
  114936. onButtonUpObservable: Observable<DualShockButton>;
  114937. /** Observable raised when a pad is pressed */
  114938. onPadDownObservable: Observable<DualShockDpad>;
  114939. /** Observable raised when a pad is released */
  114940. onPadUpObservable: Observable<DualShockDpad>;
  114941. private _buttonCross;
  114942. private _buttonCircle;
  114943. private _buttonSquare;
  114944. private _buttonTriangle;
  114945. private _buttonShare;
  114946. private _buttonOptions;
  114947. private _buttonL1;
  114948. private _buttonR1;
  114949. private _buttonLeftStick;
  114950. private _buttonRightStick;
  114951. private _dPadUp;
  114952. private _dPadDown;
  114953. private _dPadLeft;
  114954. private _dPadRight;
  114955. /**
  114956. * Creates a new DualShock gamepad object
  114957. * @param id defines the id of this gamepad
  114958. * @param index defines its index
  114959. * @param gamepad defines the internal HTML gamepad object
  114960. */
  114961. constructor(id: string, index: number, gamepad: any);
  114962. /**
  114963. * Defines the callback to call when left trigger is pressed
  114964. * @param callback defines the callback to use
  114965. */
  114966. onlefttriggerchanged(callback: (value: number) => void): void;
  114967. /**
  114968. * Defines the callback to call when right trigger is pressed
  114969. * @param callback defines the callback to use
  114970. */
  114971. onrighttriggerchanged(callback: (value: number) => void): void;
  114972. /**
  114973. * Gets the left trigger value
  114974. */
  114975. get leftTrigger(): number;
  114976. /**
  114977. * Sets the left trigger value
  114978. */
  114979. set leftTrigger(newValue: number);
  114980. /**
  114981. * Gets the right trigger value
  114982. */
  114983. get rightTrigger(): number;
  114984. /**
  114985. * Sets the right trigger value
  114986. */
  114987. set rightTrigger(newValue: number);
  114988. /**
  114989. * Defines the callback to call when a button is pressed
  114990. * @param callback defines the callback to use
  114991. */
  114992. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  114993. /**
  114994. * Defines the callback to call when a button is released
  114995. * @param callback defines the callback to use
  114996. */
  114997. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  114998. /**
  114999. * Defines the callback to call when a pad is pressed
  115000. * @param callback defines the callback to use
  115001. */
  115002. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  115003. /**
  115004. * Defines the callback to call when a pad is released
  115005. * @param callback defines the callback to use
  115006. */
  115007. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  115008. private _setButtonValue;
  115009. private _setDPadValue;
  115010. /**
  115011. * Gets the value of the `Cross` button
  115012. */
  115013. get buttonCross(): number;
  115014. /**
  115015. * Sets the value of the `Cross` button
  115016. */
  115017. set buttonCross(value: number);
  115018. /**
  115019. * Gets the value of the `Circle` button
  115020. */
  115021. get buttonCircle(): number;
  115022. /**
  115023. * Sets the value of the `Circle` button
  115024. */
  115025. set buttonCircle(value: number);
  115026. /**
  115027. * Gets the value of the `Square` button
  115028. */
  115029. get buttonSquare(): number;
  115030. /**
  115031. * Sets the value of the `Square` button
  115032. */
  115033. set buttonSquare(value: number);
  115034. /**
  115035. * Gets the value of the `Triangle` button
  115036. */
  115037. get buttonTriangle(): number;
  115038. /**
  115039. * Sets the value of the `Triangle` button
  115040. */
  115041. set buttonTriangle(value: number);
  115042. /**
  115043. * Gets the value of the `Options` button
  115044. */
  115045. get buttonOptions(): number;
  115046. /**
  115047. * Sets the value of the `Options` button
  115048. */
  115049. set buttonOptions(value: number);
  115050. /**
  115051. * Gets the value of the `Share` button
  115052. */
  115053. get buttonShare(): number;
  115054. /**
  115055. * Sets the value of the `Share` button
  115056. */
  115057. set buttonShare(value: number);
  115058. /**
  115059. * Gets the value of the `L1` button
  115060. */
  115061. get buttonL1(): number;
  115062. /**
  115063. * Sets the value of the `L1` button
  115064. */
  115065. set buttonL1(value: number);
  115066. /**
  115067. * Gets the value of the `R1` button
  115068. */
  115069. get buttonR1(): number;
  115070. /**
  115071. * Sets the value of the `R1` button
  115072. */
  115073. set buttonR1(value: number);
  115074. /**
  115075. * Gets the value of the Left joystick
  115076. */
  115077. get buttonLeftStick(): number;
  115078. /**
  115079. * Sets the value of the Left joystick
  115080. */
  115081. set buttonLeftStick(value: number);
  115082. /**
  115083. * Gets the value of the Right joystick
  115084. */
  115085. get buttonRightStick(): number;
  115086. /**
  115087. * Sets the value of the Right joystick
  115088. */
  115089. set buttonRightStick(value: number);
  115090. /**
  115091. * Gets the value of D-pad up
  115092. */
  115093. get dPadUp(): number;
  115094. /**
  115095. * Sets the value of D-pad up
  115096. */
  115097. set dPadUp(value: number);
  115098. /**
  115099. * Gets the value of D-pad down
  115100. */
  115101. get dPadDown(): number;
  115102. /**
  115103. * Sets the value of D-pad down
  115104. */
  115105. set dPadDown(value: number);
  115106. /**
  115107. * Gets the value of D-pad left
  115108. */
  115109. get dPadLeft(): number;
  115110. /**
  115111. * Sets the value of D-pad left
  115112. */
  115113. set dPadLeft(value: number);
  115114. /**
  115115. * Gets the value of D-pad right
  115116. */
  115117. get dPadRight(): number;
  115118. /**
  115119. * Sets the value of D-pad right
  115120. */
  115121. set dPadRight(value: number);
  115122. /**
  115123. * Force the gamepad to synchronize with device values
  115124. */
  115125. update(): void;
  115126. /**
  115127. * Disposes the gamepad
  115128. */
  115129. dispose(): void;
  115130. }
  115131. }
  115132. declare module BABYLON {
  115133. /**
  115134. * Manager for handling gamepads
  115135. */
  115136. export class GamepadManager {
  115137. private _scene?;
  115138. private _babylonGamepads;
  115139. private _oneGamepadConnected;
  115140. /** @hidden */
  115141. _isMonitoring: boolean;
  115142. private _gamepadEventSupported;
  115143. private _gamepadSupport?;
  115144. /**
  115145. * observable to be triggered when the gamepad controller has been connected
  115146. */
  115147. onGamepadConnectedObservable: Observable<Gamepad>;
  115148. /**
  115149. * observable to be triggered when the gamepad controller has been disconnected
  115150. */
  115151. onGamepadDisconnectedObservable: Observable<Gamepad>;
  115152. private _onGamepadConnectedEvent;
  115153. private _onGamepadDisconnectedEvent;
  115154. /**
  115155. * Initializes the gamepad manager
  115156. * @param _scene BabylonJS scene
  115157. */
  115158. constructor(_scene?: Scene | undefined);
  115159. /**
  115160. * The gamepads in the game pad manager
  115161. */
  115162. get gamepads(): Gamepad[];
  115163. /**
  115164. * Get the gamepad controllers based on type
  115165. * @param type The type of gamepad controller
  115166. * @returns Nullable gamepad
  115167. */
  115168. getGamepadByType(type?: number): Nullable<Gamepad>;
  115169. /**
  115170. * Disposes the gamepad manager
  115171. */
  115172. dispose(): void;
  115173. private _addNewGamepad;
  115174. private _startMonitoringGamepads;
  115175. private _stopMonitoringGamepads;
  115176. /** @hidden */
  115177. _checkGamepadsStatus(): void;
  115178. private _updateGamepadObjects;
  115179. }
  115180. }
  115181. declare module BABYLON {
  115182. interface Scene {
  115183. /** @hidden */
  115184. _gamepadManager: Nullable<GamepadManager>;
  115185. /**
  115186. * Gets the gamepad manager associated with the scene
  115187. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  115188. */
  115189. gamepadManager: GamepadManager;
  115190. }
  115191. /**
  115192. * Interface representing a free camera inputs manager
  115193. */
  115194. interface FreeCameraInputsManager {
  115195. /**
  115196. * Adds gamepad input support to the FreeCameraInputsManager.
  115197. * @returns the FreeCameraInputsManager
  115198. */
  115199. addGamepad(): FreeCameraInputsManager;
  115200. }
  115201. /**
  115202. * Interface representing an arc rotate camera inputs manager
  115203. */
  115204. interface ArcRotateCameraInputsManager {
  115205. /**
  115206. * Adds gamepad input support to the ArcRotateCamera InputManager.
  115207. * @returns the camera inputs manager
  115208. */
  115209. addGamepad(): ArcRotateCameraInputsManager;
  115210. }
  115211. /**
  115212. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  115213. */
  115214. export class GamepadSystemSceneComponent implements ISceneComponent {
  115215. /**
  115216. * The component name helpfull to identify the component in the list of scene components.
  115217. */
  115218. readonly name: string;
  115219. /**
  115220. * The scene the component belongs to.
  115221. */
  115222. scene: Scene;
  115223. /**
  115224. * Creates a new instance of the component for the given scene
  115225. * @param scene Defines the scene to register the component in
  115226. */
  115227. constructor(scene: Scene);
  115228. /**
  115229. * Registers the component in a given scene
  115230. */
  115231. register(): void;
  115232. /**
  115233. * Rebuilds the elements related to this component in case of
  115234. * context lost for instance.
  115235. */
  115236. rebuild(): void;
  115237. /**
  115238. * Disposes the component and the associated ressources
  115239. */
  115240. dispose(): void;
  115241. private _beforeCameraUpdate;
  115242. }
  115243. }
  115244. declare module BABYLON {
  115245. /**
  115246. * 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,
  115247. * which still works and will still be found in many Playgrounds.
  115248. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  115249. */
  115250. export class UniversalCamera extends TouchCamera {
  115251. /**
  115252. * Defines the gamepad rotation sensiblity.
  115253. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  115254. */
  115255. get gamepadAngularSensibility(): number;
  115256. set gamepadAngularSensibility(value: number);
  115257. /**
  115258. * Defines the gamepad move sensiblity.
  115259. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  115260. */
  115261. get gamepadMoveSensibility(): number;
  115262. set gamepadMoveSensibility(value: number);
  115263. /**
  115264. * 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,
  115265. * which still works and will still be found in many Playgrounds.
  115266. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  115267. * @param name Define the name of the camera in the scene
  115268. * @param position Define the start position of the camera in the scene
  115269. * @param scene Define the scene the camera belongs to
  115270. */
  115271. constructor(name: string, position: Vector3, scene: Scene);
  115272. /**
  115273. * Gets the current object class name.
  115274. * @return the class name
  115275. */
  115276. getClassName(): string;
  115277. }
  115278. }
  115279. declare module BABYLON {
  115280. /**
  115281. * This represents a FPS type of camera. This is only here for back compat purpose.
  115282. * Please use the UniversalCamera instead as both are identical.
  115283. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  115284. */
  115285. export class GamepadCamera extends UniversalCamera {
  115286. /**
  115287. * Instantiates a new Gamepad Camera
  115288. * This represents a FPS type of camera. This is only here for back compat purpose.
  115289. * Please use the UniversalCamera instead as both are identical.
  115290. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  115291. * @param name Define the name of the camera in the scene
  115292. * @param position Define the start position of the camera in the scene
  115293. * @param scene Define the scene the camera belongs to
  115294. */
  115295. constructor(name: string, position: Vector3, scene: Scene);
  115296. /**
  115297. * Gets the current object class name.
  115298. * @return the class name
  115299. */
  115300. getClassName(): string;
  115301. }
  115302. }
  115303. declare module BABYLON {
  115304. /** @hidden */
  115305. export var passPixelShader: {
  115306. name: string;
  115307. shader: string;
  115308. };
  115309. }
  115310. declare module BABYLON {
  115311. /** @hidden */
  115312. export var passCubePixelShader: {
  115313. name: string;
  115314. shader: string;
  115315. };
  115316. }
  115317. declare module BABYLON {
  115318. /**
  115319. * PassPostProcess which produces an output the same as it's input
  115320. */
  115321. export class PassPostProcess extends PostProcess {
  115322. /**
  115323. * Creates the PassPostProcess
  115324. * @param name The name of the effect.
  115325. * @param options The required width/height ratio to downsize to before computing the render pass.
  115326. * @param camera The camera to apply the render pass to.
  115327. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115328. * @param engine The engine which the post process will be applied. (default: current engine)
  115329. * @param reusable If the post process can be reused on the same frame. (default: false)
  115330. * @param textureType The type of texture to be used when performing the post processing.
  115331. * @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)
  115332. */
  115333. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  115334. }
  115335. /**
  115336. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  115337. */
  115338. export class PassCubePostProcess extends PostProcess {
  115339. private _face;
  115340. /**
  115341. * Gets or sets the cube face to display.
  115342. * * 0 is +X
  115343. * * 1 is -X
  115344. * * 2 is +Y
  115345. * * 3 is -Y
  115346. * * 4 is +Z
  115347. * * 5 is -Z
  115348. */
  115349. get face(): number;
  115350. set face(value: number);
  115351. /**
  115352. * Creates the PassCubePostProcess
  115353. * @param name The name of the effect.
  115354. * @param options The required width/height ratio to downsize to before computing the render pass.
  115355. * @param camera The camera to apply the render pass to.
  115356. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115357. * @param engine The engine which the post process will be applied. (default: current engine)
  115358. * @param reusable If the post process can be reused on the same frame. (default: false)
  115359. * @param textureType The type of texture to be used when performing the post processing.
  115360. * @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)
  115361. */
  115362. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  115363. }
  115364. }
  115365. declare module BABYLON {
  115366. /** @hidden */
  115367. export var anaglyphPixelShader: {
  115368. name: string;
  115369. shader: string;
  115370. };
  115371. }
  115372. declare module BABYLON {
  115373. /**
  115374. * Postprocess used to generate anaglyphic rendering
  115375. */
  115376. export class AnaglyphPostProcess extends PostProcess {
  115377. private _passedProcess;
  115378. /**
  115379. * Creates a new AnaglyphPostProcess
  115380. * @param name defines postprocess name
  115381. * @param options defines creation options or target ratio scale
  115382. * @param rigCameras defines cameras using this postprocess
  115383. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  115384. * @param engine defines hosting engine
  115385. * @param reusable defines if the postprocess will be reused multiple times per frame
  115386. */
  115387. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  115388. }
  115389. }
  115390. declare module BABYLON {
  115391. /**
  115392. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  115393. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115394. */
  115395. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  115396. /**
  115397. * Creates a new AnaglyphArcRotateCamera
  115398. * @param name defines camera name
  115399. * @param alpha defines alpha angle (in radians)
  115400. * @param beta defines beta angle (in radians)
  115401. * @param radius defines radius
  115402. * @param target defines camera target
  115403. * @param interaxialDistance defines distance between each color axis
  115404. * @param scene defines the hosting scene
  115405. */
  115406. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  115407. /**
  115408. * Gets camera class name
  115409. * @returns AnaglyphArcRotateCamera
  115410. */
  115411. getClassName(): string;
  115412. }
  115413. }
  115414. declare module BABYLON {
  115415. /**
  115416. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  115417. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115418. */
  115419. export class AnaglyphFreeCamera extends FreeCamera {
  115420. /**
  115421. * Creates a new AnaglyphFreeCamera
  115422. * @param name defines camera name
  115423. * @param position defines initial position
  115424. * @param interaxialDistance defines distance between each color axis
  115425. * @param scene defines the hosting scene
  115426. */
  115427. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115428. /**
  115429. * Gets camera class name
  115430. * @returns AnaglyphFreeCamera
  115431. */
  115432. getClassName(): string;
  115433. }
  115434. }
  115435. declare module BABYLON {
  115436. /**
  115437. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  115438. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115439. */
  115440. export class AnaglyphGamepadCamera extends GamepadCamera {
  115441. /**
  115442. * Creates a new AnaglyphGamepadCamera
  115443. * @param name defines camera name
  115444. * @param position defines initial position
  115445. * @param interaxialDistance defines distance between each color axis
  115446. * @param scene defines the hosting scene
  115447. */
  115448. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115449. /**
  115450. * Gets camera class name
  115451. * @returns AnaglyphGamepadCamera
  115452. */
  115453. getClassName(): string;
  115454. }
  115455. }
  115456. declare module BABYLON {
  115457. /**
  115458. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  115459. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115460. */
  115461. export class AnaglyphUniversalCamera extends UniversalCamera {
  115462. /**
  115463. * Creates a new AnaglyphUniversalCamera
  115464. * @param name defines camera name
  115465. * @param position defines initial position
  115466. * @param interaxialDistance defines distance between each color axis
  115467. * @param scene defines the hosting scene
  115468. */
  115469. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115470. /**
  115471. * Gets camera class name
  115472. * @returns AnaglyphUniversalCamera
  115473. */
  115474. getClassName(): string;
  115475. }
  115476. }
  115477. declare module BABYLON {
  115478. /** @hidden */
  115479. export var stereoscopicInterlacePixelShader: {
  115480. name: string;
  115481. shader: string;
  115482. };
  115483. }
  115484. declare module BABYLON {
  115485. /**
  115486. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  115487. */
  115488. export class StereoscopicInterlacePostProcessI extends PostProcess {
  115489. private _stepSize;
  115490. private _passedProcess;
  115491. /**
  115492. * Initializes a StereoscopicInterlacePostProcessI
  115493. * @param name The name of the effect.
  115494. * @param rigCameras The rig cameras to be appled to the post process
  115495. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  115496. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  115497. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115498. * @param engine The engine which the post process will be applied. (default: current engine)
  115499. * @param reusable If the post process can be reused on the same frame. (default: false)
  115500. */
  115501. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  115502. }
  115503. /**
  115504. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  115505. */
  115506. export class StereoscopicInterlacePostProcess extends PostProcess {
  115507. private _stepSize;
  115508. private _passedProcess;
  115509. /**
  115510. * Initializes a StereoscopicInterlacePostProcess
  115511. * @param name The name of the effect.
  115512. * @param rigCameras The rig cameras to be appled to the post process
  115513. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  115514. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115515. * @param engine The engine which the post process will be applied. (default: current engine)
  115516. * @param reusable If the post process can be reused on the same frame. (default: false)
  115517. */
  115518. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  115519. }
  115520. }
  115521. declare module BABYLON {
  115522. /**
  115523. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  115524. * @see http://doc.babylonjs.com/features/cameras
  115525. */
  115526. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  115527. /**
  115528. * Creates a new StereoscopicArcRotateCamera
  115529. * @param name defines camera name
  115530. * @param alpha defines alpha angle (in radians)
  115531. * @param beta defines beta angle (in radians)
  115532. * @param radius defines radius
  115533. * @param target defines camera target
  115534. * @param interaxialDistance defines distance between each color axis
  115535. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115536. * @param scene defines the hosting scene
  115537. */
  115538. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115539. /**
  115540. * Gets camera class name
  115541. * @returns StereoscopicArcRotateCamera
  115542. */
  115543. getClassName(): string;
  115544. }
  115545. }
  115546. declare module BABYLON {
  115547. /**
  115548. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  115549. * @see http://doc.babylonjs.com/features/cameras
  115550. */
  115551. export class StereoscopicFreeCamera extends FreeCamera {
  115552. /**
  115553. * Creates a new StereoscopicFreeCamera
  115554. * @param name defines camera name
  115555. * @param position defines initial position
  115556. * @param interaxialDistance defines distance between each color axis
  115557. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115558. * @param scene defines the hosting scene
  115559. */
  115560. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115561. /**
  115562. * Gets camera class name
  115563. * @returns StereoscopicFreeCamera
  115564. */
  115565. getClassName(): string;
  115566. }
  115567. }
  115568. declare module BABYLON {
  115569. /**
  115570. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  115571. * @see http://doc.babylonjs.com/features/cameras
  115572. */
  115573. export class StereoscopicGamepadCamera extends GamepadCamera {
  115574. /**
  115575. * Creates a new StereoscopicGamepadCamera
  115576. * @param name defines camera name
  115577. * @param position defines initial position
  115578. * @param interaxialDistance defines distance between each color axis
  115579. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115580. * @param scene defines the hosting scene
  115581. */
  115582. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115583. /**
  115584. * Gets camera class name
  115585. * @returns StereoscopicGamepadCamera
  115586. */
  115587. getClassName(): string;
  115588. }
  115589. }
  115590. declare module BABYLON {
  115591. /**
  115592. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  115593. * @see http://doc.babylonjs.com/features/cameras
  115594. */
  115595. export class StereoscopicUniversalCamera extends UniversalCamera {
  115596. /**
  115597. * Creates a new StereoscopicUniversalCamera
  115598. * @param name defines camera name
  115599. * @param position defines initial position
  115600. * @param interaxialDistance defines distance between each color axis
  115601. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115602. * @param scene defines the hosting scene
  115603. */
  115604. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115605. /**
  115606. * Gets camera class name
  115607. * @returns StereoscopicUniversalCamera
  115608. */
  115609. getClassName(): string;
  115610. }
  115611. }
  115612. declare module BABYLON {
  115613. /**
  115614. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  115615. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  115616. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  115617. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  115618. */
  115619. export class VirtualJoysticksCamera extends FreeCamera {
  115620. /**
  115621. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  115622. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  115623. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  115624. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  115625. * @param name Define the name of the camera in the scene
  115626. * @param position Define the start position of the camera in the scene
  115627. * @param scene Define the scene the camera belongs to
  115628. */
  115629. constructor(name: string, position: Vector3, scene: Scene);
  115630. /**
  115631. * Gets the current object class name.
  115632. * @return the class name
  115633. */
  115634. getClassName(): string;
  115635. }
  115636. }
  115637. declare module BABYLON {
  115638. /**
  115639. * This represents all the required metrics to create a VR camera.
  115640. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  115641. */
  115642. export class VRCameraMetrics {
  115643. /**
  115644. * Define the horizontal resolution off the screen.
  115645. */
  115646. hResolution: number;
  115647. /**
  115648. * Define the vertical resolution off the screen.
  115649. */
  115650. vResolution: number;
  115651. /**
  115652. * Define the horizontal screen size.
  115653. */
  115654. hScreenSize: number;
  115655. /**
  115656. * Define the vertical screen size.
  115657. */
  115658. vScreenSize: number;
  115659. /**
  115660. * Define the vertical screen center position.
  115661. */
  115662. vScreenCenter: number;
  115663. /**
  115664. * Define the distance of the eyes to the screen.
  115665. */
  115666. eyeToScreenDistance: number;
  115667. /**
  115668. * Define the distance between both lenses
  115669. */
  115670. lensSeparationDistance: number;
  115671. /**
  115672. * Define the distance between both viewer's eyes.
  115673. */
  115674. interpupillaryDistance: number;
  115675. /**
  115676. * Define the distortion factor of the VR postprocess.
  115677. * Please, touch with care.
  115678. */
  115679. distortionK: number[];
  115680. /**
  115681. * Define the chromatic aberration correction factors for the VR post process.
  115682. */
  115683. chromaAbCorrection: number[];
  115684. /**
  115685. * Define the scale factor of the post process.
  115686. * The smaller the better but the slower.
  115687. */
  115688. postProcessScaleFactor: number;
  115689. /**
  115690. * Define an offset for the lens center.
  115691. */
  115692. lensCenterOffset: number;
  115693. /**
  115694. * Define if the current vr camera should compensate the distortion of the lense or not.
  115695. */
  115696. compensateDistortion: boolean;
  115697. /**
  115698. * Defines if multiview should be enabled when rendering (Default: false)
  115699. */
  115700. multiviewEnabled: boolean;
  115701. /**
  115702. * Gets the rendering aspect ratio based on the provided resolutions.
  115703. */
  115704. get aspectRatio(): number;
  115705. /**
  115706. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  115707. */
  115708. get aspectRatioFov(): number;
  115709. /**
  115710. * @hidden
  115711. */
  115712. get leftHMatrix(): Matrix;
  115713. /**
  115714. * @hidden
  115715. */
  115716. get rightHMatrix(): Matrix;
  115717. /**
  115718. * @hidden
  115719. */
  115720. get leftPreViewMatrix(): Matrix;
  115721. /**
  115722. * @hidden
  115723. */
  115724. get rightPreViewMatrix(): Matrix;
  115725. /**
  115726. * Get the default VRMetrics based on the most generic setup.
  115727. * @returns the default vr metrics
  115728. */
  115729. static GetDefault(): VRCameraMetrics;
  115730. }
  115731. }
  115732. declare module BABYLON {
  115733. /** @hidden */
  115734. export var vrDistortionCorrectionPixelShader: {
  115735. name: string;
  115736. shader: string;
  115737. };
  115738. }
  115739. declare module BABYLON {
  115740. /**
  115741. * VRDistortionCorrectionPostProcess used for mobile VR
  115742. */
  115743. export class VRDistortionCorrectionPostProcess extends PostProcess {
  115744. private _isRightEye;
  115745. private _distortionFactors;
  115746. private _postProcessScaleFactor;
  115747. private _lensCenterOffset;
  115748. private _scaleIn;
  115749. private _scaleFactor;
  115750. private _lensCenter;
  115751. /**
  115752. * Initializes the VRDistortionCorrectionPostProcess
  115753. * @param name The name of the effect.
  115754. * @param camera The camera to apply the render pass to.
  115755. * @param isRightEye If this is for the right eye distortion
  115756. * @param vrMetrics All the required metrics for the VR camera
  115757. */
  115758. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  115759. }
  115760. }
  115761. declare module BABYLON {
  115762. /**
  115763. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  115764. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115765. */
  115766. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  115767. /**
  115768. * Creates a new VRDeviceOrientationArcRotateCamera
  115769. * @param name defines camera name
  115770. * @param alpha defines the camera rotation along the logitudinal axis
  115771. * @param beta defines the camera rotation along the latitudinal axis
  115772. * @param radius defines the camera distance from its target
  115773. * @param target defines the camera target
  115774. * @param scene defines the scene the camera belongs to
  115775. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115776. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115777. */
  115778. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115779. /**
  115780. * Gets camera class name
  115781. * @returns VRDeviceOrientationArcRotateCamera
  115782. */
  115783. getClassName(): string;
  115784. }
  115785. }
  115786. declare module BABYLON {
  115787. /**
  115788. * Camera used to simulate VR rendering (based on FreeCamera)
  115789. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115790. */
  115791. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  115792. /**
  115793. * Creates a new VRDeviceOrientationFreeCamera
  115794. * @param name defines camera name
  115795. * @param position defines the start position of the camera
  115796. * @param scene defines the scene the camera belongs to
  115797. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115798. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115799. */
  115800. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115801. /**
  115802. * Gets camera class name
  115803. * @returns VRDeviceOrientationFreeCamera
  115804. */
  115805. getClassName(): string;
  115806. }
  115807. }
  115808. declare module BABYLON {
  115809. /**
  115810. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  115811. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115812. */
  115813. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  115814. /**
  115815. * Creates a new VRDeviceOrientationGamepadCamera
  115816. * @param name defines camera name
  115817. * @param position defines the start position of the camera
  115818. * @param scene defines the scene the camera belongs to
  115819. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115820. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115821. */
  115822. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115823. /**
  115824. * Gets camera class name
  115825. * @returns VRDeviceOrientationGamepadCamera
  115826. */
  115827. getClassName(): string;
  115828. }
  115829. }
  115830. declare module BABYLON {
  115831. /** @hidden */
  115832. export var imageProcessingPixelShader: {
  115833. name: string;
  115834. shader: string;
  115835. };
  115836. }
  115837. declare module BABYLON {
  115838. /**
  115839. * ImageProcessingPostProcess
  115840. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  115841. */
  115842. export class ImageProcessingPostProcess extends PostProcess {
  115843. /**
  115844. * Default configuration related to image processing available in the PBR Material.
  115845. */
  115846. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115847. /**
  115848. * Gets the image processing configuration used either in this material.
  115849. */
  115850. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  115851. /**
  115852. * Sets the Default image processing configuration used either in the this material.
  115853. *
  115854. * If sets to null, the scene one is in use.
  115855. */
  115856. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  115857. /**
  115858. * Keep track of the image processing observer to allow dispose and replace.
  115859. */
  115860. private _imageProcessingObserver;
  115861. /**
  115862. * Attaches a new image processing configuration to the PBR Material.
  115863. * @param configuration
  115864. */
  115865. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  115866. /**
  115867. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  115868. */
  115869. get colorCurves(): Nullable<ColorCurves>;
  115870. /**
  115871. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  115872. */
  115873. set colorCurves(value: Nullable<ColorCurves>);
  115874. /**
  115875. * Gets wether the color curves effect is enabled.
  115876. */
  115877. get colorCurvesEnabled(): boolean;
  115878. /**
  115879. * Sets wether the color curves effect is enabled.
  115880. */
  115881. set colorCurvesEnabled(value: boolean);
  115882. /**
  115883. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  115884. */
  115885. get colorGradingTexture(): Nullable<BaseTexture>;
  115886. /**
  115887. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  115888. */
  115889. set colorGradingTexture(value: Nullable<BaseTexture>);
  115890. /**
  115891. * Gets wether the color grading effect is enabled.
  115892. */
  115893. get colorGradingEnabled(): boolean;
  115894. /**
  115895. * Gets wether the color grading effect is enabled.
  115896. */
  115897. set colorGradingEnabled(value: boolean);
  115898. /**
  115899. * Gets exposure used in the effect.
  115900. */
  115901. get exposure(): number;
  115902. /**
  115903. * Sets exposure used in the effect.
  115904. */
  115905. set exposure(value: number);
  115906. /**
  115907. * Gets wether tonemapping is enabled or not.
  115908. */
  115909. get toneMappingEnabled(): boolean;
  115910. /**
  115911. * Sets wether tonemapping is enabled or not
  115912. */
  115913. set toneMappingEnabled(value: boolean);
  115914. /**
  115915. * Gets the type of tone mapping effect.
  115916. */
  115917. get toneMappingType(): number;
  115918. /**
  115919. * Sets the type of tone mapping effect.
  115920. */
  115921. set toneMappingType(value: number);
  115922. /**
  115923. * Gets contrast used in the effect.
  115924. */
  115925. get contrast(): number;
  115926. /**
  115927. * Sets contrast used in the effect.
  115928. */
  115929. set contrast(value: number);
  115930. /**
  115931. * Gets Vignette stretch size.
  115932. */
  115933. get vignetteStretch(): number;
  115934. /**
  115935. * Sets Vignette stretch size.
  115936. */
  115937. set vignetteStretch(value: number);
  115938. /**
  115939. * Gets Vignette centre X Offset.
  115940. */
  115941. get vignetteCentreX(): number;
  115942. /**
  115943. * Sets Vignette centre X Offset.
  115944. */
  115945. set vignetteCentreX(value: number);
  115946. /**
  115947. * Gets Vignette centre Y Offset.
  115948. */
  115949. get vignetteCentreY(): number;
  115950. /**
  115951. * Sets Vignette centre Y Offset.
  115952. */
  115953. set vignetteCentreY(value: number);
  115954. /**
  115955. * Gets Vignette weight or intensity of the vignette effect.
  115956. */
  115957. get vignetteWeight(): number;
  115958. /**
  115959. * Sets Vignette weight or intensity of the vignette effect.
  115960. */
  115961. set vignetteWeight(value: number);
  115962. /**
  115963. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  115964. * if vignetteEnabled is set to true.
  115965. */
  115966. get vignetteColor(): Color4;
  115967. /**
  115968. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  115969. * if vignetteEnabled is set to true.
  115970. */
  115971. set vignetteColor(value: Color4);
  115972. /**
  115973. * Gets Camera field of view used by the Vignette effect.
  115974. */
  115975. get vignetteCameraFov(): number;
  115976. /**
  115977. * Sets Camera field of view used by the Vignette effect.
  115978. */
  115979. set vignetteCameraFov(value: number);
  115980. /**
  115981. * Gets the vignette blend mode allowing different kind of effect.
  115982. */
  115983. get vignetteBlendMode(): number;
  115984. /**
  115985. * Sets the vignette blend mode allowing different kind of effect.
  115986. */
  115987. set vignetteBlendMode(value: number);
  115988. /**
  115989. * Gets wether the vignette effect is enabled.
  115990. */
  115991. get vignetteEnabled(): boolean;
  115992. /**
  115993. * Sets wether the vignette effect is enabled.
  115994. */
  115995. set vignetteEnabled(value: boolean);
  115996. private _fromLinearSpace;
  115997. /**
  115998. * Gets wether the input of the processing is in Gamma or Linear Space.
  115999. */
  116000. get fromLinearSpace(): boolean;
  116001. /**
  116002. * Sets wether the input of the processing is in Gamma or Linear Space.
  116003. */
  116004. set fromLinearSpace(value: boolean);
  116005. /**
  116006. * Defines cache preventing GC.
  116007. */
  116008. private _defines;
  116009. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  116010. /**
  116011. * "ImageProcessingPostProcess"
  116012. * @returns "ImageProcessingPostProcess"
  116013. */
  116014. getClassName(): string;
  116015. protected _updateParameters(): void;
  116016. dispose(camera?: Camera): void;
  116017. }
  116018. }
  116019. declare module BABYLON {
  116020. /**
  116021. * Class containing static functions to help procedurally build meshes
  116022. */
  116023. export class GroundBuilder {
  116024. /**
  116025. * Creates a ground mesh
  116026. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  116027. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  116028. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116029. * @param name defines the name of the mesh
  116030. * @param options defines the options used to create the mesh
  116031. * @param scene defines the hosting scene
  116032. * @returns the ground mesh
  116033. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  116034. */
  116035. static CreateGround(name: string, options: {
  116036. width?: number;
  116037. height?: number;
  116038. subdivisions?: number;
  116039. subdivisionsX?: number;
  116040. subdivisionsY?: number;
  116041. updatable?: boolean;
  116042. }, scene: any): Mesh;
  116043. /**
  116044. * Creates a tiled ground mesh
  116045. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  116046. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  116047. * * 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
  116048. * * 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
  116049. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116050. * @param name defines the name of the mesh
  116051. * @param options defines the options used to create the mesh
  116052. * @param scene defines the hosting scene
  116053. * @returns the tiled ground mesh
  116054. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  116055. */
  116056. static CreateTiledGround(name: string, options: {
  116057. xmin: number;
  116058. zmin: number;
  116059. xmax: number;
  116060. zmax: number;
  116061. subdivisions?: {
  116062. w: number;
  116063. h: number;
  116064. };
  116065. precision?: {
  116066. w: number;
  116067. h: number;
  116068. };
  116069. updatable?: boolean;
  116070. }, scene?: Nullable<Scene>): Mesh;
  116071. /**
  116072. * Creates a ground mesh from a height map
  116073. * * The parameter `url` sets the URL of the height map image resource.
  116074. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  116075. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  116076. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  116077. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  116078. * * 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.
  116079. * * 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).
  116080. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  116081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116082. * @param name defines the name of the mesh
  116083. * @param url defines the url to the height map
  116084. * @param options defines the options used to create the mesh
  116085. * @param scene defines the hosting scene
  116086. * @returns the ground mesh
  116087. * @see https://doc.babylonjs.com/babylon101/height_map
  116088. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  116089. */
  116090. static CreateGroundFromHeightMap(name: string, url: string, options: {
  116091. width?: number;
  116092. height?: number;
  116093. subdivisions?: number;
  116094. minHeight?: number;
  116095. maxHeight?: number;
  116096. colorFilter?: Color3;
  116097. alphaFilter?: number;
  116098. updatable?: boolean;
  116099. onReady?: (mesh: GroundMesh) => void;
  116100. }, scene?: Nullable<Scene>): GroundMesh;
  116101. }
  116102. }
  116103. declare module BABYLON {
  116104. /**
  116105. * Class containing static functions to help procedurally build meshes
  116106. */
  116107. export class TorusBuilder {
  116108. /**
  116109. * Creates a torus mesh
  116110. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  116111. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  116112. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  116113. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116114. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116115. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116116. * @param name defines the name of the mesh
  116117. * @param options defines the options used to create the mesh
  116118. * @param scene defines the hosting scene
  116119. * @returns the torus mesh
  116120. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  116121. */
  116122. static CreateTorus(name: string, options: {
  116123. diameter?: number;
  116124. thickness?: number;
  116125. tessellation?: number;
  116126. updatable?: boolean;
  116127. sideOrientation?: number;
  116128. frontUVs?: Vector4;
  116129. backUVs?: Vector4;
  116130. }, scene: any): Mesh;
  116131. }
  116132. }
  116133. declare module BABYLON {
  116134. /**
  116135. * Class containing static functions to help procedurally build meshes
  116136. */
  116137. export class CylinderBuilder {
  116138. /**
  116139. * Creates a cylinder or a cone mesh
  116140. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  116141. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  116142. * * 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.
  116143. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  116144. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  116145. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  116146. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  116147. * * 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).
  116148. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  116149. * * 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).
  116150. * * 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
  116151. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  116152. * * 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
  116153. * * 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.
  116154. * * If `enclose` is false, a ring surface is one element.
  116155. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  116156. * * 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
  116157. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116158. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116159. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116160. * @param name defines the name of the mesh
  116161. * @param options defines the options used to create the mesh
  116162. * @param scene defines the hosting scene
  116163. * @returns the cylinder mesh
  116164. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  116165. */
  116166. static CreateCylinder(name: string, options: {
  116167. height?: number;
  116168. diameterTop?: number;
  116169. diameterBottom?: number;
  116170. diameter?: number;
  116171. tessellation?: number;
  116172. subdivisions?: number;
  116173. arc?: number;
  116174. faceColors?: Color4[];
  116175. faceUV?: Vector4[];
  116176. updatable?: boolean;
  116177. hasRings?: boolean;
  116178. enclose?: boolean;
  116179. cap?: number;
  116180. sideOrientation?: number;
  116181. frontUVs?: Vector4;
  116182. backUVs?: Vector4;
  116183. }, scene: any): Mesh;
  116184. }
  116185. }
  116186. declare module BABYLON {
  116187. /**
  116188. * States of the webXR experience
  116189. */
  116190. export enum WebXRState {
  116191. /**
  116192. * Transitioning to being in XR mode
  116193. */
  116194. ENTERING_XR = 0,
  116195. /**
  116196. * Transitioning to non XR mode
  116197. */
  116198. EXITING_XR = 1,
  116199. /**
  116200. * In XR mode and presenting
  116201. */
  116202. IN_XR = 2,
  116203. /**
  116204. * Not entered XR mode
  116205. */
  116206. NOT_IN_XR = 3
  116207. }
  116208. /**
  116209. * Abstraction of the XR render target
  116210. */
  116211. export interface WebXRRenderTarget extends IDisposable {
  116212. /**
  116213. * xrpresent context of the canvas which can be used to display/mirror xr content
  116214. */
  116215. canvasContext: WebGLRenderingContext;
  116216. /**
  116217. * xr layer for the canvas
  116218. */
  116219. xrLayer: Nullable<XRWebGLLayer>;
  116220. /**
  116221. * Initializes the xr layer for the session
  116222. * @param xrSession xr session
  116223. * @returns a promise that will resolve once the XR Layer has been created
  116224. */
  116225. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  116226. }
  116227. }
  116228. declare module BABYLON {
  116229. /**
  116230. * COnfiguration object for WebXR output canvas
  116231. */
  116232. export class WebXRManagedOutputCanvasOptions {
  116233. /**
  116234. * An optional canvas in case you wish to create it yourself and provide it here.
  116235. * If not provided, a new canvas will be created
  116236. */
  116237. canvasElement?: HTMLCanvasElement;
  116238. /**
  116239. * Options for this XR Layer output
  116240. */
  116241. canvasOptions?: XRWebGLLayerOptions;
  116242. /**
  116243. * CSS styling for a newly created canvas (if not provided)
  116244. */
  116245. newCanvasCssStyle?: string;
  116246. /**
  116247. * Get the default values of the configuration object
  116248. * @returns default values of this configuration object
  116249. */
  116250. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  116251. }
  116252. /**
  116253. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  116254. */
  116255. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  116256. private _options;
  116257. private _canvas;
  116258. private _engine;
  116259. /**
  116260. * Rendering context of the canvas which can be used to display/mirror xr content
  116261. */
  116262. canvasContext: WebGLRenderingContext;
  116263. /**
  116264. * xr layer for the canvas
  116265. */
  116266. xrLayer: Nullable<XRWebGLLayer>;
  116267. /**
  116268. * Initializes the canvas to be added/removed upon entering/exiting xr
  116269. * @param _xrSessionManager The XR Session manager
  116270. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  116271. */
  116272. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  116273. /**
  116274. * Disposes of the object
  116275. */
  116276. dispose(): void;
  116277. /**
  116278. * Initializes the xr layer for the session
  116279. * @param xrSession xr session
  116280. * @returns a promise that will resolve once the XR Layer has been created
  116281. */
  116282. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  116283. private _addCanvas;
  116284. private _removeCanvas;
  116285. private _setManagedOutputCanvas;
  116286. }
  116287. }
  116288. declare module BABYLON {
  116289. /**
  116290. * Manages an XRSession to work with Babylon's engine
  116291. * @see https://doc.babylonjs.com/how_to/webxr
  116292. */
  116293. export class WebXRSessionManager implements IDisposable {
  116294. /** The scene which the session should be created for */
  116295. scene: Scene;
  116296. private _referenceSpace;
  116297. private _rttProvider;
  116298. private _sessionEnded;
  116299. private _xrNavigator;
  116300. private baseLayer;
  116301. /**
  116302. * The base reference space from which the session started. good if you want to reset your
  116303. * reference space
  116304. */
  116305. baseReferenceSpace: XRReferenceSpace;
  116306. /**
  116307. * Current XR frame
  116308. */
  116309. currentFrame: Nullable<XRFrame>;
  116310. /** WebXR timestamp updated every frame */
  116311. currentTimestamp: number;
  116312. /**
  116313. * Used just in case of a failure to initialize an immersive session.
  116314. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  116315. */
  116316. defaultHeightCompensation: number;
  116317. /**
  116318. * Fires every time a new xrFrame arrives which can be used to update the camera
  116319. */
  116320. onXRFrameObservable: Observable<XRFrame>;
  116321. /**
  116322. * Fires when the reference space changed
  116323. */
  116324. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  116325. /**
  116326. * Fires when the xr session is ended either by the device or manually done
  116327. */
  116328. onXRSessionEnded: Observable<any>;
  116329. /**
  116330. * Fires when the xr session is ended either by the device or manually done
  116331. */
  116332. onXRSessionInit: Observable<XRSession>;
  116333. /**
  116334. * Underlying xr session
  116335. */
  116336. session: XRSession;
  116337. /**
  116338. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  116339. * or get the offset the player is currently at.
  116340. */
  116341. viewerReferenceSpace: XRReferenceSpace;
  116342. /**
  116343. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  116344. * @param scene The scene which the session should be created for
  116345. */
  116346. constructor(
  116347. /** The scene which the session should be created for */
  116348. scene: Scene);
  116349. /**
  116350. * The current reference space used in this session. This reference space can constantly change!
  116351. * It is mainly used to offset the camera's position.
  116352. */
  116353. get referenceSpace(): XRReferenceSpace;
  116354. /**
  116355. * Set a new reference space and triggers the observable
  116356. */
  116357. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  116358. /**
  116359. * Disposes of the session manager
  116360. */
  116361. dispose(): void;
  116362. /**
  116363. * Stops the xrSession and restores the render loop
  116364. * @returns Promise which resolves after it exits XR
  116365. */
  116366. exitXRAsync(): Promise<void>;
  116367. /**
  116368. * Gets the correct render target texture to be rendered this frame for this eye
  116369. * @param eye the eye for which to get the render target
  116370. * @returns the render target for the specified eye
  116371. */
  116372. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  116373. /**
  116374. * Creates a WebXRRenderTarget object for the XR session
  116375. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  116376. * @param options optional options to provide when creating a new render target
  116377. * @returns a WebXR render target to which the session can render
  116378. */
  116379. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  116380. /**
  116381. * Initializes the manager
  116382. * After initialization enterXR can be called to start an XR session
  116383. * @returns Promise which resolves after it is initialized
  116384. */
  116385. initializeAsync(): Promise<void>;
  116386. /**
  116387. * Initializes an xr session
  116388. * @param xrSessionMode mode to initialize
  116389. * @param xrSessionInit defines optional and required values to pass to the session builder
  116390. * @returns a promise which will resolve once the session has been initialized
  116391. */
  116392. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  116393. /**
  116394. * Checks if a session would be supported for the creation options specified
  116395. * @param sessionMode session mode to check if supported eg. immersive-vr
  116396. * @returns A Promise that resolves to true if supported and false if not
  116397. */
  116398. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  116399. /**
  116400. * Resets the reference space to the one started the session
  116401. */
  116402. resetReferenceSpace(): void;
  116403. /**
  116404. * Starts rendering to the xr layer
  116405. */
  116406. runXRRenderLoop(): void;
  116407. /**
  116408. * Sets the reference space on the xr session
  116409. * @param referenceSpaceType space to set
  116410. * @returns a promise that will resolve once the reference space has been set
  116411. */
  116412. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  116413. /**
  116414. * Updates the render state of the session
  116415. * @param state state to set
  116416. * @returns a promise that resolves once the render state has been updated
  116417. */
  116418. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  116419. /**
  116420. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  116421. * @param sessionMode defines the session to test
  116422. * @returns a promise with boolean as final value
  116423. */
  116424. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  116425. private _createRenderTargetTexture;
  116426. }
  116427. }
  116428. declare module BABYLON {
  116429. /**
  116430. * WebXR Camera which holds the views for the xrSession
  116431. * @see https://doc.babylonjs.com/how_to/webxr_camera
  116432. */
  116433. export class WebXRCamera extends FreeCamera {
  116434. private _xrSessionManager;
  116435. private _firstFrame;
  116436. private _referenceQuaternion;
  116437. private _referencedPosition;
  116438. private _xrInvPositionCache;
  116439. private _xrInvQuaternionCache;
  116440. /**
  116441. * Should position compensation execute on first frame.
  116442. * This is used when copying the position from a native (non XR) camera
  116443. */
  116444. compensateOnFirstFrame: boolean;
  116445. /**
  116446. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  116447. * @param name the name of the camera
  116448. * @param scene the scene to add the camera to
  116449. * @param _xrSessionManager a constructed xr session manager
  116450. */
  116451. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  116452. /**
  116453. * Return the user's height, unrelated to the current ground.
  116454. * This will be the y position of this camera, when ground level is 0.
  116455. */
  116456. get realWorldHeight(): number;
  116457. /** @hidden */
  116458. _updateForDualEyeDebugging(): void;
  116459. /**
  116460. * Sets this camera's transformation based on a non-vr camera
  116461. * @param otherCamera the non-vr camera to copy the transformation from
  116462. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  116463. */
  116464. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  116465. /**
  116466. * Gets the current instance class name ("WebXRCamera").
  116467. * @returns the class name
  116468. */
  116469. getClassName(): string;
  116470. private _updateFromXRSession;
  116471. private _updateNumberOfRigCameras;
  116472. private _updateReferenceSpace;
  116473. private _updateReferenceSpaceOffset;
  116474. }
  116475. }
  116476. declare module BABYLON {
  116477. /**
  116478. * Defining the interface required for a (webxr) feature
  116479. */
  116480. export interface IWebXRFeature extends IDisposable {
  116481. /**
  116482. * Is this feature attached
  116483. */
  116484. attached: boolean;
  116485. /**
  116486. * Should auto-attach be disabled?
  116487. */
  116488. disableAutoAttach: boolean;
  116489. /**
  116490. * Attach the feature to the session
  116491. * Will usually be called by the features manager
  116492. *
  116493. * @param force should attachment be forced (even when already attached)
  116494. * @returns true if successful.
  116495. */
  116496. attach(force?: boolean): boolean;
  116497. /**
  116498. * Detach the feature from the session
  116499. * Will usually be called by the features manager
  116500. *
  116501. * @returns true if successful.
  116502. */
  116503. detach(): boolean;
  116504. }
  116505. /**
  116506. * A list of the currently available features without referencing them
  116507. */
  116508. export class WebXRFeatureName {
  116509. /**
  116510. * The name of the anchor system feature
  116511. */
  116512. static ANCHOR_SYSTEM: string;
  116513. /**
  116514. * The name of the background remover feature
  116515. */
  116516. static BACKGROUND_REMOVER: string;
  116517. /**
  116518. * The name of the hit test feature
  116519. */
  116520. static HIT_TEST: string;
  116521. /**
  116522. * physics impostors for xr controllers feature
  116523. */
  116524. static PHYSICS_CONTROLLERS: string;
  116525. /**
  116526. * The name of the plane detection feature
  116527. */
  116528. static PLANE_DETECTION: string;
  116529. /**
  116530. * The name of the pointer selection feature
  116531. */
  116532. static POINTER_SELECTION: string;
  116533. /**
  116534. * The name of the teleportation feature
  116535. */
  116536. static TELEPORTATION: string;
  116537. }
  116538. /**
  116539. * Defining the constructor of a feature. Used to register the modules.
  116540. */
  116541. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  116542. /**
  116543. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  116544. * It is mainly used in AR sessions.
  116545. *
  116546. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  116547. */
  116548. export class WebXRFeaturesManager implements IDisposable {
  116549. private _xrSessionManager;
  116550. private static readonly _AvailableFeatures;
  116551. private _features;
  116552. /**
  116553. * constructs a new features manages.
  116554. *
  116555. * @param _xrSessionManager an instance of WebXRSessionManager
  116556. */
  116557. constructor(_xrSessionManager: WebXRSessionManager);
  116558. /**
  116559. * Used to register a module. After calling this function a developer can use this feature in the scene.
  116560. * Mainly used internally.
  116561. *
  116562. * @param featureName the name of the feature to register
  116563. * @param constructorFunction the function used to construct the module
  116564. * @param version the (babylon) version of the module
  116565. * @param stable is that a stable version of this module
  116566. */
  116567. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  116568. /**
  116569. * Returns a constructor of a specific feature.
  116570. *
  116571. * @param featureName the name of the feature to construct
  116572. * @param version the version of the feature to load
  116573. * @param xrSessionManager the xrSessionManager. Used to construct the module
  116574. * @param options optional options provided to the module.
  116575. * @returns a function that, when called, will return a new instance of this feature
  116576. */
  116577. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  116578. /**
  116579. * Can be used to return the list of features currently registered
  116580. *
  116581. * @returns an Array of available features
  116582. */
  116583. static GetAvailableFeatures(): string[];
  116584. /**
  116585. * Gets the versions available for a specific feature
  116586. * @param featureName the name of the feature
  116587. * @returns an array with the available versions
  116588. */
  116589. static GetAvailableVersions(featureName: string): string[];
  116590. /**
  116591. * Return the latest unstable version of this feature
  116592. * @param featureName the name of the feature to search
  116593. * @returns the version number. if not found will return -1
  116594. */
  116595. static GetLatestVersionOfFeature(featureName: string): number;
  116596. /**
  116597. * Return the latest stable version of this feature
  116598. * @param featureName the name of the feature to search
  116599. * @returns the version number. if not found will return -1
  116600. */
  116601. static GetStableVersionOfFeature(featureName: string): number;
  116602. /**
  116603. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  116604. * Can be used during a session to start a feature
  116605. * @param featureName the name of feature to attach
  116606. */
  116607. attachFeature(featureName: string): void;
  116608. /**
  116609. * Can be used inside a session or when the session ends to detach a specific feature
  116610. * @param featureName the name of the feature to detach
  116611. */
  116612. detachFeature(featureName: string): void;
  116613. /**
  116614. * Used to disable an already-enabled feature
  116615. * The feature will be disposed and will be recreated once enabled.
  116616. * @param featureName the feature to disable
  116617. * @returns true if disable was successful
  116618. */
  116619. disableFeature(featureName: string | {
  116620. Name: string;
  116621. }): boolean;
  116622. /**
  116623. * dispose this features manager
  116624. */
  116625. dispose(): void;
  116626. /**
  116627. * 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.
  116628. * 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.
  116629. *
  116630. * @param featureName the name of the feature to load or the class of the feature
  116631. * @param version optional version to load. if not provided the latest version will be enabled
  116632. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  116633. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  116634. * @returns a new constructed feature or throws an error if feature not found.
  116635. */
  116636. enableFeature(featureName: string | {
  116637. Name: string;
  116638. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  116639. /**
  116640. * get the implementation of an enabled feature.
  116641. * @param featureName the name of the feature to load
  116642. * @returns the feature class, if found
  116643. */
  116644. getEnabledFeature(featureName: string): IWebXRFeature;
  116645. /**
  116646. * Get the list of enabled features
  116647. * @returns an array of enabled features
  116648. */
  116649. getEnabledFeatures(): string[];
  116650. }
  116651. }
  116652. declare module BABYLON {
  116653. /**
  116654. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  116655. * @see https://doc.babylonjs.com/how_to/webxr
  116656. */
  116657. export class WebXRExperienceHelper implements IDisposable {
  116658. private scene;
  116659. private _nonVRCamera;
  116660. private _originalSceneAutoClear;
  116661. private _supported;
  116662. /**
  116663. * Camera used to render xr content
  116664. */
  116665. camera: WebXRCamera;
  116666. /** A features manager for this xr session */
  116667. featuresManager: WebXRFeaturesManager;
  116668. /**
  116669. * Observers registered here will be triggered after the camera's initial transformation is set
  116670. * This can be used to set a different ground level or an extra rotation.
  116671. *
  116672. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  116673. * to the position set after this observable is done executing.
  116674. */
  116675. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  116676. /**
  116677. * Fires when the state of the experience helper has changed
  116678. */
  116679. onStateChangedObservable: Observable<WebXRState>;
  116680. /** Session manager used to keep track of xr session */
  116681. sessionManager: WebXRSessionManager;
  116682. /**
  116683. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  116684. */
  116685. state: WebXRState;
  116686. /**
  116687. * Creates a WebXRExperienceHelper
  116688. * @param scene The scene the helper should be created in
  116689. */
  116690. private constructor();
  116691. /**
  116692. * Creates the experience helper
  116693. * @param scene the scene to attach the experience helper to
  116694. * @returns a promise for the experience helper
  116695. */
  116696. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  116697. /**
  116698. * Disposes of the experience helper
  116699. */
  116700. dispose(): void;
  116701. /**
  116702. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  116703. * @param sessionMode options for the XR session
  116704. * @param referenceSpaceType frame of reference of the XR session
  116705. * @param renderTarget the output canvas that will be used to enter XR mode
  116706. * @returns promise that resolves after xr mode has entered
  116707. */
  116708. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  116709. /**
  116710. * Exits XR mode and returns the scene to its original state
  116711. * @returns promise that resolves after xr mode has exited
  116712. */
  116713. exitXRAsync(): Promise<void>;
  116714. private _nonXRToXRCamera;
  116715. private _setState;
  116716. }
  116717. }
  116718. declare module BABYLON {
  116719. /**
  116720. * X-Y values for axes in WebXR
  116721. */
  116722. export interface IWebXRMotionControllerAxesValue {
  116723. /**
  116724. * The value of the x axis
  116725. */
  116726. x: number;
  116727. /**
  116728. * The value of the y-axis
  116729. */
  116730. y: number;
  116731. }
  116732. /**
  116733. * changed / previous values for the values of this component
  116734. */
  116735. export interface IWebXRMotionControllerComponentChangesValues<T> {
  116736. /**
  116737. * current (this frame) value
  116738. */
  116739. current: T;
  116740. /**
  116741. * previous (last change) value
  116742. */
  116743. previous: T;
  116744. }
  116745. /**
  116746. * Represents changes in the component between current frame and last values recorded
  116747. */
  116748. export interface IWebXRMotionControllerComponentChanges {
  116749. /**
  116750. * will be populated with previous and current values if axes changed
  116751. */
  116752. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  116753. /**
  116754. * will be populated with previous and current values if pressed changed
  116755. */
  116756. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  116757. /**
  116758. * will be populated with previous and current values if touched changed
  116759. */
  116760. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  116761. /**
  116762. * will be populated with previous and current values if value changed
  116763. */
  116764. value?: IWebXRMotionControllerComponentChangesValues<number>;
  116765. }
  116766. /**
  116767. * This class represents a single component (for example button or thumbstick) of a motion controller
  116768. */
  116769. export class WebXRControllerComponent implements IDisposable {
  116770. /**
  116771. * the id of this component
  116772. */
  116773. id: string;
  116774. /**
  116775. * the type of the component
  116776. */
  116777. type: MotionControllerComponentType;
  116778. private _buttonIndex;
  116779. private _axesIndices;
  116780. private _axes;
  116781. private _changes;
  116782. private _currentValue;
  116783. private _hasChanges;
  116784. private _pressed;
  116785. private _touched;
  116786. /**
  116787. * button component type
  116788. */
  116789. static BUTTON_TYPE: MotionControllerComponentType;
  116790. /**
  116791. * squeeze component type
  116792. */
  116793. static SQUEEZE_TYPE: MotionControllerComponentType;
  116794. /**
  116795. * Thumbstick component type
  116796. */
  116797. static THUMBSTICK_TYPE: MotionControllerComponentType;
  116798. /**
  116799. * Touchpad component type
  116800. */
  116801. static TOUCHPAD_TYPE: MotionControllerComponentType;
  116802. /**
  116803. * trigger component type
  116804. */
  116805. static TRIGGER_TYPE: MotionControllerComponentType;
  116806. /**
  116807. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  116808. * the axes data changes
  116809. */
  116810. onAxisValueChangedObservable: Observable<{
  116811. x: number;
  116812. y: number;
  116813. }>;
  116814. /**
  116815. * Observers registered here will be triggered when the state of a button changes
  116816. * State change is either pressed / touched / value
  116817. */
  116818. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  116819. /**
  116820. * Creates a new component for a motion controller.
  116821. * It is created by the motion controller itself
  116822. *
  116823. * @param id the id of this component
  116824. * @param type the type of the component
  116825. * @param _buttonIndex index in the buttons array of the gamepad
  116826. * @param _axesIndices indices of the values in the axes array of the gamepad
  116827. */
  116828. constructor(
  116829. /**
  116830. * the id of this component
  116831. */
  116832. id: string,
  116833. /**
  116834. * the type of the component
  116835. */
  116836. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  116837. /**
  116838. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  116839. */
  116840. get axes(): IWebXRMotionControllerAxesValue;
  116841. /**
  116842. * Get the changes. Elements will be populated only if they changed with their previous and current value
  116843. */
  116844. get changes(): IWebXRMotionControllerComponentChanges;
  116845. /**
  116846. * Return whether or not the component changed the last frame
  116847. */
  116848. get hasChanges(): boolean;
  116849. /**
  116850. * is the button currently pressed
  116851. */
  116852. get pressed(): boolean;
  116853. /**
  116854. * is the button currently touched
  116855. */
  116856. get touched(): boolean;
  116857. /**
  116858. * Get the current value of this component
  116859. */
  116860. get value(): number;
  116861. /**
  116862. * Dispose this component
  116863. */
  116864. dispose(): void;
  116865. /**
  116866. * Are there axes correlating to this component
  116867. * @return true is axes data is available
  116868. */
  116869. isAxes(): boolean;
  116870. /**
  116871. * Is this component a button (hence - pressable)
  116872. * @returns true if can be pressed
  116873. */
  116874. isButton(): boolean;
  116875. /**
  116876. * update this component using the gamepad object it is in. Called on every frame
  116877. * @param nativeController the native gamepad controller object
  116878. */
  116879. update(nativeController: IMinimalMotionControllerObject): void;
  116880. }
  116881. }
  116882. declare module BABYLON {
  116883. /**
  116884. * Class used to represent data loading progression
  116885. */
  116886. export class SceneLoaderProgressEvent {
  116887. /** defines if data length to load can be evaluated */
  116888. readonly lengthComputable: boolean;
  116889. /** defines the loaded data length */
  116890. readonly loaded: number;
  116891. /** defines the data length to load */
  116892. readonly total: number;
  116893. /**
  116894. * Create a new progress event
  116895. * @param lengthComputable defines if data length to load can be evaluated
  116896. * @param loaded defines the loaded data length
  116897. * @param total defines the data length to load
  116898. */
  116899. constructor(
  116900. /** defines if data length to load can be evaluated */
  116901. lengthComputable: boolean,
  116902. /** defines the loaded data length */
  116903. loaded: number,
  116904. /** defines the data length to load */
  116905. total: number);
  116906. /**
  116907. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  116908. * @param event defines the source event
  116909. * @returns a new SceneLoaderProgressEvent
  116910. */
  116911. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  116912. }
  116913. /**
  116914. * Interface used by SceneLoader plugins to define supported file extensions
  116915. */
  116916. export interface ISceneLoaderPluginExtensions {
  116917. /**
  116918. * Defines the list of supported extensions
  116919. */
  116920. [extension: string]: {
  116921. isBinary: boolean;
  116922. };
  116923. }
  116924. /**
  116925. * Interface used by SceneLoader plugin factory
  116926. */
  116927. export interface ISceneLoaderPluginFactory {
  116928. /**
  116929. * Defines the name of the factory
  116930. */
  116931. name: string;
  116932. /**
  116933. * Function called to create a new plugin
  116934. * @return the new plugin
  116935. */
  116936. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  116937. /**
  116938. * The callback that returns true if the data can be directly loaded.
  116939. * @param data string containing the file data
  116940. * @returns if the data can be loaded directly
  116941. */
  116942. canDirectLoad?(data: string): boolean;
  116943. }
  116944. /**
  116945. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  116946. */
  116947. export interface ISceneLoaderPluginBase {
  116948. /**
  116949. * The friendly name of this plugin.
  116950. */
  116951. name: string;
  116952. /**
  116953. * The file extensions supported by this plugin.
  116954. */
  116955. extensions: string | ISceneLoaderPluginExtensions;
  116956. /**
  116957. * The callback called when loading from a url.
  116958. * @param scene scene loading this url
  116959. * @param url url to load
  116960. * @param onSuccess callback called when the file successfully loads
  116961. * @param onProgress callback called while file is loading (if the server supports this mode)
  116962. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  116963. * @param onError callback called when the file fails to load
  116964. * @returns a file request object
  116965. */
  116966. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  116967. /**
  116968. * The callback called when loading from a file object.
  116969. * @param scene scene loading this file
  116970. * @param file defines the file to load
  116971. * @param onSuccess defines the callback to call when data is loaded
  116972. * @param onProgress defines the callback to call during loading process
  116973. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  116974. * @param onError defines the callback to call when an error occurs
  116975. * @returns a file request object
  116976. */
  116977. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  116978. /**
  116979. * The callback that returns true if the data can be directly loaded.
  116980. * @param data string containing the file data
  116981. * @returns if the data can be loaded directly
  116982. */
  116983. canDirectLoad?(data: string): boolean;
  116984. /**
  116985. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  116986. * @param scene scene loading this data
  116987. * @param data string containing the data
  116988. * @returns data to pass to the plugin
  116989. */
  116990. directLoad?(scene: Scene, data: string): any;
  116991. /**
  116992. * The callback that allows custom handling of the root url based on the response url.
  116993. * @param rootUrl the original root url
  116994. * @param responseURL the response url if available
  116995. * @returns the new root url
  116996. */
  116997. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  116998. }
  116999. /**
  117000. * Interface used to define a SceneLoader plugin
  117001. */
  117002. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  117003. /**
  117004. * Import meshes into a scene.
  117005. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  117006. * @param scene The scene to import into
  117007. * @param data The data to import
  117008. * @param rootUrl The root url for scene and resources
  117009. * @param meshes The meshes array to import into
  117010. * @param particleSystems The particle systems array to import into
  117011. * @param skeletons The skeletons array to import into
  117012. * @param onError The callback when import fails
  117013. * @returns True if successful or false otherwise
  117014. */
  117015. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  117016. /**
  117017. * Load into a scene.
  117018. * @param scene The scene to load into
  117019. * @param data The data to import
  117020. * @param rootUrl The root url for scene and resources
  117021. * @param onError The callback when import fails
  117022. * @returns True if successful or false otherwise
  117023. */
  117024. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  117025. /**
  117026. * Load into an asset container.
  117027. * @param scene The scene to load into
  117028. * @param data The data to import
  117029. * @param rootUrl The root url for scene and resources
  117030. * @param onError The callback when import fails
  117031. * @returns The loaded asset container
  117032. */
  117033. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  117034. }
  117035. /**
  117036. * Interface used to define an async SceneLoader plugin
  117037. */
  117038. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  117039. /**
  117040. * Import meshes into a scene.
  117041. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  117042. * @param scene The scene to import into
  117043. * @param data The data to import
  117044. * @param rootUrl The root url for scene and resources
  117045. * @param onProgress The callback when the load progresses
  117046. * @param fileName Defines the name of the file to load
  117047. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  117048. */
  117049. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  117050. meshes: AbstractMesh[];
  117051. particleSystems: IParticleSystem[];
  117052. skeletons: Skeleton[];
  117053. animationGroups: AnimationGroup[];
  117054. }>;
  117055. /**
  117056. * Load into a scene.
  117057. * @param scene The scene to load into
  117058. * @param data The data to import
  117059. * @param rootUrl The root url for scene and resources
  117060. * @param onProgress The callback when the load progresses
  117061. * @param fileName Defines the name of the file to load
  117062. * @returns Nothing
  117063. */
  117064. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  117065. /**
  117066. * Load into an asset container.
  117067. * @param scene The scene to load into
  117068. * @param data The data to import
  117069. * @param rootUrl The root url for scene and resources
  117070. * @param onProgress The callback when the load progresses
  117071. * @param fileName Defines the name of the file to load
  117072. * @returns The loaded asset container
  117073. */
  117074. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  117075. }
  117076. /**
  117077. * Mode that determines how to handle old animation groups before loading new ones.
  117078. */
  117079. export enum SceneLoaderAnimationGroupLoadingMode {
  117080. /**
  117081. * Reset all old animations to initial state then dispose them.
  117082. */
  117083. Clean = 0,
  117084. /**
  117085. * Stop all old animations.
  117086. */
  117087. Stop = 1,
  117088. /**
  117089. * Restart old animations from first frame.
  117090. */
  117091. Sync = 2,
  117092. /**
  117093. * Old animations remains untouched.
  117094. */
  117095. NoSync = 3
  117096. }
  117097. /**
  117098. * Class used to load scene from various file formats using registered plugins
  117099. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  117100. */
  117101. export class SceneLoader {
  117102. /**
  117103. * No logging while loading
  117104. */
  117105. static readonly NO_LOGGING: number;
  117106. /**
  117107. * Minimal logging while loading
  117108. */
  117109. static readonly MINIMAL_LOGGING: number;
  117110. /**
  117111. * Summary logging while loading
  117112. */
  117113. static readonly SUMMARY_LOGGING: number;
  117114. /**
  117115. * Detailled logging while loading
  117116. */
  117117. static readonly DETAILED_LOGGING: number;
  117118. /**
  117119. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  117120. */
  117121. static get ForceFullSceneLoadingForIncremental(): boolean;
  117122. static set ForceFullSceneLoadingForIncremental(value: boolean);
  117123. /**
  117124. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  117125. */
  117126. static get ShowLoadingScreen(): boolean;
  117127. static set ShowLoadingScreen(value: boolean);
  117128. /**
  117129. * Defines the current logging level (while loading the scene)
  117130. * @ignorenaming
  117131. */
  117132. static get loggingLevel(): number;
  117133. static set loggingLevel(value: number);
  117134. /**
  117135. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  117136. */
  117137. static get CleanBoneMatrixWeights(): boolean;
  117138. static set CleanBoneMatrixWeights(value: boolean);
  117139. /**
  117140. * Event raised when a plugin is used to load a scene
  117141. */
  117142. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  117143. private static _registeredPlugins;
  117144. private static _getDefaultPlugin;
  117145. private static _getPluginForExtension;
  117146. private static _getPluginForDirectLoad;
  117147. private static _getPluginForFilename;
  117148. private static _getDirectLoad;
  117149. private static _loadData;
  117150. private static _getFileInfo;
  117151. /**
  117152. * Gets a plugin that can load the given extension
  117153. * @param extension defines the extension to load
  117154. * @returns a plugin or null if none works
  117155. */
  117156. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  117157. /**
  117158. * Gets a boolean indicating that the given extension can be loaded
  117159. * @param extension defines the extension to load
  117160. * @returns true if the extension is supported
  117161. */
  117162. static IsPluginForExtensionAvailable(extension: string): boolean;
  117163. /**
  117164. * Adds a new plugin to the list of registered plugins
  117165. * @param plugin defines the plugin to add
  117166. */
  117167. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  117168. /**
  117169. * Import meshes into a scene
  117170. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  117171. * @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)
  117172. * @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)
  117173. * @param scene the instance of BABYLON.Scene to append to
  117174. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  117175. * @param onProgress a callback with a progress event for each file being loaded
  117176. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  117177. * @param pluginExtension the extension used to determine the plugin
  117178. * @returns The loaded plugin
  117179. */
  117180. 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>;
  117181. /**
  117182. * Import meshes into a scene
  117183. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  117184. * @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)
  117185. * @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)
  117186. * @param scene the instance of BABYLON.Scene to append to
  117187. * @param onProgress a callback with a progress event for each file being loaded
  117188. * @param pluginExtension the extension used to determine the plugin
  117189. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  117190. */
  117191. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  117192. meshes: AbstractMesh[];
  117193. particleSystems: IParticleSystem[];
  117194. skeletons: Skeleton[];
  117195. animationGroups: AnimationGroup[];
  117196. }>;
  117197. /**
  117198. * Load a scene
  117199. * @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)
  117200. * @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)
  117201. * @param engine is the instance of BABYLON.Engine to use to create the scene
  117202. * @param onSuccess a callback with the scene when import succeeds
  117203. * @param onProgress a callback with a progress event for each file being loaded
  117204. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  117205. * @param pluginExtension the extension used to determine the plugin
  117206. * @returns The loaded plugin
  117207. */
  117208. 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>;
  117209. /**
  117210. * Load a scene
  117211. * @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)
  117212. * @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)
  117213. * @param engine is the instance of BABYLON.Engine to use to create the scene
  117214. * @param onProgress a callback with a progress event for each file being loaded
  117215. * @param pluginExtension the extension used to determine the plugin
  117216. * @returns The loaded scene
  117217. */
  117218. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  117219. /**
  117220. * Append a scene
  117221. * @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)
  117222. * @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)
  117223. * @param scene is the instance of BABYLON.Scene to append to
  117224. * @param onSuccess a callback with the scene when import succeeds
  117225. * @param onProgress a callback with a progress event for each file being loaded
  117226. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  117227. * @param pluginExtension the extension used to determine the plugin
  117228. * @returns The loaded plugin
  117229. */
  117230. 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>;
  117231. /**
  117232. * Append a scene
  117233. * @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)
  117234. * @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)
  117235. * @param scene is the instance of BABYLON.Scene to append to
  117236. * @param onProgress a callback with a progress event for each file being loaded
  117237. * @param pluginExtension the extension used to determine the plugin
  117238. * @returns The given scene
  117239. */
  117240. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  117241. /**
  117242. * Load a scene into an asset container
  117243. * @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)
  117244. * @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)
  117245. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  117246. * @param onSuccess a callback with the scene when import succeeds
  117247. * @param onProgress a callback with a progress event for each file being loaded
  117248. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  117249. * @param pluginExtension the extension used to determine the plugin
  117250. * @returns The loaded plugin
  117251. */
  117252. 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>;
  117253. /**
  117254. * Load a scene into an asset container
  117255. * @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)
  117256. * @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)
  117257. * @param scene is the instance of Scene to append to
  117258. * @param onProgress a callback with a progress event for each file being loaded
  117259. * @param pluginExtension the extension used to determine the plugin
  117260. * @returns The loaded asset container
  117261. */
  117262. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  117263. /**
  117264. * Import animations from a file into a scene
  117265. * @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)
  117266. * @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)
  117267. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  117268. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  117269. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  117270. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  117271. * @param onSuccess a callback with the scene when import succeeds
  117272. * @param onProgress a callback with a progress event for each file being loaded
  117273. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  117274. */
  117275. 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;
  117276. /**
  117277. * Import animations from a file into a scene
  117278. * @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)
  117279. * @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)
  117280. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  117281. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  117282. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  117283. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  117284. * @param onSuccess a callback with the scene when import succeeds
  117285. * @param onProgress a callback with a progress event for each file being loaded
  117286. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  117287. * @returns the updated scene with imported animations
  117288. */
  117289. 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>;
  117290. }
  117291. }
  117292. declare module BABYLON {
  117293. /**
  117294. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  117295. */
  117296. export type MotionControllerHandness = "none" | "left" | "right";
  117297. /**
  117298. * The type of components available in motion controllers.
  117299. * This is not the name of the component.
  117300. */
  117301. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  117302. /**
  117303. * The state of a controller component
  117304. */
  117305. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  117306. /**
  117307. * The schema of motion controller layout.
  117308. * No object will be initialized using this interface
  117309. * This is used just to define the profile.
  117310. */
  117311. export interface IMotionControllerLayout {
  117312. /**
  117313. * Path to load the assets. Usually relative to the base path
  117314. */
  117315. assetPath: string;
  117316. /**
  117317. * Available components (unsorted)
  117318. */
  117319. components: {
  117320. /**
  117321. * A map of component Ids
  117322. */
  117323. [componentId: string]: {
  117324. /**
  117325. * The type of input the component outputs
  117326. */
  117327. type: MotionControllerComponentType;
  117328. /**
  117329. * The indices of this component in the gamepad object
  117330. */
  117331. gamepadIndices: {
  117332. /**
  117333. * Index of button
  117334. */
  117335. button?: number;
  117336. /**
  117337. * If available, index of x-axis
  117338. */
  117339. xAxis?: number;
  117340. /**
  117341. * If available, index of y-axis
  117342. */
  117343. yAxis?: number;
  117344. };
  117345. /**
  117346. * The mesh's root node name
  117347. */
  117348. rootNodeName: string;
  117349. /**
  117350. * Animation definitions for this model
  117351. */
  117352. visualResponses: {
  117353. [stateKey: string]: {
  117354. /**
  117355. * What property will be animated
  117356. */
  117357. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  117358. /**
  117359. * What states influence this visual response
  117360. */
  117361. states: MotionControllerComponentStateType[];
  117362. /**
  117363. * Type of animation - movement or visibility
  117364. */
  117365. valueNodeProperty: "transform" | "visibility";
  117366. /**
  117367. * Base node name to move. Its position will be calculated according to the min and max nodes
  117368. */
  117369. valueNodeName?: string;
  117370. /**
  117371. * Minimum movement node
  117372. */
  117373. minNodeName?: string;
  117374. /**
  117375. * Max movement node
  117376. */
  117377. maxNodeName?: string;
  117378. };
  117379. };
  117380. /**
  117381. * If touch enabled, what is the name of node to display user feedback
  117382. */
  117383. touchPointNodeName?: string;
  117384. };
  117385. };
  117386. /**
  117387. * Is it xr standard mapping or not
  117388. */
  117389. gamepadMapping: "" | "xr-standard";
  117390. /**
  117391. * Base root node of this entire model
  117392. */
  117393. rootNodeName: string;
  117394. /**
  117395. * Defines the main button component id
  117396. */
  117397. selectComponentId: string;
  117398. }
  117399. /**
  117400. * A definition for the layout map in the input profile
  117401. */
  117402. export interface IMotionControllerLayoutMap {
  117403. /**
  117404. * Layouts with handness type as a key
  117405. */
  117406. [handness: string]: IMotionControllerLayout;
  117407. }
  117408. /**
  117409. * The XR Input profile schema
  117410. * Profiles can be found here:
  117411. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  117412. */
  117413. export interface IMotionControllerProfile {
  117414. /**
  117415. * fallback profiles for this profileId
  117416. */
  117417. fallbackProfileIds: string[];
  117418. /**
  117419. * The layout map, with handness as key
  117420. */
  117421. layouts: IMotionControllerLayoutMap;
  117422. /**
  117423. * The id of this profile
  117424. * correlates to the profile(s) in the xrInput.profiles array
  117425. */
  117426. profileId: string;
  117427. }
  117428. /**
  117429. * A helper-interface for the 3 meshes needed for controller button animation
  117430. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  117431. */
  117432. export interface IMotionControllerButtonMeshMap {
  117433. /**
  117434. * the mesh that defines the pressed value mesh position.
  117435. * This is used to find the max-position of this button
  117436. */
  117437. pressedMesh: AbstractMesh;
  117438. /**
  117439. * the mesh that defines the unpressed value mesh position.
  117440. * This is used to find the min (or initial) position of this button
  117441. */
  117442. unpressedMesh: AbstractMesh;
  117443. /**
  117444. * The mesh that will be changed when value changes
  117445. */
  117446. valueMesh: AbstractMesh;
  117447. }
  117448. /**
  117449. * A helper-interface for the 3 meshes needed for controller axis animation.
  117450. * This will be expanded when touchpad animations are fully supported
  117451. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  117452. */
  117453. export interface IMotionControllerMeshMap {
  117454. /**
  117455. * the mesh that defines the maximum value mesh position.
  117456. */
  117457. maxMesh?: AbstractMesh;
  117458. /**
  117459. * the mesh that defines the minimum value mesh position.
  117460. */
  117461. minMesh?: AbstractMesh;
  117462. /**
  117463. * The mesh that will be changed when axis value changes
  117464. */
  117465. valueMesh: AbstractMesh;
  117466. }
  117467. /**
  117468. * The elements needed for change-detection of the gamepad objects in motion controllers
  117469. */
  117470. export interface IMinimalMotionControllerObject {
  117471. /**
  117472. * Available axes of this controller
  117473. */
  117474. axes: number[];
  117475. /**
  117476. * An array of available buttons
  117477. */
  117478. buttons: Array<{
  117479. /**
  117480. * Value of the button/trigger
  117481. */
  117482. value: number;
  117483. /**
  117484. * If the button/trigger is currently touched
  117485. */
  117486. touched: boolean;
  117487. /**
  117488. * If the button/trigger is currently pressed
  117489. */
  117490. pressed: boolean;
  117491. }>;
  117492. }
  117493. /**
  117494. * An Abstract Motion controller
  117495. * This class receives an xrInput and a profile layout and uses those to initialize the components
  117496. * Each component has an observable to check for changes in value and state
  117497. */
  117498. export abstract class WebXRAbstractMotionController implements IDisposable {
  117499. protected scene: Scene;
  117500. protected layout: IMotionControllerLayout;
  117501. /**
  117502. * The gamepad object correlating to this controller
  117503. */
  117504. gamepadObject: IMinimalMotionControllerObject;
  117505. /**
  117506. * handness (left/right/none) of this controller
  117507. */
  117508. handness: MotionControllerHandness;
  117509. private _initComponent;
  117510. private _modelReady;
  117511. /**
  117512. * A map of components (WebXRControllerComponent) in this motion controller
  117513. * Components have a ComponentType and can also have both button and axis definitions
  117514. */
  117515. readonly components: {
  117516. [id: string]: WebXRControllerComponent;
  117517. };
  117518. /**
  117519. * Disable the model's animation. Can be set at any time.
  117520. */
  117521. disableAnimation: boolean;
  117522. /**
  117523. * Observers registered here will be triggered when the model of this controller is done loading
  117524. */
  117525. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  117526. /**
  117527. * The profile id of this motion controller
  117528. */
  117529. abstract profileId: string;
  117530. /**
  117531. * The root mesh of the model. It is null if the model was not yet initialized
  117532. */
  117533. rootMesh: Nullable<AbstractMesh>;
  117534. /**
  117535. * constructs a new abstract motion controller
  117536. * @param scene the scene to which the model of the controller will be added
  117537. * @param layout The profile layout to load
  117538. * @param gamepadObject The gamepad object correlating to this controller
  117539. * @param handness handness (left/right/none) of this controller
  117540. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  117541. */
  117542. constructor(scene: Scene, layout: IMotionControllerLayout,
  117543. /**
  117544. * The gamepad object correlating to this controller
  117545. */
  117546. gamepadObject: IMinimalMotionControllerObject,
  117547. /**
  117548. * handness (left/right/none) of this controller
  117549. */
  117550. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  117551. /**
  117552. * Dispose this controller, the model mesh and all its components
  117553. */
  117554. dispose(): void;
  117555. /**
  117556. * Returns all components of specific type
  117557. * @param type the type to search for
  117558. * @return an array of components with this type
  117559. */
  117560. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  117561. /**
  117562. * get a component based an its component id as defined in layout.components
  117563. * @param id the id of the component
  117564. * @returns the component correlates to the id or undefined if not found
  117565. */
  117566. getComponent(id: string): WebXRControllerComponent;
  117567. /**
  117568. * Get the list of components available in this motion controller
  117569. * @returns an array of strings correlating to available components
  117570. */
  117571. getComponentIds(): string[];
  117572. /**
  117573. * Get the first component of specific type
  117574. * @param type type of component to find
  117575. * @return a controller component or null if not found
  117576. */
  117577. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  117578. /**
  117579. * Get the main (Select) component of this controller as defined in the layout
  117580. * @returns the main component of this controller
  117581. */
  117582. getMainComponent(): WebXRControllerComponent;
  117583. /**
  117584. * Loads the model correlating to this controller
  117585. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  117586. * @returns A promise fulfilled with the result of the model loading
  117587. */
  117588. loadModel(): Promise<boolean>;
  117589. /**
  117590. * Update this model using the current XRFrame
  117591. * @param xrFrame the current xr frame to use and update the model
  117592. */
  117593. updateFromXRFrame(xrFrame: XRFrame): void;
  117594. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  117595. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  117596. /**
  117597. * Moves the axis on the controller mesh based on its current state
  117598. * @param axis the index of the axis
  117599. * @param axisValue the value of the axis which determines the meshes new position
  117600. * @hidden
  117601. */
  117602. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  117603. /**
  117604. * Update the model itself with the current frame data
  117605. * @param xrFrame the frame to use for updating the model mesh
  117606. */
  117607. protected updateModel(xrFrame: XRFrame): void;
  117608. /**
  117609. * Get the filename and path for this controller's model
  117610. * @returns a map of filename and path
  117611. */
  117612. protected abstract _getFilenameAndPath(): {
  117613. filename: string;
  117614. path: string;
  117615. };
  117616. /**
  117617. * This function is called before the mesh is loaded. It checks for loading constraints.
  117618. * For example, this function can check if the GLB loader is available
  117619. * If this function returns false, the generic controller will be loaded instead
  117620. * @returns Is the client ready to load the mesh
  117621. */
  117622. protected abstract _getModelLoadingConstraints(): boolean;
  117623. /**
  117624. * This function will be called after the model was successfully loaded and can be used
  117625. * for mesh transformations before it is available for the user
  117626. * @param meshes the loaded meshes
  117627. */
  117628. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  117629. /**
  117630. * Set the root mesh for this controller. Important for the WebXR controller class
  117631. * @param meshes the loaded meshes
  117632. */
  117633. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  117634. /**
  117635. * A function executed each frame that updates the mesh (if needed)
  117636. * @param xrFrame the current xrFrame
  117637. */
  117638. protected abstract _updateModel(xrFrame: XRFrame): void;
  117639. private _getGenericFilenameAndPath;
  117640. private _getGenericParentMesh;
  117641. }
  117642. }
  117643. declare module BABYLON {
  117644. /**
  117645. * A generic trigger-only motion controller for WebXR
  117646. */
  117647. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  117648. /**
  117649. * Static version of the profile id of this controller
  117650. */
  117651. static ProfileId: string;
  117652. profileId: string;
  117653. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  117654. protected _getFilenameAndPath(): {
  117655. filename: string;
  117656. path: string;
  117657. };
  117658. protected _getModelLoadingConstraints(): boolean;
  117659. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  117660. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117661. protected _updateModel(): void;
  117662. }
  117663. }
  117664. declare module BABYLON {
  117665. /**
  117666. * Class containing static functions to help procedurally build meshes
  117667. */
  117668. export class SphereBuilder {
  117669. /**
  117670. * Creates a sphere mesh
  117671. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  117672. * * 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`)
  117673. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  117674. * * 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
  117675. * * 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)
  117676. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117677. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117679. * @param name defines the name of the mesh
  117680. * @param options defines the options used to create the mesh
  117681. * @param scene defines the hosting scene
  117682. * @returns the sphere mesh
  117683. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  117684. */
  117685. static CreateSphere(name: string, options: {
  117686. segments?: number;
  117687. diameter?: number;
  117688. diameterX?: number;
  117689. diameterY?: number;
  117690. diameterZ?: number;
  117691. arc?: number;
  117692. slice?: number;
  117693. sideOrientation?: number;
  117694. frontUVs?: Vector4;
  117695. backUVs?: Vector4;
  117696. updatable?: boolean;
  117697. }, scene?: Nullable<Scene>): Mesh;
  117698. }
  117699. }
  117700. declare module BABYLON {
  117701. /**
  117702. * A profiled motion controller has its profile loaded from an online repository.
  117703. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  117704. */
  117705. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  117706. private _repositoryUrl;
  117707. private _buttonMeshMapping;
  117708. private _touchDots;
  117709. /**
  117710. * The profile ID of this controller. Will be populated when the controller initializes.
  117711. */
  117712. profileId: string;
  117713. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  117714. dispose(): void;
  117715. protected _getFilenameAndPath(): {
  117716. filename: string;
  117717. path: string;
  117718. };
  117719. protected _getModelLoadingConstraints(): boolean;
  117720. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  117721. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117722. protected _updateModel(_xrFrame: XRFrame): void;
  117723. }
  117724. }
  117725. declare module BABYLON {
  117726. /**
  117727. * A construction function type to create a new controller based on an xrInput object
  117728. */
  117729. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  117730. /**
  117731. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  117732. *
  117733. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  117734. * it should be replaced with auto-loaded controllers.
  117735. *
  117736. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  117737. */
  117738. export class WebXRMotionControllerManager {
  117739. private static _AvailableControllers;
  117740. private static _Fallbacks;
  117741. private static _ProfileLoadingPromises;
  117742. private static _ProfilesList;
  117743. /**
  117744. * The base URL of the online controller repository. Can be changed at any time.
  117745. */
  117746. static BaseRepositoryUrl: string;
  117747. /**
  117748. * Which repository gets priority - local or online
  117749. */
  117750. static PrioritizeOnlineRepository: boolean;
  117751. /**
  117752. * Use the online repository, or use only locally-defined controllers
  117753. */
  117754. static UseOnlineRepository: boolean;
  117755. /**
  117756. * Clear the cache used for profile loading and reload when requested again
  117757. */
  117758. static ClearProfilesCache(): void;
  117759. /**
  117760. * Register the default fallbacks.
  117761. * This function is called automatically when this file is imported.
  117762. */
  117763. static DefaultFallbacks(): void;
  117764. /**
  117765. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  117766. * @param profileId the profile to which a fallback needs to be found
  117767. * @return an array with corresponding fallback profiles
  117768. */
  117769. static FindFallbackWithProfileId(profileId: string): string[];
  117770. /**
  117771. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  117772. * The order of search:
  117773. *
  117774. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  117775. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  117776. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  117777. * 4) return the generic trigger controller if none were found
  117778. *
  117779. * @param xrInput the xrInput to which a new controller is initialized
  117780. * @param scene the scene to which the model will be added
  117781. * @param forceProfile force a certain profile for this controller
  117782. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  117783. */
  117784. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  117785. /**
  117786. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  117787. *
  117788. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  117789. *
  117790. * @param type the profile type to register
  117791. * @param constructFunction the function to be called when loading this profile
  117792. */
  117793. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  117794. /**
  117795. * Register a fallback to a specific profile.
  117796. * @param profileId the profileId that will receive the fallbacks
  117797. * @param fallbacks A list of fallback profiles
  117798. */
  117799. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  117800. /**
  117801. * Will update the list of profiles available in the repository
  117802. * @return a promise that resolves to a map of profiles available online
  117803. */
  117804. static UpdateProfilesList(): Promise<{
  117805. [profile: string]: string;
  117806. }>;
  117807. private static _LoadProfileFromRepository;
  117808. private static _LoadProfilesFromAvailableControllers;
  117809. }
  117810. }
  117811. declare module BABYLON {
  117812. /**
  117813. * Configuration options for the WebXR controller creation
  117814. */
  117815. export interface IWebXRControllerOptions {
  117816. /**
  117817. * Should the controller mesh be animated when a user interacts with it
  117818. * The pressed buttons / thumbstick and touchpad animations will be disabled
  117819. */
  117820. disableMotionControllerAnimation?: boolean;
  117821. /**
  117822. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  117823. */
  117824. doNotLoadControllerMesh?: boolean;
  117825. /**
  117826. * Force a specific controller type for this controller.
  117827. * This can be used when creating your own profile or when testing different controllers
  117828. */
  117829. forceControllerProfile?: string;
  117830. }
  117831. /**
  117832. * Represents an XR controller
  117833. */
  117834. export class WebXRInputSource {
  117835. private _scene;
  117836. /** The underlying input source for the controller */
  117837. inputSource: XRInputSource;
  117838. private _options;
  117839. private _tmpQuaternion;
  117840. private _tmpVector;
  117841. private _uniqueId;
  117842. /**
  117843. * 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
  117844. */
  117845. grip?: AbstractMesh;
  117846. /**
  117847. * If available, this is the gamepad object related to this controller.
  117848. * Using this object it is possible to get click events and trackpad changes of the
  117849. * webxr controller that is currently being used.
  117850. */
  117851. motionController?: WebXRAbstractMotionController;
  117852. /**
  117853. * Event that fires when the controller is removed/disposed.
  117854. * The object provided as event data is this controller, after associated assets were disposed.
  117855. * uniqueId is still available.
  117856. */
  117857. onDisposeObservable: Observable<WebXRInputSource>;
  117858. /**
  117859. * Will be triggered when the mesh associated with the motion controller is done loading.
  117860. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  117861. * A shortened version of controller -> motion controller -> on mesh loaded.
  117862. */
  117863. onMeshLoadedObservable: Observable<AbstractMesh>;
  117864. /**
  117865. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  117866. */
  117867. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  117868. /**
  117869. * Pointer which can be used to select objects or attach a visible laser to
  117870. */
  117871. pointer: AbstractMesh;
  117872. /**
  117873. * Creates the controller
  117874. * @see https://doc.babylonjs.com/how_to/webxr
  117875. * @param _scene the scene which the controller should be associated to
  117876. * @param inputSource the underlying input source for the controller
  117877. * @param _options options for this controller creation
  117878. */
  117879. constructor(_scene: Scene,
  117880. /** The underlying input source for the controller */
  117881. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  117882. /**
  117883. * Get this controllers unique id
  117884. */
  117885. get uniqueId(): string;
  117886. /**
  117887. * Disposes of the object
  117888. */
  117889. dispose(): void;
  117890. /**
  117891. * Gets a world space ray coming from the pointer or grip
  117892. * @param result the resulting ray
  117893. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  117894. */
  117895. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  117896. /**
  117897. * Updates the controller pose based on the given XRFrame
  117898. * @param xrFrame xr frame to update the pose with
  117899. * @param referenceSpace reference space to use
  117900. */
  117901. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  117902. }
  117903. }
  117904. declare module BABYLON {
  117905. /**
  117906. * The schema for initialization options of the XR Input class
  117907. */
  117908. export interface IWebXRInputOptions {
  117909. /**
  117910. * If set to true no model will be automatically loaded
  117911. */
  117912. doNotLoadControllerMeshes?: boolean;
  117913. /**
  117914. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  117915. * If not found, the xr input profile data will be used.
  117916. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  117917. */
  117918. forceInputProfile?: string;
  117919. /**
  117920. * Do not send a request to the controller repository to load the profile.
  117921. *
  117922. * Instead, use the controllers available in babylon itself.
  117923. */
  117924. disableOnlineControllerRepository?: boolean;
  117925. /**
  117926. * A custom URL for the controllers repository
  117927. */
  117928. customControllersRepositoryURL?: string;
  117929. /**
  117930. * Should the controller model's components not move according to the user input
  117931. */
  117932. disableControllerAnimation?: boolean;
  117933. }
  117934. /**
  117935. * XR input used to track XR inputs such as controllers/rays
  117936. */
  117937. export class WebXRInput implements IDisposable {
  117938. /**
  117939. * the xr session manager for this session
  117940. */
  117941. xrSessionManager: WebXRSessionManager;
  117942. /**
  117943. * the WebXR camera for this session. Mainly used for teleportation
  117944. */
  117945. xrCamera: WebXRCamera;
  117946. private readonly options;
  117947. /**
  117948. * XR controllers being tracked
  117949. */
  117950. controllers: Array<WebXRInputSource>;
  117951. private _frameObserver;
  117952. private _sessionEndedObserver;
  117953. private _sessionInitObserver;
  117954. /**
  117955. * Event when a controller has been connected/added
  117956. */
  117957. onControllerAddedObservable: Observable<WebXRInputSource>;
  117958. /**
  117959. * Event when a controller has been removed/disconnected
  117960. */
  117961. onControllerRemovedObservable: Observable<WebXRInputSource>;
  117962. /**
  117963. * Initializes the WebXRInput
  117964. * @param xrSessionManager the xr session manager for this session
  117965. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  117966. * @param options = initialization options for this xr input
  117967. */
  117968. constructor(
  117969. /**
  117970. * the xr session manager for this session
  117971. */
  117972. xrSessionManager: WebXRSessionManager,
  117973. /**
  117974. * the WebXR camera for this session. Mainly used for teleportation
  117975. */
  117976. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  117977. private _onInputSourcesChange;
  117978. private _addAndRemoveControllers;
  117979. /**
  117980. * Disposes of the object
  117981. */
  117982. dispose(): void;
  117983. }
  117984. }
  117985. declare module BABYLON {
  117986. /**
  117987. * This is the base class for all WebXR features.
  117988. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  117989. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  117990. */
  117991. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  117992. protected _xrSessionManager: WebXRSessionManager;
  117993. private _attached;
  117994. private _removeOnDetach;
  117995. /**
  117996. * Should auto-attach be disabled?
  117997. */
  117998. disableAutoAttach: boolean;
  117999. /**
  118000. * Construct a new (abstract) WebXR feature
  118001. * @param _xrSessionManager the xr session manager for this feature
  118002. */
  118003. constructor(_xrSessionManager: WebXRSessionManager);
  118004. /**
  118005. * Is this feature attached
  118006. */
  118007. get attached(): boolean;
  118008. /**
  118009. * attach this feature
  118010. *
  118011. * @param force should attachment be forced (even when already attached)
  118012. * @returns true if successful, false is failed or already attached
  118013. */
  118014. attach(force?: boolean): boolean;
  118015. /**
  118016. * detach this feature.
  118017. *
  118018. * @returns true if successful, false if failed or already detached
  118019. */
  118020. detach(): boolean;
  118021. /**
  118022. * Dispose this feature and all of the resources attached
  118023. */
  118024. dispose(): void;
  118025. /**
  118026. * This is used to register callbacks that will automatically be removed when detach is called.
  118027. * @param observable the observable to which the observer will be attached
  118028. * @param callback the callback to register
  118029. */
  118030. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  118031. /**
  118032. * Code in this function will be executed on each xrFrame received from the browser.
  118033. * This function will not execute after the feature is detached.
  118034. * @param _xrFrame the current frame
  118035. */
  118036. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  118037. }
  118038. }
  118039. declare module BABYLON {
  118040. /**
  118041. * Renders a layer on top of an existing scene
  118042. */
  118043. export class UtilityLayerRenderer implements IDisposable {
  118044. /** the original scene that will be rendered on top of */
  118045. originalScene: Scene;
  118046. private _pointerCaptures;
  118047. private _lastPointerEvents;
  118048. private static _DefaultUtilityLayer;
  118049. private static _DefaultKeepDepthUtilityLayer;
  118050. private _sharedGizmoLight;
  118051. private _renderCamera;
  118052. /**
  118053. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  118054. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  118055. * @returns the camera that is used when rendering the utility layer
  118056. */
  118057. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  118058. /**
  118059. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  118060. * @param cam the camera that should be used when rendering the utility layer
  118061. */
  118062. setRenderCamera(cam: Nullable<Camera>): void;
  118063. /**
  118064. * @hidden
  118065. * Light which used by gizmos to get light shading
  118066. */
  118067. _getSharedGizmoLight(): HemisphericLight;
  118068. /**
  118069. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  118070. */
  118071. pickUtilitySceneFirst: boolean;
  118072. /**
  118073. * 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)
  118074. */
  118075. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  118076. /**
  118077. * 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)
  118078. */
  118079. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  118080. /**
  118081. * The scene that is rendered on top of the original scene
  118082. */
  118083. utilityLayerScene: Scene;
  118084. /**
  118085. * If the utility layer should automatically be rendered on top of existing scene
  118086. */
  118087. shouldRender: boolean;
  118088. /**
  118089. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  118090. */
  118091. onlyCheckPointerDownEvents: boolean;
  118092. /**
  118093. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  118094. */
  118095. processAllEvents: boolean;
  118096. /**
  118097. * Observable raised when the pointer move from the utility layer scene to the main scene
  118098. */
  118099. onPointerOutObservable: Observable<number>;
  118100. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  118101. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  118102. private _afterRenderObserver;
  118103. private _sceneDisposeObserver;
  118104. private _originalPointerObserver;
  118105. /**
  118106. * Instantiates a UtilityLayerRenderer
  118107. * @param originalScene the original scene that will be rendered on top of
  118108. * @param handleEvents boolean indicating if the utility layer should handle events
  118109. */
  118110. constructor(
  118111. /** the original scene that will be rendered on top of */
  118112. originalScene: Scene, handleEvents?: boolean);
  118113. private _notifyObservers;
  118114. /**
  118115. * Renders the utility layers scene on top of the original scene
  118116. */
  118117. render(): void;
  118118. /**
  118119. * Disposes of the renderer
  118120. */
  118121. dispose(): void;
  118122. private _updateCamera;
  118123. }
  118124. }
  118125. declare module BABYLON {
  118126. /**
  118127. * Options interface for the pointer selection module
  118128. */
  118129. export interface IWebXRControllerPointerSelectionOptions {
  118130. /**
  118131. * if provided, this scene will be used to render meshes.
  118132. */
  118133. customUtilityLayerScene?: Scene;
  118134. /**
  118135. * 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)
  118136. * If not disabled, the last picked point will be used to execute a pointer up event
  118137. * If disabled, pointer up event will be triggered right after the pointer down event.
  118138. * Used in screen and gaze target ray mode only
  118139. */
  118140. disablePointerUpOnTouchOut: boolean;
  118141. /**
  118142. * For gaze mode (time to select instead of press)
  118143. */
  118144. forceGazeMode: boolean;
  118145. /**
  118146. * 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
  118147. * to start a new countdown to the pointer down event.
  118148. * Defaults to 1.
  118149. */
  118150. gazeModePointerMovedFactor?: number;
  118151. /**
  118152. * Different button type to use instead of the main component
  118153. */
  118154. overrideButtonId?: string;
  118155. /**
  118156. * use this rendering group id for the meshes (optional)
  118157. */
  118158. renderingGroupId?: number;
  118159. /**
  118160. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  118161. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  118162. * 3000 means 3 seconds between pointing at something and selecting it
  118163. */
  118164. timeToSelect?: number;
  118165. /**
  118166. * Should meshes created here be added to a utility layer or the main scene
  118167. */
  118168. useUtilityLayer?: boolean;
  118169. /**
  118170. * the xr input to use with this pointer selection
  118171. */
  118172. xrInput: WebXRInput;
  118173. }
  118174. /**
  118175. * A module that will enable pointer selection for motion controllers of XR Input Sources
  118176. */
  118177. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  118178. private readonly _options;
  118179. private static _idCounter;
  118180. private _attachController;
  118181. private _controllers;
  118182. private _scene;
  118183. private _tmpVectorForPickCompare;
  118184. /**
  118185. * The module's name
  118186. */
  118187. static readonly Name: string;
  118188. /**
  118189. * The (Babylon) version of this module.
  118190. * This is an integer representing the implementation version.
  118191. * This number does not correspond to the WebXR specs version
  118192. */
  118193. static readonly Version: number;
  118194. /**
  118195. * Disable lighting on the laser pointer (so it will always be visible)
  118196. */
  118197. disablePointerLighting: boolean;
  118198. /**
  118199. * Disable lighting on the selection mesh (so it will always be visible)
  118200. */
  118201. disableSelectionMeshLighting: boolean;
  118202. /**
  118203. * Should the laser pointer be displayed
  118204. */
  118205. displayLaserPointer: boolean;
  118206. /**
  118207. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  118208. */
  118209. displaySelectionMesh: boolean;
  118210. /**
  118211. * This color will be set to the laser pointer when selection is triggered
  118212. */
  118213. laserPointerPickedColor: Color3;
  118214. /**
  118215. * Default color of the laser pointer
  118216. */
  118217. lasterPointerDefaultColor: Color3;
  118218. /**
  118219. * default color of the selection ring
  118220. */
  118221. selectionMeshDefaultColor: Color3;
  118222. /**
  118223. * This color will be applied to the selection ring when selection is triggered
  118224. */
  118225. selectionMeshPickedColor: Color3;
  118226. /**
  118227. * Optional filter to be used for ray selection. This predicate shares behavior with
  118228. * scene.pointerMovePredicate which takes priority if it is also assigned.
  118229. */
  118230. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  118231. /**
  118232. * constructs a new background remover module
  118233. * @param _xrSessionManager the session manager for this module
  118234. * @param _options read-only options to be used in this module
  118235. */
  118236. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  118237. /**
  118238. * attach this feature
  118239. * Will usually be called by the features manager
  118240. *
  118241. * @returns true if successful.
  118242. */
  118243. attach(): boolean;
  118244. /**
  118245. * detach this feature.
  118246. * Will usually be called by the features manager
  118247. *
  118248. * @returns true if successful.
  118249. */
  118250. detach(): boolean;
  118251. /**
  118252. * Will get the mesh under a specific pointer.
  118253. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  118254. * @param controllerId the controllerId to check
  118255. * @returns The mesh under pointer or null if no mesh is under the pointer
  118256. */
  118257. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  118258. /**
  118259. * Get the xr controller that correlates to the pointer id in the pointer event
  118260. *
  118261. * @param id the pointer id to search for
  118262. * @returns the controller that correlates to this id or null if not found
  118263. */
  118264. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  118265. protected _onXRFrame(_xrFrame: XRFrame): void;
  118266. private _attachGazeMode;
  118267. private _attachScreenRayMode;
  118268. private _attachTrackedPointerRayMode;
  118269. private _convertNormalToDirectionOfRay;
  118270. private _detachController;
  118271. private _generateNewMeshPair;
  118272. private _pickingMoved;
  118273. private _updatePointerDistance;
  118274. }
  118275. }
  118276. declare module BABYLON {
  118277. /**
  118278. * Button which can be used to enter a different mode of XR
  118279. */
  118280. export class WebXREnterExitUIButton {
  118281. /** button element */
  118282. element: HTMLElement;
  118283. /** XR initialization options for the button */
  118284. sessionMode: XRSessionMode;
  118285. /** Reference space type */
  118286. referenceSpaceType: XRReferenceSpaceType;
  118287. /**
  118288. * Creates a WebXREnterExitUIButton
  118289. * @param element button element
  118290. * @param sessionMode XR initialization session mode
  118291. * @param referenceSpaceType the type of reference space to be used
  118292. */
  118293. constructor(
  118294. /** button element */
  118295. element: HTMLElement,
  118296. /** XR initialization options for the button */
  118297. sessionMode: XRSessionMode,
  118298. /** Reference space type */
  118299. referenceSpaceType: XRReferenceSpaceType);
  118300. /**
  118301. * Extendable function which can be used to update the button's visuals when the state changes
  118302. * @param activeButton the current active button in the UI
  118303. */
  118304. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  118305. }
  118306. /**
  118307. * Options to create the webXR UI
  118308. */
  118309. export class WebXREnterExitUIOptions {
  118310. /**
  118311. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  118312. */
  118313. customButtons?: Array<WebXREnterExitUIButton>;
  118314. /**
  118315. * A reference space type to use when creating the default button.
  118316. * Default is local-floor
  118317. */
  118318. referenceSpaceType?: XRReferenceSpaceType;
  118319. /**
  118320. * Context to enter xr with
  118321. */
  118322. renderTarget?: Nullable<WebXRRenderTarget>;
  118323. /**
  118324. * A session mode to use when creating the default button.
  118325. * Default is immersive-vr
  118326. */
  118327. sessionMode?: XRSessionMode;
  118328. }
  118329. /**
  118330. * UI to allow the user to enter/exit XR mode
  118331. */
  118332. export class WebXREnterExitUI implements IDisposable {
  118333. private scene;
  118334. /** version of the options passed to this UI */
  118335. options: WebXREnterExitUIOptions;
  118336. private _activeButton;
  118337. private _buttons;
  118338. private _overlay;
  118339. /**
  118340. * Fired every time the active button is changed.
  118341. *
  118342. * When xr is entered via a button that launches xr that button will be the callback parameter
  118343. *
  118344. * When exiting xr the callback parameter will be null)
  118345. */
  118346. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  118347. /**
  118348. *
  118349. * @param scene babylon scene object to use
  118350. * @param options (read-only) version of the options passed to this UI
  118351. */
  118352. private constructor();
  118353. /**
  118354. * Creates UI to allow the user to enter/exit XR mode
  118355. * @param scene the scene to add the ui to
  118356. * @param helper the xr experience helper to enter/exit xr with
  118357. * @param options options to configure the UI
  118358. * @returns the created ui
  118359. */
  118360. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  118361. /**
  118362. * Disposes of the XR UI component
  118363. */
  118364. dispose(): void;
  118365. private _updateButtons;
  118366. }
  118367. }
  118368. declare module BABYLON {
  118369. /**
  118370. * Class containing static functions to help procedurally build meshes
  118371. */
  118372. export class LinesBuilder {
  118373. /**
  118374. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  118375. * * 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
  118376. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  118377. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  118378. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  118379. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  118380. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  118381. * * 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
  118382. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  118383. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118384. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  118385. * @param name defines the name of the new line system
  118386. * @param options defines the options used to create the line system
  118387. * @param scene defines the hosting scene
  118388. * @returns a new line system mesh
  118389. */
  118390. static CreateLineSystem(name: string, options: {
  118391. lines: Vector3[][];
  118392. updatable?: boolean;
  118393. instance?: Nullable<LinesMesh>;
  118394. colors?: Nullable<Color4[][]>;
  118395. useVertexAlpha?: boolean;
  118396. }, scene: Nullable<Scene>): LinesMesh;
  118397. /**
  118398. * Creates a line mesh
  118399. * 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
  118400. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  118401. * * The parameter `points` is an array successive Vector3
  118402. * * 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
  118403. * * The optional parameter `colors` is an array of successive Color4, one per line point
  118404. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  118405. * * When updating an instance, remember that only point positions can change, not the number of points
  118406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118407. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  118408. * @param name defines the name of the new line system
  118409. * @param options defines the options used to create the line system
  118410. * @param scene defines the hosting scene
  118411. * @returns a new line mesh
  118412. */
  118413. static CreateLines(name: string, options: {
  118414. points: Vector3[];
  118415. updatable?: boolean;
  118416. instance?: Nullable<LinesMesh>;
  118417. colors?: Color4[];
  118418. useVertexAlpha?: boolean;
  118419. }, scene?: Nullable<Scene>): LinesMesh;
  118420. /**
  118421. * Creates a dashed line mesh
  118422. * * 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
  118423. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  118424. * * The parameter `points` is an array successive Vector3
  118425. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  118426. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  118427. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  118428. * * 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
  118429. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  118430. * * When updating an instance, remember that only point positions can change, not the number of points
  118431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118432. * @param name defines the name of the mesh
  118433. * @param options defines the options used to create the mesh
  118434. * @param scene defines the hosting scene
  118435. * @returns the dashed line mesh
  118436. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  118437. */
  118438. static CreateDashedLines(name: string, options: {
  118439. points: Vector3[];
  118440. dashSize?: number;
  118441. gapSize?: number;
  118442. dashNb?: number;
  118443. updatable?: boolean;
  118444. instance?: LinesMesh;
  118445. useVertexAlpha?: boolean;
  118446. }, scene?: Nullable<Scene>): LinesMesh;
  118447. }
  118448. }
  118449. declare module BABYLON {
  118450. /**
  118451. * The options container for the teleportation module
  118452. */
  118453. export interface IWebXRTeleportationOptions {
  118454. /**
  118455. * if provided, this scene will be used to render meshes.
  118456. */
  118457. customUtilityLayerScene?: Scene;
  118458. /**
  118459. * Values to configure the default target mesh
  118460. */
  118461. defaultTargetMeshOptions?: {
  118462. /**
  118463. * Fill color of the teleportation area
  118464. */
  118465. teleportationFillColor?: string;
  118466. /**
  118467. * Border color for the teleportation area
  118468. */
  118469. teleportationBorderColor?: string;
  118470. /**
  118471. * Disable the mesh's animation sequence
  118472. */
  118473. disableAnimation?: boolean;
  118474. /**
  118475. * Disable lighting on the material or the ring and arrow
  118476. */
  118477. disableLighting?: boolean;
  118478. /**
  118479. * Override the default material of the torus and arrow
  118480. */
  118481. torusArrowMaterial?: Material;
  118482. };
  118483. /**
  118484. * A list of meshes to use as floor meshes.
  118485. * Meshes can be added and removed after initializing the feature using the
  118486. * addFloorMesh and removeFloorMesh functions
  118487. * If empty, rotation will still work
  118488. */
  118489. floorMeshes?: AbstractMesh[];
  118490. /**
  118491. * use this rendering group id for the meshes (optional)
  118492. */
  118493. renderingGroupId?: number;
  118494. /**
  118495. * Should teleportation move only to snap points
  118496. */
  118497. snapPointsOnly?: boolean;
  118498. /**
  118499. * An array of points to which the teleportation will snap to.
  118500. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  118501. */
  118502. snapPositions?: Vector3[];
  118503. /**
  118504. * How close should the teleportation ray be in order to snap to position.
  118505. * Default to 0.8 units (meters)
  118506. */
  118507. snapToPositionRadius?: number;
  118508. /**
  118509. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  118510. * If you want to support rotation, make sure your mesh has a direction indicator.
  118511. *
  118512. * When left untouched, the default mesh will be initialized.
  118513. */
  118514. teleportationTargetMesh?: AbstractMesh;
  118515. /**
  118516. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  118517. */
  118518. timeToTeleport?: number;
  118519. /**
  118520. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  118521. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  118522. */
  118523. useMainComponentOnly?: boolean;
  118524. /**
  118525. * Should meshes created here be added to a utility layer or the main scene
  118526. */
  118527. useUtilityLayer?: boolean;
  118528. /**
  118529. * Babylon XR Input class for controller
  118530. */
  118531. xrInput: WebXRInput;
  118532. }
  118533. /**
  118534. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  118535. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  118536. * the input of the attached controllers.
  118537. */
  118538. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  118539. private _options;
  118540. private _controllers;
  118541. private _currentTeleportationControllerId;
  118542. private _floorMeshes;
  118543. private _quadraticBezierCurve;
  118544. private _selectionFeature;
  118545. private _snapToPositions;
  118546. private _snappedToPoint;
  118547. private _teleportationRingMaterial?;
  118548. private _tmpRay;
  118549. private _tmpVector;
  118550. /**
  118551. * The module's name
  118552. */
  118553. static readonly Name: string;
  118554. /**
  118555. * The (Babylon) version of this module.
  118556. * This is an integer representing the implementation version.
  118557. * This number does not correspond to the webxr specs version
  118558. */
  118559. static readonly Version: number;
  118560. /**
  118561. * Is movement backwards enabled
  118562. */
  118563. backwardsMovementEnabled: boolean;
  118564. /**
  118565. * Distance to travel when moving backwards
  118566. */
  118567. backwardsTeleportationDistance: number;
  118568. /**
  118569. * The distance from the user to the inspection point in the direction of the controller
  118570. * A higher number will allow the user to move further
  118571. * defaults to 5 (meters, in xr units)
  118572. */
  118573. parabolicCheckRadius: number;
  118574. /**
  118575. * Should the module support parabolic ray on top of direct ray
  118576. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  118577. * Very helpful when moving between floors / different heights
  118578. */
  118579. parabolicRayEnabled: boolean;
  118580. /**
  118581. * How much rotation should be applied when rotating right and left
  118582. */
  118583. rotationAngle: number;
  118584. /**
  118585. * Is rotation enabled when moving forward?
  118586. * Disabling this feature will prevent the user from deciding the direction when teleporting
  118587. */
  118588. rotationEnabled: boolean;
  118589. /**
  118590. * constructs a new anchor system
  118591. * @param _xrSessionManager an instance of WebXRSessionManager
  118592. * @param _options configuration object for this feature
  118593. */
  118594. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  118595. /**
  118596. * Get the snapPointsOnly flag
  118597. */
  118598. get snapPointsOnly(): boolean;
  118599. /**
  118600. * Sets the snapPointsOnly flag
  118601. * @param snapToPoints should teleportation be exclusively to snap points
  118602. */
  118603. set snapPointsOnly(snapToPoints: boolean);
  118604. /**
  118605. * Add a new mesh to the floor meshes array
  118606. * @param mesh the mesh to use as floor mesh
  118607. */
  118608. addFloorMesh(mesh: AbstractMesh): void;
  118609. /**
  118610. * Add a new snap-to point to fix teleportation to this position
  118611. * @param newSnapPoint The new Snap-To point
  118612. */
  118613. addSnapPoint(newSnapPoint: Vector3): void;
  118614. attach(): boolean;
  118615. detach(): boolean;
  118616. dispose(): void;
  118617. /**
  118618. * Remove a mesh from the floor meshes array
  118619. * @param mesh the mesh to remove
  118620. */
  118621. removeFloorMesh(mesh: AbstractMesh): void;
  118622. /**
  118623. * Remove a mesh from the floor meshes array using its name
  118624. * @param name the mesh name to remove
  118625. */
  118626. removeFloorMeshByName(name: string): void;
  118627. /**
  118628. * 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
  118629. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  118630. * @returns was the point found and removed or not
  118631. */
  118632. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  118633. /**
  118634. * This function sets a selection feature that will be disabled when
  118635. * the forward ray is shown and will be reattached when hidden.
  118636. * This is used to remove the selection rays when moving.
  118637. * @param selectionFeature the feature to disable when forward movement is enabled
  118638. */
  118639. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  118640. protected _onXRFrame(_xrFrame: XRFrame): void;
  118641. private _attachController;
  118642. private _createDefaultTargetMesh;
  118643. private _detachController;
  118644. private _findClosestSnapPointWithRadius;
  118645. private _setTargetMeshPosition;
  118646. private _setTargetMeshVisibility;
  118647. private _showParabolicPath;
  118648. private _teleportForward;
  118649. }
  118650. }
  118651. declare module BABYLON {
  118652. /**
  118653. * Options for the default xr helper
  118654. */
  118655. export class WebXRDefaultExperienceOptions {
  118656. /**
  118657. * Enable or disable default UI to enter XR
  118658. */
  118659. disableDefaultUI?: boolean;
  118660. /**
  118661. * Should teleportation not initialize. defaults to false.
  118662. */
  118663. disableTeleportation?: boolean;
  118664. /**
  118665. * Floor meshes that will be used for teleport
  118666. */
  118667. floorMeshes?: Array<AbstractMesh>;
  118668. /**
  118669. * If set to true, the first frame will not be used to reset position
  118670. * The first frame is mainly used when copying transformation from the old camera
  118671. * Mainly used in AR
  118672. */
  118673. ignoreNativeCameraTransformation?: boolean;
  118674. /**
  118675. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  118676. */
  118677. inputOptions?: IWebXRInputOptions;
  118678. /**
  118679. * optional configuration for the output canvas
  118680. */
  118681. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  118682. /**
  118683. * optional UI options. This can be used among other to change session mode and reference space type
  118684. */
  118685. uiOptions?: WebXREnterExitUIOptions;
  118686. /**
  118687. * When loading teleportation and pointer select, use stable versions instead of latest.
  118688. */
  118689. useStablePlugins?: boolean;
  118690. }
  118691. /**
  118692. * Default experience which provides a similar setup to the previous webVRExperience
  118693. */
  118694. export class WebXRDefaultExperience {
  118695. /**
  118696. * Base experience
  118697. */
  118698. baseExperience: WebXRExperienceHelper;
  118699. /**
  118700. * Enables ui for entering/exiting xr
  118701. */
  118702. enterExitUI: WebXREnterExitUI;
  118703. /**
  118704. * Input experience extension
  118705. */
  118706. input: WebXRInput;
  118707. /**
  118708. * Enables laser pointer and selection
  118709. */
  118710. pointerSelection: WebXRControllerPointerSelection;
  118711. /**
  118712. * Default target xr should render to
  118713. */
  118714. renderTarget: WebXRRenderTarget;
  118715. /**
  118716. * Enables teleportation
  118717. */
  118718. teleportation: WebXRMotionControllerTeleportation;
  118719. private constructor();
  118720. /**
  118721. * Creates the default xr experience
  118722. * @param scene scene
  118723. * @param options options for basic configuration
  118724. * @returns resulting WebXRDefaultExperience
  118725. */
  118726. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  118727. /**
  118728. * DIsposes of the experience helper
  118729. */
  118730. dispose(): void;
  118731. }
  118732. }
  118733. declare module BABYLON {
  118734. /**
  118735. * Options to modify the vr teleportation behavior.
  118736. */
  118737. export interface VRTeleportationOptions {
  118738. /**
  118739. * The name of the mesh which should be used as the teleportation floor. (default: null)
  118740. */
  118741. floorMeshName?: string;
  118742. /**
  118743. * A list of meshes to be used as the teleportation floor. (default: empty)
  118744. */
  118745. floorMeshes?: Mesh[];
  118746. /**
  118747. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  118748. */
  118749. teleportationMode?: number;
  118750. /**
  118751. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  118752. */
  118753. teleportationTime?: number;
  118754. /**
  118755. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  118756. */
  118757. teleportationSpeed?: number;
  118758. /**
  118759. * The easing function used in the animation or null for Linear. (default CircleEase)
  118760. */
  118761. easingFunction?: EasingFunction;
  118762. }
  118763. /**
  118764. * Options to modify the vr experience helper's behavior.
  118765. */
  118766. export interface VRExperienceHelperOptions extends WebVROptions {
  118767. /**
  118768. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  118769. */
  118770. createDeviceOrientationCamera?: boolean;
  118771. /**
  118772. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  118773. */
  118774. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  118775. /**
  118776. * Uses the main button on the controller to toggle the laser casted. (default: true)
  118777. */
  118778. laserToggle?: boolean;
  118779. /**
  118780. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  118781. */
  118782. floorMeshes?: Mesh[];
  118783. /**
  118784. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  118785. */
  118786. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  118787. /**
  118788. * Defines if WebXR should be used instead of WebVR (if available)
  118789. */
  118790. useXR?: boolean;
  118791. }
  118792. /**
  118793. * Event containing information after VR has been entered
  118794. */
  118795. export class OnAfterEnteringVRObservableEvent {
  118796. /**
  118797. * If entering vr was successful
  118798. */
  118799. success: boolean;
  118800. }
  118801. /**
  118802. * Helps to quickly add VR support to an existing scene.
  118803. * See http://doc.babylonjs.com/how_to/webvr_helper
  118804. */
  118805. export class VRExperienceHelper {
  118806. /** Options to modify the vr experience helper's behavior. */
  118807. webVROptions: VRExperienceHelperOptions;
  118808. private _scene;
  118809. private _position;
  118810. private _btnVR;
  118811. private _btnVRDisplayed;
  118812. private _webVRsupported;
  118813. private _webVRready;
  118814. private _webVRrequesting;
  118815. private _webVRpresenting;
  118816. private _hasEnteredVR;
  118817. private _fullscreenVRpresenting;
  118818. private _inputElement;
  118819. private _webVRCamera;
  118820. private _vrDeviceOrientationCamera;
  118821. private _deviceOrientationCamera;
  118822. private _existingCamera;
  118823. private _onKeyDown;
  118824. private _onVrDisplayPresentChange;
  118825. private _onVRDisplayChanged;
  118826. private _onVRRequestPresentStart;
  118827. private _onVRRequestPresentComplete;
  118828. /**
  118829. * 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)
  118830. */
  118831. enableGazeEvenWhenNoPointerLock: boolean;
  118832. /**
  118833. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  118834. */
  118835. exitVROnDoubleTap: boolean;
  118836. /**
  118837. * Observable raised right before entering VR.
  118838. */
  118839. onEnteringVRObservable: Observable<VRExperienceHelper>;
  118840. /**
  118841. * Observable raised when entering VR has completed.
  118842. */
  118843. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  118844. /**
  118845. * Observable raised when exiting VR.
  118846. */
  118847. onExitingVRObservable: Observable<VRExperienceHelper>;
  118848. /**
  118849. * Observable raised when controller mesh is loaded.
  118850. */
  118851. onControllerMeshLoadedObservable: Observable<WebVRController>;
  118852. /** Return this.onEnteringVRObservable
  118853. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  118854. */
  118855. get onEnteringVR(): Observable<VRExperienceHelper>;
  118856. /** Return this.onExitingVRObservable
  118857. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  118858. */
  118859. get onExitingVR(): Observable<VRExperienceHelper>;
  118860. /** Return this.onControllerMeshLoadedObservable
  118861. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  118862. */
  118863. get onControllerMeshLoaded(): Observable<WebVRController>;
  118864. private _rayLength;
  118865. private _useCustomVRButton;
  118866. private _teleportationRequested;
  118867. private _teleportActive;
  118868. private _floorMeshName;
  118869. private _floorMeshesCollection;
  118870. private _teleportationMode;
  118871. private _teleportationTime;
  118872. private _teleportationSpeed;
  118873. private _teleportationEasing;
  118874. private _rotationAllowed;
  118875. private _teleportBackwardsVector;
  118876. private _teleportationTarget;
  118877. private _isDefaultTeleportationTarget;
  118878. private _postProcessMove;
  118879. private _teleportationFillColor;
  118880. private _teleportationBorderColor;
  118881. private _rotationAngle;
  118882. private _haloCenter;
  118883. private _cameraGazer;
  118884. private _padSensibilityUp;
  118885. private _padSensibilityDown;
  118886. private _leftController;
  118887. private _rightController;
  118888. private _gazeColor;
  118889. private _laserColor;
  118890. private _pickedLaserColor;
  118891. private _pickedGazeColor;
  118892. /**
  118893. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  118894. */
  118895. onNewMeshSelected: Observable<AbstractMesh>;
  118896. /**
  118897. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  118898. * This observable will provide the mesh and the controller used to select the mesh
  118899. */
  118900. onMeshSelectedWithController: Observable<{
  118901. mesh: AbstractMesh;
  118902. controller: WebVRController;
  118903. }>;
  118904. /**
  118905. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  118906. */
  118907. onNewMeshPicked: Observable<PickingInfo>;
  118908. private _circleEase;
  118909. /**
  118910. * Observable raised before camera teleportation
  118911. */
  118912. onBeforeCameraTeleport: Observable<Vector3>;
  118913. /**
  118914. * Observable raised after camera teleportation
  118915. */
  118916. onAfterCameraTeleport: Observable<Vector3>;
  118917. /**
  118918. * Observable raised when current selected mesh gets unselected
  118919. */
  118920. onSelectedMeshUnselected: Observable<AbstractMesh>;
  118921. private _raySelectionPredicate;
  118922. /**
  118923. * To be optionaly changed by user to define custom ray selection
  118924. */
  118925. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  118926. /**
  118927. * To be optionaly changed by user to define custom selection logic (after ray selection)
  118928. */
  118929. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  118930. /**
  118931. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  118932. */
  118933. teleportationEnabled: boolean;
  118934. private _defaultHeight;
  118935. private _teleportationInitialized;
  118936. private _interactionsEnabled;
  118937. private _interactionsRequested;
  118938. private _displayGaze;
  118939. private _displayLaserPointer;
  118940. /**
  118941. * The mesh used to display where the user is going to teleport.
  118942. */
  118943. get teleportationTarget(): Mesh;
  118944. /**
  118945. * Sets the mesh to be used to display where the user is going to teleport.
  118946. */
  118947. set teleportationTarget(value: Mesh);
  118948. /**
  118949. * 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
  118950. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  118951. * See http://doc.babylonjs.com/resources/baking_transformations
  118952. */
  118953. get gazeTrackerMesh(): Mesh;
  118954. set gazeTrackerMesh(value: Mesh);
  118955. /**
  118956. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  118957. */
  118958. updateGazeTrackerScale: boolean;
  118959. /**
  118960. * If the gaze trackers color should be updated when selecting meshes
  118961. */
  118962. updateGazeTrackerColor: boolean;
  118963. /**
  118964. * If the controller laser color should be updated when selecting meshes
  118965. */
  118966. updateControllerLaserColor: boolean;
  118967. /**
  118968. * The gaze tracking mesh corresponding to the left controller
  118969. */
  118970. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  118971. /**
  118972. * The gaze tracking mesh corresponding to the right controller
  118973. */
  118974. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  118975. /**
  118976. * If the ray of the gaze should be displayed.
  118977. */
  118978. get displayGaze(): boolean;
  118979. /**
  118980. * Sets if the ray of the gaze should be displayed.
  118981. */
  118982. set displayGaze(value: boolean);
  118983. /**
  118984. * If the ray of the LaserPointer should be displayed.
  118985. */
  118986. get displayLaserPointer(): boolean;
  118987. /**
  118988. * Sets if the ray of the LaserPointer should be displayed.
  118989. */
  118990. set displayLaserPointer(value: boolean);
  118991. /**
  118992. * The deviceOrientationCamera used as the camera when not in VR.
  118993. */
  118994. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  118995. /**
  118996. * Based on the current WebVR support, returns the current VR camera used.
  118997. */
  118998. get currentVRCamera(): Nullable<Camera>;
  118999. /**
  119000. * The webVRCamera which is used when in VR.
  119001. */
  119002. get webVRCamera(): WebVRFreeCamera;
  119003. /**
  119004. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  119005. */
  119006. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  119007. /**
  119008. * The html button that is used to trigger entering into VR.
  119009. */
  119010. get vrButton(): Nullable<HTMLButtonElement>;
  119011. private get _teleportationRequestInitiated();
  119012. /**
  119013. * Defines whether or not Pointer lock should be requested when switching to
  119014. * full screen.
  119015. */
  119016. requestPointerLockOnFullScreen: boolean;
  119017. /**
  119018. * If asking to force XR, this will be populated with the default xr experience
  119019. */
  119020. xr: WebXRDefaultExperience;
  119021. /**
  119022. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  119023. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  119024. */
  119025. xrTestDone: boolean;
  119026. /**
  119027. * Instantiates a VRExperienceHelper.
  119028. * Helps to quickly add VR support to an existing scene.
  119029. * @param scene The scene the VRExperienceHelper belongs to.
  119030. * @param webVROptions Options to modify the vr experience helper's behavior.
  119031. */
  119032. constructor(scene: Scene,
  119033. /** Options to modify the vr experience helper's behavior. */
  119034. webVROptions?: VRExperienceHelperOptions);
  119035. private completeVRInit;
  119036. private _onDefaultMeshLoaded;
  119037. private _onResize;
  119038. private _onFullscreenChange;
  119039. /**
  119040. * Gets a value indicating if we are currently in VR mode.
  119041. */
  119042. get isInVRMode(): boolean;
  119043. private onVrDisplayPresentChange;
  119044. private onVRDisplayChanged;
  119045. private moveButtonToBottomRight;
  119046. private displayVRButton;
  119047. private updateButtonVisibility;
  119048. private _cachedAngularSensibility;
  119049. /**
  119050. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  119051. * Otherwise, will use the fullscreen API.
  119052. */
  119053. enterVR(): void;
  119054. /**
  119055. * Attempt to exit VR, or fullscreen.
  119056. */
  119057. exitVR(): void;
  119058. /**
  119059. * The position of the vr experience helper.
  119060. */
  119061. get position(): Vector3;
  119062. /**
  119063. * Sets the position of the vr experience helper.
  119064. */
  119065. set position(value: Vector3);
  119066. /**
  119067. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  119068. */
  119069. enableInteractions(): void;
  119070. private get _noControllerIsActive();
  119071. private beforeRender;
  119072. private _isTeleportationFloor;
  119073. /**
  119074. * Adds a floor mesh to be used for teleportation.
  119075. * @param floorMesh the mesh to be used for teleportation.
  119076. */
  119077. addFloorMesh(floorMesh: Mesh): void;
  119078. /**
  119079. * Removes a floor mesh from being used for teleportation.
  119080. * @param floorMesh the mesh to be removed.
  119081. */
  119082. removeFloorMesh(floorMesh: Mesh): void;
  119083. /**
  119084. * Enables interactions and teleportation using the VR controllers and gaze.
  119085. * @param vrTeleportationOptions options to modify teleportation behavior.
  119086. */
  119087. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  119088. private _onNewGamepadConnected;
  119089. private _tryEnableInteractionOnController;
  119090. private _onNewGamepadDisconnected;
  119091. private _enableInteractionOnController;
  119092. private _checkTeleportWithRay;
  119093. private _checkRotate;
  119094. private _checkTeleportBackwards;
  119095. private _enableTeleportationOnController;
  119096. private _createTeleportationCircles;
  119097. private _displayTeleportationTarget;
  119098. private _hideTeleportationTarget;
  119099. private _rotateCamera;
  119100. private _moveTeleportationSelectorTo;
  119101. private _workingVector;
  119102. private _workingQuaternion;
  119103. private _workingMatrix;
  119104. /**
  119105. * Time Constant Teleportation Mode
  119106. */
  119107. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  119108. /**
  119109. * Speed Constant Teleportation Mode
  119110. */
  119111. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  119112. /**
  119113. * Teleports the users feet to the desired location
  119114. * @param location The location where the user's feet should be placed
  119115. */
  119116. teleportCamera(location: Vector3): void;
  119117. private _convertNormalToDirectionOfRay;
  119118. private _castRayAndSelectObject;
  119119. private _notifySelectedMeshUnselected;
  119120. /**
  119121. * Permanently set new colors for the laser pointer
  119122. * @param color the new laser color
  119123. * @param pickedColor the new laser color when picked mesh detected
  119124. */
  119125. setLaserColor(color: Color3, pickedColor?: Color3): void;
  119126. /**
  119127. * Set lighting enabled / disabled on the laser pointer of both controllers
  119128. * @param enabled should the lighting be enabled on the laser pointer
  119129. */
  119130. setLaserLightingState(enabled?: boolean): void;
  119131. /**
  119132. * Permanently set new colors for the gaze pointer
  119133. * @param color the new gaze color
  119134. * @param pickedColor the new gaze color when picked mesh detected
  119135. */
  119136. setGazeColor(color: Color3, pickedColor?: Color3): void;
  119137. /**
  119138. * Sets the color of the laser ray from the vr controllers.
  119139. * @param color new color for the ray.
  119140. */
  119141. changeLaserColor(color: Color3): void;
  119142. /**
  119143. * Sets the color of the ray from the vr headsets gaze.
  119144. * @param color new color for the ray.
  119145. */
  119146. changeGazeColor(color: Color3): void;
  119147. /**
  119148. * Exits VR and disposes of the vr experience helper
  119149. */
  119150. dispose(): void;
  119151. /**
  119152. * Gets the name of the VRExperienceHelper class
  119153. * @returns "VRExperienceHelper"
  119154. */
  119155. getClassName(): string;
  119156. }
  119157. }
  119158. declare module BABYLON {
  119159. /**
  119160. * Contains an array of blocks representing the octree
  119161. */
  119162. export interface IOctreeContainer<T> {
  119163. /**
  119164. * Blocks within the octree
  119165. */
  119166. blocks: Array<OctreeBlock<T>>;
  119167. }
  119168. /**
  119169. * Class used to store a cell in an octree
  119170. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  119171. */
  119172. export class OctreeBlock<T> {
  119173. /**
  119174. * Gets the content of the current block
  119175. */
  119176. entries: T[];
  119177. /**
  119178. * Gets the list of block children
  119179. */
  119180. blocks: Array<OctreeBlock<T>>;
  119181. private _depth;
  119182. private _maxDepth;
  119183. private _capacity;
  119184. private _minPoint;
  119185. private _maxPoint;
  119186. private _boundingVectors;
  119187. private _creationFunc;
  119188. /**
  119189. * Creates a new block
  119190. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  119191. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  119192. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  119193. * @param depth defines the current depth of this block in the octree
  119194. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  119195. * @param creationFunc defines a callback to call when an element is added to the block
  119196. */
  119197. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  119198. /**
  119199. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  119200. */
  119201. get capacity(): number;
  119202. /**
  119203. * Gets the minimum vector (in world space) of the block's bounding box
  119204. */
  119205. get minPoint(): Vector3;
  119206. /**
  119207. * Gets the maximum vector (in world space) of the block's bounding box
  119208. */
  119209. get maxPoint(): Vector3;
  119210. /**
  119211. * Add a new element to this block
  119212. * @param entry defines the element to add
  119213. */
  119214. addEntry(entry: T): void;
  119215. /**
  119216. * Remove an element from this block
  119217. * @param entry defines the element to remove
  119218. */
  119219. removeEntry(entry: T): void;
  119220. /**
  119221. * Add an array of elements to this block
  119222. * @param entries defines the array of elements to add
  119223. */
  119224. addEntries(entries: T[]): void;
  119225. /**
  119226. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  119227. * @param frustumPlanes defines the frustum planes to test
  119228. * @param selection defines the array to store current content if selection is positive
  119229. * @param allowDuplicate defines if the selection array can contains duplicated entries
  119230. */
  119231. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  119232. /**
  119233. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  119234. * @param sphereCenter defines the bounding sphere center
  119235. * @param sphereRadius defines the bounding sphere radius
  119236. * @param selection defines the array to store current content if selection is positive
  119237. * @param allowDuplicate defines if the selection array can contains duplicated entries
  119238. */
  119239. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  119240. /**
  119241. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  119242. * @param ray defines the ray to test with
  119243. * @param selection defines the array to store current content if selection is positive
  119244. */
  119245. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  119246. /**
  119247. * Subdivide the content into child blocks (this block will then be empty)
  119248. */
  119249. createInnerBlocks(): void;
  119250. /**
  119251. * @hidden
  119252. */
  119253. 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;
  119254. }
  119255. }
  119256. declare module BABYLON {
  119257. /**
  119258. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  119259. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  119260. */
  119261. export class Octree<T> {
  119262. /** 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.) */
  119263. maxDepth: number;
  119264. /**
  119265. * Blocks within the octree containing objects
  119266. */
  119267. blocks: Array<OctreeBlock<T>>;
  119268. /**
  119269. * Content stored in the octree
  119270. */
  119271. dynamicContent: T[];
  119272. private _maxBlockCapacity;
  119273. private _selectionContent;
  119274. private _creationFunc;
  119275. /**
  119276. * Creates a octree
  119277. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  119278. * @param creationFunc function to be used to instatiate the octree
  119279. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  119280. * @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.)
  119281. */
  119282. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  119283. /** 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.) */
  119284. maxDepth?: number);
  119285. /**
  119286. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  119287. * @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);
  119288. * @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);
  119289. * @param entries meshes to be added to the octree blocks
  119290. */
  119291. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  119292. /**
  119293. * Adds a mesh to the octree
  119294. * @param entry Mesh to add to the octree
  119295. */
  119296. addMesh(entry: T): void;
  119297. /**
  119298. * Remove an element from the octree
  119299. * @param entry defines the element to remove
  119300. */
  119301. removeMesh(entry: T): void;
  119302. /**
  119303. * Selects an array of meshes within the frustum
  119304. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  119305. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  119306. * @returns array of meshes within the frustum
  119307. */
  119308. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  119309. /**
  119310. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  119311. * @param sphereCenter defines the bounding sphere center
  119312. * @param sphereRadius defines the bounding sphere radius
  119313. * @param allowDuplicate defines if the selection array can contains duplicated entries
  119314. * @returns an array of objects that intersect the sphere
  119315. */
  119316. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  119317. /**
  119318. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  119319. * @param ray defines the ray to test with
  119320. * @returns array of intersected objects
  119321. */
  119322. intersectsRay(ray: Ray): SmartArray<T>;
  119323. /**
  119324. * Adds a mesh into the octree block if it intersects the block
  119325. */
  119326. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  119327. /**
  119328. * Adds a submesh into the octree block if it intersects the block
  119329. */
  119330. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  119331. }
  119332. }
  119333. declare module BABYLON {
  119334. interface Scene {
  119335. /**
  119336. * @hidden
  119337. * Backing Filed
  119338. */
  119339. _selectionOctree: Octree<AbstractMesh>;
  119340. /**
  119341. * Gets the octree used to boost mesh selection (picking)
  119342. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  119343. */
  119344. selectionOctree: Octree<AbstractMesh>;
  119345. /**
  119346. * Creates or updates the octree used to boost selection (picking)
  119347. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  119348. * @param maxCapacity defines the maximum capacity per leaf
  119349. * @param maxDepth defines the maximum depth of the octree
  119350. * @returns an octree of AbstractMesh
  119351. */
  119352. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  119353. }
  119354. interface AbstractMesh {
  119355. /**
  119356. * @hidden
  119357. * Backing Field
  119358. */
  119359. _submeshesOctree: Octree<SubMesh>;
  119360. /**
  119361. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  119362. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  119363. * @param maxCapacity defines the maximum size of each block (64 by default)
  119364. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  119365. * @returns the new octree
  119366. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  119367. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  119368. */
  119369. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  119370. }
  119371. /**
  119372. * Defines the octree scene component responsible to manage any octrees
  119373. * in a given scene.
  119374. */
  119375. export class OctreeSceneComponent {
  119376. /**
  119377. * The component name help to identify the component in the list of scene components.
  119378. */
  119379. readonly name: string;
  119380. /**
  119381. * The scene the component belongs to.
  119382. */
  119383. scene: Scene;
  119384. /**
  119385. * Indicates if the meshes have been checked to make sure they are isEnabled()
  119386. */
  119387. readonly checksIsEnabled: boolean;
  119388. /**
  119389. * Creates a new instance of the component for the given scene
  119390. * @param scene Defines the scene to register the component in
  119391. */
  119392. constructor(scene: Scene);
  119393. /**
  119394. * Registers the component in a given scene
  119395. */
  119396. register(): void;
  119397. /**
  119398. * Return the list of active meshes
  119399. * @returns the list of active meshes
  119400. */
  119401. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  119402. /**
  119403. * Return the list of active sub meshes
  119404. * @param mesh The mesh to get the candidates sub meshes from
  119405. * @returns the list of active sub meshes
  119406. */
  119407. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  119408. private _tempRay;
  119409. /**
  119410. * Return the list of sub meshes intersecting with a given local ray
  119411. * @param mesh defines the mesh to find the submesh for
  119412. * @param localRay defines the ray in local space
  119413. * @returns the list of intersecting sub meshes
  119414. */
  119415. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  119416. /**
  119417. * Return the list of sub meshes colliding with a collider
  119418. * @param mesh defines the mesh to find the submesh for
  119419. * @param collider defines the collider to evaluate the collision against
  119420. * @returns the list of colliding sub meshes
  119421. */
  119422. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  119423. /**
  119424. * Rebuilds the elements related to this component in case of
  119425. * context lost for instance.
  119426. */
  119427. rebuild(): void;
  119428. /**
  119429. * Disposes the component and the associated ressources.
  119430. */
  119431. dispose(): void;
  119432. }
  119433. }
  119434. declare module BABYLON {
  119435. /**
  119436. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  119437. */
  119438. export class Gizmo implements IDisposable {
  119439. /** The utility layer the gizmo will be added to */
  119440. gizmoLayer: UtilityLayerRenderer;
  119441. /**
  119442. * The root mesh of the gizmo
  119443. */
  119444. _rootMesh: Mesh;
  119445. private _attachedMesh;
  119446. /**
  119447. * Ratio for the scale of the gizmo (Default: 1)
  119448. */
  119449. scaleRatio: number;
  119450. /**
  119451. * If a custom mesh has been set (Default: false)
  119452. */
  119453. protected _customMeshSet: boolean;
  119454. /**
  119455. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  119456. * * When set, interactions will be enabled
  119457. */
  119458. get attachedMesh(): Nullable<AbstractMesh>;
  119459. set attachedMesh(value: Nullable<AbstractMesh>);
  119460. /**
  119461. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  119462. * @param mesh The mesh to replace the default mesh of the gizmo
  119463. */
  119464. setCustomMesh(mesh: Mesh): void;
  119465. /**
  119466. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  119467. */
  119468. updateGizmoRotationToMatchAttachedMesh: boolean;
  119469. /**
  119470. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  119471. */
  119472. updateGizmoPositionToMatchAttachedMesh: boolean;
  119473. /**
  119474. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  119475. */
  119476. updateScale: boolean;
  119477. protected _interactionsEnabled: boolean;
  119478. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119479. private _beforeRenderObserver;
  119480. private _tempVector;
  119481. /**
  119482. * Creates a gizmo
  119483. * @param gizmoLayer The utility layer the gizmo will be added to
  119484. */
  119485. constructor(
  119486. /** The utility layer the gizmo will be added to */
  119487. gizmoLayer?: UtilityLayerRenderer);
  119488. /**
  119489. * Updates the gizmo to match the attached mesh's position/rotation
  119490. */
  119491. protected _update(): void;
  119492. /**
  119493. * Disposes of the gizmo
  119494. */
  119495. dispose(): void;
  119496. }
  119497. }
  119498. declare module BABYLON {
  119499. /**
  119500. * Single plane drag gizmo
  119501. */
  119502. export class PlaneDragGizmo extends Gizmo {
  119503. /**
  119504. * Drag behavior responsible for the gizmos dragging interactions
  119505. */
  119506. dragBehavior: PointerDragBehavior;
  119507. private _pointerObserver;
  119508. /**
  119509. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119510. */
  119511. snapDistance: number;
  119512. /**
  119513. * Event that fires each time the gizmo snaps to a new location.
  119514. * * snapDistance is the the change in distance
  119515. */
  119516. onSnapObservable: Observable<{
  119517. snapDistance: number;
  119518. }>;
  119519. private _plane;
  119520. private _coloredMaterial;
  119521. private _hoverMaterial;
  119522. private _isEnabled;
  119523. private _parent;
  119524. /** @hidden */
  119525. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  119526. /** @hidden */
  119527. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  119528. /**
  119529. * Creates a PlaneDragGizmo
  119530. * @param gizmoLayer The utility layer the gizmo will be added to
  119531. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  119532. * @param color The color of the gizmo
  119533. */
  119534. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  119535. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119536. /**
  119537. * If the gizmo is enabled
  119538. */
  119539. set isEnabled(value: boolean);
  119540. get isEnabled(): boolean;
  119541. /**
  119542. * Disposes of the gizmo
  119543. */
  119544. dispose(): void;
  119545. }
  119546. }
  119547. declare module BABYLON {
  119548. /**
  119549. * Gizmo that enables dragging a mesh along 3 axis
  119550. */
  119551. export class PositionGizmo extends Gizmo {
  119552. /**
  119553. * Internal gizmo used for interactions on the x axis
  119554. */
  119555. xGizmo: AxisDragGizmo;
  119556. /**
  119557. * Internal gizmo used for interactions on the y axis
  119558. */
  119559. yGizmo: AxisDragGizmo;
  119560. /**
  119561. * Internal gizmo used for interactions on the z axis
  119562. */
  119563. zGizmo: AxisDragGizmo;
  119564. /**
  119565. * Internal gizmo used for interactions on the yz plane
  119566. */
  119567. xPlaneGizmo: PlaneDragGizmo;
  119568. /**
  119569. * Internal gizmo used for interactions on the xz plane
  119570. */
  119571. yPlaneGizmo: PlaneDragGizmo;
  119572. /**
  119573. * Internal gizmo used for interactions on the xy plane
  119574. */
  119575. zPlaneGizmo: PlaneDragGizmo;
  119576. /**
  119577. * private variables
  119578. */
  119579. private _meshAttached;
  119580. private _updateGizmoRotationToMatchAttachedMesh;
  119581. private _snapDistance;
  119582. private _scaleRatio;
  119583. /** Fires an event when any of it's sub gizmos are dragged */
  119584. onDragStartObservable: Observable<unknown>;
  119585. /** Fires an event when any of it's sub gizmos are released from dragging */
  119586. onDragEndObservable: Observable<unknown>;
  119587. /**
  119588. * If set to true, planar drag is enabled
  119589. */
  119590. private _planarGizmoEnabled;
  119591. get attachedMesh(): Nullable<AbstractMesh>;
  119592. set attachedMesh(mesh: Nullable<AbstractMesh>);
  119593. /**
  119594. * Creates a PositionGizmo
  119595. * @param gizmoLayer The utility layer the gizmo will be added to
  119596. */
  119597. constructor(gizmoLayer?: UtilityLayerRenderer);
  119598. /**
  119599. * If the planar drag gizmo is enabled
  119600. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  119601. */
  119602. set planarGizmoEnabled(value: boolean);
  119603. get planarGizmoEnabled(): boolean;
  119604. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  119605. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  119606. /**
  119607. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119608. */
  119609. set snapDistance(value: number);
  119610. get snapDistance(): number;
  119611. /**
  119612. * Ratio for the scale of the gizmo (Default: 1)
  119613. */
  119614. set scaleRatio(value: number);
  119615. get scaleRatio(): number;
  119616. /**
  119617. * Disposes of the gizmo
  119618. */
  119619. dispose(): void;
  119620. /**
  119621. * CustomMeshes are not supported by this gizmo
  119622. * @param mesh The mesh to replace the default mesh of the gizmo
  119623. */
  119624. setCustomMesh(mesh: Mesh): void;
  119625. }
  119626. }
  119627. declare module BABYLON {
  119628. /**
  119629. * Single axis drag gizmo
  119630. */
  119631. export class AxisDragGizmo extends Gizmo {
  119632. /**
  119633. * Drag behavior responsible for the gizmos dragging interactions
  119634. */
  119635. dragBehavior: PointerDragBehavior;
  119636. private _pointerObserver;
  119637. /**
  119638. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119639. */
  119640. snapDistance: number;
  119641. /**
  119642. * Event that fires each time the gizmo snaps to a new location.
  119643. * * snapDistance is the the change in distance
  119644. */
  119645. onSnapObservable: Observable<{
  119646. snapDistance: number;
  119647. }>;
  119648. private _isEnabled;
  119649. private _parent;
  119650. private _arrow;
  119651. private _coloredMaterial;
  119652. private _hoverMaterial;
  119653. /** @hidden */
  119654. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  119655. /** @hidden */
  119656. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  119657. /**
  119658. * Creates an AxisDragGizmo
  119659. * @param gizmoLayer The utility layer the gizmo will be added to
  119660. * @param dragAxis The axis which the gizmo will be able to drag on
  119661. * @param color The color of the gizmo
  119662. */
  119663. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  119664. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119665. /**
  119666. * If the gizmo is enabled
  119667. */
  119668. set isEnabled(value: boolean);
  119669. get isEnabled(): boolean;
  119670. /**
  119671. * Disposes of the gizmo
  119672. */
  119673. dispose(): void;
  119674. }
  119675. }
  119676. declare module BABYLON.Debug {
  119677. /**
  119678. * The Axes viewer will show 3 axes in a specific point in space
  119679. */
  119680. export class AxesViewer {
  119681. private _xAxis;
  119682. private _yAxis;
  119683. private _zAxis;
  119684. private _scaleLinesFactor;
  119685. private _instanced;
  119686. /**
  119687. * Gets the hosting scene
  119688. */
  119689. scene: Scene;
  119690. /**
  119691. * Gets or sets a number used to scale line length
  119692. */
  119693. scaleLines: number;
  119694. /** Gets the node hierarchy used to render x-axis */
  119695. get xAxis(): TransformNode;
  119696. /** Gets the node hierarchy used to render y-axis */
  119697. get yAxis(): TransformNode;
  119698. /** Gets the node hierarchy used to render z-axis */
  119699. get zAxis(): TransformNode;
  119700. /**
  119701. * Creates a new AxesViewer
  119702. * @param scene defines the hosting scene
  119703. * @param scaleLines defines a number used to scale line length (1 by default)
  119704. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  119705. * @param xAxis defines the node hierarchy used to render the x-axis
  119706. * @param yAxis defines the node hierarchy used to render the y-axis
  119707. * @param zAxis defines the node hierarchy used to render the z-axis
  119708. */
  119709. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  119710. /**
  119711. * Force the viewer to update
  119712. * @param position defines the position of the viewer
  119713. * @param xaxis defines the x axis of the viewer
  119714. * @param yaxis defines the y axis of the viewer
  119715. * @param zaxis defines the z axis of the viewer
  119716. */
  119717. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  119718. /**
  119719. * Creates an instance of this axes viewer.
  119720. * @returns a new axes viewer with instanced meshes
  119721. */
  119722. createInstance(): AxesViewer;
  119723. /** Releases resources */
  119724. dispose(): void;
  119725. private static _SetRenderingGroupId;
  119726. }
  119727. }
  119728. declare module BABYLON.Debug {
  119729. /**
  119730. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  119731. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  119732. */
  119733. export class BoneAxesViewer extends AxesViewer {
  119734. /**
  119735. * Gets or sets the target mesh where to display the axes viewer
  119736. */
  119737. mesh: Nullable<Mesh>;
  119738. /**
  119739. * Gets or sets the target bone where to display the axes viewer
  119740. */
  119741. bone: Nullable<Bone>;
  119742. /** Gets current position */
  119743. pos: Vector3;
  119744. /** Gets direction of X axis */
  119745. xaxis: Vector3;
  119746. /** Gets direction of Y axis */
  119747. yaxis: Vector3;
  119748. /** Gets direction of Z axis */
  119749. zaxis: Vector3;
  119750. /**
  119751. * Creates a new BoneAxesViewer
  119752. * @param scene defines the hosting scene
  119753. * @param bone defines the target bone
  119754. * @param mesh defines the target mesh
  119755. * @param scaleLines defines a scaling factor for line length (1 by default)
  119756. */
  119757. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  119758. /**
  119759. * Force the viewer to update
  119760. */
  119761. update(): void;
  119762. /** Releases resources */
  119763. dispose(): void;
  119764. }
  119765. }
  119766. declare module BABYLON {
  119767. /**
  119768. * Interface used to define scene explorer extensibility option
  119769. */
  119770. export interface IExplorerExtensibilityOption {
  119771. /**
  119772. * Define the option label
  119773. */
  119774. label: string;
  119775. /**
  119776. * Defines the action to execute on click
  119777. */
  119778. action: (entity: any) => void;
  119779. }
  119780. /**
  119781. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  119782. */
  119783. export interface IExplorerExtensibilityGroup {
  119784. /**
  119785. * Defines a predicate to test if a given type mut be extended
  119786. */
  119787. predicate: (entity: any) => boolean;
  119788. /**
  119789. * Gets the list of options added to a type
  119790. */
  119791. entries: IExplorerExtensibilityOption[];
  119792. }
  119793. /**
  119794. * Interface used to define the options to use to create the Inspector
  119795. */
  119796. export interface IInspectorOptions {
  119797. /**
  119798. * Display in overlay mode (default: false)
  119799. */
  119800. overlay?: boolean;
  119801. /**
  119802. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  119803. */
  119804. globalRoot?: HTMLElement;
  119805. /**
  119806. * Display the Scene explorer
  119807. */
  119808. showExplorer?: boolean;
  119809. /**
  119810. * Display the property inspector
  119811. */
  119812. showInspector?: boolean;
  119813. /**
  119814. * Display in embed mode (both panes on the right)
  119815. */
  119816. embedMode?: boolean;
  119817. /**
  119818. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  119819. */
  119820. handleResize?: boolean;
  119821. /**
  119822. * Allow the panes to popup (default: true)
  119823. */
  119824. enablePopup?: boolean;
  119825. /**
  119826. * Allow the panes to be closed by users (default: true)
  119827. */
  119828. enableClose?: boolean;
  119829. /**
  119830. * Optional list of extensibility entries
  119831. */
  119832. explorerExtensibility?: IExplorerExtensibilityGroup[];
  119833. /**
  119834. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  119835. */
  119836. inspectorURL?: string;
  119837. /**
  119838. * Optional initial tab (default to DebugLayerTab.Properties)
  119839. */
  119840. initialTab?: DebugLayerTab;
  119841. }
  119842. interface Scene {
  119843. /**
  119844. * @hidden
  119845. * Backing field
  119846. */
  119847. _debugLayer: DebugLayer;
  119848. /**
  119849. * Gets the debug layer (aka Inspector) associated with the scene
  119850. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119851. */
  119852. debugLayer: DebugLayer;
  119853. }
  119854. /**
  119855. * Enum of inspector action tab
  119856. */
  119857. export enum DebugLayerTab {
  119858. /**
  119859. * Properties tag (default)
  119860. */
  119861. Properties = 0,
  119862. /**
  119863. * Debug tab
  119864. */
  119865. Debug = 1,
  119866. /**
  119867. * Statistics tab
  119868. */
  119869. Statistics = 2,
  119870. /**
  119871. * Tools tab
  119872. */
  119873. Tools = 3,
  119874. /**
  119875. * Settings tab
  119876. */
  119877. Settings = 4
  119878. }
  119879. /**
  119880. * The debug layer (aka Inspector) is the go to tool in order to better understand
  119881. * what is happening in your scene
  119882. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119883. */
  119884. export class DebugLayer {
  119885. /**
  119886. * Define the url to get the inspector script from.
  119887. * By default it uses the babylonjs CDN.
  119888. * @ignoreNaming
  119889. */
  119890. static InspectorURL: string;
  119891. private _scene;
  119892. private BJSINSPECTOR;
  119893. private _onPropertyChangedObservable?;
  119894. /**
  119895. * Observable triggered when a property is changed through the inspector.
  119896. */
  119897. get onPropertyChangedObservable(): any;
  119898. /**
  119899. * Instantiates a new debug layer.
  119900. * The debug layer (aka Inspector) is the go to tool in order to better understand
  119901. * what is happening in your scene
  119902. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119903. * @param scene Defines the scene to inspect
  119904. */
  119905. constructor(scene: Scene);
  119906. /** Creates the inspector window. */
  119907. private _createInspector;
  119908. /**
  119909. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  119910. * @param entity defines the entity to select
  119911. * @param lineContainerTitle defines the specific block to highlight
  119912. */
  119913. select(entity: any, lineContainerTitle?: string): void;
  119914. /** Get the inspector from bundle or global */
  119915. private _getGlobalInspector;
  119916. /**
  119917. * Get if the inspector is visible or not.
  119918. * @returns true if visible otherwise, false
  119919. */
  119920. isVisible(): boolean;
  119921. /**
  119922. * Hide the inspector and close its window.
  119923. */
  119924. hide(): void;
  119925. /**
  119926. * Launch the debugLayer.
  119927. * @param config Define the configuration of the inspector
  119928. * @return a promise fulfilled when the debug layer is visible
  119929. */
  119930. show(config?: IInspectorOptions): Promise<DebugLayer>;
  119931. }
  119932. }
  119933. declare module BABYLON {
  119934. /**
  119935. * Class containing static functions to help procedurally build meshes
  119936. */
  119937. export class BoxBuilder {
  119938. /**
  119939. * Creates a box mesh
  119940. * * The parameter `size` sets the size (float) of each box side (default 1)
  119941. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  119942. * * 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)
  119943. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  119944. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119945. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119946. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119947. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  119948. * @param name defines the name of the mesh
  119949. * @param options defines the options used to create the mesh
  119950. * @param scene defines the hosting scene
  119951. * @returns the box mesh
  119952. */
  119953. static CreateBox(name: string, options: {
  119954. size?: number;
  119955. width?: number;
  119956. height?: number;
  119957. depth?: number;
  119958. faceUV?: Vector4[];
  119959. faceColors?: Color4[];
  119960. sideOrientation?: number;
  119961. frontUVs?: Vector4;
  119962. backUVs?: Vector4;
  119963. wrap?: boolean;
  119964. topBaseAt?: number;
  119965. bottomBaseAt?: number;
  119966. updatable?: boolean;
  119967. }, scene?: Nullable<Scene>): Mesh;
  119968. }
  119969. }
  119970. declare module BABYLON.Debug {
  119971. /**
  119972. * Used to show the physics impostor around the specific mesh
  119973. */
  119974. export class PhysicsViewer {
  119975. /** @hidden */
  119976. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  119977. /** @hidden */
  119978. protected _meshes: Array<Nullable<AbstractMesh>>;
  119979. /** @hidden */
  119980. protected _scene: Nullable<Scene>;
  119981. /** @hidden */
  119982. protected _numMeshes: number;
  119983. /** @hidden */
  119984. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  119985. private _renderFunction;
  119986. private _utilityLayer;
  119987. private _debugBoxMesh;
  119988. private _debugSphereMesh;
  119989. private _debugCylinderMesh;
  119990. private _debugMaterial;
  119991. private _debugMeshMeshes;
  119992. /**
  119993. * Creates a new PhysicsViewer
  119994. * @param scene defines the hosting scene
  119995. */
  119996. constructor(scene: Scene);
  119997. /** @hidden */
  119998. protected _updateDebugMeshes(): void;
  119999. /**
  120000. * Renders a specified physic impostor
  120001. * @param impostor defines the impostor to render
  120002. * @param targetMesh defines the mesh represented by the impostor
  120003. * @returns the new debug mesh used to render the impostor
  120004. */
  120005. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  120006. /**
  120007. * Hides a specified physic impostor
  120008. * @param impostor defines the impostor to hide
  120009. */
  120010. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  120011. private _getDebugMaterial;
  120012. private _getDebugBoxMesh;
  120013. private _getDebugSphereMesh;
  120014. private _getDebugCylinderMesh;
  120015. private _getDebugMeshMesh;
  120016. private _getDebugMesh;
  120017. /** Releases all resources */
  120018. dispose(): void;
  120019. }
  120020. }
  120021. declare module BABYLON {
  120022. /**
  120023. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  120024. * in order to better appreciate the issue one might have.
  120025. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  120026. */
  120027. export class RayHelper {
  120028. /**
  120029. * Defines the ray we are currently tryin to visualize.
  120030. */
  120031. ray: Nullable<Ray>;
  120032. private _renderPoints;
  120033. private _renderLine;
  120034. private _renderFunction;
  120035. private _scene;
  120036. private _updateToMeshFunction;
  120037. private _attachedToMesh;
  120038. private _meshSpaceDirection;
  120039. private _meshSpaceOrigin;
  120040. /**
  120041. * Helper function to create a colored helper in a scene in one line.
  120042. * @param ray Defines the ray we are currently tryin to visualize
  120043. * @param scene Defines the scene the ray is used in
  120044. * @param color Defines the color we want to see the ray in
  120045. * @returns The newly created ray helper.
  120046. */
  120047. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  120048. /**
  120049. * Instantiate a new ray helper.
  120050. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  120051. * in order to better appreciate the issue one might have.
  120052. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  120053. * @param ray Defines the ray we are currently tryin to visualize
  120054. */
  120055. constructor(ray: Ray);
  120056. /**
  120057. * Shows the ray we are willing to debug.
  120058. * @param scene Defines the scene the ray needs to be rendered in
  120059. * @param color Defines the color the ray needs to be rendered in
  120060. */
  120061. show(scene: Scene, color?: Color3): void;
  120062. /**
  120063. * Hides the ray we are debugging.
  120064. */
  120065. hide(): void;
  120066. private _render;
  120067. /**
  120068. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  120069. * @param mesh Defines the mesh we want the helper attached to
  120070. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  120071. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  120072. * @param length Defines the length of the ray
  120073. */
  120074. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  120075. /**
  120076. * Detach the ray helper from the mesh it has previously been attached to.
  120077. */
  120078. detachFromMesh(): void;
  120079. private _updateToMesh;
  120080. /**
  120081. * Dispose the helper and release its associated resources.
  120082. */
  120083. dispose(): void;
  120084. }
  120085. }
  120086. declare module BABYLON.Debug {
  120087. /**
  120088. * Class used to render a debug view of a given skeleton
  120089. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  120090. */
  120091. export class SkeletonViewer {
  120092. /** defines the skeleton to render */
  120093. skeleton: Skeleton;
  120094. /** defines the mesh attached to the skeleton */
  120095. mesh: AbstractMesh;
  120096. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  120097. autoUpdateBonesMatrices: boolean;
  120098. /** defines the rendering group id to use with the viewer */
  120099. renderingGroupId: number;
  120100. /** Gets or sets the color used to render the skeleton */
  120101. color: Color3;
  120102. private _scene;
  120103. private _debugLines;
  120104. private _debugMesh;
  120105. private _isEnabled;
  120106. private _renderFunction;
  120107. private _utilityLayer;
  120108. /**
  120109. * Returns the mesh used to render the bones
  120110. */
  120111. get debugMesh(): Nullable<LinesMesh>;
  120112. /**
  120113. * Creates a new SkeletonViewer
  120114. * @param skeleton defines the skeleton to render
  120115. * @param mesh defines the mesh attached to the skeleton
  120116. * @param scene defines the hosting scene
  120117. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  120118. * @param renderingGroupId defines the rendering group id to use with the viewer
  120119. */
  120120. constructor(
  120121. /** defines the skeleton to render */
  120122. skeleton: Skeleton,
  120123. /** defines the mesh attached to the skeleton */
  120124. mesh: AbstractMesh, scene: Scene,
  120125. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  120126. autoUpdateBonesMatrices?: boolean,
  120127. /** defines the rendering group id to use with the viewer */
  120128. renderingGroupId?: number);
  120129. /** Gets or sets a boolean indicating if the viewer is enabled */
  120130. set isEnabled(value: boolean);
  120131. get isEnabled(): boolean;
  120132. private _getBonePosition;
  120133. private _getLinesForBonesWithLength;
  120134. private _getLinesForBonesNoLength;
  120135. /** Update the viewer to sync with current skeleton state */
  120136. update(): void;
  120137. /** Release associated resources */
  120138. dispose(): void;
  120139. }
  120140. }
  120141. declare module BABYLON {
  120142. /**
  120143. * Options to create the null engine
  120144. */
  120145. export class NullEngineOptions {
  120146. /**
  120147. * Render width (Default: 512)
  120148. */
  120149. renderWidth: number;
  120150. /**
  120151. * Render height (Default: 256)
  120152. */
  120153. renderHeight: number;
  120154. /**
  120155. * Texture size (Default: 512)
  120156. */
  120157. textureSize: number;
  120158. /**
  120159. * If delta time between frames should be constant
  120160. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120161. */
  120162. deterministicLockstep: boolean;
  120163. /**
  120164. * Maximum about of steps between frames (Default: 4)
  120165. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120166. */
  120167. lockstepMaxSteps: number;
  120168. }
  120169. /**
  120170. * The null engine class provides support for headless version of babylon.js.
  120171. * This can be used in server side scenario or for testing purposes
  120172. */
  120173. export class NullEngine extends Engine {
  120174. private _options;
  120175. /**
  120176. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  120177. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120178. * @returns true if engine is in deterministic lock step mode
  120179. */
  120180. isDeterministicLockStep(): boolean;
  120181. /**
  120182. * Gets the max steps when engine is running in deterministic lock step
  120183. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120184. * @returns the max steps
  120185. */
  120186. getLockstepMaxSteps(): number;
  120187. /**
  120188. * Gets the current hardware scaling level.
  120189. * By default the hardware scaling level is computed from the window device ratio.
  120190. * 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.
  120191. * @returns a number indicating the current hardware scaling level
  120192. */
  120193. getHardwareScalingLevel(): number;
  120194. constructor(options?: NullEngineOptions);
  120195. /**
  120196. * Creates a vertex buffer
  120197. * @param vertices the data for the vertex buffer
  120198. * @returns the new WebGL static buffer
  120199. */
  120200. createVertexBuffer(vertices: FloatArray): DataBuffer;
  120201. /**
  120202. * Creates a new index buffer
  120203. * @param indices defines the content of the index buffer
  120204. * @param updatable defines if the index buffer must be updatable
  120205. * @returns a new webGL buffer
  120206. */
  120207. createIndexBuffer(indices: IndicesArray): DataBuffer;
  120208. /**
  120209. * Clear the current render buffer or the current render target (if any is set up)
  120210. * @param color defines the color to use
  120211. * @param backBuffer defines if the back buffer must be cleared
  120212. * @param depth defines if the depth buffer must be cleared
  120213. * @param stencil defines if the stencil buffer must be cleared
  120214. */
  120215. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  120216. /**
  120217. * Gets the current render width
  120218. * @param useScreen defines if screen size must be used (or the current render target if any)
  120219. * @returns a number defining the current render width
  120220. */
  120221. getRenderWidth(useScreen?: boolean): number;
  120222. /**
  120223. * Gets the current render height
  120224. * @param useScreen defines if screen size must be used (or the current render target if any)
  120225. * @returns a number defining the current render height
  120226. */
  120227. getRenderHeight(useScreen?: boolean): number;
  120228. /**
  120229. * Set the WebGL's viewport
  120230. * @param viewport defines the viewport element to be used
  120231. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  120232. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  120233. */
  120234. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  120235. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  120236. /**
  120237. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  120238. * @param pipelineContext defines the pipeline context to use
  120239. * @param uniformsNames defines the list of uniform names
  120240. * @returns an array of webGL uniform locations
  120241. */
  120242. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  120243. /**
  120244. * Gets the lsit of active attributes for a given webGL program
  120245. * @param pipelineContext defines the pipeline context to use
  120246. * @param attributesNames defines the list of attribute names to get
  120247. * @returns an array of indices indicating the offset of each attribute
  120248. */
  120249. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  120250. /**
  120251. * Binds an effect to the webGL context
  120252. * @param effect defines the effect to bind
  120253. */
  120254. bindSamplers(effect: Effect): void;
  120255. /**
  120256. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  120257. * @param effect defines the effect to activate
  120258. */
  120259. enableEffect(effect: Effect): void;
  120260. /**
  120261. * Set various states to the webGL context
  120262. * @param culling defines backface culling state
  120263. * @param zOffset defines the value to apply to zOffset (0 by default)
  120264. * @param force defines if states must be applied even if cache is up to date
  120265. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  120266. */
  120267. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  120268. /**
  120269. * Set the value of an uniform to an array of int32
  120270. * @param uniform defines the webGL uniform location where to store the value
  120271. * @param array defines the array of int32 to store
  120272. */
  120273. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  120274. /**
  120275. * Set the value of an uniform to an array of int32 (stored as vec2)
  120276. * @param uniform defines the webGL uniform location where to store the value
  120277. * @param array defines the array of int32 to store
  120278. */
  120279. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  120280. /**
  120281. * Set the value of an uniform to an array of int32 (stored as vec3)
  120282. * @param uniform defines the webGL uniform location where to store the value
  120283. * @param array defines the array of int32 to store
  120284. */
  120285. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  120286. /**
  120287. * Set the value of an uniform to an array of int32 (stored as vec4)
  120288. * @param uniform defines the webGL uniform location where to store the value
  120289. * @param array defines the array of int32 to store
  120290. */
  120291. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  120292. /**
  120293. * Set the value of an uniform to an array of float32
  120294. * @param uniform defines the webGL uniform location where to store the value
  120295. * @param array defines the array of float32 to store
  120296. */
  120297. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  120298. /**
  120299. * Set the value of an uniform to an array of float32 (stored as vec2)
  120300. * @param uniform defines the webGL uniform location where to store the value
  120301. * @param array defines the array of float32 to store
  120302. */
  120303. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  120304. /**
  120305. * Set the value of an uniform to an array of float32 (stored as vec3)
  120306. * @param uniform defines the webGL uniform location where to store the value
  120307. * @param array defines the array of float32 to store
  120308. */
  120309. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  120310. /**
  120311. * Set the value of an uniform to an array of float32 (stored as vec4)
  120312. * @param uniform defines the webGL uniform location where to store the value
  120313. * @param array defines the array of float32 to store
  120314. */
  120315. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  120316. /**
  120317. * Set the value of an uniform to an array of number
  120318. * @param uniform defines the webGL uniform location where to store the value
  120319. * @param array defines the array of number to store
  120320. */
  120321. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  120322. /**
  120323. * Set the value of an uniform to an array of number (stored as vec2)
  120324. * @param uniform defines the webGL uniform location where to store the value
  120325. * @param array defines the array of number to store
  120326. */
  120327. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  120328. /**
  120329. * Set the value of an uniform to an array of number (stored as vec3)
  120330. * @param uniform defines the webGL uniform location where to store the value
  120331. * @param array defines the array of number to store
  120332. */
  120333. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  120334. /**
  120335. * Set the value of an uniform to an array of number (stored as vec4)
  120336. * @param uniform defines the webGL uniform location where to store the value
  120337. * @param array defines the array of number to store
  120338. */
  120339. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  120340. /**
  120341. * Set the value of an uniform to an array of float32 (stored as matrices)
  120342. * @param uniform defines the webGL uniform location where to store the value
  120343. * @param matrices defines the array of float32 to store
  120344. */
  120345. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  120346. /**
  120347. * Set the value of an uniform to a matrix (3x3)
  120348. * @param uniform defines the webGL uniform location where to store the value
  120349. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  120350. */
  120351. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120352. /**
  120353. * Set the value of an uniform to a matrix (2x2)
  120354. * @param uniform defines the webGL uniform location where to store the value
  120355. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  120356. */
  120357. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120358. /**
  120359. * Set the value of an uniform to a number (float)
  120360. * @param uniform defines the webGL uniform location where to store the value
  120361. * @param value defines the float number to store
  120362. */
  120363. setFloat(uniform: WebGLUniformLocation, value: number): void;
  120364. /**
  120365. * Set the value of an uniform to a vec2
  120366. * @param uniform defines the webGL uniform location where to store the value
  120367. * @param x defines the 1st component of the value
  120368. * @param y defines the 2nd component of the value
  120369. */
  120370. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  120371. /**
  120372. * Set the value of an uniform to a vec3
  120373. * @param uniform defines the webGL uniform location where to store the value
  120374. * @param x defines the 1st component of the value
  120375. * @param y defines the 2nd component of the value
  120376. * @param z defines the 3rd component of the value
  120377. */
  120378. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  120379. /**
  120380. * Set the value of an uniform to a boolean
  120381. * @param uniform defines the webGL uniform location where to store the value
  120382. * @param bool defines the boolean to store
  120383. */
  120384. setBool(uniform: WebGLUniformLocation, bool: number): void;
  120385. /**
  120386. * Set the value of an uniform to a vec4
  120387. * @param uniform defines the webGL uniform location where to store the value
  120388. * @param x defines the 1st component of the value
  120389. * @param y defines the 2nd component of the value
  120390. * @param z defines the 3rd component of the value
  120391. * @param w defines the 4th component of the value
  120392. */
  120393. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  120394. /**
  120395. * Sets the current alpha mode
  120396. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  120397. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  120398. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120399. */
  120400. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  120401. /**
  120402. * Bind webGl buffers directly to the webGL context
  120403. * @param vertexBuffers defines the vertex buffer to bind
  120404. * @param indexBuffer defines the index buffer to bind
  120405. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  120406. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  120407. * @param effect defines the effect associated with the vertex buffer
  120408. */
  120409. bindBuffers(vertexBuffers: {
  120410. [key: string]: VertexBuffer;
  120411. }, indexBuffer: DataBuffer, effect: Effect): void;
  120412. /**
  120413. * Force the entire cache to be cleared
  120414. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  120415. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  120416. */
  120417. wipeCaches(bruteForce?: boolean): void;
  120418. /**
  120419. * Send a draw order
  120420. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  120421. * @param indexStart defines the starting index
  120422. * @param indexCount defines the number of index to draw
  120423. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120424. */
  120425. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  120426. /**
  120427. * Draw a list of indexed primitives
  120428. * @param fillMode defines the primitive to use
  120429. * @param indexStart defines the starting index
  120430. * @param indexCount defines the number of index to draw
  120431. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120432. */
  120433. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  120434. /**
  120435. * Draw a list of unindexed primitives
  120436. * @param fillMode defines the primitive to use
  120437. * @param verticesStart defines the index of first vertex to draw
  120438. * @param verticesCount defines the count of vertices to draw
  120439. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120440. */
  120441. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120442. /** @hidden */
  120443. _createTexture(): WebGLTexture;
  120444. /** @hidden */
  120445. _releaseTexture(texture: InternalTexture): void;
  120446. /**
  120447. * Usually called from Texture.ts.
  120448. * Passed information to create a WebGLTexture
  120449. * @param urlArg defines a value which contains one of the following:
  120450. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  120451. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  120452. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  120453. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  120454. * @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)
  120455. * @param scene needed for loading to the correct scene
  120456. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  120457. * @param onLoad optional callback to be called upon successful completion
  120458. * @param onError optional callback to be called upon failure
  120459. * @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
  120460. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  120461. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  120462. * @param forcedExtension defines the extension to use to pick the right loader
  120463. * @param mimeType defines an optional mime type
  120464. * @returns a InternalTexture for assignment back into BABYLON.Texture
  120465. */
  120466. 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;
  120467. /**
  120468. * Creates a new render target texture
  120469. * @param size defines the size of the texture
  120470. * @param options defines the options used to create the texture
  120471. * @returns a new render target texture stored in an InternalTexture
  120472. */
  120473. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  120474. /**
  120475. * Update the sampling mode of a given texture
  120476. * @param samplingMode defines the required sampling mode
  120477. * @param texture defines the texture to update
  120478. */
  120479. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  120480. /**
  120481. * Binds the frame buffer to the specified texture.
  120482. * @param texture The texture to render to or null for the default canvas
  120483. * @param faceIndex The face of the texture to render to in case of cube texture
  120484. * @param requiredWidth The width of the target to render to
  120485. * @param requiredHeight The height of the target to render to
  120486. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  120487. * @param lodLevel defines le lod level to bind to the frame buffer
  120488. */
  120489. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  120490. /**
  120491. * Unbind the current render target texture from the webGL context
  120492. * @param texture defines the render target texture to unbind
  120493. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  120494. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  120495. */
  120496. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  120497. /**
  120498. * Creates a dynamic vertex buffer
  120499. * @param vertices the data for the dynamic vertex buffer
  120500. * @returns the new WebGL dynamic buffer
  120501. */
  120502. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  120503. /**
  120504. * Update the content of a dynamic texture
  120505. * @param texture defines the texture to update
  120506. * @param canvas defines the canvas containing the source
  120507. * @param invertY defines if data must be stored with Y axis inverted
  120508. * @param premulAlpha defines if alpha is stored as premultiplied
  120509. * @param format defines the format of the data
  120510. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  120511. */
  120512. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  120513. /**
  120514. * Gets a boolean indicating if all created effects are ready
  120515. * @returns true if all effects are ready
  120516. */
  120517. areAllEffectsReady(): boolean;
  120518. /**
  120519. * @hidden
  120520. * Get the current error code of the webGL context
  120521. * @returns the error code
  120522. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  120523. */
  120524. getError(): number;
  120525. /** @hidden */
  120526. _getUnpackAlignement(): number;
  120527. /** @hidden */
  120528. _unpackFlipY(value: boolean): void;
  120529. /**
  120530. * Update a dynamic index buffer
  120531. * @param indexBuffer defines the target index buffer
  120532. * @param indices defines the data to update
  120533. * @param offset defines the offset in the target index buffer where update should start
  120534. */
  120535. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  120536. /**
  120537. * Updates a dynamic vertex buffer.
  120538. * @param vertexBuffer the vertex buffer to update
  120539. * @param vertices the data used to update the vertex buffer
  120540. * @param byteOffset the byte offset of the data (optional)
  120541. * @param byteLength the byte length of the data (optional)
  120542. */
  120543. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  120544. /** @hidden */
  120545. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  120546. /** @hidden */
  120547. _bindTexture(channel: number, texture: InternalTexture): void;
  120548. protected _deleteBuffer(buffer: WebGLBuffer): void;
  120549. /**
  120550. * 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
  120551. */
  120552. releaseEffects(): void;
  120553. displayLoadingUI(): void;
  120554. hideLoadingUI(): void;
  120555. /** @hidden */
  120556. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120557. /** @hidden */
  120558. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120559. /** @hidden */
  120560. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120561. /** @hidden */
  120562. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  120563. }
  120564. }
  120565. declare module BABYLON {
  120566. /**
  120567. * @hidden
  120568. **/
  120569. export class _TimeToken {
  120570. _startTimeQuery: Nullable<WebGLQuery>;
  120571. _endTimeQuery: Nullable<WebGLQuery>;
  120572. _timeElapsedQuery: Nullable<WebGLQuery>;
  120573. _timeElapsedQueryEnded: boolean;
  120574. }
  120575. }
  120576. declare module BABYLON {
  120577. /** @hidden */
  120578. export class _OcclusionDataStorage {
  120579. /** @hidden */
  120580. occlusionInternalRetryCounter: number;
  120581. /** @hidden */
  120582. isOcclusionQueryInProgress: boolean;
  120583. /** @hidden */
  120584. isOccluded: boolean;
  120585. /** @hidden */
  120586. occlusionRetryCount: number;
  120587. /** @hidden */
  120588. occlusionType: number;
  120589. /** @hidden */
  120590. occlusionQueryAlgorithmType: number;
  120591. }
  120592. interface Engine {
  120593. /**
  120594. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  120595. * @return the new query
  120596. */
  120597. createQuery(): WebGLQuery;
  120598. /**
  120599. * Delete and release a webGL query
  120600. * @param query defines the query to delete
  120601. * @return the current engine
  120602. */
  120603. deleteQuery(query: WebGLQuery): Engine;
  120604. /**
  120605. * Check if a given query has resolved and got its value
  120606. * @param query defines the query to check
  120607. * @returns true if the query got its value
  120608. */
  120609. isQueryResultAvailable(query: WebGLQuery): boolean;
  120610. /**
  120611. * Gets the value of a given query
  120612. * @param query defines the query to check
  120613. * @returns the value of the query
  120614. */
  120615. getQueryResult(query: WebGLQuery): number;
  120616. /**
  120617. * Initiates an occlusion query
  120618. * @param algorithmType defines the algorithm to use
  120619. * @param query defines the query to use
  120620. * @returns the current engine
  120621. * @see http://doc.babylonjs.com/features/occlusionquery
  120622. */
  120623. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  120624. /**
  120625. * Ends an occlusion query
  120626. * @see http://doc.babylonjs.com/features/occlusionquery
  120627. * @param algorithmType defines the algorithm to use
  120628. * @returns the current engine
  120629. */
  120630. endOcclusionQuery(algorithmType: number): Engine;
  120631. /**
  120632. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  120633. * Please note that only one query can be issued at a time
  120634. * @returns a time token used to track the time span
  120635. */
  120636. startTimeQuery(): Nullable<_TimeToken>;
  120637. /**
  120638. * Ends a time query
  120639. * @param token defines the token used to measure the time span
  120640. * @returns the time spent (in ns)
  120641. */
  120642. endTimeQuery(token: _TimeToken): int;
  120643. /** @hidden */
  120644. _currentNonTimestampToken: Nullable<_TimeToken>;
  120645. /** @hidden */
  120646. _createTimeQuery(): WebGLQuery;
  120647. /** @hidden */
  120648. _deleteTimeQuery(query: WebGLQuery): void;
  120649. /** @hidden */
  120650. _getGlAlgorithmType(algorithmType: number): number;
  120651. /** @hidden */
  120652. _getTimeQueryResult(query: WebGLQuery): any;
  120653. /** @hidden */
  120654. _getTimeQueryAvailability(query: WebGLQuery): any;
  120655. }
  120656. interface AbstractMesh {
  120657. /**
  120658. * Backing filed
  120659. * @hidden
  120660. */
  120661. __occlusionDataStorage: _OcclusionDataStorage;
  120662. /**
  120663. * Access property
  120664. * @hidden
  120665. */
  120666. _occlusionDataStorage: _OcclusionDataStorage;
  120667. /**
  120668. * 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.
  120669. * The default value is -1 which means don't break the query and wait till the result
  120670. * @see http://doc.babylonjs.com/features/occlusionquery
  120671. */
  120672. occlusionRetryCount: number;
  120673. /**
  120674. * 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:
  120675. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  120676. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  120677. * * 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.
  120678. * @see http://doc.babylonjs.com/features/occlusionquery
  120679. */
  120680. occlusionType: number;
  120681. /**
  120682. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  120683. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  120684. * * 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.
  120685. * @see http://doc.babylonjs.com/features/occlusionquery
  120686. */
  120687. occlusionQueryAlgorithmType: number;
  120688. /**
  120689. * 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
  120690. * @see http://doc.babylonjs.com/features/occlusionquery
  120691. */
  120692. isOccluded: boolean;
  120693. /**
  120694. * Flag to check the progress status of the query
  120695. * @see http://doc.babylonjs.com/features/occlusionquery
  120696. */
  120697. isOcclusionQueryInProgress: boolean;
  120698. }
  120699. }
  120700. declare module BABYLON {
  120701. /** @hidden */
  120702. export var _forceTransformFeedbackToBundle: boolean;
  120703. interface Engine {
  120704. /**
  120705. * Creates a webGL transform feedback object
  120706. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  120707. * @returns the webGL transform feedback object
  120708. */
  120709. createTransformFeedback(): WebGLTransformFeedback;
  120710. /**
  120711. * Delete a webGL transform feedback object
  120712. * @param value defines the webGL transform feedback object to delete
  120713. */
  120714. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  120715. /**
  120716. * Bind a webGL transform feedback object to the webgl context
  120717. * @param value defines the webGL transform feedback object to bind
  120718. */
  120719. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  120720. /**
  120721. * Begins a transform feedback operation
  120722. * @param usePoints defines if points or triangles must be used
  120723. */
  120724. beginTransformFeedback(usePoints: boolean): void;
  120725. /**
  120726. * Ends a transform feedback operation
  120727. */
  120728. endTransformFeedback(): void;
  120729. /**
  120730. * Specify the varyings to use with transform feedback
  120731. * @param program defines the associated webGL program
  120732. * @param value defines the list of strings representing the varying names
  120733. */
  120734. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  120735. /**
  120736. * Bind a webGL buffer for a transform feedback operation
  120737. * @param value defines the webGL buffer to bind
  120738. */
  120739. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  120740. }
  120741. }
  120742. declare module BABYLON {
  120743. /**
  120744. * Creation options of the multi render target texture.
  120745. */
  120746. export interface IMultiRenderTargetOptions {
  120747. /**
  120748. * Define if the texture needs to create mip maps after render.
  120749. */
  120750. generateMipMaps?: boolean;
  120751. /**
  120752. * Define the types of all the draw buffers we want to create
  120753. */
  120754. types?: number[];
  120755. /**
  120756. * Define the sampling modes of all the draw buffers we want to create
  120757. */
  120758. samplingModes?: number[];
  120759. /**
  120760. * Define if a depth buffer is required
  120761. */
  120762. generateDepthBuffer?: boolean;
  120763. /**
  120764. * Define if a stencil buffer is required
  120765. */
  120766. generateStencilBuffer?: boolean;
  120767. /**
  120768. * Define if a depth texture is required instead of a depth buffer
  120769. */
  120770. generateDepthTexture?: boolean;
  120771. /**
  120772. * Define the number of desired draw buffers
  120773. */
  120774. textureCount?: number;
  120775. /**
  120776. * Define if aspect ratio should be adapted to the texture or stay the scene one
  120777. */
  120778. doNotChangeAspectRatio?: boolean;
  120779. /**
  120780. * Define the default type of the buffers we are creating
  120781. */
  120782. defaultType?: number;
  120783. }
  120784. /**
  120785. * A multi render target, like a render target provides the ability to render to a texture.
  120786. * Unlike the render target, it can render to several draw buffers in one draw.
  120787. * This is specially interesting in deferred rendering or for any effects requiring more than
  120788. * just one color from a single pass.
  120789. */
  120790. export class MultiRenderTarget extends RenderTargetTexture {
  120791. private _internalTextures;
  120792. private _textures;
  120793. private _multiRenderTargetOptions;
  120794. /**
  120795. * Get if draw buffers are currently supported by the used hardware and browser.
  120796. */
  120797. get isSupported(): boolean;
  120798. /**
  120799. * Get the list of textures generated by the multi render target.
  120800. */
  120801. get textures(): Texture[];
  120802. /**
  120803. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  120804. */
  120805. get depthTexture(): Texture;
  120806. /**
  120807. * Set the wrapping mode on U of all the textures we are rendering to.
  120808. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  120809. */
  120810. set wrapU(wrap: number);
  120811. /**
  120812. * Set the wrapping mode on V of all the textures we are rendering to.
  120813. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  120814. */
  120815. set wrapV(wrap: number);
  120816. /**
  120817. * Instantiate a new multi render target texture.
  120818. * A multi render target, like a render target provides the ability to render to a texture.
  120819. * Unlike the render target, it can render to several draw buffers in one draw.
  120820. * This is specially interesting in deferred rendering or for any effects requiring more than
  120821. * just one color from a single pass.
  120822. * @param name Define the name of the texture
  120823. * @param size Define the size of the buffers to render to
  120824. * @param count Define the number of target we are rendering into
  120825. * @param scene Define the scene the texture belongs to
  120826. * @param options Define the options used to create the multi render target
  120827. */
  120828. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  120829. /** @hidden */
  120830. _rebuild(): void;
  120831. private _createInternalTextures;
  120832. private _createTextures;
  120833. /**
  120834. * Define the number of samples used if MSAA is enabled.
  120835. */
  120836. get samples(): number;
  120837. set samples(value: number);
  120838. /**
  120839. * Resize all the textures in the multi render target.
  120840. * Be carrefull as it will recreate all the data in the new texture.
  120841. * @param size Define the new size
  120842. */
  120843. resize(size: any): void;
  120844. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  120845. /**
  120846. * Dispose the render targets and their associated resources
  120847. */
  120848. dispose(): void;
  120849. /**
  120850. * Release all the underlying texture used as draw buffers.
  120851. */
  120852. releaseInternalTextures(): void;
  120853. }
  120854. }
  120855. declare module BABYLON {
  120856. interface ThinEngine {
  120857. /**
  120858. * Unbind a list of render target textures from the webGL context
  120859. * This is used only when drawBuffer extension or webGL2 are active
  120860. * @param textures defines the render target textures to unbind
  120861. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  120862. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  120863. */
  120864. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  120865. /**
  120866. * Create a multi render target texture
  120867. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  120868. * @param size defines the size of the texture
  120869. * @param options defines the creation options
  120870. * @returns the cube texture as an InternalTexture
  120871. */
  120872. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  120873. /**
  120874. * Update the sample count for a given multiple render target texture
  120875. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  120876. * @param textures defines the textures to update
  120877. * @param samples defines the sample count to set
  120878. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  120879. */
  120880. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  120881. }
  120882. }
  120883. declare module BABYLON {
  120884. /**
  120885. * Class used to define an additional view for the engine
  120886. * @see https://doc.babylonjs.com/how_to/multi_canvases
  120887. */
  120888. export class EngineView {
  120889. /** Defines the canvas where to render the view */
  120890. target: HTMLCanvasElement;
  120891. /** Defines an optional camera used to render the view (will use active camera else) */
  120892. camera?: Camera;
  120893. }
  120894. interface Engine {
  120895. /**
  120896. * Gets or sets the HTML element to use for attaching events
  120897. */
  120898. inputElement: Nullable<HTMLElement>;
  120899. /**
  120900. * Gets the current engine view
  120901. * @see https://doc.babylonjs.com/how_to/multi_canvases
  120902. */
  120903. activeView: Nullable<EngineView>;
  120904. /** Gets or sets the list of views */
  120905. views: EngineView[];
  120906. /**
  120907. * Register a new child canvas
  120908. * @param canvas defines the canvas to register
  120909. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  120910. * @returns the associated view
  120911. */
  120912. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  120913. /**
  120914. * Remove a registered child canvas
  120915. * @param canvas defines the canvas to remove
  120916. * @returns the current engine
  120917. */
  120918. unRegisterView(canvas: HTMLCanvasElement): Engine;
  120919. }
  120920. }
  120921. declare module BABYLON {
  120922. /**
  120923. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  120924. */
  120925. export interface CubeMapInfo {
  120926. /**
  120927. * The pixel array for the front face.
  120928. * This is stored in format, left to right, up to down format.
  120929. */
  120930. front: Nullable<ArrayBufferView>;
  120931. /**
  120932. * The pixel array for the back face.
  120933. * This is stored in format, left to right, up to down format.
  120934. */
  120935. back: Nullable<ArrayBufferView>;
  120936. /**
  120937. * The pixel array for the left face.
  120938. * This is stored in format, left to right, up to down format.
  120939. */
  120940. left: Nullable<ArrayBufferView>;
  120941. /**
  120942. * The pixel array for the right face.
  120943. * This is stored in format, left to right, up to down format.
  120944. */
  120945. right: Nullable<ArrayBufferView>;
  120946. /**
  120947. * The pixel array for the up face.
  120948. * This is stored in format, left to right, up to down format.
  120949. */
  120950. up: Nullable<ArrayBufferView>;
  120951. /**
  120952. * The pixel array for the down face.
  120953. * This is stored in format, left to right, up to down format.
  120954. */
  120955. down: Nullable<ArrayBufferView>;
  120956. /**
  120957. * The size of the cubemap stored.
  120958. *
  120959. * Each faces will be size * size pixels.
  120960. */
  120961. size: number;
  120962. /**
  120963. * The format of the texture.
  120964. *
  120965. * RGBA, RGB.
  120966. */
  120967. format: number;
  120968. /**
  120969. * The type of the texture data.
  120970. *
  120971. * UNSIGNED_INT, FLOAT.
  120972. */
  120973. type: number;
  120974. /**
  120975. * Specifies whether the texture is in gamma space.
  120976. */
  120977. gammaSpace: boolean;
  120978. }
  120979. /**
  120980. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  120981. */
  120982. export class PanoramaToCubeMapTools {
  120983. private static FACE_FRONT;
  120984. private static FACE_BACK;
  120985. private static FACE_RIGHT;
  120986. private static FACE_LEFT;
  120987. private static FACE_DOWN;
  120988. private static FACE_UP;
  120989. /**
  120990. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  120991. *
  120992. * @param float32Array The source data.
  120993. * @param inputWidth The width of the input panorama.
  120994. * @param inputHeight The height of the input panorama.
  120995. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  120996. * @return The cubemap data
  120997. */
  120998. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  120999. private static CreateCubemapTexture;
  121000. private static CalcProjectionSpherical;
  121001. }
  121002. }
  121003. declare module BABYLON {
  121004. /**
  121005. * Helper class dealing with the extraction of spherical polynomial dataArray
  121006. * from a cube map.
  121007. */
  121008. export class CubeMapToSphericalPolynomialTools {
  121009. private static FileFaces;
  121010. /**
  121011. * Converts a texture to the according Spherical Polynomial data.
  121012. * This extracts the first 3 orders only as they are the only one used in the lighting.
  121013. *
  121014. * @param texture The texture to extract the information from.
  121015. * @return The Spherical Polynomial data.
  121016. */
  121017. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  121018. /**
  121019. * Converts a cubemap to the according Spherical Polynomial data.
  121020. * This extracts the first 3 orders only as they are the only one used in the lighting.
  121021. *
  121022. * @param cubeInfo The Cube map to extract the information from.
  121023. * @return The Spherical Polynomial data.
  121024. */
  121025. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  121026. }
  121027. }
  121028. declare module BABYLON {
  121029. interface BaseTexture {
  121030. /**
  121031. * Get the polynomial representation of the texture data.
  121032. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  121033. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  121034. */
  121035. sphericalPolynomial: Nullable<SphericalPolynomial>;
  121036. }
  121037. }
  121038. declare module BABYLON {
  121039. /** @hidden */
  121040. export var rgbdEncodePixelShader: {
  121041. name: string;
  121042. shader: string;
  121043. };
  121044. }
  121045. declare module BABYLON {
  121046. /** @hidden */
  121047. export var rgbdDecodePixelShader: {
  121048. name: string;
  121049. shader: string;
  121050. };
  121051. }
  121052. declare module BABYLON {
  121053. /**
  121054. * Raw texture data and descriptor sufficient for WebGL texture upload
  121055. */
  121056. export interface EnvironmentTextureInfo {
  121057. /**
  121058. * Version of the environment map
  121059. */
  121060. version: number;
  121061. /**
  121062. * Width of image
  121063. */
  121064. width: number;
  121065. /**
  121066. * Irradiance information stored in the file.
  121067. */
  121068. irradiance: any;
  121069. /**
  121070. * Specular information stored in the file.
  121071. */
  121072. specular: any;
  121073. }
  121074. /**
  121075. * Defines One Image in the file. It requires only the position in the file
  121076. * as well as the length.
  121077. */
  121078. interface BufferImageData {
  121079. /**
  121080. * Length of the image data.
  121081. */
  121082. length: number;
  121083. /**
  121084. * Position of the data from the null terminator delimiting the end of the JSON.
  121085. */
  121086. position: number;
  121087. }
  121088. /**
  121089. * Defines the specular data enclosed in the file.
  121090. * This corresponds to the version 1 of the data.
  121091. */
  121092. export interface EnvironmentTextureSpecularInfoV1 {
  121093. /**
  121094. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  121095. */
  121096. specularDataPosition?: number;
  121097. /**
  121098. * This contains all the images data needed to reconstruct the cubemap.
  121099. */
  121100. mipmaps: Array<BufferImageData>;
  121101. /**
  121102. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  121103. */
  121104. lodGenerationScale: number;
  121105. }
  121106. /**
  121107. * Sets of helpers addressing the serialization and deserialization of environment texture
  121108. * stored in a BabylonJS env file.
  121109. * Those files are usually stored as .env files.
  121110. */
  121111. export class EnvironmentTextureTools {
  121112. /**
  121113. * Magic number identifying the env file.
  121114. */
  121115. private static _MagicBytes;
  121116. /**
  121117. * Gets the environment info from an env file.
  121118. * @param data The array buffer containing the .env bytes.
  121119. * @returns the environment file info (the json header) if successfully parsed.
  121120. */
  121121. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  121122. /**
  121123. * Creates an environment texture from a loaded cube texture.
  121124. * @param texture defines the cube texture to convert in env file
  121125. * @return a promise containing the environment data if succesfull.
  121126. */
  121127. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  121128. /**
  121129. * Creates a JSON representation of the spherical data.
  121130. * @param texture defines the texture containing the polynomials
  121131. * @return the JSON representation of the spherical info
  121132. */
  121133. private static _CreateEnvTextureIrradiance;
  121134. /**
  121135. * Creates the ArrayBufferViews used for initializing environment texture image data.
  121136. * @param data the image data
  121137. * @param info parameters that determine what views will be created for accessing the underlying buffer
  121138. * @return the views described by info providing access to the underlying buffer
  121139. */
  121140. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  121141. /**
  121142. * Uploads the texture info contained in the env file to the GPU.
  121143. * @param texture defines the internal texture to upload to
  121144. * @param data defines the data to load
  121145. * @param info defines the texture info retrieved through the GetEnvInfo method
  121146. * @returns a promise
  121147. */
  121148. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  121149. private static _OnImageReadyAsync;
  121150. /**
  121151. * Uploads the levels of image data to the GPU.
  121152. * @param texture defines the internal texture to upload to
  121153. * @param imageData defines the array buffer views of image data [mipmap][face]
  121154. * @returns a promise
  121155. */
  121156. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  121157. /**
  121158. * Uploads spherical polynomials information to the texture.
  121159. * @param texture defines the texture we are trying to upload the information to
  121160. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  121161. */
  121162. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  121163. /** @hidden */
  121164. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  121165. }
  121166. }
  121167. declare module BABYLON {
  121168. /**
  121169. * Contains position and normal vectors for a vertex
  121170. */
  121171. export class PositionNormalVertex {
  121172. /** the position of the vertex (defaut: 0,0,0) */
  121173. position: Vector3;
  121174. /** the normal of the vertex (defaut: 0,1,0) */
  121175. normal: Vector3;
  121176. /**
  121177. * Creates a PositionNormalVertex
  121178. * @param position the position of the vertex (defaut: 0,0,0)
  121179. * @param normal the normal of the vertex (defaut: 0,1,0)
  121180. */
  121181. constructor(
  121182. /** the position of the vertex (defaut: 0,0,0) */
  121183. position?: Vector3,
  121184. /** the normal of the vertex (defaut: 0,1,0) */
  121185. normal?: Vector3);
  121186. /**
  121187. * Clones the PositionNormalVertex
  121188. * @returns the cloned PositionNormalVertex
  121189. */
  121190. clone(): PositionNormalVertex;
  121191. }
  121192. /**
  121193. * Contains position, normal and uv vectors for a vertex
  121194. */
  121195. export class PositionNormalTextureVertex {
  121196. /** the position of the vertex (defaut: 0,0,0) */
  121197. position: Vector3;
  121198. /** the normal of the vertex (defaut: 0,1,0) */
  121199. normal: Vector3;
  121200. /** the uv of the vertex (default: 0,0) */
  121201. uv: Vector2;
  121202. /**
  121203. * Creates a PositionNormalTextureVertex
  121204. * @param position the position of the vertex (defaut: 0,0,0)
  121205. * @param normal the normal of the vertex (defaut: 0,1,0)
  121206. * @param uv the uv of the vertex (default: 0,0)
  121207. */
  121208. constructor(
  121209. /** the position of the vertex (defaut: 0,0,0) */
  121210. position?: Vector3,
  121211. /** the normal of the vertex (defaut: 0,1,0) */
  121212. normal?: Vector3,
  121213. /** the uv of the vertex (default: 0,0) */
  121214. uv?: Vector2);
  121215. /**
  121216. * Clones the PositionNormalTextureVertex
  121217. * @returns the cloned PositionNormalTextureVertex
  121218. */
  121219. clone(): PositionNormalTextureVertex;
  121220. }
  121221. }
  121222. declare module BABYLON {
  121223. /** @hidden */
  121224. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  121225. private _genericAttributeLocation;
  121226. private _varyingLocationCount;
  121227. private _varyingLocationMap;
  121228. private _replacements;
  121229. private _textureCount;
  121230. private _uniforms;
  121231. lineProcessor(line: string): string;
  121232. attributeProcessor(attribute: string): string;
  121233. varyingProcessor(varying: string, isFragment: boolean): string;
  121234. uniformProcessor(uniform: string): string;
  121235. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  121236. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  121237. }
  121238. }
  121239. declare module BABYLON {
  121240. /**
  121241. * Container for accessors for natively-stored mesh data buffers.
  121242. */
  121243. class NativeDataBuffer extends DataBuffer {
  121244. /**
  121245. * Accessor value used to identify/retrieve a natively-stored index buffer.
  121246. */
  121247. nativeIndexBuffer?: any;
  121248. /**
  121249. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  121250. */
  121251. nativeVertexBuffer?: any;
  121252. }
  121253. /** @hidden */
  121254. class NativeTexture extends InternalTexture {
  121255. getInternalTexture(): InternalTexture;
  121256. getViewCount(): number;
  121257. }
  121258. /** @hidden */
  121259. export class NativeEngine extends Engine {
  121260. private readonly _native;
  121261. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  121262. private readonly INVALID_HANDLE;
  121263. getHardwareScalingLevel(): number;
  121264. constructor();
  121265. /**
  121266. * Can be used to override the current requestAnimationFrame requester.
  121267. * @hidden
  121268. */
  121269. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  121270. /**
  121271. * Override default engine behavior.
  121272. * @param color
  121273. * @param backBuffer
  121274. * @param depth
  121275. * @param stencil
  121276. */
  121277. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  121278. /**
  121279. * Gets host document
  121280. * @returns the host document object
  121281. */
  121282. getHostDocument(): Nullable<Document>;
  121283. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  121284. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  121285. createVertexBuffer(data: DataArray): NativeDataBuffer;
  121286. recordVertexArrayObject(vertexBuffers: {
  121287. [key: string]: VertexBuffer;
  121288. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  121289. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  121290. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  121291. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  121292. /**
  121293. * Draw a list of indexed primitives
  121294. * @param fillMode defines the primitive to use
  121295. * @param indexStart defines the starting index
  121296. * @param indexCount defines the number of index to draw
  121297. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121298. */
  121299. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  121300. /**
  121301. * Draw a list of unindexed primitives
  121302. * @param fillMode defines the primitive to use
  121303. * @param verticesStart defines the index of first vertex to draw
  121304. * @param verticesCount defines the count of vertices to draw
  121305. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121306. */
  121307. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  121308. createPipelineContext(): IPipelineContext;
  121309. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  121310. /** @hidden */
  121311. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  121312. /** @hidden */
  121313. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  121314. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  121315. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  121316. protected _setProgram(program: WebGLProgram): void;
  121317. _releaseEffect(effect: Effect): void;
  121318. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  121319. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  121320. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  121321. bindSamplers(effect: Effect): void;
  121322. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  121323. getRenderWidth(useScreen?: boolean): number;
  121324. getRenderHeight(useScreen?: boolean): number;
  121325. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  121326. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  121327. /**
  121328. * Set the z offset to apply to current rendering
  121329. * @param value defines the offset to apply
  121330. */
  121331. setZOffset(value: number): void;
  121332. /**
  121333. * Gets the current value of the zOffset
  121334. * @returns the current zOffset state
  121335. */
  121336. getZOffset(): number;
  121337. /**
  121338. * Enable or disable depth buffering
  121339. * @param enable defines the state to set
  121340. */
  121341. setDepthBuffer(enable: boolean): void;
  121342. /**
  121343. * Gets a boolean indicating if depth writing is enabled
  121344. * @returns the current depth writing state
  121345. */
  121346. getDepthWrite(): boolean;
  121347. /**
  121348. * Enable or disable depth writing
  121349. * @param enable defines the state to set
  121350. */
  121351. setDepthWrite(enable: boolean): void;
  121352. /**
  121353. * Enable or disable color writing
  121354. * @param enable defines the state to set
  121355. */
  121356. setColorWrite(enable: boolean): void;
  121357. /**
  121358. * Gets a boolean indicating if color writing is enabled
  121359. * @returns the current color writing state
  121360. */
  121361. getColorWrite(): boolean;
  121362. /**
  121363. * Sets alpha constants used by some alpha blending modes
  121364. * @param r defines the red component
  121365. * @param g defines the green component
  121366. * @param b defines the blue component
  121367. * @param a defines the alpha component
  121368. */
  121369. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  121370. /**
  121371. * Sets the current alpha mode
  121372. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  121373. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  121374. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  121375. */
  121376. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  121377. /**
  121378. * Gets the current alpha mode
  121379. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  121380. * @returns the current alpha mode
  121381. */
  121382. getAlphaMode(): number;
  121383. setInt(uniform: WebGLUniformLocation, int: number): void;
  121384. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  121385. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  121386. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  121387. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  121388. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  121389. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  121390. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  121391. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  121392. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  121393. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  121394. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  121395. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  121396. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  121397. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  121398. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  121399. setFloat(uniform: WebGLUniformLocation, value: number): void;
  121400. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  121401. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  121402. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  121403. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  121404. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  121405. wipeCaches(bruteForce?: boolean): void;
  121406. _createTexture(): WebGLTexture;
  121407. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  121408. /**
  121409. * Usually called from Texture.ts.
  121410. * Passed information to create a WebGLTexture
  121411. * @param urlArg defines a value which contains one of the following:
  121412. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  121413. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  121414. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  121415. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  121416. * @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)
  121417. * @param scene needed for loading to the correct scene
  121418. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  121419. * @param onLoad optional callback to be called upon successful completion
  121420. * @param onError optional callback to be called upon failure
  121421. * @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
  121422. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  121423. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  121424. * @param forcedExtension defines the extension to use to pick the right loader
  121425. * @param mimeType defines an optional mime type
  121426. * @returns a InternalTexture for assignment back into BABYLON.Texture
  121427. */
  121428. 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;
  121429. /**
  121430. * Creates a cube texture
  121431. * @param rootUrl defines the url where the files to load is located
  121432. * @param scene defines the current scene
  121433. * @param files defines the list of files to load (1 per face)
  121434. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  121435. * @param onLoad defines an optional callback raised when the texture is loaded
  121436. * @param onError defines an optional callback raised if there is an issue to load the texture
  121437. * @param format defines the format of the data
  121438. * @param forcedExtension defines the extension to use to pick the right loader
  121439. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  121440. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  121441. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  121442. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  121443. * @returns the cube texture as an InternalTexture
  121444. */
  121445. 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;
  121446. private _getSamplingFilter;
  121447. private static _GetNativeTextureFormat;
  121448. createRenderTargetTexture(size: number | {
  121449. width: number;
  121450. height: number;
  121451. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  121452. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  121453. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  121454. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  121455. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  121456. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  121457. /**
  121458. * Updates a dynamic vertex buffer.
  121459. * @param vertexBuffer the vertex buffer to update
  121460. * @param data the data used to update the vertex buffer
  121461. * @param byteOffset the byte offset of the data (optional)
  121462. * @param byteLength the byte length of the data (optional)
  121463. */
  121464. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  121465. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  121466. private _updateAnisotropicLevel;
  121467. private _getAddressMode;
  121468. /** @hidden */
  121469. _bindTexture(channel: number, texture: InternalTexture): void;
  121470. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  121471. releaseEffects(): void;
  121472. /** @hidden */
  121473. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121474. /** @hidden */
  121475. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121476. /** @hidden */
  121477. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121478. /** @hidden */
  121479. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  121480. }
  121481. }
  121482. declare module BABYLON {
  121483. /**
  121484. * Gather the list of clipboard event types as constants.
  121485. */
  121486. export class ClipboardEventTypes {
  121487. /**
  121488. * The clipboard event is fired when a copy command is active (pressed).
  121489. */
  121490. static readonly COPY: number;
  121491. /**
  121492. * The clipboard event is fired when a cut command is active (pressed).
  121493. */
  121494. static readonly CUT: number;
  121495. /**
  121496. * The clipboard event is fired when a paste command is active (pressed).
  121497. */
  121498. static readonly PASTE: number;
  121499. }
  121500. /**
  121501. * This class is used to store clipboard related info for the onClipboardObservable event.
  121502. */
  121503. export class ClipboardInfo {
  121504. /**
  121505. * Defines the type of event (BABYLON.ClipboardEventTypes)
  121506. */
  121507. type: number;
  121508. /**
  121509. * Defines the related dom event
  121510. */
  121511. event: ClipboardEvent;
  121512. /**
  121513. *Creates an instance of ClipboardInfo.
  121514. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  121515. * @param event Defines the related dom event
  121516. */
  121517. constructor(
  121518. /**
  121519. * Defines the type of event (BABYLON.ClipboardEventTypes)
  121520. */
  121521. type: number,
  121522. /**
  121523. * Defines the related dom event
  121524. */
  121525. event: ClipboardEvent);
  121526. /**
  121527. * Get the clipboard event's type from the keycode.
  121528. * @param keyCode Defines the keyCode for the current keyboard event.
  121529. * @return {number}
  121530. */
  121531. static GetTypeFromCharacter(keyCode: number): number;
  121532. }
  121533. }
  121534. declare module BABYLON {
  121535. /**
  121536. * Google Daydream controller
  121537. */
  121538. export class DaydreamController extends WebVRController {
  121539. /**
  121540. * Base Url for the controller model.
  121541. */
  121542. static MODEL_BASE_URL: string;
  121543. /**
  121544. * File name for the controller model.
  121545. */
  121546. static MODEL_FILENAME: string;
  121547. /**
  121548. * Gamepad Id prefix used to identify Daydream Controller.
  121549. */
  121550. static readonly GAMEPAD_ID_PREFIX: string;
  121551. /**
  121552. * Creates a new DaydreamController from a gamepad
  121553. * @param vrGamepad the gamepad that the controller should be created from
  121554. */
  121555. constructor(vrGamepad: any);
  121556. /**
  121557. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121558. * @param scene scene in which to add meshes
  121559. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121560. */
  121561. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121562. /**
  121563. * Called once for each button that changed state since the last frame
  121564. * @param buttonIdx Which button index changed
  121565. * @param state New state of the button
  121566. * @param changes Which properties on the state changed since last frame
  121567. */
  121568. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121569. }
  121570. }
  121571. declare module BABYLON {
  121572. /**
  121573. * Gear VR Controller
  121574. */
  121575. export class GearVRController extends WebVRController {
  121576. /**
  121577. * Base Url for the controller model.
  121578. */
  121579. static MODEL_BASE_URL: string;
  121580. /**
  121581. * File name for the controller model.
  121582. */
  121583. static MODEL_FILENAME: string;
  121584. /**
  121585. * Gamepad Id prefix used to identify this controller.
  121586. */
  121587. static readonly GAMEPAD_ID_PREFIX: string;
  121588. private readonly _buttonIndexToObservableNameMap;
  121589. /**
  121590. * Creates a new GearVRController from a gamepad
  121591. * @param vrGamepad the gamepad that the controller should be created from
  121592. */
  121593. constructor(vrGamepad: any);
  121594. /**
  121595. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121596. * @param scene scene in which to add meshes
  121597. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121598. */
  121599. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121600. /**
  121601. * Called once for each button that changed state since the last frame
  121602. * @param buttonIdx Which button index changed
  121603. * @param state New state of the button
  121604. * @param changes Which properties on the state changed since last frame
  121605. */
  121606. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121607. }
  121608. }
  121609. declare module BABYLON {
  121610. /**
  121611. * Generic Controller
  121612. */
  121613. export class GenericController extends WebVRController {
  121614. /**
  121615. * Base Url for the controller model.
  121616. */
  121617. static readonly MODEL_BASE_URL: string;
  121618. /**
  121619. * File name for the controller model.
  121620. */
  121621. static readonly MODEL_FILENAME: string;
  121622. /**
  121623. * Creates a new GenericController from a gamepad
  121624. * @param vrGamepad the gamepad that the controller should be created from
  121625. */
  121626. constructor(vrGamepad: any);
  121627. /**
  121628. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121629. * @param scene scene in which to add meshes
  121630. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121631. */
  121632. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121633. /**
  121634. * Called once for each button that changed state since the last frame
  121635. * @param buttonIdx Which button index changed
  121636. * @param state New state of the button
  121637. * @param changes Which properties on the state changed since last frame
  121638. */
  121639. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121640. }
  121641. }
  121642. declare module BABYLON {
  121643. /**
  121644. * Oculus Touch Controller
  121645. */
  121646. export class OculusTouchController extends WebVRController {
  121647. /**
  121648. * Base Url for the controller model.
  121649. */
  121650. static MODEL_BASE_URL: string;
  121651. /**
  121652. * File name for the left controller model.
  121653. */
  121654. static MODEL_LEFT_FILENAME: string;
  121655. /**
  121656. * File name for the right controller model.
  121657. */
  121658. static MODEL_RIGHT_FILENAME: string;
  121659. /**
  121660. * Base Url for the Quest controller model.
  121661. */
  121662. static QUEST_MODEL_BASE_URL: string;
  121663. /**
  121664. * @hidden
  121665. * If the controllers are running on a device that needs the updated Quest controller models
  121666. */
  121667. static _IsQuest: boolean;
  121668. /**
  121669. * Fired when the secondary trigger on this controller is modified
  121670. */
  121671. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  121672. /**
  121673. * Fired when the thumb rest on this controller is modified
  121674. */
  121675. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  121676. /**
  121677. * Creates a new OculusTouchController from a gamepad
  121678. * @param vrGamepad the gamepad that the controller should be created from
  121679. */
  121680. constructor(vrGamepad: any);
  121681. /**
  121682. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121683. * @param scene scene in which to add meshes
  121684. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121685. */
  121686. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121687. /**
  121688. * Fired when the A button on this controller is modified
  121689. */
  121690. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121691. /**
  121692. * Fired when the B button on this controller is modified
  121693. */
  121694. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121695. /**
  121696. * Fired when the X button on this controller is modified
  121697. */
  121698. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121699. /**
  121700. * Fired when the Y button on this controller is modified
  121701. */
  121702. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121703. /**
  121704. * Called once for each button that changed state since the last frame
  121705. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  121706. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  121707. * 2) secondary trigger (same)
  121708. * 3) A (right) X (left), touch, pressed = value
  121709. * 4) B / Y
  121710. * 5) thumb rest
  121711. * @param buttonIdx Which button index changed
  121712. * @param state New state of the button
  121713. * @param changes Which properties on the state changed since last frame
  121714. */
  121715. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121716. }
  121717. }
  121718. declare module BABYLON {
  121719. /**
  121720. * Vive Controller
  121721. */
  121722. export class ViveController extends WebVRController {
  121723. /**
  121724. * Base Url for the controller model.
  121725. */
  121726. static MODEL_BASE_URL: string;
  121727. /**
  121728. * File name for the controller model.
  121729. */
  121730. static MODEL_FILENAME: string;
  121731. /**
  121732. * Creates a new ViveController from a gamepad
  121733. * @param vrGamepad the gamepad that the controller should be created from
  121734. */
  121735. constructor(vrGamepad: any);
  121736. /**
  121737. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121738. * @param scene scene in which to add meshes
  121739. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121740. */
  121741. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121742. /**
  121743. * Fired when the left button on this controller is modified
  121744. */
  121745. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121746. /**
  121747. * Fired when the right button on this controller is modified
  121748. */
  121749. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121750. /**
  121751. * Fired when the menu button on this controller is modified
  121752. */
  121753. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121754. /**
  121755. * Called once for each button that changed state since the last frame
  121756. * Vive mapping:
  121757. * 0: touchpad
  121758. * 1: trigger
  121759. * 2: left AND right buttons
  121760. * 3: menu button
  121761. * @param buttonIdx Which button index changed
  121762. * @param state New state of the button
  121763. * @param changes Which properties on the state changed since last frame
  121764. */
  121765. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121766. }
  121767. }
  121768. declare module BABYLON {
  121769. /**
  121770. * Defines the WindowsMotionController object that the state of the windows motion controller
  121771. */
  121772. export class WindowsMotionController extends WebVRController {
  121773. /**
  121774. * The base url used to load the left and right controller models
  121775. */
  121776. static MODEL_BASE_URL: string;
  121777. /**
  121778. * The name of the left controller model file
  121779. */
  121780. static MODEL_LEFT_FILENAME: string;
  121781. /**
  121782. * The name of the right controller model file
  121783. */
  121784. static MODEL_RIGHT_FILENAME: string;
  121785. /**
  121786. * The controller name prefix for this controller type
  121787. */
  121788. static readonly GAMEPAD_ID_PREFIX: string;
  121789. /**
  121790. * The controller id pattern for this controller type
  121791. */
  121792. private static readonly GAMEPAD_ID_PATTERN;
  121793. private _loadedMeshInfo;
  121794. protected readonly _mapping: {
  121795. buttons: string[];
  121796. buttonMeshNames: {
  121797. 'trigger': string;
  121798. 'menu': string;
  121799. 'grip': string;
  121800. 'thumbstick': string;
  121801. 'trackpad': string;
  121802. };
  121803. buttonObservableNames: {
  121804. 'trigger': string;
  121805. 'menu': string;
  121806. 'grip': string;
  121807. 'thumbstick': string;
  121808. 'trackpad': string;
  121809. };
  121810. axisMeshNames: string[];
  121811. pointingPoseMeshName: string;
  121812. };
  121813. /**
  121814. * Fired when the trackpad on this controller is clicked
  121815. */
  121816. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  121817. /**
  121818. * Fired when the trackpad on this controller is modified
  121819. */
  121820. onTrackpadValuesChangedObservable: Observable<StickValues>;
  121821. /**
  121822. * The current x and y values of this controller's trackpad
  121823. */
  121824. trackpad: StickValues;
  121825. /**
  121826. * Creates a new WindowsMotionController from a gamepad
  121827. * @param vrGamepad the gamepad that the controller should be created from
  121828. */
  121829. constructor(vrGamepad: any);
  121830. /**
  121831. * Fired when the trigger on this controller is modified
  121832. */
  121833. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121834. /**
  121835. * Fired when the menu button on this controller is modified
  121836. */
  121837. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121838. /**
  121839. * Fired when the grip button on this controller is modified
  121840. */
  121841. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121842. /**
  121843. * Fired when the thumbstick button on this controller is modified
  121844. */
  121845. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121846. /**
  121847. * Fired when the touchpad button on this controller is modified
  121848. */
  121849. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121850. /**
  121851. * Fired when the touchpad values on this controller are modified
  121852. */
  121853. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  121854. protected _updateTrackpad(): void;
  121855. /**
  121856. * Called once per frame by the engine.
  121857. */
  121858. update(): void;
  121859. /**
  121860. * Called once for each button that changed state since the last frame
  121861. * @param buttonIdx Which button index changed
  121862. * @param state New state of the button
  121863. * @param changes Which properties on the state changed since last frame
  121864. */
  121865. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121866. /**
  121867. * Moves the buttons on the controller mesh based on their current state
  121868. * @param buttonName the name of the button to move
  121869. * @param buttonValue the value of the button which determines the buttons new position
  121870. */
  121871. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  121872. /**
  121873. * Moves the axis on the controller mesh based on its current state
  121874. * @param axis the index of the axis
  121875. * @param axisValue the value of the axis which determines the meshes new position
  121876. * @hidden
  121877. */
  121878. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  121879. /**
  121880. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121881. * @param scene scene in which to add meshes
  121882. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121883. */
  121884. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  121885. /**
  121886. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  121887. * can be transformed by button presses and axes values, based on this._mapping.
  121888. *
  121889. * @param scene scene in which the meshes exist
  121890. * @param meshes list of meshes that make up the controller model to process
  121891. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  121892. */
  121893. private processModel;
  121894. private createMeshInfo;
  121895. /**
  121896. * Gets the ray of the controller in the direction the controller is pointing
  121897. * @param length the length the resulting ray should be
  121898. * @returns a ray in the direction the controller is pointing
  121899. */
  121900. getForwardRay(length?: number): Ray;
  121901. /**
  121902. * Disposes of the controller
  121903. */
  121904. dispose(): void;
  121905. }
  121906. /**
  121907. * This class represents a new windows motion controller in XR.
  121908. */
  121909. export class XRWindowsMotionController extends WindowsMotionController {
  121910. /**
  121911. * Changing the original WIndowsMotionController mapping to fir the new mapping
  121912. */
  121913. protected readonly _mapping: {
  121914. buttons: string[];
  121915. buttonMeshNames: {
  121916. 'trigger': string;
  121917. 'menu': string;
  121918. 'grip': string;
  121919. 'thumbstick': string;
  121920. 'trackpad': string;
  121921. };
  121922. buttonObservableNames: {
  121923. 'trigger': string;
  121924. 'menu': string;
  121925. 'grip': string;
  121926. 'thumbstick': string;
  121927. 'trackpad': string;
  121928. };
  121929. axisMeshNames: string[];
  121930. pointingPoseMeshName: string;
  121931. };
  121932. /**
  121933. * Construct a new XR-Based windows motion controller
  121934. *
  121935. * @param gamepadInfo the gamepad object from the browser
  121936. */
  121937. constructor(gamepadInfo: any);
  121938. /**
  121939. * holds the thumbstick values (X,Y)
  121940. */
  121941. thumbstickValues: StickValues;
  121942. /**
  121943. * Fired when the thumbstick on this controller is clicked
  121944. */
  121945. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  121946. /**
  121947. * Fired when the thumbstick on this controller is modified
  121948. */
  121949. onThumbstickValuesChangedObservable: Observable<StickValues>;
  121950. /**
  121951. * Fired when the touchpad button on this controller is modified
  121952. */
  121953. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  121954. /**
  121955. * Fired when the touchpad values on this controller are modified
  121956. */
  121957. onTrackpadValuesChangedObservable: Observable<StickValues>;
  121958. /**
  121959. * Fired when the thumbstick button on this controller is modified
  121960. * here to prevent breaking changes
  121961. */
  121962. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121963. /**
  121964. * updating the thumbstick(!) and not the trackpad.
  121965. * This is named this way due to the difference between WebVR and XR and to avoid
  121966. * changing the parent class.
  121967. */
  121968. protected _updateTrackpad(): void;
  121969. /**
  121970. * Disposes the class with joy
  121971. */
  121972. dispose(): void;
  121973. }
  121974. }
  121975. declare module BABYLON {
  121976. /**
  121977. * Class containing static functions to help procedurally build meshes
  121978. */
  121979. export class PolyhedronBuilder {
  121980. /**
  121981. * Creates a polyhedron mesh
  121982. * * 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
  121983. * * The parameter `size` (positive float, default 1) sets the polygon size
  121984. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  121985. * * 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`
  121986. * * 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
  121987. * * 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)`)
  121988. * * 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
  121989. * * 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
  121990. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121991. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121992. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121993. * @param name defines the name of the mesh
  121994. * @param options defines the options used to create the mesh
  121995. * @param scene defines the hosting scene
  121996. * @returns the polyhedron mesh
  121997. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  121998. */
  121999. static CreatePolyhedron(name: string, options: {
  122000. type?: number;
  122001. size?: number;
  122002. sizeX?: number;
  122003. sizeY?: number;
  122004. sizeZ?: number;
  122005. custom?: any;
  122006. faceUV?: Vector4[];
  122007. faceColors?: Color4[];
  122008. flat?: boolean;
  122009. updatable?: boolean;
  122010. sideOrientation?: number;
  122011. frontUVs?: Vector4;
  122012. backUVs?: Vector4;
  122013. }, scene?: Nullable<Scene>): Mesh;
  122014. }
  122015. }
  122016. declare module BABYLON {
  122017. /**
  122018. * Gizmo that enables scaling a mesh along 3 axis
  122019. */
  122020. export class ScaleGizmo extends Gizmo {
  122021. /**
  122022. * Internal gizmo used for interactions on the x axis
  122023. */
  122024. xGizmo: AxisScaleGizmo;
  122025. /**
  122026. * Internal gizmo used for interactions on the y axis
  122027. */
  122028. yGizmo: AxisScaleGizmo;
  122029. /**
  122030. * Internal gizmo used for interactions on the z axis
  122031. */
  122032. zGizmo: AxisScaleGizmo;
  122033. /**
  122034. * Internal gizmo used to scale all axis equally
  122035. */
  122036. uniformScaleGizmo: AxisScaleGizmo;
  122037. private _meshAttached;
  122038. private _updateGizmoRotationToMatchAttachedMesh;
  122039. private _snapDistance;
  122040. private _scaleRatio;
  122041. private _uniformScalingMesh;
  122042. private _octahedron;
  122043. private _sensitivity;
  122044. /** Fires an event when any of it's sub gizmos are dragged */
  122045. onDragStartObservable: Observable<unknown>;
  122046. /** Fires an event when any of it's sub gizmos are released from dragging */
  122047. onDragEndObservable: Observable<unknown>;
  122048. get attachedMesh(): Nullable<AbstractMesh>;
  122049. set attachedMesh(mesh: Nullable<AbstractMesh>);
  122050. /**
  122051. * Creates a ScaleGizmo
  122052. * @param gizmoLayer The utility layer the gizmo will be added to
  122053. */
  122054. constructor(gizmoLayer?: UtilityLayerRenderer);
  122055. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  122056. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  122057. /**
  122058. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  122059. */
  122060. set snapDistance(value: number);
  122061. get snapDistance(): number;
  122062. /**
  122063. * Ratio for the scale of the gizmo (Default: 1)
  122064. */
  122065. set scaleRatio(value: number);
  122066. get scaleRatio(): number;
  122067. /**
  122068. * Sensitivity factor for dragging (Default: 1)
  122069. */
  122070. set sensitivity(value: number);
  122071. get sensitivity(): number;
  122072. /**
  122073. * Disposes of the gizmo
  122074. */
  122075. dispose(): void;
  122076. }
  122077. }
  122078. declare module BABYLON {
  122079. /**
  122080. * Single axis scale gizmo
  122081. */
  122082. export class AxisScaleGizmo extends Gizmo {
  122083. /**
  122084. * Drag behavior responsible for the gizmos dragging interactions
  122085. */
  122086. dragBehavior: PointerDragBehavior;
  122087. private _pointerObserver;
  122088. /**
  122089. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  122090. */
  122091. snapDistance: number;
  122092. /**
  122093. * Event that fires each time the gizmo snaps to a new location.
  122094. * * snapDistance is the the change in distance
  122095. */
  122096. onSnapObservable: Observable<{
  122097. snapDistance: number;
  122098. }>;
  122099. /**
  122100. * If the scaling operation should be done on all axis (default: false)
  122101. */
  122102. uniformScaling: boolean;
  122103. /**
  122104. * Custom sensitivity value for the drag strength
  122105. */
  122106. sensitivity: number;
  122107. private _isEnabled;
  122108. private _parent;
  122109. private _arrow;
  122110. private _coloredMaterial;
  122111. private _hoverMaterial;
  122112. /**
  122113. * Creates an AxisScaleGizmo
  122114. * @param gizmoLayer The utility layer the gizmo will be added to
  122115. * @param dragAxis The axis which the gizmo will be able to scale on
  122116. * @param color The color of the gizmo
  122117. */
  122118. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  122119. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  122120. /**
  122121. * If the gizmo is enabled
  122122. */
  122123. set isEnabled(value: boolean);
  122124. get isEnabled(): boolean;
  122125. /**
  122126. * Disposes of the gizmo
  122127. */
  122128. dispose(): void;
  122129. /**
  122130. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  122131. * @param mesh The mesh to replace the default mesh of the gizmo
  122132. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  122133. */
  122134. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  122135. }
  122136. }
  122137. declare module BABYLON {
  122138. /**
  122139. * Bounding box gizmo
  122140. */
  122141. export class BoundingBoxGizmo extends Gizmo {
  122142. private _lineBoundingBox;
  122143. private _rotateSpheresParent;
  122144. private _scaleBoxesParent;
  122145. private _boundingDimensions;
  122146. private _renderObserver;
  122147. private _pointerObserver;
  122148. private _scaleDragSpeed;
  122149. private _tmpQuaternion;
  122150. private _tmpVector;
  122151. private _tmpRotationMatrix;
  122152. /**
  122153. * 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)
  122154. */
  122155. ignoreChildren: boolean;
  122156. /**
  122157. * 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)
  122158. */
  122159. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  122160. /**
  122161. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  122162. */
  122163. rotationSphereSize: number;
  122164. /**
  122165. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  122166. */
  122167. scaleBoxSize: number;
  122168. /**
  122169. * 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)
  122170. */
  122171. fixedDragMeshScreenSize: boolean;
  122172. /**
  122173. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  122174. */
  122175. fixedDragMeshScreenSizeDistanceFactor: number;
  122176. /**
  122177. * Fired when a rotation sphere or scale box is dragged
  122178. */
  122179. onDragStartObservable: Observable<{}>;
  122180. /**
  122181. * Fired when a scale box is dragged
  122182. */
  122183. onScaleBoxDragObservable: Observable<{}>;
  122184. /**
  122185. * Fired when a scale box drag is ended
  122186. */
  122187. onScaleBoxDragEndObservable: Observable<{}>;
  122188. /**
  122189. * Fired when a rotation sphere is dragged
  122190. */
  122191. onRotationSphereDragObservable: Observable<{}>;
  122192. /**
  122193. * Fired when a rotation sphere drag is ended
  122194. */
  122195. onRotationSphereDragEndObservable: Observable<{}>;
  122196. /**
  122197. * 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)
  122198. */
  122199. scalePivot: Nullable<Vector3>;
  122200. /**
  122201. * Mesh used as a pivot to rotate the attached mesh
  122202. */
  122203. private _anchorMesh;
  122204. private _existingMeshScale;
  122205. private _dragMesh;
  122206. private pointerDragBehavior;
  122207. private coloredMaterial;
  122208. private hoverColoredMaterial;
  122209. /**
  122210. * Sets the color of the bounding box gizmo
  122211. * @param color the color to set
  122212. */
  122213. setColor(color: Color3): void;
  122214. /**
  122215. * Creates an BoundingBoxGizmo
  122216. * @param gizmoLayer The utility layer the gizmo will be added to
  122217. * @param color The color of the gizmo
  122218. */
  122219. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  122220. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  122221. private _selectNode;
  122222. /**
  122223. * Updates the bounding box information for the Gizmo
  122224. */
  122225. updateBoundingBox(): void;
  122226. private _updateRotationSpheres;
  122227. private _updateScaleBoxes;
  122228. /**
  122229. * Enables rotation on the specified axis and disables rotation on the others
  122230. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  122231. */
  122232. setEnabledRotationAxis(axis: string): void;
  122233. /**
  122234. * Enables/disables scaling
  122235. * @param enable if scaling should be enabled
  122236. */
  122237. setEnabledScaling(enable: boolean): void;
  122238. private _updateDummy;
  122239. /**
  122240. * Enables a pointer drag behavior on the bounding box of the gizmo
  122241. */
  122242. enableDragBehavior(): void;
  122243. /**
  122244. * Disposes of the gizmo
  122245. */
  122246. dispose(): void;
  122247. /**
  122248. * 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)
  122249. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  122250. * @returns the bounding box mesh with the passed in mesh as a child
  122251. */
  122252. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  122253. /**
  122254. * CustomMeshes are not supported by this gizmo
  122255. * @param mesh The mesh to replace the default mesh of the gizmo
  122256. */
  122257. setCustomMesh(mesh: Mesh): void;
  122258. }
  122259. }
  122260. declare module BABYLON {
  122261. /**
  122262. * Single plane rotation gizmo
  122263. */
  122264. export class PlaneRotationGizmo extends Gizmo {
  122265. /**
  122266. * Drag behavior responsible for the gizmos dragging interactions
  122267. */
  122268. dragBehavior: PointerDragBehavior;
  122269. private _pointerObserver;
  122270. /**
  122271. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  122272. */
  122273. snapDistance: number;
  122274. /**
  122275. * Event that fires each time the gizmo snaps to a new location.
  122276. * * snapDistance is the the change in distance
  122277. */
  122278. onSnapObservable: Observable<{
  122279. snapDistance: number;
  122280. }>;
  122281. private _isEnabled;
  122282. private _parent;
  122283. /**
  122284. * Creates a PlaneRotationGizmo
  122285. * @param gizmoLayer The utility layer the gizmo will be added to
  122286. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  122287. * @param color The color of the gizmo
  122288. * @param tessellation Amount of tessellation to be used when creating rotation circles
  122289. * @param useEulerRotation Use and update Euler angle instead of quaternion
  122290. */
  122291. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  122292. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  122293. /**
  122294. * If the gizmo is enabled
  122295. */
  122296. set isEnabled(value: boolean);
  122297. get isEnabled(): boolean;
  122298. /**
  122299. * Disposes of the gizmo
  122300. */
  122301. dispose(): void;
  122302. }
  122303. }
  122304. declare module BABYLON {
  122305. /**
  122306. * Gizmo that enables rotating a mesh along 3 axis
  122307. */
  122308. export class RotationGizmo extends Gizmo {
  122309. /**
  122310. * Internal gizmo used for interactions on the x axis
  122311. */
  122312. xGizmo: PlaneRotationGizmo;
  122313. /**
  122314. * Internal gizmo used for interactions on the y axis
  122315. */
  122316. yGizmo: PlaneRotationGizmo;
  122317. /**
  122318. * Internal gizmo used for interactions on the z axis
  122319. */
  122320. zGizmo: PlaneRotationGizmo;
  122321. /** Fires an event when any of it's sub gizmos are dragged */
  122322. onDragStartObservable: Observable<unknown>;
  122323. /** Fires an event when any of it's sub gizmos are released from dragging */
  122324. onDragEndObservable: Observable<unknown>;
  122325. private _meshAttached;
  122326. get attachedMesh(): Nullable<AbstractMesh>;
  122327. set attachedMesh(mesh: Nullable<AbstractMesh>);
  122328. /**
  122329. * Creates a RotationGizmo
  122330. * @param gizmoLayer The utility layer the gizmo will be added to
  122331. * @param tessellation Amount of tessellation to be used when creating rotation circles
  122332. * @param useEulerRotation Use and update Euler angle instead of quaternion
  122333. */
  122334. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  122335. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  122336. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  122337. /**
  122338. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  122339. */
  122340. set snapDistance(value: number);
  122341. get snapDistance(): number;
  122342. /**
  122343. * Ratio for the scale of the gizmo (Default: 1)
  122344. */
  122345. set scaleRatio(value: number);
  122346. get scaleRatio(): number;
  122347. /**
  122348. * Disposes of the gizmo
  122349. */
  122350. dispose(): void;
  122351. /**
  122352. * CustomMeshes are not supported by this gizmo
  122353. * @param mesh The mesh to replace the default mesh of the gizmo
  122354. */
  122355. setCustomMesh(mesh: Mesh): void;
  122356. }
  122357. }
  122358. declare module BABYLON {
  122359. /**
  122360. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  122361. */
  122362. export class GizmoManager implements IDisposable {
  122363. private scene;
  122364. /**
  122365. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  122366. */
  122367. gizmos: {
  122368. positionGizmo: Nullable<PositionGizmo>;
  122369. rotationGizmo: Nullable<RotationGizmo>;
  122370. scaleGizmo: Nullable<ScaleGizmo>;
  122371. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  122372. };
  122373. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  122374. clearGizmoOnEmptyPointerEvent: boolean;
  122375. /** Fires an event when the manager is attached to a mesh */
  122376. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  122377. private _gizmosEnabled;
  122378. private _pointerObserver;
  122379. private _attachedMesh;
  122380. private _boundingBoxColor;
  122381. private _defaultUtilityLayer;
  122382. private _defaultKeepDepthUtilityLayer;
  122383. /**
  122384. * When bounding box gizmo is enabled, this can be used to track drag/end events
  122385. */
  122386. boundingBoxDragBehavior: SixDofDragBehavior;
  122387. /**
  122388. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  122389. */
  122390. attachableMeshes: Nullable<Array<AbstractMesh>>;
  122391. /**
  122392. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  122393. */
  122394. usePointerToAttachGizmos: boolean;
  122395. /**
  122396. * Utility layer that the bounding box gizmo belongs to
  122397. */
  122398. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  122399. /**
  122400. * Utility layer that all gizmos besides bounding box belong to
  122401. */
  122402. get utilityLayer(): UtilityLayerRenderer;
  122403. /**
  122404. * Instatiates a gizmo manager
  122405. * @param scene the scene to overlay the gizmos on top of
  122406. */
  122407. constructor(scene: Scene);
  122408. /**
  122409. * Attaches a set of gizmos to the specified mesh
  122410. * @param mesh The mesh the gizmo's should be attached to
  122411. */
  122412. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  122413. /**
  122414. * If the position gizmo is enabled
  122415. */
  122416. set positionGizmoEnabled(value: boolean);
  122417. get positionGizmoEnabled(): boolean;
  122418. /**
  122419. * If the rotation gizmo is enabled
  122420. */
  122421. set rotationGizmoEnabled(value: boolean);
  122422. get rotationGizmoEnabled(): boolean;
  122423. /**
  122424. * If the scale gizmo is enabled
  122425. */
  122426. set scaleGizmoEnabled(value: boolean);
  122427. get scaleGizmoEnabled(): boolean;
  122428. /**
  122429. * If the boundingBox gizmo is enabled
  122430. */
  122431. set boundingBoxGizmoEnabled(value: boolean);
  122432. get boundingBoxGizmoEnabled(): boolean;
  122433. /**
  122434. * Disposes of the gizmo manager
  122435. */
  122436. dispose(): void;
  122437. }
  122438. }
  122439. declare module BABYLON {
  122440. /**
  122441. * A directional light is defined by a direction (what a surprise!).
  122442. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  122443. * 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.
  122444. * Documentation: https://doc.babylonjs.com/babylon101/lights
  122445. */
  122446. export class DirectionalLight extends ShadowLight {
  122447. private _shadowFrustumSize;
  122448. /**
  122449. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  122450. */
  122451. get shadowFrustumSize(): number;
  122452. /**
  122453. * Specifies a fix frustum size for the shadow generation.
  122454. */
  122455. set shadowFrustumSize(value: number);
  122456. private _shadowOrthoScale;
  122457. /**
  122458. * Gets the shadow projection scale against the optimal computed one.
  122459. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  122460. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  122461. */
  122462. get shadowOrthoScale(): number;
  122463. /**
  122464. * Sets the shadow projection scale against the optimal computed one.
  122465. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  122466. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  122467. */
  122468. set shadowOrthoScale(value: number);
  122469. /**
  122470. * Automatically compute the projection matrix to best fit (including all the casters)
  122471. * on each frame.
  122472. */
  122473. autoUpdateExtends: boolean;
  122474. /**
  122475. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  122476. * on each frame. autoUpdateExtends must be set to true for this to work
  122477. */
  122478. autoCalcShadowZBounds: boolean;
  122479. private _orthoLeft;
  122480. private _orthoRight;
  122481. private _orthoTop;
  122482. private _orthoBottom;
  122483. /**
  122484. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  122485. * The directional light is emitted from everywhere in the given direction.
  122486. * It can cast shadows.
  122487. * Documentation : https://doc.babylonjs.com/babylon101/lights
  122488. * @param name The friendly name of the light
  122489. * @param direction The direction of the light
  122490. * @param scene The scene the light belongs to
  122491. */
  122492. constructor(name: string, direction: Vector3, scene: Scene);
  122493. /**
  122494. * Returns the string "DirectionalLight".
  122495. * @return The class name
  122496. */
  122497. getClassName(): string;
  122498. /**
  122499. * Returns the integer 1.
  122500. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  122501. */
  122502. getTypeID(): number;
  122503. /**
  122504. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  122505. * Returns the DirectionalLight Shadow projection matrix.
  122506. */
  122507. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122508. /**
  122509. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  122510. * Returns the DirectionalLight Shadow projection matrix.
  122511. */
  122512. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  122513. /**
  122514. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  122515. * Returns the DirectionalLight Shadow projection matrix.
  122516. */
  122517. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122518. protected _buildUniformLayout(): void;
  122519. /**
  122520. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  122521. * @param effect The effect to update
  122522. * @param lightIndex The index of the light in the effect to update
  122523. * @returns The directional light
  122524. */
  122525. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  122526. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  122527. /**
  122528. * Gets the minZ used for shadow according to both the scene and the light.
  122529. *
  122530. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  122531. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  122532. * @param activeCamera The camera we are returning the min for
  122533. * @returns the depth min z
  122534. */
  122535. getDepthMinZ(activeCamera: Camera): number;
  122536. /**
  122537. * Gets the maxZ used for shadow according to both the scene and the light.
  122538. *
  122539. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  122540. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  122541. * @param activeCamera The camera we are returning the max for
  122542. * @returns the depth max z
  122543. */
  122544. getDepthMaxZ(activeCamera: Camera): number;
  122545. /**
  122546. * Prepares the list of defines specific to the light type.
  122547. * @param defines the list of defines
  122548. * @param lightIndex defines the index of the light for the effect
  122549. */
  122550. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  122551. }
  122552. }
  122553. declare module BABYLON {
  122554. /**
  122555. * Class containing static functions to help procedurally build meshes
  122556. */
  122557. export class HemisphereBuilder {
  122558. /**
  122559. * Creates a hemisphere mesh
  122560. * @param name defines the name of the mesh
  122561. * @param options defines the options used to create the mesh
  122562. * @param scene defines the hosting scene
  122563. * @returns the hemisphere mesh
  122564. */
  122565. static CreateHemisphere(name: string, options: {
  122566. segments?: number;
  122567. diameter?: number;
  122568. sideOrientation?: number;
  122569. }, scene: any): Mesh;
  122570. }
  122571. }
  122572. declare module BABYLON {
  122573. /**
  122574. * A spot light is defined by a position, a direction, an angle, and an exponent.
  122575. * These values define a cone of light starting from the position, emitting toward the direction.
  122576. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  122577. * and the exponent defines the speed of the decay of the light with distance (reach).
  122578. * Documentation: https://doc.babylonjs.com/babylon101/lights
  122579. */
  122580. export class SpotLight extends ShadowLight {
  122581. private _angle;
  122582. private _innerAngle;
  122583. private _cosHalfAngle;
  122584. private _lightAngleScale;
  122585. private _lightAngleOffset;
  122586. /**
  122587. * Gets the cone angle of the spot light in Radians.
  122588. */
  122589. get angle(): number;
  122590. /**
  122591. * Sets the cone angle of the spot light in Radians.
  122592. */
  122593. set angle(value: number);
  122594. /**
  122595. * Only used in gltf falloff mode, this defines the angle where
  122596. * the directional falloff will start before cutting at angle which could be seen
  122597. * as outer angle.
  122598. */
  122599. get innerAngle(): number;
  122600. /**
  122601. * Only used in gltf falloff mode, this defines the angle where
  122602. * the directional falloff will start before cutting at angle which could be seen
  122603. * as outer angle.
  122604. */
  122605. set innerAngle(value: number);
  122606. private _shadowAngleScale;
  122607. /**
  122608. * Allows scaling the angle of the light for shadow generation only.
  122609. */
  122610. get shadowAngleScale(): number;
  122611. /**
  122612. * Allows scaling the angle of the light for shadow generation only.
  122613. */
  122614. set shadowAngleScale(value: number);
  122615. /**
  122616. * The light decay speed with the distance from the emission spot.
  122617. */
  122618. exponent: number;
  122619. private _projectionTextureMatrix;
  122620. /**
  122621. * Allows reading the projecton texture
  122622. */
  122623. get projectionTextureMatrix(): Matrix;
  122624. protected _projectionTextureLightNear: number;
  122625. /**
  122626. * Gets the near clip of the Spotlight for texture projection.
  122627. */
  122628. get projectionTextureLightNear(): number;
  122629. /**
  122630. * Sets the near clip of the Spotlight for texture projection.
  122631. */
  122632. set projectionTextureLightNear(value: number);
  122633. protected _projectionTextureLightFar: number;
  122634. /**
  122635. * Gets the far clip of the Spotlight for texture projection.
  122636. */
  122637. get projectionTextureLightFar(): number;
  122638. /**
  122639. * Sets the far clip of the Spotlight for texture projection.
  122640. */
  122641. set projectionTextureLightFar(value: number);
  122642. protected _projectionTextureUpDirection: Vector3;
  122643. /**
  122644. * Gets the Up vector of the Spotlight for texture projection.
  122645. */
  122646. get projectionTextureUpDirection(): Vector3;
  122647. /**
  122648. * Sets the Up vector of the Spotlight for texture projection.
  122649. */
  122650. set projectionTextureUpDirection(value: Vector3);
  122651. private _projectionTexture;
  122652. /**
  122653. * Gets the projection texture of the light.
  122654. */
  122655. get projectionTexture(): Nullable<BaseTexture>;
  122656. /**
  122657. * Sets the projection texture of the light.
  122658. */
  122659. set projectionTexture(value: Nullable<BaseTexture>);
  122660. private _projectionTextureViewLightDirty;
  122661. private _projectionTextureProjectionLightDirty;
  122662. private _projectionTextureDirty;
  122663. private _projectionTextureViewTargetVector;
  122664. private _projectionTextureViewLightMatrix;
  122665. private _projectionTextureProjectionLightMatrix;
  122666. private _projectionTextureScalingMatrix;
  122667. /**
  122668. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  122669. * It can cast shadows.
  122670. * Documentation : https://doc.babylonjs.com/babylon101/lights
  122671. * @param name The light friendly name
  122672. * @param position The position of the spot light in the scene
  122673. * @param direction The direction of the light in the scene
  122674. * @param angle The cone angle of the light in Radians
  122675. * @param exponent The light decay speed with the distance from the emission spot
  122676. * @param scene The scene the lights belongs to
  122677. */
  122678. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  122679. /**
  122680. * Returns the string "SpotLight".
  122681. * @returns the class name
  122682. */
  122683. getClassName(): string;
  122684. /**
  122685. * Returns the integer 2.
  122686. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  122687. */
  122688. getTypeID(): number;
  122689. /**
  122690. * Overrides the direction setter to recompute the projection texture view light Matrix.
  122691. */
  122692. protected _setDirection(value: Vector3): void;
  122693. /**
  122694. * Overrides the position setter to recompute the projection texture view light Matrix.
  122695. */
  122696. protected _setPosition(value: Vector3): void;
  122697. /**
  122698. * 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.
  122699. * Returns the SpotLight.
  122700. */
  122701. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122702. protected _computeProjectionTextureViewLightMatrix(): void;
  122703. protected _computeProjectionTextureProjectionLightMatrix(): void;
  122704. /**
  122705. * Main function for light texture projection matrix computing.
  122706. */
  122707. protected _computeProjectionTextureMatrix(): void;
  122708. protected _buildUniformLayout(): void;
  122709. private _computeAngleValues;
  122710. /**
  122711. * Sets the passed Effect "effect" with the Light textures.
  122712. * @param effect The effect to update
  122713. * @param lightIndex The index of the light in the effect to update
  122714. * @returns The light
  122715. */
  122716. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  122717. /**
  122718. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  122719. * @param effect The effect to update
  122720. * @param lightIndex The index of the light in the effect to update
  122721. * @returns The spot light
  122722. */
  122723. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  122724. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  122725. /**
  122726. * Disposes the light and the associated resources.
  122727. */
  122728. dispose(): void;
  122729. /**
  122730. * Prepares the list of defines specific to the light type.
  122731. * @param defines the list of defines
  122732. * @param lightIndex defines the index of the light for the effect
  122733. */
  122734. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  122735. }
  122736. }
  122737. declare module BABYLON {
  122738. /**
  122739. * Gizmo that enables viewing a light
  122740. */
  122741. export class LightGizmo extends Gizmo {
  122742. private _lightMesh;
  122743. private _material;
  122744. private _cachedPosition;
  122745. private _cachedForward;
  122746. private _attachedMeshParent;
  122747. /**
  122748. * Creates a LightGizmo
  122749. * @param gizmoLayer The utility layer the gizmo will be added to
  122750. */
  122751. constructor(gizmoLayer?: UtilityLayerRenderer);
  122752. private _light;
  122753. /**
  122754. * The light that the gizmo is attached to
  122755. */
  122756. set light(light: Nullable<Light>);
  122757. get light(): Nullable<Light>;
  122758. /**
  122759. * Gets the material used to render the light gizmo
  122760. */
  122761. get material(): StandardMaterial;
  122762. /**
  122763. * @hidden
  122764. * Updates the gizmo to match the attached mesh's position/rotation
  122765. */
  122766. protected _update(): void;
  122767. private static _Scale;
  122768. /**
  122769. * Creates the lines for a light mesh
  122770. */
  122771. private static _CreateLightLines;
  122772. /**
  122773. * Disposes of the light gizmo
  122774. */
  122775. dispose(): void;
  122776. private static _CreateHemisphericLightMesh;
  122777. private static _CreatePointLightMesh;
  122778. private static _CreateSpotLightMesh;
  122779. private static _CreateDirectionalLightMesh;
  122780. }
  122781. }
  122782. declare module BABYLON {
  122783. /** @hidden */
  122784. export var backgroundFragmentDeclaration: {
  122785. name: string;
  122786. shader: string;
  122787. };
  122788. }
  122789. declare module BABYLON {
  122790. /** @hidden */
  122791. export var backgroundUboDeclaration: {
  122792. name: string;
  122793. shader: string;
  122794. };
  122795. }
  122796. declare module BABYLON {
  122797. /** @hidden */
  122798. export var backgroundPixelShader: {
  122799. name: string;
  122800. shader: string;
  122801. };
  122802. }
  122803. declare module BABYLON {
  122804. /** @hidden */
  122805. export var backgroundVertexDeclaration: {
  122806. name: string;
  122807. shader: string;
  122808. };
  122809. }
  122810. declare module BABYLON {
  122811. /** @hidden */
  122812. export var backgroundVertexShader: {
  122813. name: string;
  122814. shader: string;
  122815. };
  122816. }
  122817. declare module BABYLON {
  122818. /**
  122819. * Background material used to create an efficient environement around your scene.
  122820. */
  122821. export class BackgroundMaterial extends PushMaterial {
  122822. /**
  122823. * Standard reflectance value at parallel view angle.
  122824. */
  122825. static StandardReflectance0: number;
  122826. /**
  122827. * Standard reflectance value at grazing angle.
  122828. */
  122829. static StandardReflectance90: number;
  122830. protected _primaryColor: Color3;
  122831. /**
  122832. * Key light Color (multiply against the environement texture)
  122833. */
  122834. primaryColor: Color3;
  122835. protected __perceptualColor: Nullable<Color3>;
  122836. /**
  122837. * Experimental Internal Use Only.
  122838. *
  122839. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  122840. * This acts as a helper to set the primary color to a more "human friendly" value.
  122841. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  122842. * output color as close as possible from the chosen value.
  122843. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  122844. * part of lighting setup.)
  122845. */
  122846. get _perceptualColor(): Nullable<Color3>;
  122847. set _perceptualColor(value: Nullable<Color3>);
  122848. protected _primaryColorShadowLevel: float;
  122849. /**
  122850. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  122851. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  122852. */
  122853. get primaryColorShadowLevel(): float;
  122854. set primaryColorShadowLevel(value: float);
  122855. protected _primaryColorHighlightLevel: float;
  122856. /**
  122857. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  122858. * The primary color is used at the level chosen to define what the white area would look.
  122859. */
  122860. get primaryColorHighlightLevel(): float;
  122861. set primaryColorHighlightLevel(value: float);
  122862. protected _reflectionTexture: Nullable<BaseTexture>;
  122863. /**
  122864. * Reflection Texture used in the material.
  122865. * Should be author in a specific way for the best result (refer to the documentation).
  122866. */
  122867. reflectionTexture: Nullable<BaseTexture>;
  122868. protected _reflectionBlur: float;
  122869. /**
  122870. * Reflection Texture level of blur.
  122871. *
  122872. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  122873. * texture twice.
  122874. */
  122875. reflectionBlur: float;
  122876. protected _diffuseTexture: Nullable<BaseTexture>;
  122877. /**
  122878. * Diffuse Texture used in the material.
  122879. * Should be author in a specific way for the best result (refer to the documentation).
  122880. */
  122881. diffuseTexture: Nullable<BaseTexture>;
  122882. protected _shadowLights: Nullable<IShadowLight[]>;
  122883. /**
  122884. * Specify the list of lights casting shadow on the material.
  122885. * All scene shadow lights will be included if null.
  122886. */
  122887. shadowLights: Nullable<IShadowLight[]>;
  122888. protected _shadowLevel: float;
  122889. /**
  122890. * Helps adjusting the shadow to a softer level if required.
  122891. * 0 means black shadows and 1 means no shadows.
  122892. */
  122893. shadowLevel: float;
  122894. protected _sceneCenter: Vector3;
  122895. /**
  122896. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  122897. * It is usually zero but might be interesting to modify according to your setup.
  122898. */
  122899. sceneCenter: Vector3;
  122900. protected _opacityFresnel: boolean;
  122901. /**
  122902. * This helps specifying that the material is falling off to the sky box at grazing angle.
  122903. * This helps ensuring a nice transition when the camera goes under the ground.
  122904. */
  122905. opacityFresnel: boolean;
  122906. protected _reflectionFresnel: boolean;
  122907. /**
  122908. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  122909. * This helps adding a mirror texture on the ground.
  122910. */
  122911. reflectionFresnel: boolean;
  122912. protected _reflectionFalloffDistance: number;
  122913. /**
  122914. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  122915. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  122916. */
  122917. reflectionFalloffDistance: number;
  122918. protected _reflectionAmount: number;
  122919. /**
  122920. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  122921. */
  122922. reflectionAmount: number;
  122923. protected _reflectionReflectance0: number;
  122924. /**
  122925. * This specifies the weight of the reflection at grazing angle.
  122926. */
  122927. reflectionReflectance0: number;
  122928. protected _reflectionReflectance90: number;
  122929. /**
  122930. * This specifies the weight of the reflection at a perpendicular point of view.
  122931. */
  122932. reflectionReflectance90: number;
  122933. /**
  122934. * Sets the reflection reflectance fresnel values according to the default standard
  122935. * empirically know to work well :-)
  122936. */
  122937. set reflectionStandardFresnelWeight(value: number);
  122938. protected _useRGBColor: boolean;
  122939. /**
  122940. * Helps to directly use the maps channels instead of their level.
  122941. */
  122942. useRGBColor: boolean;
  122943. protected _enableNoise: boolean;
  122944. /**
  122945. * This helps reducing the banding effect that could occur on the background.
  122946. */
  122947. enableNoise: boolean;
  122948. /**
  122949. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  122950. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  122951. * Recommended to be keep at 1.0 except for special cases.
  122952. */
  122953. get fovMultiplier(): number;
  122954. set fovMultiplier(value: number);
  122955. private _fovMultiplier;
  122956. /**
  122957. * Enable the FOV adjustment feature controlled by fovMultiplier.
  122958. */
  122959. useEquirectangularFOV: boolean;
  122960. private _maxSimultaneousLights;
  122961. /**
  122962. * Number of Simultaneous lights allowed on the material.
  122963. */
  122964. maxSimultaneousLights: int;
  122965. /**
  122966. * Default configuration related to image processing available in the Background Material.
  122967. */
  122968. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  122969. /**
  122970. * Keep track of the image processing observer to allow dispose and replace.
  122971. */
  122972. private _imageProcessingObserver;
  122973. /**
  122974. * Attaches a new image processing configuration to the PBR Material.
  122975. * @param configuration (if null the scene configuration will be use)
  122976. */
  122977. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  122978. /**
  122979. * Gets the image processing configuration used either in this material.
  122980. */
  122981. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  122982. /**
  122983. * Sets the Default image processing configuration used either in the this material.
  122984. *
  122985. * If sets to null, the scene one is in use.
  122986. */
  122987. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  122988. /**
  122989. * Gets wether the color curves effect is enabled.
  122990. */
  122991. get cameraColorCurvesEnabled(): boolean;
  122992. /**
  122993. * Sets wether the color curves effect is enabled.
  122994. */
  122995. set cameraColorCurvesEnabled(value: boolean);
  122996. /**
  122997. * Gets wether the color grading effect is enabled.
  122998. */
  122999. get cameraColorGradingEnabled(): boolean;
  123000. /**
  123001. * Gets wether the color grading effect is enabled.
  123002. */
  123003. set cameraColorGradingEnabled(value: boolean);
  123004. /**
  123005. * Gets wether tonemapping is enabled or not.
  123006. */
  123007. get cameraToneMappingEnabled(): boolean;
  123008. /**
  123009. * Sets wether tonemapping is enabled or not
  123010. */
  123011. set cameraToneMappingEnabled(value: boolean);
  123012. /**
  123013. * The camera exposure used on this material.
  123014. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  123015. * This corresponds to a photographic exposure.
  123016. */
  123017. get cameraExposure(): float;
  123018. /**
  123019. * The camera exposure used on this material.
  123020. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  123021. * This corresponds to a photographic exposure.
  123022. */
  123023. set cameraExposure(value: float);
  123024. /**
  123025. * Gets The camera contrast used on this material.
  123026. */
  123027. get cameraContrast(): float;
  123028. /**
  123029. * Sets The camera contrast used on this material.
  123030. */
  123031. set cameraContrast(value: float);
  123032. /**
  123033. * Gets the Color Grading 2D Lookup Texture.
  123034. */
  123035. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  123036. /**
  123037. * Sets the Color Grading 2D Lookup Texture.
  123038. */
  123039. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  123040. /**
  123041. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  123042. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  123043. * 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;
  123044. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  123045. */
  123046. get cameraColorCurves(): Nullable<ColorCurves>;
  123047. /**
  123048. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  123049. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  123050. * 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;
  123051. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  123052. */
  123053. set cameraColorCurves(value: Nullable<ColorCurves>);
  123054. /**
  123055. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  123056. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  123057. */
  123058. switchToBGR: boolean;
  123059. private _renderTargets;
  123060. private _reflectionControls;
  123061. private _white;
  123062. private _primaryShadowColor;
  123063. private _primaryHighlightColor;
  123064. /**
  123065. * Instantiates a Background Material in the given scene
  123066. * @param name The friendly name of the material
  123067. * @param scene The scene to add the material to
  123068. */
  123069. constructor(name: string, scene: Scene);
  123070. /**
  123071. * Gets a boolean indicating that current material needs to register RTT
  123072. */
  123073. get hasRenderTargetTextures(): boolean;
  123074. /**
  123075. * The entire material has been created in order to prevent overdraw.
  123076. * @returns false
  123077. */
  123078. needAlphaTesting(): boolean;
  123079. /**
  123080. * The entire material has been created in order to prevent overdraw.
  123081. * @returns true if blending is enable
  123082. */
  123083. needAlphaBlending(): boolean;
  123084. /**
  123085. * Checks wether the material is ready to be rendered for a given mesh.
  123086. * @param mesh The mesh to render
  123087. * @param subMesh The submesh to check against
  123088. * @param useInstances Specify wether or not the material is used with instances
  123089. * @returns true if all the dependencies are ready (Textures, Effects...)
  123090. */
  123091. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  123092. /**
  123093. * Compute the primary color according to the chosen perceptual color.
  123094. */
  123095. private _computePrimaryColorFromPerceptualColor;
  123096. /**
  123097. * Compute the highlights and shadow colors according to their chosen levels.
  123098. */
  123099. private _computePrimaryColors;
  123100. /**
  123101. * Build the uniform buffer used in the material.
  123102. */
  123103. buildUniformLayout(): void;
  123104. /**
  123105. * Unbind the material.
  123106. */
  123107. unbind(): void;
  123108. /**
  123109. * Bind only the world matrix to the material.
  123110. * @param world The world matrix to bind.
  123111. */
  123112. bindOnlyWorldMatrix(world: Matrix): void;
  123113. /**
  123114. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  123115. * @param world The world matrix to bind.
  123116. * @param subMesh The submesh to bind for.
  123117. */
  123118. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  123119. /**
  123120. * Checks to see if a texture is used in the material.
  123121. * @param texture - Base texture to use.
  123122. * @returns - Boolean specifying if a texture is used in the material.
  123123. */
  123124. hasTexture(texture: BaseTexture): boolean;
  123125. /**
  123126. * Dispose the material.
  123127. * @param forceDisposeEffect Force disposal of the associated effect.
  123128. * @param forceDisposeTextures Force disposal of the associated textures.
  123129. */
  123130. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  123131. /**
  123132. * Clones the material.
  123133. * @param name The cloned name.
  123134. * @returns The cloned material.
  123135. */
  123136. clone(name: string): BackgroundMaterial;
  123137. /**
  123138. * Serializes the current material to its JSON representation.
  123139. * @returns The JSON representation.
  123140. */
  123141. serialize(): any;
  123142. /**
  123143. * Gets the class name of the material
  123144. * @returns "BackgroundMaterial"
  123145. */
  123146. getClassName(): string;
  123147. /**
  123148. * Parse a JSON input to create back a background material.
  123149. * @param source The JSON data to parse
  123150. * @param scene The scene to create the parsed material in
  123151. * @param rootUrl The root url of the assets the material depends upon
  123152. * @returns the instantiated BackgroundMaterial.
  123153. */
  123154. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  123155. }
  123156. }
  123157. declare module BABYLON {
  123158. /**
  123159. * Represents the different options available during the creation of
  123160. * a Environment helper.
  123161. *
  123162. * This can control the default ground, skybox and image processing setup of your scene.
  123163. */
  123164. export interface IEnvironmentHelperOptions {
  123165. /**
  123166. * Specifies whether or not to create a ground.
  123167. * True by default.
  123168. */
  123169. createGround: boolean;
  123170. /**
  123171. * Specifies the ground size.
  123172. * 15 by default.
  123173. */
  123174. groundSize: number;
  123175. /**
  123176. * The texture used on the ground for the main color.
  123177. * Comes from the BabylonJS CDN by default.
  123178. *
  123179. * Remarks: Can be either a texture or a url.
  123180. */
  123181. groundTexture: string | BaseTexture;
  123182. /**
  123183. * The color mixed in the ground texture by default.
  123184. * BabylonJS clearColor by default.
  123185. */
  123186. groundColor: Color3;
  123187. /**
  123188. * Specifies the ground opacity.
  123189. * 1 by default.
  123190. */
  123191. groundOpacity: number;
  123192. /**
  123193. * Enables the ground to receive shadows.
  123194. * True by default.
  123195. */
  123196. enableGroundShadow: boolean;
  123197. /**
  123198. * Helps preventing the shadow to be fully black on the ground.
  123199. * 0.5 by default.
  123200. */
  123201. groundShadowLevel: number;
  123202. /**
  123203. * Creates a mirror texture attach to the ground.
  123204. * false by default.
  123205. */
  123206. enableGroundMirror: boolean;
  123207. /**
  123208. * Specifies the ground mirror size ratio.
  123209. * 0.3 by default as the default kernel is 64.
  123210. */
  123211. groundMirrorSizeRatio: number;
  123212. /**
  123213. * Specifies the ground mirror blur kernel size.
  123214. * 64 by default.
  123215. */
  123216. groundMirrorBlurKernel: number;
  123217. /**
  123218. * Specifies the ground mirror visibility amount.
  123219. * 1 by default
  123220. */
  123221. groundMirrorAmount: number;
  123222. /**
  123223. * Specifies the ground mirror reflectance weight.
  123224. * This uses the standard weight of the background material to setup the fresnel effect
  123225. * of the mirror.
  123226. * 1 by default.
  123227. */
  123228. groundMirrorFresnelWeight: number;
  123229. /**
  123230. * Specifies the ground mirror Falloff distance.
  123231. * This can helps reducing the size of the reflection.
  123232. * 0 by Default.
  123233. */
  123234. groundMirrorFallOffDistance: number;
  123235. /**
  123236. * Specifies the ground mirror texture type.
  123237. * Unsigned Int by Default.
  123238. */
  123239. groundMirrorTextureType: number;
  123240. /**
  123241. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  123242. * the shown objects.
  123243. */
  123244. groundYBias: number;
  123245. /**
  123246. * Specifies whether or not to create a skybox.
  123247. * True by default.
  123248. */
  123249. createSkybox: boolean;
  123250. /**
  123251. * Specifies the skybox size.
  123252. * 20 by default.
  123253. */
  123254. skyboxSize: number;
  123255. /**
  123256. * The texture used on the skybox for the main color.
  123257. * Comes from the BabylonJS CDN by default.
  123258. *
  123259. * Remarks: Can be either a texture or a url.
  123260. */
  123261. skyboxTexture: string | BaseTexture;
  123262. /**
  123263. * The color mixed in the skybox texture by default.
  123264. * BabylonJS clearColor by default.
  123265. */
  123266. skyboxColor: Color3;
  123267. /**
  123268. * The background rotation around the Y axis of the scene.
  123269. * This helps aligning the key lights of your scene with the background.
  123270. * 0 by default.
  123271. */
  123272. backgroundYRotation: number;
  123273. /**
  123274. * Compute automatically the size of the elements to best fit with the scene.
  123275. */
  123276. sizeAuto: boolean;
  123277. /**
  123278. * Default position of the rootMesh if autoSize is not true.
  123279. */
  123280. rootPosition: Vector3;
  123281. /**
  123282. * Sets up the image processing in the scene.
  123283. * true by default.
  123284. */
  123285. setupImageProcessing: boolean;
  123286. /**
  123287. * The texture used as your environment texture in the scene.
  123288. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  123289. *
  123290. * Remarks: Can be either a texture or a url.
  123291. */
  123292. environmentTexture: string | BaseTexture;
  123293. /**
  123294. * The value of the exposure to apply to the scene.
  123295. * 0.6 by default if setupImageProcessing is true.
  123296. */
  123297. cameraExposure: number;
  123298. /**
  123299. * The value of the contrast to apply to the scene.
  123300. * 1.6 by default if setupImageProcessing is true.
  123301. */
  123302. cameraContrast: number;
  123303. /**
  123304. * Specifies whether or not tonemapping should be enabled in the scene.
  123305. * true by default if setupImageProcessing is true.
  123306. */
  123307. toneMappingEnabled: boolean;
  123308. }
  123309. /**
  123310. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  123311. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  123312. * It also helps with the default setup of your imageProcessing configuration.
  123313. */
  123314. export class EnvironmentHelper {
  123315. /**
  123316. * Default ground texture URL.
  123317. */
  123318. private static _groundTextureCDNUrl;
  123319. /**
  123320. * Default skybox texture URL.
  123321. */
  123322. private static _skyboxTextureCDNUrl;
  123323. /**
  123324. * Default environment texture URL.
  123325. */
  123326. private static _environmentTextureCDNUrl;
  123327. /**
  123328. * Creates the default options for the helper.
  123329. */
  123330. private static _getDefaultOptions;
  123331. private _rootMesh;
  123332. /**
  123333. * Gets the root mesh created by the helper.
  123334. */
  123335. get rootMesh(): Mesh;
  123336. private _skybox;
  123337. /**
  123338. * Gets the skybox created by the helper.
  123339. */
  123340. get skybox(): Nullable<Mesh>;
  123341. private _skyboxTexture;
  123342. /**
  123343. * Gets the skybox texture created by the helper.
  123344. */
  123345. get skyboxTexture(): Nullable<BaseTexture>;
  123346. private _skyboxMaterial;
  123347. /**
  123348. * Gets the skybox material created by the helper.
  123349. */
  123350. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  123351. private _ground;
  123352. /**
  123353. * Gets the ground mesh created by the helper.
  123354. */
  123355. get ground(): Nullable<Mesh>;
  123356. private _groundTexture;
  123357. /**
  123358. * Gets the ground texture created by the helper.
  123359. */
  123360. get groundTexture(): Nullable<BaseTexture>;
  123361. private _groundMirror;
  123362. /**
  123363. * Gets the ground mirror created by the helper.
  123364. */
  123365. get groundMirror(): Nullable<MirrorTexture>;
  123366. /**
  123367. * Gets the ground mirror render list to helps pushing the meshes
  123368. * you wish in the ground reflection.
  123369. */
  123370. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  123371. private _groundMaterial;
  123372. /**
  123373. * Gets the ground material created by the helper.
  123374. */
  123375. get groundMaterial(): Nullable<BackgroundMaterial>;
  123376. /**
  123377. * Stores the creation options.
  123378. */
  123379. private readonly _scene;
  123380. private _options;
  123381. /**
  123382. * This observable will be notified with any error during the creation of the environment,
  123383. * mainly texture creation errors.
  123384. */
  123385. onErrorObservable: Observable<{
  123386. message?: string;
  123387. exception?: any;
  123388. }>;
  123389. /**
  123390. * constructor
  123391. * @param options Defines the options we want to customize the helper
  123392. * @param scene The scene to add the material to
  123393. */
  123394. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  123395. /**
  123396. * Updates the background according to the new options
  123397. * @param options
  123398. */
  123399. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  123400. /**
  123401. * Sets the primary color of all the available elements.
  123402. * @param color the main color to affect to the ground and the background
  123403. */
  123404. setMainColor(color: Color3): void;
  123405. /**
  123406. * Setup the image processing according to the specified options.
  123407. */
  123408. private _setupImageProcessing;
  123409. /**
  123410. * Setup the environment texture according to the specified options.
  123411. */
  123412. private _setupEnvironmentTexture;
  123413. /**
  123414. * Setup the background according to the specified options.
  123415. */
  123416. private _setupBackground;
  123417. /**
  123418. * Get the scene sizes according to the setup.
  123419. */
  123420. private _getSceneSize;
  123421. /**
  123422. * Setup the ground according to the specified options.
  123423. */
  123424. private _setupGround;
  123425. /**
  123426. * Setup the ground material according to the specified options.
  123427. */
  123428. private _setupGroundMaterial;
  123429. /**
  123430. * Setup the ground diffuse texture according to the specified options.
  123431. */
  123432. private _setupGroundDiffuseTexture;
  123433. /**
  123434. * Setup the ground mirror texture according to the specified options.
  123435. */
  123436. private _setupGroundMirrorTexture;
  123437. /**
  123438. * Setup the ground to receive the mirror texture.
  123439. */
  123440. private _setupMirrorInGroundMaterial;
  123441. /**
  123442. * Setup the skybox according to the specified options.
  123443. */
  123444. private _setupSkybox;
  123445. /**
  123446. * Setup the skybox material according to the specified options.
  123447. */
  123448. private _setupSkyboxMaterial;
  123449. /**
  123450. * Setup the skybox reflection texture according to the specified options.
  123451. */
  123452. private _setupSkyboxReflectionTexture;
  123453. private _errorHandler;
  123454. /**
  123455. * Dispose all the elements created by the Helper.
  123456. */
  123457. dispose(): void;
  123458. }
  123459. }
  123460. declare module BABYLON {
  123461. /**
  123462. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  123463. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  123464. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  123465. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  123466. */
  123467. export class PhotoDome extends TransformNode {
  123468. /**
  123469. * Define the image as a Monoscopic panoramic 360 image.
  123470. */
  123471. static readonly MODE_MONOSCOPIC: number;
  123472. /**
  123473. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  123474. */
  123475. static readonly MODE_TOPBOTTOM: number;
  123476. /**
  123477. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  123478. */
  123479. static readonly MODE_SIDEBYSIDE: number;
  123480. private _useDirectMapping;
  123481. /**
  123482. * The texture being displayed on the sphere
  123483. */
  123484. protected _photoTexture: Texture;
  123485. /**
  123486. * Gets or sets the texture being displayed on the sphere
  123487. */
  123488. get photoTexture(): Texture;
  123489. set photoTexture(value: Texture);
  123490. /**
  123491. * Observable raised when an error occured while loading the 360 image
  123492. */
  123493. onLoadErrorObservable: Observable<string>;
  123494. /**
  123495. * The skybox material
  123496. */
  123497. protected _material: BackgroundMaterial;
  123498. /**
  123499. * The surface used for the skybox
  123500. */
  123501. protected _mesh: Mesh;
  123502. /**
  123503. * Gets the mesh used for the skybox.
  123504. */
  123505. get mesh(): Mesh;
  123506. /**
  123507. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  123508. * Also see the options.resolution property.
  123509. */
  123510. get fovMultiplier(): number;
  123511. set fovMultiplier(value: number);
  123512. private _imageMode;
  123513. /**
  123514. * Gets or set the current video mode for the video. It can be:
  123515. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  123516. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  123517. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  123518. */
  123519. get imageMode(): number;
  123520. set imageMode(value: number);
  123521. /**
  123522. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  123523. * @param name Element's name, child elements will append suffixes for their own names.
  123524. * @param urlsOfPhoto defines the url of the photo to display
  123525. * @param options defines an object containing optional or exposed sub element properties
  123526. * @param onError defines a callback called when an error occured while loading the texture
  123527. */
  123528. constructor(name: string, urlOfPhoto: string, options: {
  123529. resolution?: number;
  123530. size?: number;
  123531. useDirectMapping?: boolean;
  123532. faceForward?: boolean;
  123533. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  123534. private _onBeforeCameraRenderObserver;
  123535. private _changeImageMode;
  123536. /**
  123537. * Releases resources associated with this node.
  123538. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  123539. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  123540. */
  123541. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  123542. }
  123543. }
  123544. declare module BABYLON {
  123545. /**
  123546. * Class used to host RGBD texture specific utilities
  123547. */
  123548. export class RGBDTextureTools {
  123549. /**
  123550. * Expand the RGBD Texture from RGBD to Half Float if possible.
  123551. * @param texture the texture to expand.
  123552. */
  123553. static ExpandRGBDTexture(texture: Texture): void;
  123554. }
  123555. }
  123556. declare module BABYLON {
  123557. /**
  123558. * Class used to host texture specific utilities
  123559. */
  123560. export class BRDFTextureTools {
  123561. /**
  123562. * Prevents texture cache collision
  123563. */
  123564. private static _instanceNumber;
  123565. /**
  123566. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  123567. * @param scene defines the hosting scene
  123568. * @returns the environment BRDF texture
  123569. */
  123570. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  123571. private static _environmentBRDFBase64Texture;
  123572. }
  123573. }
  123574. declare module BABYLON {
  123575. /**
  123576. * @hidden
  123577. */
  123578. export interface IMaterialClearCoatDefines {
  123579. CLEARCOAT: boolean;
  123580. CLEARCOAT_DEFAULTIOR: boolean;
  123581. CLEARCOAT_TEXTURE: boolean;
  123582. CLEARCOAT_TEXTUREDIRECTUV: number;
  123583. CLEARCOAT_BUMP: boolean;
  123584. CLEARCOAT_BUMPDIRECTUV: number;
  123585. CLEARCOAT_TINT: boolean;
  123586. CLEARCOAT_TINT_TEXTURE: boolean;
  123587. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  123588. /** @hidden */
  123589. _areTexturesDirty: boolean;
  123590. }
  123591. /**
  123592. * Define the code related to the clear coat parameters of the pbr material.
  123593. */
  123594. export class PBRClearCoatConfiguration {
  123595. /**
  123596. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  123597. * The default fits with a polyurethane material.
  123598. */
  123599. private static readonly _DefaultIndexOfRefraction;
  123600. private _isEnabled;
  123601. /**
  123602. * Defines if the clear coat is enabled in the material.
  123603. */
  123604. isEnabled: boolean;
  123605. /**
  123606. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  123607. */
  123608. intensity: number;
  123609. /**
  123610. * Defines the clear coat layer roughness.
  123611. */
  123612. roughness: number;
  123613. private _indexOfRefraction;
  123614. /**
  123615. * Defines the index of refraction of the clear coat.
  123616. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  123617. * The default fits with a polyurethane material.
  123618. * Changing the default value is more performance intensive.
  123619. */
  123620. indexOfRefraction: number;
  123621. private _texture;
  123622. /**
  123623. * Stores the clear coat values in a texture.
  123624. */
  123625. texture: Nullable<BaseTexture>;
  123626. private _bumpTexture;
  123627. /**
  123628. * Define the clear coat specific bump texture.
  123629. */
  123630. bumpTexture: Nullable<BaseTexture>;
  123631. private _isTintEnabled;
  123632. /**
  123633. * Defines if the clear coat tint is enabled in the material.
  123634. */
  123635. isTintEnabled: boolean;
  123636. /**
  123637. * Defines the clear coat tint of the material.
  123638. * This is only use if tint is enabled
  123639. */
  123640. tintColor: Color3;
  123641. /**
  123642. * Defines the distance at which the tint color should be found in the
  123643. * clear coat media.
  123644. * This is only use if tint is enabled
  123645. */
  123646. tintColorAtDistance: number;
  123647. /**
  123648. * Defines the clear coat layer thickness.
  123649. * This is only use if tint is enabled
  123650. */
  123651. tintThickness: number;
  123652. private _tintTexture;
  123653. /**
  123654. * Stores the clear tint values in a texture.
  123655. * rgb is tint
  123656. * a is a thickness factor
  123657. */
  123658. tintTexture: Nullable<BaseTexture>;
  123659. /** @hidden */
  123660. private _internalMarkAllSubMeshesAsTexturesDirty;
  123661. /** @hidden */
  123662. _markAllSubMeshesAsTexturesDirty(): void;
  123663. /**
  123664. * Instantiate a new istance of clear coat configuration.
  123665. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123666. */
  123667. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123668. /**
  123669. * Gets wehter the submesh is ready to be used or not.
  123670. * @param defines the list of "defines" to update.
  123671. * @param scene defines the scene the material belongs to.
  123672. * @param engine defines the engine the material belongs to.
  123673. * @param disableBumpMap defines wether the material disables bump or not.
  123674. * @returns - boolean indicating that the submesh is ready or not.
  123675. */
  123676. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  123677. /**
  123678. * Checks to see if a texture is used in the material.
  123679. * @param defines the list of "defines" to update.
  123680. * @param scene defines the scene to the material belongs to.
  123681. */
  123682. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  123683. /**
  123684. * Binds the material data.
  123685. * @param uniformBuffer defines the Uniform buffer to fill in.
  123686. * @param scene defines the scene the material belongs to.
  123687. * @param engine defines the engine the material belongs to.
  123688. * @param disableBumpMap defines wether the material disables bump or not.
  123689. * @param isFrozen defines wether the material is frozen or not.
  123690. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  123691. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  123692. */
  123693. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  123694. /**
  123695. * Checks to see if a texture is used in the material.
  123696. * @param texture - Base texture to use.
  123697. * @returns - Boolean specifying if a texture is used in the material.
  123698. */
  123699. hasTexture(texture: BaseTexture): boolean;
  123700. /**
  123701. * Returns an array of the actively used textures.
  123702. * @param activeTextures Array of BaseTextures
  123703. */
  123704. getActiveTextures(activeTextures: BaseTexture[]): void;
  123705. /**
  123706. * Returns the animatable textures.
  123707. * @param animatables Array of animatable textures.
  123708. */
  123709. getAnimatables(animatables: IAnimatable[]): void;
  123710. /**
  123711. * Disposes the resources of the material.
  123712. * @param forceDisposeTextures - Forces the disposal of all textures.
  123713. */
  123714. dispose(forceDisposeTextures?: boolean): void;
  123715. /**
  123716. * Get the current class name of the texture useful for serialization or dynamic coding.
  123717. * @returns "PBRClearCoatConfiguration"
  123718. */
  123719. getClassName(): string;
  123720. /**
  123721. * Add fallbacks to the effect fallbacks list.
  123722. * @param defines defines the Base texture to use.
  123723. * @param fallbacks defines the current fallback list.
  123724. * @param currentRank defines the current fallback rank.
  123725. * @returns the new fallback rank.
  123726. */
  123727. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123728. /**
  123729. * Add the required uniforms to the current list.
  123730. * @param uniforms defines the current uniform list.
  123731. */
  123732. static AddUniforms(uniforms: string[]): void;
  123733. /**
  123734. * Add the required samplers to the current list.
  123735. * @param samplers defines the current sampler list.
  123736. */
  123737. static AddSamplers(samplers: string[]): void;
  123738. /**
  123739. * Add the required uniforms to the current buffer.
  123740. * @param uniformBuffer defines the current uniform buffer.
  123741. */
  123742. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123743. /**
  123744. * Makes a duplicate of the current configuration into another one.
  123745. * @param clearCoatConfiguration define the config where to copy the info
  123746. */
  123747. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  123748. /**
  123749. * Serializes this clear coat configuration.
  123750. * @returns - An object with the serialized config.
  123751. */
  123752. serialize(): any;
  123753. /**
  123754. * Parses a anisotropy Configuration from a serialized object.
  123755. * @param source - Serialized object.
  123756. * @param scene Defines the scene we are parsing for
  123757. * @param rootUrl Defines the rootUrl to load from
  123758. */
  123759. parse(source: any, scene: Scene, rootUrl: string): void;
  123760. }
  123761. }
  123762. declare module BABYLON {
  123763. /**
  123764. * @hidden
  123765. */
  123766. export interface IMaterialAnisotropicDefines {
  123767. ANISOTROPIC: boolean;
  123768. ANISOTROPIC_TEXTURE: boolean;
  123769. ANISOTROPIC_TEXTUREDIRECTUV: number;
  123770. MAINUV1: boolean;
  123771. _areTexturesDirty: boolean;
  123772. _needUVs: boolean;
  123773. }
  123774. /**
  123775. * Define the code related to the anisotropic parameters of the pbr material.
  123776. */
  123777. export class PBRAnisotropicConfiguration {
  123778. private _isEnabled;
  123779. /**
  123780. * Defines if the anisotropy is enabled in the material.
  123781. */
  123782. isEnabled: boolean;
  123783. /**
  123784. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  123785. */
  123786. intensity: number;
  123787. /**
  123788. * Defines if the effect is along the tangents, bitangents or in between.
  123789. * By default, the effect is "strectching" the highlights along the tangents.
  123790. */
  123791. direction: Vector2;
  123792. private _texture;
  123793. /**
  123794. * Stores the anisotropy values in a texture.
  123795. * rg is direction (like normal from -1 to 1)
  123796. * b is a intensity
  123797. */
  123798. texture: Nullable<BaseTexture>;
  123799. /** @hidden */
  123800. private _internalMarkAllSubMeshesAsTexturesDirty;
  123801. /** @hidden */
  123802. _markAllSubMeshesAsTexturesDirty(): void;
  123803. /**
  123804. * Instantiate a new istance of anisotropy configuration.
  123805. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123806. */
  123807. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123808. /**
  123809. * Specifies that the submesh is ready to be used.
  123810. * @param defines the list of "defines" to update.
  123811. * @param scene defines the scene the material belongs to.
  123812. * @returns - boolean indicating that the submesh is ready or not.
  123813. */
  123814. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  123815. /**
  123816. * Checks to see if a texture is used in the material.
  123817. * @param defines the list of "defines" to update.
  123818. * @param mesh the mesh we are preparing the defines for.
  123819. * @param scene defines the scene the material belongs to.
  123820. */
  123821. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  123822. /**
  123823. * Binds the material data.
  123824. * @param uniformBuffer defines the Uniform buffer to fill in.
  123825. * @param scene defines the scene the material belongs to.
  123826. * @param isFrozen defines wether the material is frozen or not.
  123827. */
  123828. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  123829. /**
  123830. * Checks to see if a texture is used in the material.
  123831. * @param texture - Base texture to use.
  123832. * @returns - Boolean specifying if a texture is used in the material.
  123833. */
  123834. hasTexture(texture: BaseTexture): boolean;
  123835. /**
  123836. * Returns an array of the actively used textures.
  123837. * @param activeTextures Array of BaseTextures
  123838. */
  123839. getActiveTextures(activeTextures: BaseTexture[]): void;
  123840. /**
  123841. * Returns the animatable textures.
  123842. * @param animatables Array of animatable textures.
  123843. */
  123844. getAnimatables(animatables: IAnimatable[]): void;
  123845. /**
  123846. * Disposes the resources of the material.
  123847. * @param forceDisposeTextures - Forces the disposal of all textures.
  123848. */
  123849. dispose(forceDisposeTextures?: boolean): void;
  123850. /**
  123851. * Get the current class name of the texture useful for serialization or dynamic coding.
  123852. * @returns "PBRAnisotropicConfiguration"
  123853. */
  123854. getClassName(): string;
  123855. /**
  123856. * Add fallbacks to the effect fallbacks list.
  123857. * @param defines defines the Base texture to use.
  123858. * @param fallbacks defines the current fallback list.
  123859. * @param currentRank defines the current fallback rank.
  123860. * @returns the new fallback rank.
  123861. */
  123862. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123863. /**
  123864. * Add the required uniforms to the current list.
  123865. * @param uniforms defines the current uniform list.
  123866. */
  123867. static AddUniforms(uniforms: string[]): void;
  123868. /**
  123869. * Add the required uniforms to the current buffer.
  123870. * @param uniformBuffer defines the current uniform buffer.
  123871. */
  123872. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123873. /**
  123874. * Add the required samplers to the current list.
  123875. * @param samplers defines the current sampler list.
  123876. */
  123877. static AddSamplers(samplers: string[]): void;
  123878. /**
  123879. * Makes a duplicate of the current configuration into another one.
  123880. * @param anisotropicConfiguration define the config where to copy the info
  123881. */
  123882. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  123883. /**
  123884. * Serializes this anisotropy configuration.
  123885. * @returns - An object with the serialized config.
  123886. */
  123887. serialize(): any;
  123888. /**
  123889. * Parses a anisotropy Configuration from a serialized object.
  123890. * @param source - Serialized object.
  123891. * @param scene Defines the scene we are parsing for
  123892. * @param rootUrl Defines the rootUrl to load from
  123893. */
  123894. parse(source: any, scene: Scene, rootUrl: string): void;
  123895. }
  123896. }
  123897. declare module BABYLON {
  123898. /**
  123899. * @hidden
  123900. */
  123901. export interface IMaterialBRDFDefines {
  123902. BRDF_V_HEIGHT_CORRELATED: boolean;
  123903. MS_BRDF_ENERGY_CONSERVATION: boolean;
  123904. SPHERICAL_HARMONICS: boolean;
  123905. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  123906. /** @hidden */
  123907. _areMiscDirty: boolean;
  123908. }
  123909. /**
  123910. * Define the code related to the BRDF parameters of the pbr material.
  123911. */
  123912. export class PBRBRDFConfiguration {
  123913. /**
  123914. * Default value used for the energy conservation.
  123915. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  123916. */
  123917. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  123918. /**
  123919. * Default value used for the Smith Visibility Height Correlated mode.
  123920. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  123921. */
  123922. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  123923. /**
  123924. * Default value used for the IBL diffuse part.
  123925. * This can help switching back to the polynomials mode globally which is a tiny bit
  123926. * less GPU intensive at the drawback of a lower quality.
  123927. */
  123928. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  123929. /**
  123930. * Default value used for activating energy conservation for the specular workflow.
  123931. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  123932. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  123933. */
  123934. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  123935. private _useEnergyConservation;
  123936. /**
  123937. * Defines if the material uses energy conservation.
  123938. */
  123939. useEnergyConservation: boolean;
  123940. private _useSmithVisibilityHeightCorrelated;
  123941. /**
  123942. * LEGACY Mode set to false
  123943. * Defines if the material uses height smith correlated visibility term.
  123944. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  123945. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  123946. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  123947. * Not relying on height correlated will also disable energy conservation.
  123948. */
  123949. useSmithVisibilityHeightCorrelated: boolean;
  123950. private _useSphericalHarmonics;
  123951. /**
  123952. * LEGACY Mode set to false
  123953. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  123954. * diffuse part of the IBL.
  123955. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  123956. * to the ground truth.
  123957. */
  123958. useSphericalHarmonics: boolean;
  123959. private _useSpecularGlossinessInputEnergyConservation;
  123960. /**
  123961. * Defines if the material uses energy conservation, when the specular workflow is active.
  123962. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  123963. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  123964. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  123965. */
  123966. useSpecularGlossinessInputEnergyConservation: boolean;
  123967. /** @hidden */
  123968. private _internalMarkAllSubMeshesAsMiscDirty;
  123969. /** @hidden */
  123970. _markAllSubMeshesAsMiscDirty(): void;
  123971. /**
  123972. * Instantiate a new istance of clear coat configuration.
  123973. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  123974. */
  123975. constructor(markAllSubMeshesAsMiscDirty: () => void);
  123976. /**
  123977. * Checks to see if a texture is used in the material.
  123978. * @param defines the list of "defines" to update.
  123979. */
  123980. prepareDefines(defines: IMaterialBRDFDefines): void;
  123981. /**
  123982. * Get the current class name of the texture useful for serialization or dynamic coding.
  123983. * @returns "PBRClearCoatConfiguration"
  123984. */
  123985. getClassName(): string;
  123986. /**
  123987. * Makes a duplicate of the current configuration into another one.
  123988. * @param brdfConfiguration define the config where to copy the info
  123989. */
  123990. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  123991. /**
  123992. * Serializes this BRDF configuration.
  123993. * @returns - An object with the serialized config.
  123994. */
  123995. serialize(): any;
  123996. /**
  123997. * Parses a anisotropy Configuration from a serialized object.
  123998. * @param source - Serialized object.
  123999. * @param scene Defines the scene we are parsing for
  124000. * @param rootUrl Defines the rootUrl to load from
  124001. */
  124002. parse(source: any, scene: Scene, rootUrl: string): void;
  124003. }
  124004. }
  124005. declare module BABYLON {
  124006. /**
  124007. * @hidden
  124008. */
  124009. export interface IMaterialSheenDefines {
  124010. SHEEN: boolean;
  124011. SHEEN_TEXTURE: boolean;
  124012. SHEEN_TEXTUREDIRECTUV: number;
  124013. SHEEN_LINKWITHALBEDO: boolean;
  124014. SHEEN_ROUGHNESS: boolean;
  124015. SHEEN_ALBEDOSCALING: boolean;
  124016. /** @hidden */
  124017. _areTexturesDirty: boolean;
  124018. }
  124019. /**
  124020. * Define the code related to the Sheen parameters of the pbr material.
  124021. */
  124022. export class PBRSheenConfiguration {
  124023. private _isEnabled;
  124024. /**
  124025. * Defines if the material uses sheen.
  124026. */
  124027. isEnabled: boolean;
  124028. private _linkSheenWithAlbedo;
  124029. /**
  124030. * Defines if the sheen is linked to the sheen color.
  124031. */
  124032. linkSheenWithAlbedo: boolean;
  124033. /**
  124034. * Defines the sheen intensity.
  124035. */
  124036. intensity: number;
  124037. /**
  124038. * Defines the sheen color.
  124039. */
  124040. color: Color3;
  124041. private _texture;
  124042. /**
  124043. * Stores the sheen tint values in a texture.
  124044. * rgb is tint
  124045. * a is a intensity
  124046. */
  124047. texture: Nullable<BaseTexture>;
  124048. private _roughness;
  124049. /**
  124050. * Defines the sheen roughness.
  124051. * It is not taken into account if linkSheenWithAlbedo is true.
  124052. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  124053. */
  124054. roughness: Nullable<number>;
  124055. private _albedoScaling;
  124056. /**
  124057. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  124058. * It allows the strength of the sheen effect to not depend on the base color of the material,
  124059. * making it easier to setup and tweak the effect
  124060. */
  124061. albedoScaling: boolean;
  124062. /** @hidden */
  124063. private _internalMarkAllSubMeshesAsTexturesDirty;
  124064. /** @hidden */
  124065. _markAllSubMeshesAsTexturesDirty(): void;
  124066. /**
  124067. * Instantiate a new istance of clear coat configuration.
  124068. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  124069. */
  124070. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  124071. /**
  124072. * Specifies that the submesh is ready to be used.
  124073. * @param defines the list of "defines" to update.
  124074. * @param scene defines the scene the material belongs to.
  124075. * @returns - boolean indicating that the submesh is ready or not.
  124076. */
  124077. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  124078. /**
  124079. * Checks to see if a texture is used in the material.
  124080. * @param defines the list of "defines" to update.
  124081. * @param scene defines the scene the material belongs to.
  124082. */
  124083. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  124084. /**
  124085. * Binds the material data.
  124086. * @param uniformBuffer defines the Uniform buffer to fill in.
  124087. * @param scene defines the scene the material belongs to.
  124088. * @param isFrozen defines wether the material is frozen or not.
  124089. */
  124090. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  124091. /**
  124092. * Checks to see if a texture is used in the material.
  124093. * @param texture - Base texture to use.
  124094. * @returns - Boolean specifying if a texture is used in the material.
  124095. */
  124096. hasTexture(texture: BaseTexture): boolean;
  124097. /**
  124098. * Returns an array of the actively used textures.
  124099. * @param activeTextures Array of BaseTextures
  124100. */
  124101. getActiveTextures(activeTextures: BaseTexture[]): void;
  124102. /**
  124103. * Returns the animatable textures.
  124104. * @param animatables Array of animatable textures.
  124105. */
  124106. getAnimatables(animatables: IAnimatable[]): void;
  124107. /**
  124108. * Disposes the resources of the material.
  124109. * @param forceDisposeTextures - Forces the disposal of all textures.
  124110. */
  124111. dispose(forceDisposeTextures?: boolean): void;
  124112. /**
  124113. * Get the current class name of the texture useful for serialization or dynamic coding.
  124114. * @returns "PBRSheenConfiguration"
  124115. */
  124116. getClassName(): string;
  124117. /**
  124118. * Add fallbacks to the effect fallbacks list.
  124119. * @param defines defines the Base texture to use.
  124120. * @param fallbacks defines the current fallback list.
  124121. * @param currentRank defines the current fallback rank.
  124122. * @returns the new fallback rank.
  124123. */
  124124. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  124125. /**
  124126. * Add the required uniforms to the current list.
  124127. * @param uniforms defines the current uniform list.
  124128. */
  124129. static AddUniforms(uniforms: string[]): void;
  124130. /**
  124131. * Add the required uniforms to the current buffer.
  124132. * @param uniformBuffer defines the current uniform buffer.
  124133. */
  124134. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  124135. /**
  124136. * Add the required samplers to the current list.
  124137. * @param samplers defines the current sampler list.
  124138. */
  124139. static AddSamplers(samplers: string[]): void;
  124140. /**
  124141. * Makes a duplicate of the current configuration into another one.
  124142. * @param sheenConfiguration define the config where to copy the info
  124143. */
  124144. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  124145. /**
  124146. * Serializes this BRDF configuration.
  124147. * @returns - An object with the serialized config.
  124148. */
  124149. serialize(): any;
  124150. /**
  124151. * Parses a anisotropy Configuration from a serialized object.
  124152. * @param source - Serialized object.
  124153. * @param scene Defines the scene we are parsing for
  124154. * @param rootUrl Defines the rootUrl to load from
  124155. */
  124156. parse(source: any, scene: Scene, rootUrl: string): void;
  124157. }
  124158. }
  124159. declare module BABYLON {
  124160. /**
  124161. * @hidden
  124162. */
  124163. export interface IMaterialSubSurfaceDefines {
  124164. SUBSURFACE: boolean;
  124165. SS_REFRACTION: boolean;
  124166. SS_TRANSLUCENCY: boolean;
  124167. SS_SCATERRING: boolean;
  124168. SS_THICKNESSANDMASK_TEXTURE: boolean;
  124169. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  124170. SS_REFRACTIONMAP_3D: boolean;
  124171. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  124172. SS_LODINREFRACTIONALPHA: boolean;
  124173. SS_GAMMAREFRACTION: boolean;
  124174. SS_RGBDREFRACTION: boolean;
  124175. SS_LINEARSPECULARREFRACTION: boolean;
  124176. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  124177. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  124178. /** @hidden */
  124179. _areTexturesDirty: boolean;
  124180. }
  124181. /**
  124182. * Define the code related to the sub surface parameters of the pbr material.
  124183. */
  124184. export class PBRSubSurfaceConfiguration {
  124185. private _isRefractionEnabled;
  124186. /**
  124187. * Defines if the refraction is enabled in the material.
  124188. */
  124189. isRefractionEnabled: boolean;
  124190. private _isTranslucencyEnabled;
  124191. /**
  124192. * Defines if the translucency is enabled in the material.
  124193. */
  124194. isTranslucencyEnabled: boolean;
  124195. private _isScatteringEnabled;
  124196. /**
  124197. * Defines the refraction intensity of the material.
  124198. * The refraction when enabled replaces the Diffuse part of the material.
  124199. * The intensity helps transitionning between diffuse and refraction.
  124200. */
  124201. refractionIntensity: number;
  124202. /**
  124203. * Defines the translucency intensity of the material.
  124204. * When translucency has been enabled, this defines how much of the "translucency"
  124205. * is addded to the diffuse part of the material.
  124206. */
  124207. translucencyIntensity: number;
  124208. /**
  124209. * Defines the scattering intensity of the material.
  124210. * When scattering has been enabled, this defines how much of the "scattered light"
  124211. * is addded to the diffuse part of the material.
  124212. */
  124213. scatteringIntensity: number;
  124214. private _thicknessTexture;
  124215. /**
  124216. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  124217. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  124218. * 0 would mean minimumThickness
  124219. * 1 would mean maximumThickness
  124220. * The other channels might be use as a mask to vary the different effects intensity.
  124221. */
  124222. thicknessTexture: Nullable<BaseTexture>;
  124223. private _refractionTexture;
  124224. /**
  124225. * Defines the texture to use for refraction.
  124226. */
  124227. refractionTexture: Nullable<BaseTexture>;
  124228. private _indexOfRefraction;
  124229. /**
  124230. * Defines the index of refraction used in the material.
  124231. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  124232. */
  124233. indexOfRefraction: number;
  124234. private _invertRefractionY;
  124235. /**
  124236. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  124237. */
  124238. invertRefractionY: boolean;
  124239. private _linkRefractionWithTransparency;
  124240. /**
  124241. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  124242. * Materials half opaque for instance using refraction could benefit from this control.
  124243. */
  124244. linkRefractionWithTransparency: boolean;
  124245. /**
  124246. * Defines the minimum thickness stored in the thickness map.
  124247. * If no thickness map is defined, this value will be used to simulate thickness.
  124248. */
  124249. minimumThickness: number;
  124250. /**
  124251. * Defines the maximum thickness stored in the thickness map.
  124252. */
  124253. maximumThickness: number;
  124254. /**
  124255. * Defines the volume tint of the material.
  124256. * This is used for both translucency and scattering.
  124257. */
  124258. tintColor: Color3;
  124259. /**
  124260. * Defines the distance at which the tint color should be found in the media.
  124261. * This is used for refraction only.
  124262. */
  124263. tintColorAtDistance: number;
  124264. /**
  124265. * Defines how far each channel transmit through the media.
  124266. * It is defined as a color to simplify it selection.
  124267. */
  124268. diffusionDistance: Color3;
  124269. private _useMaskFromThicknessTexture;
  124270. /**
  124271. * Stores the intensity of the different subsurface effects in the thickness texture.
  124272. * * the green channel is the translucency intensity.
  124273. * * the blue channel is the scattering intensity.
  124274. * * the alpha channel is the refraction intensity.
  124275. */
  124276. useMaskFromThicknessTexture: boolean;
  124277. /** @hidden */
  124278. private _internalMarkAllSubMeshesAsTexturesDirty;
  124279. /** @hidden */
  124280. _markAllSubMeshesAsTexturesDirty(): void;
  124281. /**
  124282. * Instantiate a new istance of sub surface configuration.
  124283. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  124284. */
  124285. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  124286. /**
  124287. * Gets wehter the submesh is ready to be used or not.
  124288. * @param defines the list of "defines" to update.
  124289. * @param scene defines the scene the material belongs to.
  124290. * @returns - boolean indicating that the submesh is ready or not.
  124291. */
  124292. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  124293. /**
  124294. * Checks to see if a texture is used in the material.
  124295. * @param defines the list of "defines" to update.
  124296. * @param scene defines the scene to the material belongs to.
  124297. */
  124298. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  124299. /**
  124300. * Binds the material data.
  124301. * @param uniformBuffer defines the Uniform buffer to fill in.
  124302. * @param scene defines the scene the material belongs to.
  124303. * @param engine defines the engine the material belongs to.
  124304. * @param isFrozen defines wether the material is frozen or not.
  124305. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  124306. */
  124307. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  124308. /**
  124309. * Unbinds the material from the mesh.
  124310. * @param activeEffect defines the effect that should be unbound from.
  124311. * @returns true if unbound, otherwise false
  124312. */
  124313. unbind(activeEffect: Effect): boolean;
  124314. /**
  124315. * Returns the texture used for refraction or null if none is used.
  124316. * @param scene defines the scene the material belongs to.
  124317. * @returns - Refraction texture if present. If no refraction texture and refraction
  124318. * is linked with transparency, returns environment texture. Otherwise, returns null.
  124319. */
  124320. private _getRefractionTexture;
  124321. /**
  124322. * Returns true if alpha blending should be disabled.
  124323. */
  124324. get disableAlphaBlending(): boolean;
  124325. /**
  124326. * Fills the list of render target textures.
  124327. * @param renderTargets the list of render targets to update
  124328. */
  124329. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  124330. /**
  124331. * Checks to see if a texture is used in the material.
  124332. * @param texture - Base texture to use.
  124333. * @returns - Boolean specifying if a texture is used in the material.
  124334. */
  124335. hasTexture(texture: BaseTexture): boolean;
  124336. /**
  124337. * Gets a boolean indicating that current material needs to register RTT
  124338. * @returns true if this uses a render target otherwise false.
  124339. */
  124340. hasRenderTargetTextures(): boolean;
  124341. /**
  124342. * Returns an array of the actively used textures.
  124343. * @param activeTextures Array of BaseTextures
  124344. */
  124345. getActiveTextures(activeTextures: BaseTexture[]): void;
  124346. /**
  124347. * Returns the animatable textures.
  124348. * @param animatables Array of animatable textures.
  124349. */
  124350. getAnimatables(animatables: IAnimatable[]): void;
  124351. /**
  124352. * Disposes the resources of the material.
  124353. * @param forceDisposeTextures - Forces the disposal of all textures.
  124354. */
  124355. dispose(forceDisposeTextures?: boolean): void;
  124356. /**
  124357. * Get the current class name of the texture useful for serialization or dynamic coding.
  124358. * @returns "PBRSubSurfaceConfiguration"
  124359. */
  124360. getClassName(): string;
  124361. /**
  124362. * Add fallbacks to the effect fallbacks list.
  124363. * @param defines defines the Base texture to use.
  124364. * @param fallbacks defines the current fallback list.
  124365. * @param currentRank defines the current fallback rank.
  124366. * @returns the new fallback rank.
  124367. */
  124368. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  124369. /**
  124370. * Add the required uniforms to the current list.
  124371. * @param uniforms defines the current uniform list.
  124372. */
  124373. static AddUniforms(uniforms: string[]): void;
  124374. /**
  124375. * Add the required samplers to the current list.
  124376. * @param samplers defines the current sampler list.
  124377. */
  124378. static AddSamplers(samplers: string[]): void;
  124379. /**
  124380. * Add the required uniforms to the current buffer.
  124381. * @param uniformBuffer defines the current uniform buffer.
  124382. */
  124383. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  124384. /**
  124385. * Makes a duplicate of the current configuration into another one.
  124386. * @param configuration define the config where to copy the info
  124387. */
  124388. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  124389. /**
  124390. * Serializes this Sub Surface configuration.
  124391. * @returns - An object with the serialized config.
  124392. */
  124393. serialize(): any;
  124394. /**
  124395. * Parses a anisotropy Configuration from a serialized object.
  124396. * @param source - Serialized object.
  124397. * @param scene Defines the scene we are parsing for
  124398. * @param rootUrl Defines the rootUrl to load from
  124399. */
  124400. parse(source: any, scene: Scene, rootUrl: string): void;
  124401. }
  124402. }
  124403. declare module BABYLON {
  124404. /** @hidden */
  124405. export var pbrFragmentDeclaration: {
  124406. name: string;
  124407. shader: string;
  124408. };
  124409. }
  124410. declare module BABYLON {
  124411. /** @hidden */
  124412. export var pbrUboDeclaration: {
  124413. name: string;
  124414. shader: string;
  124415. };
  124416. }
  124417. declare module BABYLON {
  124418. /** @hidden */
  124419. export var pbrFragmentExtraDeclaration: {
  124420. name: string;
  124421. shader: string;
  124422. };
  124423. }
  124424. declare module BABYLON {
  124425. /** @hidden */
  124426. export var pbrFragmentSamplersDeclaration: {
  124427. name: string;
  124428. shader: string;
  124429. };
  124430. }
  124431. declare module BABYLON {
  124432. /** @hidden */
  124433. export var pbrHelperFunctions: {
  124434. name: string;
  124435. shader: string;
  124436. };
  124437. }
  124438. declare module BABYLON {
  124439. /** @hidden */
  124440. export var harmonicsFunctions: {
  124441. name: string;
  124442. shader: string;
  124443. };
  124444. }
  124445. declare module BABYLON {
  124446. /** @hidden */
  124447. export var pbrDirectLightingSetupFunctions: {
  124448. name: string;
  124449. shader: string;
  124450. };
  124451. }
  124452. declare module BABYLON {
  124453. /** @hidden */
  124454. export var pbrDirectLightingFalloffFunctions: {
  124455. name: string;
  124456. shader: string;
  124457. };
  124458. }
  124459. declare module BABYLON {
  124460. /** @hidden */
  124461. export var pbrBRDFFunctions: {
  124462. name: string;
  124463. shader: string;
  124464. };
  124465. }
  124466. declare module BABYLON {
  124467. /** @hidden */
  124468. export var pbrDirectLightingFunctions: {
  124469. name: string;
  124470. shader: string;
  124471. };
  124472. }
  124473. declare module BABYLON {
  124474. /** @hidden */
  124475. export var pbrIBLFunctions: {
  124476. name: string;
  124477. shader: string;
  124478. };
  124479. }
  124480. declare module BABYLON {
  124481. /** @hidden */
  124482. export var pbrDebug: {
  124483. name: string;
  124484. shader: string;
  124485. };
  124486. }
  124487. declare module BABYLON {
  124488. /** @hidden */
  124489. export var pbrPixelShader: {
  124490. name: string;
  124491. shader: string;
  124492. };
  124493. }
  124494. declare module BABYLON {
  124495. /** @hidden */
  124496. export var pbrVertexDeclaration: {
  124497. name: string;
  124498. shader: string;
  124499. };
  124500. }
  124501. declare module BABYLON {
  124502. /** @hidden */
  124503. export var pbrVertexShader: {
  124504. name: string;
  124505. shader: string;
  124506. };
  124507. }
  124508. declare module BABYLON {
  124509. /**
  124510. * Manages the defines for the PBR Material.
  124511. * @hidden
  124512. */
  124513. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  124514. PBR: boolean;
  124515. MAINUV1: boolean;
  124516. MAINUV2: boolean;
  124517. UV1: boolean;
  124518. UV2: boolean;
  124519. ALBEDO: boolean;
  124520. GAMMAALBEDO: boolean;
  124521. ALBEDODIRECTUV: number;
  124522. VERTEXCOLOR: boolean;
  124523. AMBIENT: boolean;
  124524. AMBIENTDIRECTUV: number;
  124525. AMBIENTINGRAYSCALE: boolean;
  124526. OPACITY: boolean;
  124527. VERTEXALPHA: boolean;
  124528. OPACITYDIRECTUV: number;
  124529. OPACITYRGB: boolean;
  124530. ALPHATEST: boolean;
  124531. DEPTHPREPASS: boolean;
  124532. ALPHABLEND: boolean;
  124533. ALPHAFROMALBEDO: boolean;
  124534. ALPHATESTVALUE: string;
  124535. SPECULAROVERALPHA: boolean;
  124536. RADIANCEOVERALPHA: boolean;
  124537. ALPHAFRESNEL: boolean;
  124538. LINEARALPHAFRESNEL: boolean;
  124539. PREMULTIPLYALPHA: boolean;
  124540. EMISSIVE: boolean;
  124541. EMISSIVEDIRECTUV: number;
  124542. REFLECTIVITY: boolean;
  124543. REFLECTIVITYDIRECTUV: number;
  124544. SPECULARTERM: boolean;
  124545. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  124546. MICROSURFACEAUTOMATIC: boolean;
  124547. LODBASEDMICROSFURACE: boolean;
  124548. MICROSURFACEMAP: boolean;
  124549. MICROSURFACEMAPDIRECTUV: number;
  124550. METALLICWORKFLOW: boolean;
  124551. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  124552. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  124553. METALLNESSSTOREINMETALMAPBLUE: boolean;
  124554. AOSTOREINMETALMAPRED: boolean;
  124555. METALLICF0FACTORFROMMETALLICMAP: boolean;
  124556. ENVIRONMENTBRDF: boolean;
  124557. ENVIRONMENTBRDF_RGBD: boolean;
  124558. NORMAL: boolean;
  124559. TANGENT: boolean;
  124560. BUMP: boolean;
  124561. BUMPDIRECTUV: number;
  124562. OBJECTSPACE_NORMALMAP: boolean;
  124563. PARALLAX: boolean;
  124564. PARALLAXOCCLUSION: boolean;
  124565. NORMALXYSCALE: boolean;
  124566. LIGHTMAP: boolean;
  124567. LIGHTMAPDIRECTUV: number;
  124568. USELIGHTMAPASSHADOWMAP: boolean;
  124569. GAMMALIGHTMAP: boolean;
  124570. RGBDLIGHTMAP: boolean;
  124571. REFLECTION: boolean;
  124572. REFLECTIONMAP_3D: boolean;
  124573. REFLECTIONMAP_SPHERICAL: boolean;
  124574. REFLECTIONMAP_PLANAR: boolean;
  124575. REFLECTIONMAP_CUBIC: boolean;
  124576. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  124577. REFLECTIONMAP_PROJECTION: boolean;
  124578. REFLECTIONMAP_SKYBOX: boolean;
  124579. REFLECTIONMAP_EXPLICIT: boolean;
  124580. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  124581. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  124582. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  124583. INVERTCUBICMAP: boolean;
  124584. USESPHERICALFROMREFLECTIONMAP: boolean;
  124585. USEIRRADIANCEMAP: boolean;
  124586. SPHERICAL_HARMONICS: boolean;
  124587. USESPHERICALINVERTEX: boolean;
  124588. REFLECTIONMAP_OPPOSITEZ: boolean;
  124589. LODINREFLECTIONALPHA: boolean;
  124590. GAMMAREFLECTION: boolean;
  124591. RGBDREFLECTION: boolean;
  124592. LINEARSPECULARREFLECTION: boolean;
  124593. RADIANCEOCCLUSION: boolean;
  124594. HORIZONOCCLUSION: boolean;
  124595. INSTANCES: boolean;
  124596. NUM_BONE_INFLUENCERS: number;
  124597. BonesPerMesh: number;
  124598. BONETEXTURE: boolean;
  124599. NONUNIFORMSCALING: boolean;
  124600. MORPHTARGETS: boolean;
  124601. MORPHTARGETS_NORMAL: boolean;
  124602. MORPHTARGETS_TANGENT: boolean;
  124603. MORPHTARGETS_UV: boolean;
  124604. NUM_MORPH_INFLUENCERS: number;
  124605. IMAGEPROCESSING: boolean;
  124606. VIGNETTE: boolean;
  124607. VIGNETTEBLENDMODEMULTIPLY: boolean;
  124608. VIGNETTEBLENDMODEOPAQUE: boolean;
  124609. TONEMAPPING: boolean;
  124610. TONEMAPPING_ACES: boolean;
  124611. CONTRAST: boolean;
  124612. COLORCURVES: boolean;
  124613. COLORGRADING: boolean;
  124614. COLORGRADING3D: boolean;
  124615. SAMPLER3DGREENDEPTH: boolean;
  124616. SAMPLER3DBGRMAP: boolean;
  124617. IMAGEPROCESSINGPOSTPROCESS: boolean;
  124618. EXPOSURE: boolean;
  124619. MULTIVIEW: boolean;
  124620. USEPHYSICALLIGHTFALLOFF: boolean;
  124621. USEGLTFLIGHTFALLOFF: boolean;
  124622. TWOSIDEDLIGHTING: boolean;
  124623. SHADOWFLOAT: boolean;
  124624. CLIPPLANE: boolean;
  124625. CLIPPLANE2: boolean;
  124626. CLIPPLANE3: boolean;
  124627. CLIPPLANE4: boolean;
  124628. CLIPPLANE5: boolean;
  124629. CLIPPLANE6: boolean;
  124630. POINTSIZE: boolean;
  124631. FOG: boolean;
  124632. LOGARITHMICDEPTH: boolean;
  124633. FORCENORMALFORWARD: boolean;
  124634. SPECULARAA: boolean;
  124635. CLEARCOAT: boolean;
  124636. CLEARCOAT_DEFAULTIOR: boolean;
  124637. CLEARCOAT_TEXTURE: boolean;
  124638. CLEARCOAT_TEXTUREDIRECTUV: number;
  124639. CLEARCOAT_BUMP: boolean;
  124640. CLEARCOAT_BUMPDIRECTUV: number;
  124641. CLEARCOAT_TINT: boolean;
  124642. CLEARCOAT_TINT_TEXTURE: boolean;
  124643. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  124644. ANISOTROPIC: boolean;
  124645. ANISOTROPIC_TEXTURE: boolean;
  124646. ANISOTROPIC_TEXTUREDIRECTUV: number;
  124647. BRDF_V_HEIGHT_CORRELATED: boolean;
  124648. MS_BRDF_ENERGY_CONSERVATION: boolean;
  124649. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  124650. SHEEN: boolean;
  124651. SHEEN_TEXTURE: boolean;
  124652. SHEEN_TEXTUREDIRECTUV: number;
  124653. SHEEN_LINKWITHALBEDO: boolean;
  124654. SHEEN_ROUGHNESS: boolean;
  124655. SHEEN_ALBEDOSCALING: boolean;
  124656. SUBSURFACE: boolean;
  124657. SS_REFRACTION: boolean;
  124658. SS_TRANSLUCENCY: boolean;
  124659. SS_SCATERRING: boolean;
  124660. SS_THICKNESSANDMASK_TEXTURE: boolean;
  124661. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  124662. SS_REFRACTIONMAP_3D: boolean;
  124663. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  124664. SS_LODINREFRACTIONALPHA: boolean;
  124665. SS_GAMMAREFRACTION: boolean;
  124666. SS_RGBDREFRACTION: boolean;
  124667. SS_LINEARSPECULARREFRACTION: boolean;
  124668. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  124669. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  124670. UNLIT: boolean;
  124671. DEBUGMODE: number;
  124672. /**
  124673. * Initializes the PBR Material defines.
  124674. */
  124675. constructor();
  124676. /**
  124677. * Resets the PBR Material defines.
  124678. */
  124679. reset(): void;
  124680. }
  124681. /**
  124682. * The Physically based material base class of BJS.
  124683. *
  124684. * This offers the main features of a standard PBR material.
  124685. * For more information, please refer to the documentation :
  124686. * https://doc.babylonjs.com/how_to/physically_based_rendering
  124687. */
  124688. export abstract class PBRBaseMaterial extends PushMaterial {
  124689. /**
  124690. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  124691. */
  124692. static readonly PBRMATERIAL_OPAQUE: number;
  124693. /**
  124694. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  124695. */
  124696. static readonly PBRMATERIAL_ALPHATEST: number;
  124697. /**
  124698. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124699. */
  124700. static readonly PBRMATERIAL_ALPHABLEND: number;
  124701. /**
  124702. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124703. * They are also discarded below the alpha cutoff threshold to improve performances.
  124704. */
  124705. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  124706. /**
  124707. * Defines the default value of how much AO map is occluding the analytical lights
  124708. * (point spot...).
  124709. */
  124710. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  124711. /**
  124712. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  124713. */
  124714. static readonly LIGHTFALLOFF_PHYSICAL: number;
  124715. /**
  124716. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  124717. * to enhance interoperability with other engines.
  124718. */
  124719. static readonly LIGHTFALLOFF_GLTF: number;
  124720. /**
  124721. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  124722. * to enhance interoperability with other materials.
  124723. */
  124724. static readonly LIGHTFALLOFF_STANDARD: number;
  124725. /**
  124726. * Intensity of the direct lights e.g. the four lights available in your scene.
  124727. * This impacts both the direct diffuse and specular highlights.
  124728. */
  124729. protected _directIntensity: number;
  124730. /**
  124731. * Intensity of the emissive part of the material.
  124732. * This helps controlling the emissive effect without modifying the emissive color.
  124733. */
  124734. protected _emissiveIntensity: number;
  124735. /**
  124736. * Intensity of the environment e.g. how much the environment will light the object
  124737. * either through harmonics for rough material or through the refelction for shiny ones.
  124738. */
  124739. protected _environmentIntensity: number;
  124740. /**
  124741. * This is a special control allowing the reduction of the specular highlights coming from the
  124742. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  124743. */
  124744. protected _specularIntensity: number;
  124745. /**
  124746. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  124747. */
  124748. private _lightingInfos;
  124749. /**
  124750. * Debug Control allowing disabling the bump map on this material.
  124751. */
  124752. protected _disableBumpMap: boolean;
  124753. /**
  124754. * AKA Diffuse Texture in standard nomenclature.
  124755. */
  124756. protected _albedoTexture: Nullable<BaseTexture>;
  124757. /**
  124758. * AKA Occlusion Texture in other nomenclature.
  124759. */
  124760. protected _ambientTexture: Nullable<BaseTexture>;
  124761. /**
  124762. * AKA Occlusion Texture Intensity in other nomenclature.
  124763. */
  124764. protected _ambientTextureStrength: number;
  124765. /**
  124766. * Defines how much the AO map is occluding the analytical lights (point spot...).
  124767. * 1 means it completely occludes it
  124768. * 0 mean it has no impact
  124769. */
  124770. protected _ambientTextureImpactOnAnalyticalLights: number;
  124771. /**
  124772. * Stores the alpha values in a texture.
  124773. */
  124774. protected _opacityTexture: Nullable<BaseTexture>;
  124775. /**
  124776. * Stores the reflection values in a texture.
  124777. */
  124778. protected _reflectionTexture: Nullable<BaseTexture>;
  124779. /**
  124780. * Stores the emissive values in a texture.
  124781. */
  124782. protected _emissiveTexture: Nullable<BaseTexture>;
  124783. /**
  124784. * AKA Specular texture in other nomenclature.
  124785. */
  124786. protected _reflectivityTexture: Nullable<BaseTexture>;
  124787. /**
  124788. * Used to switch from specular/glossiness to metallic/roughness workflow.
  124789. */
  124790. protected _metallicTexture: Nullable<BaseTexture>;
  124791. /**
  124792. * Specifies the metallic scalar of the metallic/roughness workflow.
  124793. * Can also be used to scale the metalness values of the metallic texture.
  124794. */
  124795. protected _metallic: Nullable<number>;
  124796. /**
  124797. * Specifies the roughness scalar of the metallic/roughness workflow.
  124798. * Can also be used to scale the roughness values of the metallic texture.
  124799. */
  124800. protected _roughness: Nullable<number>;
  124801. /**
  124802. * Specifies the an F0 factor to help configuring the material F0.
  124803. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  124804. * to 0.5 the previously hard coded value stays the same.
  124805. * Can also be used to scale the F0 values of the metallic texture.
  124806. */
  124807. protected _metallicF0Factor: number;
  124808. /**
  124809. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  124810. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  124811. * your expectation as it multiplies with the texture data.
  124812. */
  124813. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  124814. /**
  124815. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  124816. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  124817. */
  124818. protected _microSurfaceTexture: Nullable<BaseTexture>;
  124819. /**
  124820. * Stores surface normal data used to displace a mesh in a texture.
  124821. */
  124822. protected _bumpTexture: Nullable<BaseTexture>;
  124823. /**
  124824. * Stores the pre-calculated light information of a mesh in a texture.
  124825. */
  124826. protected _lightmapTexture: Nullable<BaseTexture>;
  124827. /**
  124828. * The color of a material in ambient lighting.
  124829. */
  124830. protected _ambientColor: Color3;
  124831. /**
  124832. * AKA Diffuse Color in other nomenclature.
  124833. */
  124834. protected _albedoColor: Color3;
  124835. /**
  124836. * AKA Specular Color in other nomenclature.
  124837. */
  124838. protected _reflectivityColor: Color3;
  124839. /**
  124840. * The color applied when light is reflected from a material.
  124841. */
  124842. protected _reflectionColor: Color3;
  124843. /**
  124844. * The color applied when light is emitted from a material.
  124845. */
  124846. protected _emissiveColor: Color3;
  124847. /**
  124848. * AKA Glossiness in other nomenclature.
  124849. */
  124850. protected _microSurface: number;
  124851. /**
  124852. * Specifies that the material will use the light map as a show map.
  124853. */
  124854. protected _useLightmapAsShadowmap: boolean;
  124855. /**
  124856. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  124857. * makes the reflect vector face the model (under horizon).
  124858. */
  124859. protected _useHorizonOcclusion: boolean;
  124860. /**
  124861. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  124862. * too much the area relying on ambient texture to define their ambient occlusion.
  124863. */
  124864. protected _useRadianceOcclusion: boolean;
  124865. /**
  124866. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  124867. */
  124868. protected _useAlphaFromAlbedoTexture: boolean;
  124869. /**
  124870. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  124871. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  124872. */
  124873. protected _useSpecularOverAlpha: boolean;
  124874. /**
  124875. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  124876. */
  124877. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  124878. /**
  124879. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  124880. */
  124881. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  124882. /**
  124883. * Specifies if the metallic texture contains the roughness information in its green channel.
  124884. */
  124885. protected _useRoughnessFromMetallicTextureGreen: boolean;
  124886. /**
  124887. * Specifies if the metallic texture contains the metallness information in its blue channel.
  124888. */
  124889. protected _useMetallnessFromMetallicTextureBlue: boolean;
  124890. /**
  124891. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  124892. */
  124893. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  124894. /**
  124895. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  124896. */
  124897. protected _useAmbientInGrayScale: boolean;
  124898. /**
  124899. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  124900. * The material will try to infer what glossiness each pixel should be.
  124901. */
  124902. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  124903. /**
  124904. * Defines the falloff type used in this material.
  124905. * It by default is Physical.
  124906. */
  124907. protected _lightFalloff: number;
  124908. /**
  124909. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  124910. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  124911. */
  124912. protected _useRadianceOverAlpha: boolean;
  124913. /**
  124914. * Allows using an object space normal map (instead of tangent space).
  124915. */
  124916. protected _useObjectSpaceNormalMap: boolean;
  124917. /**
  124918. * Allows using the bump map in parallax mode.
  124919. */
  124920. protected _useParallax: boolean;
  124921. /**
  124922. * Allows using the bump map in parallax occlusion mode.
  124923. */
  124924. protected _useParallaxOcclusion: boolean;
  124925. /**
  124926. * Controls the scale bias of the parallax mode.
  124927. */
  124928. protected _parallaxScaleBias: number;
  124929. /**
  124930. * If sets to true, disables all the lights affecting the material.
  124931. */
  124932. protected _disableLighting: boolean;
  124933. /**
  124934. * Number of Simultaneous lights allowed on the material.
  124935. */
  124936. protected _maxSimultaneousLights: number;
  124937. /**
  124938. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  124939. */
  124940. protected _invertNormalMapX: boolean;
  124941. /**
  124942. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  124943. */
  124944. protected _invertNormalMapY: boolean;
  124945. /**
  124946. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  124947. */
  124948. protected _twoSidedLighting: boolean;
  124949. /**
  124950. * Defines the alpha limits in alpha test mode.
  124951. */
  124952. protected _alphaCutOff: number;
  124953. /**
  124954. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  124955. */
  124956. protected _forceAlphaTest: boolean;
  124957. /**
  124958. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124959. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  124960. */
  124961. protected _useAlphaFresnel: boolean;
  124962. /**
  124963. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124964. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  124965. */
  124966. protected _useLinearAlphaFresnel: boolean;
  124967. /**
  124968. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  124969. * from cos thetav and roughness:
  124970. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  124971. */
  124972. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  124973. /**
  124974. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  124975. */
  124976. protected _forceIrradianceInFragment: boolean;
  124977. /**
  124978. * Force normal to face away from face.
  124979. */
  124980. protected _forceNormalForward: boolean;
  124981. /**
  124982. * Enables specular anti aliasing in the PBR shader.
  124983. * It will both interacts on the Geometry for analytical and IBL lighting.
  124984. * It also prefilter the roughness map based on the bump values.
  124985. */
  124986. protected _enableSpecularAntiAliasing: boolean;
  124987. /**
  124988. * Default configuration related to image processing available in the PBR Material.
  124989. */
  124990. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  124991. /**
  124992. * Keep track of the image processing observer to allow dispose and replace.
  124993. */
  124994. private _imageProcessingObserver;
  124995. /**
  124996. * Attaches a new image processing configuration to the PBR Material.
  124997. * @param configuration
  124998. */
  124999. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  125000. /**
  125001. * Stores the available render targets.
  125002. */
  125003. private _renderTargets;
  125004. /**
  125005. * Sets the global ambient color for the material used in lighting calculations.
  125006. */
  125007. private _globalAmbientColor;
  125008. /**
  125009. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  125010. */
  125011. private _useLogarithmicDepth;
  125012. /**
  125013. * If set to true, no lighting calculations will be applied.
  125014. */
  125015. private _unlit;
  125016. private _debugMode;
  125017. /**
  125018. * @hidden
  125019. * This is reserved for the inspector.
  125020. * Defines the material debug mode.
  125021. * It helps seeing only some components of the material while troubleshooting.
  125022. */
  125023. debugMode: number;
  125024. /**
  125025. * @hidden
  125026. * This is reserved for the inspector.
  125027. * Specify from where on screen the debug mode should start.
  125028. * The value goes from -1 (full screen) to 1 (not visible)
  125029. * It helps with side by side comparison against the final render
  125030. * This defaults to -1
  125031. */
  125032. private debugLimit;
  125033. /**
  125034. * @hidden
  125035. * This is reserved for the inspector.
  125036. * As the default viewing range might not be enough (if the ambient is really small for instance)
  125037. * You can use the factor to better multiply the final value.
  125038. */
  125039. private debugFactor;
  125040. /**
  125041. * Defines the clear coat layer parameters for the material.
  125042. */
  125043. readonly clearCoat: PBRClearCoatConfiguration;
  125044. /**
  125045. * Defines the anisotropic parameters for the material.
  125046. */
  125047. readonly anisotropy: PBRAnisotropicConfiguration;
  125048. /**
  125049. * Defines the BRDF parameters for the material.
  125050. */
  125051. readonly brdf: PBRBRDFConfiguration;
  125052. /**
  125053. * Defines the Sheen parameters for the material.
  125054. */
  125055. readonly sheen: PBRSheenConfiguration;
  125056. /**
  125057. * Defines the SubSurface parameters for the material.
  125058. */
  125059. readonly subSurface: PBRSubSurfaceConfiguration;
  125060. /**
  125061. * Custom callback helping to override the default shader used in the material.
  125062. */
  125063. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  125064. protected _rebuildInParallel: boolean;
  125065. /**
  125066. * Instantiates a new PBRMaterial instance.
  125067. *
  125068. * @param name The material name
  125069. * @param scene The scene the material will be use in.
  125070. */
  125071. constructor(name: string, scene: Scene);
  125072. /**
  125073. * Gets a boolean indicating that current material needs to register RTT
  125074. */
  125075. get hasRenderTargetTextures(): boolean;
  125076. /**
  125077. * Gets the name of the material class.
  125078. */
  125079. getClassName(): string;
  125080. /**
  125081. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  125082. */
  125083. get useLogarithmicDepth(): boolean;
  125084. /**
  125085. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  125086. */
  125087. set useLogarithmicDepth(value: boolean);
  125088. /**
  125089. * Returns true if alpha blending should be disabled.
  125090. */
  125091. protected get _disableAlphaBlending(): boolean;
  125092. /**
  125093. * Specifies whether or not this material should be rendered in alpha blend mode.
  125094. */
  125095. needAlphaBlending(): boolean;
  125096. /**
  125097. * Specifies whether or not this material should be rendered in alpha test mode.
  125098. */
  125099. needAlphaTesting(): boolean;
  125100. /**
  125101. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  125102. */
  125103. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  125104. /**
  125105. * Gets the texture used for the alpha test.
  125106. */
  125107. getAlphaTestTexture(): Nullable<BaseTexture>;
  125108. /**
  125109. * Specifies that the submesh is ready to be used.
  125110. * @param mesh - BJS mesh.
  125111. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  125112. * @param useInstances - Specifies that instances should be used.
  125113. * @returns - boolean indicating that the submesh is ready or not.
  125114. */
  125115. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  125116. /**
  125117. * Specifies if the material uses metallic roughness workflow.
  125118. * @returns boolean specifiying if the material uses metallic roughness workflow.
  125119. */
  125120. isMetallicWorkflow(): boolean;
  125121. private _prepareEffect;
  125122. private _prepareDefines;
  125123. /**
  125124. * Force shader compilation
  125125. */
  125126. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  125127. /**
  125128. * Initializes the uniform buffer layout for the shader.
  125129. */
  125130. buildUniformLayout(): void;
  125131. /**
  125132. * Unbinds the material from the mesh
  125133. */
  125134. unbind(): void;
  125135. /**
  125136. * Binds the submesh data.
  125137. * @param world - The world matrix.
  125138. * @param mesh - The BJS mesh.
  125139. * @param subMesh - A submesh of the BJS mesh.
  125140. */
  125141. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  125142. /**
  125143. * Returns the animatable textures.
  125144. * @returns - Array of animatable textures.
  125145. */
  125146. getAnimatables(): IAnimatable[];
  125147. /**
  125148. * Returns the texture used for reflections.
  125149. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  125150. */
  125151. private _getReflectionTexture;
  125152. /**
  125153. * Returns an array of the actively used textures.
  125154. * @returns - Array of BaseTextures
  125155. */
  125156. getActiveTextures(): BaseTexture[];
  125157. /**
  125158. * Checks to see if a texture is used in the material.
  125159. * @param texture - Base texture to use.
  125160. * @returns - Boolean specifying if a texture is used in the material.
  125161. */
  125162. hasTexture(texture: BaseTexture): boolean;
  125163. /**
  125164. * Disposes the resources of the material.
  125165. * @param forceDisposeEffect - Forces the disposal of effects.
  125166. * @param forceDisposeTextures - Forces the disposal of all textures.
  125167. */
  125168. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  125169. }
  125170. }
  125171. declare module BABYLON {
  125172. /**
  125173. * The Physically based material of BJS.
  125174. *
  125175. * This offers the main features of a standard PBR material.
  125176. * For more information, please refer to the documentation :
  125177. * https://doc.babylonjs.com/how_to/physically_based_rendering
  125178. */
  125179. export class PBRMaterial extends PBRBaseMaterial {
  125180. /**
  125181. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  125182. */
  125183. static readonly PBRMATERIAL_OPAQUE: number;
  125184. /**
  125185. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  125186. */
  125187. static readonly PBRMATERIAL_ALPHATEST: number;
  125188. /**
  125189. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  125190. */
  125191. static readonly PBRMATERIAL_ALPHABLEND: number;
  125192. /**
  125193. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  125194. * They are also discarded below the alpha cutoff threshold to improve performances.
  125195. */
  125196. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  125197. /**
  125198. * Defines the default value of how much AO map is occluding the analytical lights
  125199. * (point spot...).
  125200. */
  125201. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  125202. /**
  125203. * Intensity of the direct lights e.g. the four lights available in your scene.
  125204. * This impacts both the direct diffuse and specular highlights.
  125205. */
  125206. directIntensity: number;
  125207. /**
  125208. * Intensity of the emissive part of the material.
  125209. * This helps controlling the emissive effect without modifying the emissive color.
  125210. */
  125211. emissiveIntensity: number;
  125212. /**
  125213. * Intensity of the environment e.g. how much the environment will light the object
  125214. * either through harmonics for rough material or through the refelction for shiny ones.
  125215. */
  125216. environmentIntensity: number;
  125217. /**
  125218. * This is a special control allowing the reduction of the specular highlights coming from the
  125219. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  125220. */
  125221. specularIntensity: number;
  125222. /**
  125223. * Debug Control allowing disabling the bump map on this material.
  125224. */
  125225. disableBumpMap: boolean;
  125226. /**
  125227. * AKA Diffuse Texture in standard nomenclature.
  125228. */
  125229. albedoTexture: BaseTexture;
  125230. /**
  125231. * AKA Occlusion Texture in other nomenclature.
  125232. */
  125233. ambientTexture: BaseTexture;
  125234. /**
  125235. * AKA Occlusion Texture Intensity in other nomenclature.
  125236. */
  125237. ambientTextureStrength: number;
  125238. /**
  125239. * Defines how much the AO map is occluding the analytical lights (point spot...).
  125240. * 1 means it completely occludes it
  125241. * 0 mean it has no impact
  125242. */
  125243. ambientTextureImpactOnAnalyticalLights: number;
  125244. /**
  125245. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  125246. */
  125247. opacityTexture: BaseTexture;
  125248. /**
  125249. * Stores the reflection values in a texture.
  125250. */
  125251. reflectionTexture: Nullable<BaseTexture>;
  125252. /**
  125253. * Stores the emissive values in a texture.
  125254. */
  125255. emissiveTexture: BaseTexture;
  125256. /**
  125257. * AKA Specular texture in other nomenclature.
  125258. */
  125259. reflectivityTexture: BaseTexture;
  125260. /**
  125261. * Used to switch from specular/glossiness to metallic/roughness workflow.
  125262. */
  125263. metallicTexture: BaseTexture;
  125264. /**
  125265. * Specifies the metallic scalar of the metallic/roughness workflow.
  125266. * Can also be used to scale the metalness values of the metallic texture.
  125267. */
  125268. metallic: Nullable<number>;
  125269. /**
  125270. * Specifies the roughness scalar of the metallic/roughness workflow.
  125271. * Can also be used to scale the roughness values of the metallic texture.
  125272. */
  125273. roughness: Nullable<number>;
  125274. /**
  125275. * Specifies the an F0 factor to help configuring the material F0.
  125276. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  125277. * to 0.5 the previously hard coded value stays the same.
  125278. * Can also be used to scale the F0 values of the metallic texture.
  125279. */
  125280. metallicF0Factor: number;
  125281. /**
  125282. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  125283. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  125284. * your expectation as it multiplies with the texture data.
  125285. */
  125286. useMetallicF0FactorFromMetallicTexture: boolean;
  125287. /**
  125288. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  125289. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  125290. */
  125291. microSurfaceTexture: BaseTexture;
  125292. /**
  125293. * Stores surface normal data used to displace a mesh in a texture.
  125294. */
  125295. bumpTexture: BaseTexture;
  125296. /**
  125297. * Stores the pre-calculated light information of a mesh in a texture.
  125298. */
  125299. lightmapTexture: BaseTexture;
  125300. /**
  125301. * Stores the refracted light information in a texture.
  125302. */
  125303. get refractionTexture(): Nullable<BaseTexture>;
  125304. set refractionTexture(value: Nullable<BaseTexture>);
  125305. /**
  125306. * The color of a material in ambient lighting.
  125307. */
  125308. ambientColor: Color3;
  125309. /**
  125310. * AKA Diffuse Color in other nomenclature.
  125311. */
  125312. albedoColor: Color3;
  125313. /**
  125314. * AKA Specular Color in other nomenclature.
  125315. */
  125316. reflectivityColor: Color3;
  125317. /**
  125318. * The color reflected from the material.
  125319. */
  125320. reflectionColor: Color3;
  125321. /**
  125322. * The color emitted from the material.
  125323. */
  125324. emissiveColor: Color3;
  125325. /**
  125326. * AKA Glossiness in other nomenclature.
  125327. */
  125328. microSurface: number;
  125329. /**
  125330. * source material index of refraction (IOR)' / 'destination material IOR.
  125331. */
  125332. get indexOfRefraction(): number;
  125333. set indexOfRefraction(value: number);
  125334. /**
  125335. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  125336. */
  125337. get invertRefractionY(): boolean;
  125338. set invertRefractionY(value: boolean);
  125339. /**
  125340. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  125341. * Materials half opaque for instance using refraction could benefit from this control.
  125342. */
  125343. get linkRefractionWithTransparency(): boolean;
  125344. set linkRefractionWithTransparency(value: boolean);
  125345. /**
  125346. * If true, the light map contains occlusion information instead of lighting info.
  125347. */
  125348. useLightmapAsShadowmap: boolean;
  125349. /**
  125350. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  125351. */
  125352. useAlphaFromAlbedoTexture: boolean;
  125353. /**
  125354. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  125355. */
  125356. forceAlphaTest: boolean;
  125357. /**
  125358. * Defines the alpha limits in alpha test mode.
  125359. */
  125360. alphaCutOff: number;
  125361. /**
  125362. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  125363. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  125364. */
  125365. useSpecularOverAlpha: boolean;
  125366. /**
  125367. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  125368. */
  125369. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  125370. /**
  125371. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  125372. */
  125373. useRoughnessFromMetallicTextureAlpha: boolean;
  125374. /**
  125375. * Specifies if the metallic texture contains the roughness information in its green channel.
  125376. */
  125377. useRoughnessFromMetallicTextureGreen: boolean;
  125378. /**
  125379. * Specifies if the metallic texture contains the metallness information in its blue channel.
  125380. */
  125381. useMetallnessFromMetallicTextureBlue: boolean;
  125382. /**
  125383. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  125384. */
  125385. useAmbientOcclusionFromMetallicTextureRed: boolean;
  125386. /**
  125387. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  125388. */
  125389. useAmbientInGrayScale: boolean;
  125390. /**
  125391. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  125392. * The material will try to infer what glossiness each pixel should be.
  125393. */
  125394. useAutoMicroSurfaceFromReflectivityMap: boolean;
  125395. /**
  125396. * BJS is using an harcoded light falloff based on a manually sets up range.
  125397. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  125398. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  125399. */
  125400. get usePhysicalLightFalloff(): boolean;
  125401. /**
  125402. * BJS is using an harcoded light falloff based on a manually sets up range.
  125403. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  125404. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  125405. */
  125406. set usePhysicalLightFalloff(value: boolean);
  125407. /**
  125408. * In order to support the falloff compatibility with gltf, a special mode has been added
  125409. * to reproduce the gltf light falloff.
  125410. */
  125411. get useGLTFLightFalloff(): boolean;
  125412. /**
  125413. * In order to support the falloff compatibility with gltf, a special mode has been added
  125414. * to reproduce the gltf light falloff.
  125415. */
  125416. set useGLTFLightFalloff(value: boolean);
  125417. /**
  125418. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  125419. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  125420. */
  125421. useRadianceOverAlpha: boolean;
  125422. /**
  125423. * Allows using an object space normal map (instead of tangent space).
  125424. */
  125425. useObjectSpaceNormalMap: boolean;
  125426. /**
  125427. * Allows using the bump map in parallax mode.
  125428. */
  125429. useParallax: boolean;
  125430. /**
  125431. * Allows using the bump map in parallax occlusion mode.
  125432. */
  125433. useParallaxOcclusion: boolean;
  125434. /**
  125435. * Controls the scale bias of the parallax mode.
  125436. */
  125437. parallaxScaleBias: number;
  125438. /**
  125439. * If sets to true, disables all the lights affecting the material.
  125440. */
  125441. disableLighting: boolean;
  125442. /**
  125443. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  125444. */
  125445. forceIrradianceInFragment: boolean;
  125446. /**
  125447. * Number of Simultaneous lights allowed on the material.
  125448. */
  125449. maxSimultaneousLights: number;
  125450. /**
  125451. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  125452. */
  125453. invertNormalMapX: boolean;
  125454. /**
  125455. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  125456. */
  125457. invertNormalMapY: boolean;
  125458. /**
  125459. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  125460. */
  125461. twoSidedLighting: boolean;
  125462. /**
  125463. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  125464. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  125465. */
  125466. useAlphaFresnel: boolean;
  125467. /**
  125468. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  125469. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  125470. */
  125471. useLinearAlphaFresnel: boolean;
  125472. /**
  125473. * Let user defines the brdf lookup texture used for IBL.
  125474. * A default 8bit version is embedded but you could point at :
  125475. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  125476. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  125477. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  125478. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  125479. */
  125480. environmentBRDFTexture: Nullable<BaseTexture>;
  125481. /**
  125482. * Force normal to face away from face.
  125483. */
  125484. forceNormalForward: boolean;
  125485. /**
  125486. * Enables specular anti aliasing in the PBR shader.
  125487. * It will both interacts on the Geometry for analytical and IBL lighting.
  125488. * It also prefilter the roughness map based on the bump values.
  125489. */
  125490. enableSpecularAntiAliasing: boolean;
  125491. /**
  125492. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  125493. * makes the reflect vector face the model (under horizon).
  125494. */
  125495. useHorizonOcclusion: boolean;
  125496. /**
  125497. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  125498. * too much the area relying on ambient texture to define their ambient occlusion.
  125499. */
  125500. useRadianceOcclusion: boolean;
  125501. /**
  125502. * If set to true, no lighting calculations will be applied.
  125503. */
  125504. unlit: boolean;
  125505. /**
  125506. * Gets the image processing configuration used either in this material.
  125507. */
  125508. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  125509. /**
  125510. * Sets the Default image processing configuration used either in the this material.
  125511. *
  125512. * If sets to null, the scene one is in use.
  125513. */
  125514. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  125515. /**
  125516. * Gets wether the color curves effect is enabled.
  125517. */
  125518. get cameraColorCurvesEnabled(): boolean;
  125519. /**
  125520. * Sets wether the color curves effect is enabled.
  125521. */
  125522. set cameraColorCurvesEnabled(value: boolean);
  125523. /**
  125524. * Gets wether the color grading effect is enabled.
  125525. */
  125526. get cameraColorGradingEnabled(): boolean;
  125527. /**
  125528. * Gets wether the color grading effect is enabled.
  125529. */
  125530. set cameraColorGradingEnabled(value: boolean);
  125531. /**
  125532. * Gets wether tonemapping is enabled or not.
  125533. */
  125534. get cameraToneMappingEnabled(): boolean;
  125535. /**
  125536. * Sets wether tonemapping is enabled or not
  125537. */
  125538. set cameraToneMappingEnabled(value: boolean);
  125539. /**
  125540. * The camera exposure used on this material.
  125541. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125542. * This corresponds to a photographic exposure.
  125543. */
  125544. get cameraExposure(): number;
  125545. /**
  125546. * The camera exposure used on this material.
  125547. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125548. * This corresponds to a photographic exposure.
  125549. */
  125550. set cameraExposure(value: number);
  125551. /**
  125552. * Gets The camera contrast used on this material.
  125553. */
  125554. get cameraContrast(): number;
  125555. /**
  125556. * Sets The camera contrast used on this material.
  125557. */
  125558. set cameraContrast(value: number);
  125559. /**
  125560. * Gets the Color Grading 2D Lookup Texture.
  125561. */
  125562. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  125563. /**
  125564. * Sets the Color Grading 2D Lookup Texture.
  125565. */
  125566. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  125567. /**
  125568. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125569. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125570. * 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;
  125571. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125572. */
  125573. get cameraColorCurves(): Nullable<ColorCurves>;
  125574. /**
  125575. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125576. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125577. * 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;
  125578. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125579. */
  125580. set cameraColorCurves(value: Nullable<ColorCurves>);
  125581. /**
  125582. * Instantiates a new PBRMaterial instance.
  125583. *
  125584. * @param name The material name
  125585. * @param scene The scene the material will be use in.
  125586. */
  125587. constructor(name: string, scene: Scene);
  125588. /**
  125589. * Returns the name of this material class.
  125590. */
  125591. getClassName(): string;
  125592. /**
  125593. * Makes a duplicate of the current material.
  125594. * @param name - name to use for the new material.
  125595. */
  125596. clone(name: string): PBRMaterial;
  125597. /**
  125598. * Serializes this PBR Material.
  125599. * @returns - An object with the serialized material.
  125600. */
  125601. serialize(): any;
  125602. /**
  125603. * Parses a PBR Material from a serialized object.
  125604. * @param source - Serialized object.
  125605. * @param scene - BJS scene instance.
  125606. * @param rootUrl - url for the scene object
  125607. * @returns - PBRMaterial
  125608. */
  125609. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  125610. }
  125611. }
  125612. declare module BABYLON {
  125613. /**
  125614. * Direct draw surface info
  125615. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  125616. */
  125617. export interface DDSInfo {
  125618. /**
  125619. * Width of the texture
  125620. */
  125621. width: number;
  125622. /**
  125623. * Width of the texture
  125624. */
  125625. height: number;
  125626. /**
  125627. * Number of Mipmaps for the texture
  125628. * @see https://en.wikipedia.org/wiki/Mipmap
  125629. */
  125630. mipmapCount: number;
  125631. /**
  125632. * If the textures format is a known fourCC format
  125633. * @see https://www.fourcc.org/
  125634. */
  125635. isFourCC: boolean;
  125636. /**
  125637. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  125638. */
  125639. isRGB: boolean;
  125640. /**
  125641. * If the texture is a lumincance format
  125642. */
  125643. isLuminance: boolean;
  125644. /**
  125645. * If this is a cube texture
  125646. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  125647. */
  125648. isCube: boolean;
  125649. /**
  125650. * If the texture is a compressed format eg. FOURCC_DXT1
  125651. */
  125652. isCompressed: boolean;
  125653. /**
  125654. * The dxgiFormat of the texture
  125655. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  125656. */
  125657. dxgiFormat: number;
  125658. /**
  125659. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  125660. */
  125661. textureType: number;
  125662. /**
  125663. * Sphericle polynomial created for the dds texture
  125664. */
  125665. sphericalPolynomial?: SphericalPolynomial;
  125666. }
  125667. /**
  125668. * Class used to provide DDS decompression tools
  125669. */
  125670. export class DDSTools {
  125671. /**
  125672. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  125673. */
  125674. static StoreLODInAlphaChannel: boolean;
  125675. /**
  125676. * Gets DDS information from an array buffer
  125677. * @param data defines the array buffer view to read data from
  125678. * @returns the DDS information
  125679. */
  125680. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  125681. private static _FloatView;
  125682. private static _Int32View;
  125683. private static _ToHalfFloat;
  125684. private static _FromHalfFloat;
  125685. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  125686. private static _GetHalfFloatRGBAArrayBuffer;
  125687. private static _GetFloatRGBAArrayBuffer;
  125688. private static _GetFloatAsUIntRGBAArrayBuffer;
  125689. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  125690. private static _GetRGBAArrayBuffer;
  125691. private static _ExtractLongWordOrder;
  125692. private static _GetRGBArrayBuffer;
  125693. private static _GetLuminanceArrayBuffer;
  125694. /**
  125695. * Uploads DDS Levels to a Babylon Texture
  125696. * @hidden
  125697. */
  125698. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  125699. }
  125700. interface ThinEngine {
  125701. /**
  125702. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  125703. * @param rootUrl defines the url where the file to load is located
  125704. * @param scene defines the current scene
  125705. * @param lodScale defines scale to apply to the mip map selection
  125706. * @param lodOffset defines offset to apply to the mip map selection
  125707. * @param onLoad defines an optional callback raised when the texture is loaded
  125708. * @param onError defines an optional callback raised if there is an issue to load the texture
  125709. * @param format defines the format of the data
  125710. * @param forcedExtension defines the extension to use to pick the right loader
  125711. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  125712. * @returns the cube texture as an InternalTexture
  125713. */
  125714. 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;
  125715. }
  125716. }
  125717. declare module BABYLON {
  125718. /**
  125719. * Implementation of the DDS Texture Loader.
  125720. * @hidden
  125721. */
  125722. export class _DDSTextureLoader implements IInternalTextureLoader {
  125723. /**
  125724. * Defines wether the loader supports cascade loading the different faces.
  125725. */
  125726. readonly supportCascades: boolean;
  125727. /**
  125728. * This returns if the loader support the current file information.
  125729. * @param extension defines the file extension of the file being loaded
  125730. * @returns true if the loader can load the specified file
  125731. */
  125732. canLoad(extension: string): boolean;
  125733. /**
  125734. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  125735. * @param data contains the texture data
  125736. * @param texture defines the BabylonJS internal texture
  125737. * @param createPolynomials will be true if polynomials have been requested
  125738. * @param onLoad defines the callback to trigger once the texture is ready
  125739. * @param onError defines the callback to trigger in case of error
  125740. */
  125741. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125742. /**
  125743. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  125744. * @param data contains the texture data
  125745. * @param texture defines the BabylonJS internal texture
  125746. * @param callback defines the method to call once ready to upload
  125747. */
  125748. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125749. }
  125750. }
  125751. declare module BABYLON {
  125752. /**
  125753. * Implementation of the ENV Texture Loader.
  125754. * @hidden
  125755. */
  125756. export class _ENVTextureLoader implements IInternalTextureLoader {
  125757. /**
  125758. * Defines wether the loader supports cascade loading the different faces.
  125759. */
  125760. readonly supportCascades: boolean;
  125761. /**
  125762. * This returns if the loader support the current file information.
  125763. * @param extension defines the file extension of the file being loaded
  125764. * @returns true if the loader can load the specified file
  125765. */
  125766. canLoad(extension: string): boolean;
  125767. /**
  125768. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  125769. * @param data contains the texture data
  125770. * @param texture defines the BabylonJS internal texture
  125771. * @param createPolynomials will be true if polynomials have been requested
  125772. * @param onLoad defines the callback to trigger once the texture is ready
  125773. * @param onError defines the callback to trigger in case of error
  125774. */
  125775. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125776. /**
  125777. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  125778. * @param data contains the texture data
  125779. * @param texture defines the BabylonJS internal texture
  125780. * @param callback defines the method to call once ready to upload
  125781. */
  125782. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125783. }
  125784. }
  125785. declare module BABYLON {
  125786. /**
  125787. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  125788. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  125789. */
  125790. export class KhronosTextureContainer {
  125791. /** contents of the KTX container file */
  125792. data: ArrayBufferView;
  125793. private static HEADER_LEN;
  125794. private static COMPRESSED_2D;
  125795. private static COMPRESSED_3D;
  125796. private static TEX_2D;
  125797. private static TEX_3D;
  125798. /**
  125799. * Gets the openGL type
  125800. */
  125801. glType: number;
  125802. /**
  125803. * Gets the openGL type size
  125804. */
  125805. glTypeSize: number;
  125806. /**
  125807. * Gets the openGL format
  125808. */
  125809. glFormat: number;
  125810. /**
  125811. * Gets the openGL internal format
  125812. */
  125813. glInternalFormat: number;
  125814. /**
  125815. * Gets the base internal format
  125816. */
  125817. glBaseInternalFormat: number;
  125818. /**
  125819. * Gets image width in pixel
  125820. */
  125821. pixelWidth: number;
  125822. /**
  125823. * Gets image height in pixel
  125824. */
  125825. pixelHeight: number;
  125826. /**
  125827. * Gets image depth in pixels
  125828. */
  125829. pixelDepth: number;
  125830. /**
  125831. * Gets the number of array elements
  125832. */
  125833. numberOfArrayElements: number;
  125834. /**
  125835. * Gets the number of faces
  125836. */
  125837. numberOfFaces: number;
  125838. /**
  125839. * Gets the number of mipmap levels
  125840. */
  125841. numberOfMipmapLevels: number;
  125842. /**
  125843. * Gets the bytes of key value data
  125844. */
  125845. bytesOfKeyValueData: number;
  125846. /**
  125847. * Gets the load type
  125848. */
  125849. loadType: number;
  125850. /**
  125851. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  125852. */
  125853. isInvalid: boolean;
  125854. /**
  125855. * Creates a new KhronosTextureContainer
  125856. * @param data contents of the KTX container file
  125857. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  125858. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  125859. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  125860. */
  125861. constructor(
  125862. /** contents of the KTX container file */
  125863. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  125864. /**
  125865. * Uploads KTX content to a Babylon Texture.
  125866. * It is assumed that the texture has already been created & is currently bound
  125867. * @hidden
  125868. */
  125869. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  125870. private _upload2DCompressedLevels;
  125871. /**
  125872. * Checks if the given data starts with a KTX file identifier.
  125873. * @param data the data to check
  125874. * @returns true if the data is a KTX file or false otherwise
  125875. */
  125876. static IsValid(data: ArrayBufferView): boolean;
  125877. }
  125878. }
  125879. declare module BABYLON {
  125880. /**
  125881. * Class for loading KTX2 files
  125882. * !!! Experimental Extension Subject to Changes !!!
  125883. * @hidden
  125884. */
  125885. export class KhronosTextureContainer2 {
  125886. private static _ModulePromise;
  125887. private static _TranscodeFormat;
  125888. constructor(engine: ThinEngine);
  125889. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  125890. private _determineTranscodeFormat;
  125891. /**
  125892. * Checks if the given data starts with a KTX2 file identifier.
  125893. * @param data the data to check
  125894. * @returns true if the data is a KTX2 file or false otherwise
  125895. */
  125896. static IsValid(data: ArrayBufferView): boolean;
  125897. }
  125898. }
  125899. declare module BABYLON {
  125900. /**
  125901. * Implementation of the KTX Texture Loader.
  125902. * @hidden
  125903. */
  125904. export class _KTXTextureLoader implements IInternalTextureLoader {
  125905. /**
  125906. * Defines wether the loader supports cascade loading the different faces.
  125907. */
  125908. readonly supportCascades: boolean;
  125909. /**
  125910. * This returns if the loader support the current file information.
  125911. * @param extension defines the file extension of the file being loaded
  125912. * @returns true if the loader can load the specified file
  125913. */
  125914. canLoad(extension: string): boolean;
  125915. /**
  125916. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  125917. * @param data contains the texture data
  125918. * @param texture defines the BabylonJS internal texture
  125919. * @param createPolynomials will be true if polynomials have been requested
  125920. * @param onLoad defines the callback to trigger once the texture is ready
  125921. * @param onError defines the callback to trigger in case of error
  125922. */
  125923. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125924. /**
  125925. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  125926. * @param data contains the texture data
  125927. * @param texture defines the BabylonJS internal texture
  125928. * @param callback defines the method to call once ready to upload
  125929. */
  125930. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  125931. }
  125932. }
  125933. declare module BABYLON {
  125934. /** @hidden */
  125935. export var _forceSceneHelpersToBundle: boolean;
  125936. interface Scene {
  125937. /**
  125938. * Creates a default light for the scene.
  125939. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  125940. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  125941. */
  125942. createDefaultLight(replace?: boolean): void;
  125943. /**
  125944. * Creates a default camera for the scene.
  125945. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  125946. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  125947. * @param replace has default false, when true replaces the active camera in the scene
  125948. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  125949. */
  125950. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  125951. /**
  125952. * Creates a default camera and a default light.
  125953. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  125954. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  125955. * @param replace has the default false, when true replaces the active camera/light in the scene
  125956. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  125957. */
  125958. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  125959. /**
  125960. * Creates a new sky box
  125961. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  125962. * @param environmentTexture defines the texture to use as environment texture
  125963. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  125964. * @param scale defines the overall scale of the skybox
  125965. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  125966. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  125967. * @returns a new mesh holding the sky box
  125968. */
  125969. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  125970. /**
  125971. * Creates a new environment
  125972. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  125973. * @param options defines the options you can use to configure the environment
  125974. * @returns the new EnvironmentHelper
  125975. */
  125976. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  125977. /**
  125978. * Creates a new VREXperienceHelper
  125979. * @see http://doc.babylonjs.com/how_to/webvr_helper
  125980. * @param webVROptions defines the options used to create the new VREXperienceHelper
  125981. * @returns a new VREXperienceHelper
  125982. */
  125983. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  125984. /**
  125985. * Creates a new WebXRDefaultExperience
  125986. * @see http://doc.babylonjs.com/how_to/webxr
  125987. * @param options experience options
  125988. * @returns a promise for a new WebXRDefaultExperience
  125989. */
  125990. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  125991. }
  125992. }
  125993. declare module BABYLON {
  125994. /**
  125995. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  125996. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  125997. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  125998. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  125999. */
  126000. export class VideoDome extends TransformNode {
  126001. /**
  126002. * Define the video source as a Monoscopic panoramic 360 video.
  126003. */
  126004. static readonly MODE_MONOSCOPIC: number;
  126005. /**
  126006. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  126007. */
  126008. static readonly MODE_TOPBOTTOM: number;
  126009. /**
  126010. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  126011. */
  126012. static readonly MODE_SIDEBYSIDE: number;
  126013. private _halfDome;
  126014. private _useDirectMapping;
  126015. /**
  126016. * The video texture being displayed on the sphere
  126017. */
  126018. protected _videoTexture: VideoTexture;
  126019. /**
  126020. * Gets the video texture being displayed on the sphere
  126021. */
  126022. get videoTexture(): VideoTexture;
  126023. /**
  126024. * The skybox material
  126025. */
  126026. protected _material: BackgroundMaterial;
  126027. /**
  126028. * The surface used for the skybox
  126029. */
  126030. protected _mesh: Mesh;
  126031. /**
  126032. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  126033. */
  126034. private _halfDomeMask;
  126035. /**
  126036. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  126037. * Also see the options.resolution property.
  126038. */
  126039. get fovMultiplier(): number;
  126040. set fovMultiplier(value: number);
  126041. private _videoMode;
  126042. /**
  126043. * Gets or set the current video mode for the video. It can be:
  126044. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  126045. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  126046. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  126047. */
  126048. get videoMode(): number;
  126049. set videoMode(value: number);
  126050. /**
  126051. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  126052. *
  126053. */
  126054. get halfDome(): boolean;
  126055. /**
  126056. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  126057. */
  126058. set halfDome(enabled: boolean);
  126059. /**
  126060. * Oberserver used in Stereoscopic VR Mode.
  126061. */
  126062. private _onBeforeCameraRenderObserver;
  126063. /**
  126064. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  126065. * @param name Element's name, child elements will append suffixes for their own names.
  126066. * @param urlsOrVideo defines the url(s) or the video element to use
  126067. * @param options An object containing optional or exposed sub element properties
  126068. */
  126069. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  126070. resolution?: number;
  126071. clickToPlay?: boolean;
  126072. autoPlay?: boolean;
  126073. loop?: boolean;
  126074. size?: number;
  126075. poster?: string;
  126076. faceForward?: boolean;
  126077. useDirectMapping?: boolean;
  126078. halfDomeMode?: boolean;
  126079. }, scene: Scene);
  126080. private _changeVideoMode;
  126081. /**
  126082. * Releases resources associated with this node.
  126083. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  126084. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  126085. */
  126086. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  126087. }
  126088. }
  126089. declare module BABYLON {
  126090. /**
  126091. * This class can be used to get instrumentation data from a Babylon engine
  126092. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  126093. */
  126094. export class EngineInstrumentation implements IDisposable {
  126095. /**
  126096. * Define the instrumented engine.
  126097. */
  126098. engine: Engine;
  126099. private _captureGPUFrameTime;
  126100. private _gpuFrameTimeToken;
  126101. private _gpuFrameTime;
  126102. private _captureShaderCompilationTime;
  126103. private _shaderCompilationTime;
  126104. private _onBeginFrameObserver;
  126105. private _onEndFrameObserver;
  126106. private _onBeforeShaderCompilationObserver;
  126107. private _onAfterShaderCompilationObserver;
  126108. /**
  126109. * Gets the perf counter used for GPU frame time
  126110. */
  126111. get gpuFrameTimeCounter(): PerfCounter;
  126112. /**
  126113. * Gets the GPU frame time capture status
  126114. */
  126115. get captureGPUFrameTime(): boolean;
  126116. /**
  126117. * Enable or disable the GPU frame time capture
  126118. */
  126119. set captureGPUFrameTime(value: boolean);
  126120. /**
  126121. * Gets the perf counter used for shader compilation time
  126122. */
  126123. get shaderCompilationTimeCounter(): PerfCounter;
  126124. /**
  126125. * Gets the shader compilation time capture status
  126126. */
  126127. get captureShaderCompilationTime(): boolean;
  126128. /**
  126129. * Enable or disable the shader compilation time capture
  126130. */
  126131. set captureShaderCompilationTime(value: boolean);
  126132. /**
  126133. * Instantiates a new engine instrumentation.
  126134. * This class can be used to get instrumentation data from a Babylon engine
  126135. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  126136. * @param engine Defines the engine to instrument
  126137. */
  126138. constructor(
  126139. /**
  126140. * Define the instrumented engine.
  126141. */
  126142. engine: Engine);
  126143. /**
  126144. * Dispose and release associated resources.
  126145. */
  126146. dispose(): void;
  126147. }
  126148. }
  126149. declare module BABYLON {
  126150. /**
  126151. * This class can be used to get instrumentation data from a Babylon engine
  126152. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  126153. */
  126154. export class SceneInstrumentation implements IDisposable {
  126155. /**
  126156. * Defines the scene to instrument
  126157. */
  126158. scene: Scene;
  126159. private _captureActiveMeshesEvaluationTime;
  126160. private _activeMeshesEvaluationTime;
  126161. private _captureRenderTargetsRenderTime;
  126162. private _renderTargetsRenderTime;
  126163. private _captureFrameTime;
  126164. private _frameTime;
  126165. private _captureRenderTime;
  126166. private _renderTime;
  126167. private _captureInterFrameTime;
  126168. private _interFrameTime;
  126169. private _captureParticlesRenderTime;
  126170. private _particlesRenderTime;
  126171. private _captureSpritesRenderTime;
  126172. private _spritesRenderTime;
  126173. private _capturePhysicsTime;
  126174. private _physicsTime;
  126175. private _captureAnimationsTime;
  126176. private _animationsTime;
  126177. private _captureCameraRenderTime;
  126178. private _cameraRenderTime;
  126179. private _onBeforeActiveMeshesEvaluationObserver;
  126180. private _onAfterActiveMeshesEvaluationObserver;
  126181. private _onBeforeRenderTargetsRenderObserver;
  126182. private _onAfterRenderTargetsRenderObserver;
  126183. private _onAfterRenderObserver;
  126184. private _onBeforeDrawPhaseObserver;
  126185. private _onAfterDrawPhaseObserver;
  126186. private _onBeforeAnimationsObserver;
  126187. private _onBeforeParticlesRenderingObserver;
  126188. private _onAfterParticlesRenderingObserver;
  126189. private _onBeforeSpritesRenderingObserver;
  126190. private _onAfterSpritesRenderingObserver;
  126191. private _onBeforePhysicsObserver;
  126192. private _onAfterPhysicsObserver;
  126193. private _onAfterAnimationsObserver;
  126194. private _onBeforeCameraRenderObserver;
  126195. private _onAfterCameraRenderObserver;
  126196. /**
  126197. * Gets the perf counter used for active meshes evaluation time
  126198. */
  126199. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  126200. /**
  126201. * Gets the active meshes evaluation time capture status
  126202. */
  126203. get captureActiveMeshesEvaluationTime(): boolean;
  126204. /**
  126205. * Enable or disable the active meshes evaluation time capture
  126206. */
  126207. set captureActiveMeshesEvaluationTime(value: boolean);
  126208. /**
  126209. * Gets the perf counter used for render targets render time
  126210. */
  126211. get renderTargetsRenderTimeCounter(): PerfCounter;
  126212. /**
  126213. * Gets the render targets render time capture status
  126214. */
  126215. get captureRenderTargetsRenderTime(): boolean;
  126216. /**
  126217. * Enable or disable the render targets render time capture
  126218. */
  126219. set captureRenderTargetsRenderTime(value: boolean);
  126220. /**
  126221. * Gets the perf counter used for particles render time
  126222. */
  126223. get particlesRenderTimeCounter(): PerfCounter;
  126224. /**
  126225. * Gets the particles render time capture status
  126226. */
  126227. get captureParticlesRenderTime(): boolean;
  126228. /**
  126229. * Enable or disable the particles render time capture
  126230. */
  126231. set captureParticlesRenderTime(value: boolean);
  126232. /**
  126233. * Gets the perf counter used for sprites render time
  126234. */
  126235. get spritesRenderTimeCounter(): PerfCounter;
  126236. /**
  126237. * Gets the sprites render time capture status
  126238. */
  126239. get captureSpritesRenderTime(): boolean;
  126240. /**
  126241. * Enable or disable the sprites render time capture
  126242. */
  126243. set captureSpritesRenderTime(value: boolean);
  126244. /**
  126245. * Gets the perf counter used for physics time
  126246. */
  126247. get physicsTimeCounter(): PerfCounter;
  126248. /**
  126249. * Gets the physics time capture status
  126250. */
  126251. get capturePhysicsTime(): boolean;
  126252. /**
  126253. * Enable or disable the physics time capture
  126254. */
  126255. set capturePhysicsTime(value: boolean);
  126256. /**
  126257. * Gets the perf counter used for animations time
  126258. */
  126259. get animationsTimeCounter(): PerfCounter;
  126260. /**
  126261. * Gets the animations time capture status
  126262. */
  126263. get captureAnimationsTime(): boolean;
  126264. /**
  126265. * Enable or disable the animations time capture
  126266. */
  126267. set captureAnimationsTime(value: boolean);
  126268. /**
  126269. * Gets the perf counter used for frame time capture
  126270. */
  126271. get frameTimeCounter(): PerfCounter;
  126272. /**
  126273. * Gets the frame time capture status
  126274. */
  126275. get captureFrameTime(): boolean;
  126276. /**
  126277. * Enable or disable the frame time capture
  126278. */
  126279. set captureFrameTime(value: boolean);
  126280. /**
  126281. * Gets the perf counter used for inter-frames time capture
  126282. */
  126283. get interFrameTimeCounter(): PerfCounter;
  126284. /**
  126285. * Gets the inter-frames time capture status
  126286. */
  126287. get captureInterFrameTime(): boolean;
  126288. /**
  126289. * Enable or disable the inter-frames time capture
  126290. */
  126291. set captureInterFrameTime(value: boolean);
  126292. /**
  126293. * Gets the perf counter used for render time capture
  126294. */
  126295. get renderTimeCounter(): PerfCounter;
  126296. /**
  126297. * Gets the render time capture status
  126298. */
  126299. get captureRenderTime(): boolean;
  126300. /**
  126301. * Enable or disable the render time capture
  126302. */
  126303. set captureRenderTime(value: boolean);
  126304. /**
  126305. * Gets the perf counter used for camera render time capture
  126306. */
  126307. get cameraRenderTimeCounter(): PerfCounter;
  126308. /**
  126309. * Gets the camera render time capture status
  126310. */
  126311. get captureCameraRenderTime(): boolean;
  126312. /**
  126313. * Enable or disable the camera render time capture
  126314. */
  126315. set captureCameraRenderTime(value: boolean);
  126316. /**
  126317. * Gets the perf counter used for draw calls
  126318. */
  126319. get drawCallsCounter(): PerfCounter;
  126320. /**
  126321. * Instantiates a new scene instrumentation.
  126322. * This class can be used to get instrumentation data from a Babylon engine
  126323. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  126324. * @param scene Defines the scene to instrument
  126325. */
  126326. constructor(
  126327. /**
  126328. * Defines the scene to instrument
  126329. */
  126330. scene: Scene);
  126331. /**
  126332. * Dispose and release associated resources.
  126333. */
  126334. dispose(): void;
  126335. }
  126336. }
  126337. declare module BABYLON {
  126338. /** @hidden */
  126339. export var glowMapGenerationPixelShader: {
  126340. name: string;
  126341. shader: string;
  126342. };
  126343. }
  126344. declare module BABYLON {
  126345. /** @hidden */
  126346. export var glowMapGenerationVertexShader: {
  126347. name: string;
  126348. shader: string;
  126349. };
  126350. }
  126351. declare module BABYLON {
  126352. /**
  126353. * Effect layer options. This helps customizing the behaviour
  126354. * of the effect layer.
  126355. */
  126356. export interface IEffectLayerOptions {
  126357. /**
  126358. * Multiplication factor apply to the canvas size to compute the render target size
  126359. * used to generated the objects (the smaller the faster).
  126360. */
  126361. mainTextureRatio: number;
  126362. /**
  126363. * Enforces a fixed size texture to ensure effect stability across devices.
  126364. */
  126365. mainTextureFixedSize?: number;
  126366. /**
  126367. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  126368. */
  126369. alphaBlendingMode: number;
  126370. /**
  126371. * The camera attached to the layer.
  126372. */
  126373. camera: Nullable<Camera>;
  126374. /**
  126375. * The rendering group to draw the layer in.
  126376. */
  126377. renderingGroupId: number;
  126378. }
  126379. /**
  126380. * The effect layer Helps adding post process effect blended with the main pass.
  126381. *
  126382. * This can be for instance use to generate glow or higlight effects on the scene.
  126383. *
  126384. * The effect layer class can not be used directly and is intented to inherited from to be
  126385. * customized per effects.
  126386. */
  126387. export abstract class EffectLayer {
  126388. private _vertexBuffers;
  126389. private _indexBuffer;
  126390. private _cachedDefines;
  126391. private _effectLayerMapGenerationEffect;
  126392. private _effectLayerOptions;
  126393. private _mergeEffect;
  126394. protected _scene: Scene;
  126395. protected _engine: Engine;
  126396. protected _maxSize: number;
  126397. protected _mainTextureDesiredSize: ISize;
  126398. protected _mainTexture: RenderTargetTexture;
  126399. protected _shouldRender: boolean;
  126400. protected _postProcesses: PostProcess[];
  126401. protected _textures: BaseTexture[];
  126402. protected _emissiveTextureAndColor: {
  126403. texture: Nullable<BaseTexture>;
  126404. color: Color4;
  126405. };
  126406. /**
  126407. * The name of the layer
  126408. */
  126409. name: string;
  126410. /**
  126411. * The clear color of the texture used to generate the glow map.
  126412. */
  126413. neutralColor: Color4;
  126414. /**
  126415. * Specifies whether the highlight layer is enabled or not.
  126416. */
  126417. isEnabled: boolean;
  126418. /**
  126419. * Gets the camera attached to the layer.
  126420. */
  126421. get camera(): Nullable<Camera>;
  126422. /**
  126423. * Gets the rendering group id the layer should render in.
  126424. */
  126425. get renderingGroupId(): number;
  126426. set renderingGroupId(renderingGroupId: number);
  126427. /**
  126428. * An event triggered when the effect layer has been disposed.
  126429. */
  126430. onDisposeObservable: Observable<EffectLayer>;
  126431. /**
  126432. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  126433. */
  126434. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  126435. /**
  126436. * An event triggered when the generated texture is being merged in the scene.
  126437. */
  126438. onBeforeComposeObservable: Observable<EffectLayer>;
  126439. /**
  126440. * An event triggered when the mesh is rendered into the effect render target.
  126441. */
  126442. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  126443. /**
  126444. * An event triggered after the mesh has been rendered into the effect render target.
  126445. */
  126446. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  126447. /**
  126448. * An event triggered when the generated texture has been merged in the scene.
  126449. */
  126450. onAfterComposeObservable: Observable<EffectLayer>;
  126451. /**
  126452. * An event triggered when the efffect layer changes its size.
  126453. */
  126454. onSizeChangedObservable: Observable<EffectLayer>;
  126455. /** @hidden */
  126456. static _SceneComponentInitialization: (scene: Scene) => void;
  126457. /**
  126458. * Instantiates a new effect Layer and references it in the scene.
  126459. * @param name The name of the layer
  126460. * @param scene The scene to use the layer in
  126461. */
  126462. constructor(
  126463. /** The Friendly of the effect in the scene */
  126464. name: string, scene: Scene);
  126465. /**
  126466. * Get the effect name of the layer.
  126467. * @return The effect name
  126468. */
  126469. abstract getEffectName(): string;
  126470. /**
  126471. * Checks for the readiness of the element composing the layer.
  126472. * @param subMesh the mesh to check for
  126473. * @param useInstances specify whether or not to use instances to render the mesh
  126474. * @return true if ready otherwise, false
  126475. */
  126476. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126477. /**
  126478. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  126479. * @returns true if the effect requires stencil during the main canvas render pass.
  126480. */
  126481. abstract needStencil(): boolean;
  126482. /**
  126483. * Create the merge effect. This is the shader use to blit the information back
  126484. * to the main canvas at the end of the scene rendering.
  126485. * @returns The effect containing the shader used to merge the effect on the main canvas
  126486. */
  126487. protected abstract _createMergeEffect(): Effect;
  126488. /**
  126489. * Creates the render target textures and post processes used in the effect layer.
  126490. */
  126491. protected abstract _createTextureAndPostProcesses(): void;
  126492. /**
  126493. * Implementation specific of rendering the generating effect on the main canvas.
  126494. * @param effect The effect used to render through
  126495. */
  126496. protected abstract _internalRender(effect: Effect): void;
  126497. /**
  126498. * Sets the required values for both the emissive texture and and the main color.
  126499. */
  126500. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126501. /**
  126502. * Free any resources and references associated to a mesh.
  126503. * Internal use
  126504. * @param mesh The mesh to free.
  126505. */
  126506. abstract _disposeMesh(mesh: Mesh): void;
  126507. /**
  126508. * Serializes this layer (Glow or Highlight for example)
  126509. * @returns a serialized layer object
  126510. */
  126511. abstract serialize?(): any;
  126512. /**
  126513. * Initializes the effect layer with the required options.
  126514. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  126515. */
  126516. protected _init(options: Partial<IEffectLayerOptions>): void;
  126517. /**
  126518. * Generates the index buffer of the full screen quad blending to the main canvas.
  126519. */
  126520. private _generateIndexBuffer;
  126521. /**
  126522. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  126523. */
  126524. private _generateVertexBuffer;
  126525. /**
  126526. * Sets the main texture desired size which is the closest power of two
  126527. * of the engine canvas size.
  126528. */
  126529. private _setMainTextureSize;
  126530. /**
  126531. * Creates the main texture for the effect layer.
  126532. */
  126533. protected _createMainTexture(): void;
  126534. /**
  126535. * Adds specific effects defines.
  126536. * @param defines The defines to add specifics to.
  126537. */
  126538. protected _addCustomEffectDefines(defines: string[]): void;
  126539. /**
  126540. * Checks for the readiness of the element composing the layer.
  126541. * @param subMesh the mesh to check for
  126542. * @param useInstances specify whether or not to use instances to render the mesh
  126543. * @param emissiveTexture the associated emissive texture used to generate the glow
  126544. * @return true if ready otherwise, false
  126545. */
  126546. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  126547. /**
  126548. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  126549. */
  126550. render(): void;
  126551. /**
  126552. * Determine if a given mesh will be used in the current effect.
  126553. * @param mesh mesh to test
  126554. * @returns true if the mesh will be used
  126555. */
  126556. hasMesh(mesh: AbstractMesh): boolean;
  126557. /**
  126558. * Returns true if the layer contains information to display, otherwise false.
  126559. * @returns true if the glow layer should be rendered
  126560. */
  126561. shouldRender(): boolean;
  126562. /**
  126563. * Returns true if the mesh should render, otherwise false.
  126564. * @param mesh The mesh to render
  126565. * @returns true if it should render otherwise false
  126566. */
  126567. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  126568. /**
  126569. * Returns true if the mesh can be rendered, otherwise false.
  126570. * @param mesh The mesh to render
  126571. * @param material The material used on the mesh
  126572. * @returns true if it can be rendered otherwise false
  126573. */
  126574. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  126575. /**
  126576. * Returns true if the mesh should render, otherwise false.
  126577. * @param mesh The mesh to render
  126578. * @returns true if it should render otherwise false
  126579. */
  126580. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  126581. /**
  126582. * Renders the submesh passed in parameter to the generation map.
  126583. */
  126584. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  126585. /**
  126586. * Defines whether the current material of the mesh should be use to render the effect.
  126587. * @param mesh defines the current mesh to render
  126588. */
  126589. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  126590. /**
  126591. * Rebuild the required buffers.
  126592. * @hidden Internal use only.
  126593. */
  126594. _rebuild(): void;
  126595. /**
  126596. * Dispose only the render target textures and post process.
  126597. */
  126598. private _disposeTextureAndPostProcesses;
  126599. /**
  126600. * Dispose the highlight layer and free resources.
  126601. */
  126602. dispose(): void;
  126603. /**
  126604. * Gets the class name of the effect layer
  126605. * @returns the string with the class name of the effect layer
  126606. */
  126607. getClassName(): string;
  126608. /**
  126609. * Creates an effect layer from parsed effect layer data
  126610. * @param parsedEffectLayer defines effect layer data
  126611. * @param scene defines the current scene
  126612. * @param rootUrl defines the root URL containing the effect layer information
  126613. * @returns a parsed effect Layer
  126614. */
  126615. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  126616. }
  126617. }
  126618. declare module BABYLON {
  126619. interface AbstractScene {
  126620. /**
  126621. * The list of effect layers (highlights/glow) added to the scene
  126622. * @see http://doc.babylonjs.com/how_to/highlight_layer
  126623. * @see http://doc.babylonjs.com/how_to/glow_layer
  126624. */
  126625. effectLayers: Array<EffectLayer>;
  126626. /**
  126627. * Removes the given effect layer from this scene.
  126628. * @param toRemove defines the effect layer to remove
  126629. * @returns the index of the removed effect layer
  126630. */
  126631. removeEffectLayer(toRemove: EffectLayer): number;
  126632. /**
  126633. * Adds the given effect layer to this scene
  126634. * @param newEffectLayer defines the effect layer to add
  126635. */
  126636. addEffectLayer(newEffectLayer: EffectLayer): void;
  126637. }
  126638. /**
  126639. * Defines the layer scene component responsible to manage any effect layers
  126640. * in a given scene.
  126641. */
  126642. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  126643. /**
  126644. * The component name helpfull to identify the component in the list of scene components.
  126645. */
  126646. readonly name: string;
  126647. /**
  126648. * The scene the component belongs to.
  126649. */
  126650. scene: Scene;
  126651. private _engine;
  126652. private _renderEffects;
  126653. private _needStencil;
  126654. private _previousStencilState;
  126655. /**
  126656. * Creates a new instance of the component for the given scene
  126657. * @param scene Defines the scene to register the component in
  126658. */
  126659. constructor(scene: Scene);
  126660. /**
  126661. * Registers the component in a given scene
  126662. */
  126663. register(): void;
  126664. /**
  126665. * Rebuilds the elements related to this component in case of
  126666. * context lost for instance.
  126667. */
  126668. rebuild(): void;
  126669. /**
  126670. * Serializes the component data to the specified json object
  126671. * @param serializationObject The object to serialize to
  126672. */
  126673. serialize(serializationObject: any): void;
  126674. /**
  126675. * Adds all the elements from the container to the scene
  126676. * @param container the container holding the elements
  126677. */
  126678. addFromContainer(container: AbstractScene): void;
  126679. /**
  126680. * Removes all the elements in the container from the scene
  126681. * @param container contains the elements to remove
  126682. * @param dispose if the removed element should be disposed (default: false)
  126683. */
  126684. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126685. /**
  126686. * Disposes the component and the associated ressources.
  126687. */
  126688. dispose(): void;
  126689. private _isReadyForMesh;
  126690. private _renderMainTexture;
  126691. private _setStencil;
  126692. private _setStencilBack;
  126693. private _draw;
  126694. private _drawCamera;
  126695. private _drawRenderingGroup;
  126696. }
  126697. }
  126698. declare module BABYLON {
  126699. /** @hidden */
  126700. export var glowMapMergePixelShader: {
  126701. name: string;
  126702. shader: string;
  126703. };
  126704. }
  126705. declare module BABYLON {
  126706. /** @hidden */
  126707. export var glowMapMergeVertexShader: {
  126708. name: string;
  126709. shader: string;
  126710. };
  126711. }
  126712. declare module BABYLON {
  126713. interface AbstractScene {
  126714. /**
  126715. * Return a the first highlight layer of the scene with a given name.
  126716. * @param name The name of the highlight layer to look for.
  126717. * @return The highlight layer if found otherwise null.
  126718. */
  126719. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  126720. }
  126721. /**
  126722. * Glow layer options. This helps customizing the behaviour
  126723. * of the glow layer.
  126724. */
  126725. export interface IGlowLayerOptions {
  126726. /**
  126727. * Multiplication factor apply to the canvas size to compute the render target size
  126728. * used to generated the glowing objects (the smaller the faster).
  126729. */
  126730. mainTextureRatio: number;
  126731. /**
  126732. * Enforces a fixed size texture to ensure resize independant blur.
  126733. */
  126734. mainTextureFixedSize?: number;
  126735. /**
  126736. * How big is the kernel of the blur texture.
  126737. */
  126738. blurKernelSize: number;
  126739. /**
  126740. * The camera attached to the layer.
  126741. */
  126742. camera: Nullable<Camera>;
  126743. /**
  126744. * Enable MSAA by chosing the number of samples.
  126745. */
  126746. mainTextureSamples?: number;
  126747. /**
  126748. * The rendering group to draw the layer in.
  126749. */
  126750. renderingGroupId: number;
  126751. }
  126752. /**
  126753. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  126754. *
  126755. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  126756. *
  126757. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  126758. */
  126759. export class GlowLayer extends EffectLayer {
  126760. /**
  126761. * Effect Name of the layer.
  126762. */
  126763. static readonly EffectName: string;
  126764. /**
  126765. * The default blur kernel size used for the glow.
  126766. */
  126767. static DefaultBlurKernelSize: number;
  126768. /**
  126769. * The default texture size ratio used for the glow.
  126770. */
  126771. static DefaultTextureRatio: number;
  126772. /**
  126773. * Sets the kernel size of the blur.
  126774. */
  126775. set blurKernelSize(value: number);
  126776. /**
  126777. * Gets the kernel size of the blur.
  126778. */
  126779. get blurKernelSize(): number;
  126780. /**
  126781. * Sets the glow intensity.
  126782. */
  126783. set intensity(value: number);
  126784. /**
  126785. * Gets the glow intensity.
  126786. */
  126787. get intensity(): number;
  126788. private _options;
  126789. private _intensity;
  126790. private _horizontalBlurPostprocess1;
  126791. private _verticalBlurPostprocess1;
  126792. private _horizontalBlurPostprocess2;
  126793. private _verticalBlurPostprocess2;
  126794. private _blurTexture1;
  126795. private _blurTexture2;
  126796. private _postProcesses1;
  126797. private _postProcesses2;
  126798. private _includedOnlyMeshes;
  126799. private _excludedMeshes;
  126800. private _meshesUsingTheirOwnMaterials;
  126801. /**
  126802. * Callback used to let the user override the color selection on a per mesh basis
  126803. */
  126804. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  126805. /**
  126806. * Callback used to let the user override the texture selection on a per mesh basis
  126807. */
  126808. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  126809. /**
  126810. * Instantiates a new glow Layer and references it to the scene.
  126811. * @param name The name of the layer
  126812. * @param scene The scene to use the layer in
  126813. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  126814. */
  126815. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  126816. /**
  126817. * Get the effect name of the layer.
  126818. * @return The effect name
  126819. */
  126820. getEffectName(): string;
  126821. /**
  126822. * Create the merge effect. This is the shader use to blit the information back
  126823. * to the main canvas at the end of the scene rendering.
  126824. */
  126825. protected _createMergeEffect(): Effect;
  126826. /**
  126827. * Creates the render target textures and post processes used in the glow layer.
  126828. */
  126829. protected _createTextureAndPostProcesses(): void;
  126830. /**
  126831. * Checks for the readiness of the element composing the layer.
  126832. * @param subMesh the mesh to check for
  126833. * @param useInstances specify wether or not to use instances to render the mesh
  126834. * @param emissiveTexture the associated emissive texture used to generate the glow
  126835. * @return true if ready otherwise, false
  126836. */
  126837. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126838. /**
  126839. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  126840. */
  126841. needStencil(): boolean;
  126842. /**
  126843. * Returns true if the mesh can be rendered, otherwise false.
  126844. * @param mesh The mesh to render
  126845. * @param material The material used on the mesh
  126846. * @returns true if it can be rendered otherwise false
  126847. */
  126848. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  126849. /**
  126850. * Implementation specific of rendering the generating effect on the main canvas.
  126851. * @param effect The effect used to render through
  126852. */
  126853. protected _internalRender(effect: Effect): void;
  126854. /**
  126855. * Sets the required values for both the emissive texture and and the main color.
  126856. */
  126857. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126858. /**
  126859. * Returns true if the mesh should render, otherwise false.
  126860. * @param mesh The mesh to render
  126861. * @returns true if it should render otherwise false
  126862. */
  126863. protected _shouldRenderMesh(mesh: Mesh): boolean;
  126864. /**
  126865. * Adds specific effects defines.
  126866. * @param defines The defines to add specifics to.
  126867. */
  126868. protected _addCustomEffectDefines(defines: string[]): void;
  126869. /**
  126870. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  126871. * @param mesh The mesh to exclude from the glow layer
  126872. */
  126873. addExcludedMesh(mesh: Mesh): void;
  126874. /**
  126875. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  126876. * @param mesh The mesh to remove
  126877. */
  126878. removeExcludedMesh(mesh: Mesh): void;
  126879. /**
  126880. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  126881. * @param mesh The mesh to include in the glow layer
  126882. */
  126883. addIncludedOnlyMesh(mesh: Mesh): void;
  126884. /**
  126885. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  126886. * @param mesh The mesh to remove
  126887. */
  126888. removeIncludedOnlyMesh(mesh: Mesh): void;
  126889. /**
  126890. * Determine if a given mesh will be used in the glow layer
  126891. * @param mesh The mesh to test
  126892. * @returns true if the mesh will be highlighted by the current glow layer
  126893. */
  126894. hasMesh(mesh: AbstractMesh): boolean;
  126895. /**
  126896. * Defines whether the current material of the mesh should be use to render the effect.
  126897. * @param mesh defines the current mesh to render
  126898. */
  126899. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  126900. /**
  126901. * Add a mesh to be rendered through its own material and not with emissive only.
  126902. * @param mesh The mesh for which we need to use its material
  126903. */
  126904. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  126905. /**
  126906. * Remove a mesh from being rendered through its own material and not with emissive only.
  126907. * @param mesh The mesh for which we need to not use its material
  126908. */
  126909. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  126910. /**
  126911. * Free any resources and references associated to a mesh.
  126912. * Internal use
  126913. * @param mesh The mesh to free.
  126914. * @hidden
  126915. */
  126916. _disposeMesh(mesh: Mesh): void;
  126917. /**
  126918. * Gets the class name of the effect layer
  126919. * @returns the string with the class name of the effect layer
  126920. */
  126921. getClassName(): string;
  126922. /**
  126923. * Serializes this glow layer
  126924. * @returns a serialized glow layer object
  126925. */
  126926. serialize(): any;
  126927. /**
  126928. * Creates a Glow Layer from parsed glow layer data
  126929. * @param parsedGlowLayer defines glow layer data
  126930. * @param scene defines the current scene
  126931. * @param rootUrl defines the root URL containing the glow layer information
  126932. * @returns a parsed Glow Layer
  126933. */
  126934. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  126935. }
  126936. }
  126937. declare module BABYLON {
  126938. /** @hidden */
  126939. export var glowBlurPostProcessPixelShader: {
  126940. name: string;
  126941. shader: string;
  126942. };
  126943. }
  126944. declare module BABYLON {
  126945. interface AbstractScene {
  126946. /**
  126947. * Return a the first highlight layer of the scene with a given name.
  126948. * @param name The name of the highlight layer to look for.
  126949. * @return The highlight layer if found otherwise null.
  126950. */
  126951. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  126952. }
  126953. /**
  126954. * Highlight layer options. This helps customizing the behaviour
  126955. * of the highlight layer.
  126956. */
  126957. export interface IHighlightLayerOptions {
  126958. /**
  126959. * Multiplication factor apply to the canvas size to compute the render target size
  126960. * used to generated the glowing objects (the smaller the faster).
  126961. */
  126962. mainTextureRatio: number;
  126963. /**
  126964. * Enforces a fixed size texture to ensure resize independant blur.
  126965. */
  126966. mainTextureFixedSize?: number;
  126967. /**
  126968. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  126969. * of the picture to blur (the smaller the faster).
  126970. */
  126971. blurTextureSizeRatio: number;
  126972. /**
  126973. * How big in texel of the blur texture is the vertical blur.
  126974. */
  126975. blurVerticalSize: number;
  126976. /**
  126977. * How big in texel of the blur texture is the horizontal blur.
  126978. */
  126979. blurHorizontalSize: number;
  126980. /**
  126981. * Alpha blending mode used to apply the blur. Default is combine.
  126982. */
  126983. alphaBlendingMode: number;
  126984. /**
  126985. * The camera attached to the layer.
  126986. */
  126987. camera: Nullable<Camera>;
  126988. /**
  126989. * Should we display highlight as a solid stroke?
  126990. */
  126991. isStroke?: boolean;
  126992. /**
  126993. * The rendering group to draw the layer in.
  126994. */
  126995. renderingGroupId: number;
  126996. }
  126997. /**
  126998. * The highlight layer Helps adding a glow effect around a mesh.
  126999. *
  127000. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  127001. * glowy meshes to your scene.
  127002. *
  127003. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  127004. */
  127005. export class HighlightLayer extends EffectLayer {
  127006. name: string;
  127007. /**
  127008. * Effect Name of the highlight layer.
  127009. */
  127010. static readonly EffectName: string;
  127011. /**
  127012. * The neutral color used during the preparation of the glow effect.
  127013. * This is black by default as the blend operation is a blend operation.
  127014. */
  127015. static NeutralColor: Color4;
  127016. /**
  127017. * Stencil value used for glowing meshes.
  127018. */
  127019. static GlowingMeshStencilReference: number;
  127020. /**
  127021. * Stencil value used for the other meshes in the scene.
  127022. */
  127023. static NormalMeshStencilReference: number;
  127024. /**
  127025. * Specifies whether or not the inner glow is ACTIVE in the layer.
  127026. */
  127027. innerGlow: boolean;
  127028. /**
  127029. * Specifies whether or not the outer glow is ACTIVE in the layer.
  127030. */
  127031. outerGlow: boolean;
  127032. /**
  127033. * Specifies the horizontal size of the blur.
  127034. */
  127035. set blurHorizontalSize(value: number);
  127036. /**
  127037. * Specifies the vertical size of the blur.
  127038. */
  127039. set blurVerticalSize(value: number);
  127040. /**
  127041. * Gets the horizontal size of the blur.
  127042. */
  127043. get blurHorizontalSize(): number;
  127044. /**
  127045. * Gets the vertical size of the blur.
  127046. */
  127047. get blurVerticalSize(): number;
  127048. /**
  127049. * An event triggered when the highlight layer is being blurred.
  127050. */
  127051. onBeforeBlurObservable: Observable<HighlightLayer>;
  127052. /**
  127053. * An event triggered when the highlight layer has been blurred.
  127054. */
  127055. onAfterBlurObservable: Observable<HighlightLayer>;
  127056. private _instanceGlowingMeshStencilReference;
  127057. private _options;
  127058. private _downSamplePostprocess;
  127059. private _horizontalBlurPostprocess;
  127060. private _verticalBlurPostprocess;
  127061. private _blurTexture;
  127062. private _meshes;
  127063. private _excludedMeshes;
  127064. /**
  127065. * Instantiates a new highlight Layer and references it to the scene..
  127066. * @param name The name of the layer
  127067. * @param scene The scene to use the layer in
  127068. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  127069. */
  127070. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  127071. /**
  127072. * Get the effect name of the layer.
  127073. * @return The effect name
  127074. */
  127075. getEffectName(): string;
  127076. /**
  127077. * Create the merge effect. This is the shader use to blit the information back
  127078. * to the main canvas at the end of the scene rendering.
  127079. */
  127080. protected _createMergeEffect(): Effect;
  127081. /**
  127082. * Creates the render target textures and post processes used in the highlight layer.
  127083. */
  127084. protected _createTextureAndPostProcesses(): void;
  127085. /**
  127086. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  127087. */
  127088. needStencil(): boolean;
  127089. /**
  127090. * Checks for the readiness of the element composing the layer.
  127091. * @param subMesh the mesh to check for
  127092. * @param useInstances specify wether or not to use instances to render the mesh
  127093. * @param emissiveTexture the associated emissive texture used to generate the glow
  127094. * @return true if ready otherwise, false
  127095. */
  127096. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127097. /**
  127098. * Implementation specific of rendering the generating effect on the main canvas.
  127099. * @param effect The effect used to render through
  127100. */
  127101. protected _internalRender(effect: Effect): void;
  127102. /**
  127103. * Returns true if the layer contains information to display, otherwise false.
  127104. */
  127105. shouldRender(): boolean;
  127106. /**
  127107. * Returns true if the mesh should render, otherwise false.
  127108. * @param mesh The mesh to render
  127109. * @returns true if it should render otherwise false
  127110. */
  127111. protected _shouldRenderMesh(mesh: Mesh): boolean;
  127112. /**
  127113. * Sets the required values for both the emissive texture and and the main color.
  127114. */
  127115. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  127116. /**
  127117. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  127118. * @param mesh The mesh to exclude from the highlight layer
  127119. */
  127120. addExcludedMesh(mesh: Mesh): void;
  127121. /**
  127122. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  127123. * @param mesh The mesh to highlight
  127124. */
  127125. removeExcludedMesh(mesh: Mesh): void;
  127126. /**
  127127. * Determine if a given mesh will be highlighted by the current HighlightLayer
  127128. * @param mesh mesh to test
  127129. * @returns true if the mesh will be highlighted by the current HighlightLayer
  127130. */
  127131. hasMesh(mesh: AbstractMesh): boolean;
  127132. /**
  127133. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  127134. * @param mesh The mesh to highlight
  127135. * @param color The color of the highlight
  127136. * @param glowEmissiveOnly Extract the glow from the emissive texture
  127137. */
  127138. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  127139. /**
  127140. * Remove a mesh from the highlight layer in order to make it stop glowing.
  127141. * @param mesh The mesh to highlight
  127142. */
  127143. removeMesh(mesh: Mesh): void;
  127144. /**
  127145. * Remove all the meshes currently referenced in the highlight layer
  127146. */
  127147. removeAllMeshes(): void;
  127148. /**
  127149. * Force the stencil to the normal expected value for none glowing parts
  127150. */
  127151. private _defaultStencilReference;
  127152. /**
  127153. * Free any resources and references associated to a mesh.
  127154. * Internal use
  127155. * @param mesh The mesh to free.
  127156. * @hidden
  127157. */
  127158. _disposeMesh(mesh: Mesh): void;
  127159. /**
  127160. * Dispose the highlight layer and free resources.
  127161. */
  127162. dispose(): void;
  127163. /**
  127164. * Gets the class name of the effect layer
  127165. * @returns the string with the class name of the effect layer
  127166. */
  127167. getClassName(): string;
  127168. /**
  127169. * Serializes this Highlight layer
  127170. * @returns a serialized Highlight layer object
  127171. */
  127172. serialize(): any;
  127173. /**
  127174. * Creates a Highlight layer from parsed Highlight layer data
  127175. * @param parsedHightlightLayer defines the Highlight layer data
  127176. * @param scene defines the current scene
  127177. * @param rootUrl defines the root URL containing the Highlight layer information
  127178. * @returns a parsed Highlight layer
  127179. */
  127180. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  127181. }
  127182. }
  127183. declare module BABYLON {
  127184. interface AbstractScene {
  127185. /**
  127186. * The list of layers (background and foreground) of the scene
  127187. */
  127188. layers: Array<Layer>;
  127189. }
  127190. /**
  127191. * Defines the layer scene component responsible to manage any layers
  127192. * in a given scene.
  127193. */
  127194. export class LayerSceneComponent implements ISceneComponent {
  127195. /**
  127196. * The component name helpfull to identify the component in the list of scene components.
  127197. */
  127198. readonly name: string;
  127199. /**
  127200. * The scene the component belongs to.
  127201. */
  127202. scene: Scene;
  127203. private _engine;
  127204. /**
  127205. * Creates a new instance of the component for the given scene
  127206. * @param scene Defines the scene to register the component in
  127207. */
  127208. constructor(scene: Scene);
  127209. /**
  127210. * Registers the component in a given scene
  127211. */
  127212. register(): void;
  127213. /**
  127214. * Rebuilds the elements related to this component in case of
  127215. * context lost for instance.
  127216. */
  127217. rebuild(): void;
  127218. /**
  127219. * Disposes the component and the associated ressources.
  127220. */
  127221. dispose(): void;
  127222. private _draw;
  127223. private _drawCameraPredicate;
  127224. private _drawCameraBackground;
  127225. private _drawCameraForeground;
  127226. private _drawRenderTargetPredicate;
  127227. private _drawRenderTargetBackground;
  127228. private _drawRenderTargetForeground;
  127229. /**
  127230. * Adds all the elements from the container to the scene
  127231. * @param container the container holding the elements
  127232. */
  127233. addFromContainer(container: AbstractScene): void;
  127234. /**
  127235. * Removes all the elements in the container from the scene
  127236. * @param container contains the elements to remove
  127237. * @param dispose if the removed element should be disposed (default: false)
  127238. */
  127239. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127240. }
  127241. }
  127242. declare module BABYLON {
  127243. /** @hidden */
  127244. export var layerPixelShader: {
  127245. name: string;
  127246. shader: string;
  127247. };
  127248. }
  127249. declare module BABYLON {
  127250. /** @hidden */
  127251. export var layerVertexShader: {
  127252. name: string;
  127253. shader: string;
  127254. };
  127255. }
  127256. declare module BABYLON {
  127257. /**
  127258. * This represents a full screen 2d layer.
  127259. * This can be useful to display a picture in the background of your scene for instance.
  127260. * @see https://www.babylonjs-playground.com/#08A2BS#1
  127261. */
  127262. export class Layer {
  127263. /**
  127264. * Define the name of the layer.
  127265. */
  127266. name: string;
  127267. /**
  127268. * Define the texture the layer should display.
  127269. */
  127270. texture: Nullable<Texture>;
  127271. /**
  127272. * Is the layer in background or foreground.
  127273. */
  127274. isBackground: boolean;
  127275. /**
  127276. * Define the color of the layer (instead of texture).
  127277. */
  127278. color: Color4;
  127279. /**
  127280. * Define the scale of the layer in order to zoom in out of the texture.
  127281. */
  127282. scale: Vector2;
  127283. /**
  127284. * Define an offset for the layer in order to shift the texture.
  127285. */
  127286. offset: Vector2;
  127287. /**
  127288. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  127289. */
  127290. alphaBlendingMode: number;
  127291. /**
  127292. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  127293. * Alpha test will not mix with the background color in case of transparency.
  127294. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  127295. */
  127296. alphaTest: boolean;
  127297. /**
  127298. * Define a mask to restrict the layer to only some of the scene cameras.
  127299. */
  127300. layerMask: number;
  127301. /**
  127302. * Define the list of render target the layer is visible into.
  127303. */
  127304. renderTargetTextures: RenderTargetTexture[];
  127305. /**
  127306. * Define if the layer is only used in renderTarget or if it also
  127307. * renders in the main frame buffer of the canvas.
  127308. */
  127309. renderOnlyInRenderTargetTextures: boolean;
  127310. private _scene;
  127311. private _vertexBuffers;
  127312. private _indexBuffer;
  127313. private _effect;
  127314. private _previousDefines;
  127315. /**
  127316. * An event triggered when the layer is disposed.
  127317. */
  127318. onDisposeObservable: Observable<Layer>;
  127319. private _onDisposeObserver;
  127320. /**
  127321. * Back compatibility with callback before the onDisposeObservable existed.
  127322. * The set callback will be triggered when the layer has been disposed.
  127323. */
  127324. set onDispose(callback: () => void);
  127325. /**
  127326. * An event triggered before rendering the scene
  127327. */
  127328. onBeforeRenderObservable: Observable<Layer>;
  127329. private _onBeforeRenderObserver;
  127330. /**
  127331. * Back compatibility with callback before the onBeforeRenderObservable existed.
  127332. * The set callback will be triggered just before rendering the layer.
  127333. */
  127334. set onBeforeRender(callback: () => void);
  127335. /**
  127336. * An event triggered after rendering the scene
  127337. */
  127338. onAfterRenderObservable: Observable<Layer>;
  127339. private _onAfterRenderObserver;
  127340. /**
  127341. * Back compatibility with callback before the onAfterRenderObservable existed.
  127342. * The set callback will be triggered just after rendering the layer.
  127343. */
  127344. set onAfterRender(callback: () => void);
  127345. /**
  127346. * Instantiates a new layer.
  127347. * This represents a full screen 2d layer.
  127348. * This can be useful to display a picture in the background of your scene for instance.
  127349. * @see https://www.babylonjs-playground.com/#08A2BS#1
  127350. * @param name Define the name of the layer in the scene
  127351. * @param imgUrl Define the url of the texture to display in the layer
  127352. * @param scene Define the scene the layer belongs to
  127353. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  127354. * @param color Defines a color for the layer
  127355. */
  127356. constructor(
  127357. /**
  127358. * Define the name of the layer.
  127359. */
  127360. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  127361. private _createIndexBuffer;
  127362. /** @hidden */
  127363. _rebuild(): void;
  127364. /**
  127365. * Renders the layer in the scene.
  127366. */
  127367. render(): void;
  127368. /**
  127369. * Disposes and releases the associated ressources.
  127370. */
  127371. dispose(): void;
  127372. }
  127373. }
  127374. declare module BABYLON {
  127375. /** @hidden */
  127376. export var lensFlarePixelShader: {
  127377. name: string;
  127378. shader: string;
  127379. };
  127380. }
  127381. declare module BABYLON {
  127382. /** @hidden */
  127383. export var lensFlareVertexShader: {
  127384. name: string;
  127385. shader: string;
  127386. };
  127387. }
  127388. declare module BABYLON {
  127389. /**
  127390. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  127391. * It is usually composed of several `lensFlare`.
  127392. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127393. */
  127394. export class LensFlareSystem {
  127395. /**
  127396. * Define the name of the lens flare system
  127397. */
  127398. name: string;
  127399. /**
  127400. * List of lens flares used in this system.
  127401. */
  127402. lensFlares: LensFlare[];
  127403. /**
  127404. * Define a limit from the border the lens flare can be visible.
  127405. */
  127406. borderLimit: number;
  127407. /**
  127408. * Define a viewport border we do not want to see the lens flare in.
  127409. */
  127410. viewportBorder: number;
  127411. /**
  127412. * Define a predicate which could limit the list of meshes able to occlude the effect.
  127413. */
  127414. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  127415. /**
  127416. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  127417. */
  127418. layerMask: number;
  127419. /**
  127420. * Define the id of the lens flare system in the scene.
  127421. * (equal to name by default)
  127422. */
  127423. id: string;
  127424. private _scene;
  127425. private _emitter;
  127426. private _vertexBuffers;
  127427. private _indexBuffer;
  127428. private _effect;
  127429. private _positionX;
  127430. private _positionY;
  127431. private _isEnabled;
  127432. /** @hidden */
  127433. static _SceneComponentInitialization: (scene: Scene) => void;
  127434. /**
  127435. * Instantiates a lens flare system.
  127436. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  127437. * It is usually composed of several `lensFlare`.
  127438. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127439. * @param name Define the name of the lens flare system in the scene
  127440. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  127441. * @param scene Define the scene the lens flare system belongs to
  127442. */
  127443. constructor(
  127444. /**
  127445. * Define the name of the lens flare system
  127446. */
  127447. name: string, emitter: any, scene: Scene);
  127448. /**
  127449. * Define if the lens flare system is enabled.
  127450. */
  127451. get isEnabled(): boolean;
  127452. set isEnabled(value: boolean);
  127453. /**
  127454. * Get the scene the effects belongs to.
  127455. * @returns the scene holding the lens flare system
  127456. */
  127457. getScene(): Scene;
  127458. /**
  127459. * Get the emitter of the lens flare system.
  127460. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  127461. * @returns the emitter of the lens flare system
  127462. */
  127463. getEmitter(): any;
  127464. /**
  127465. * Set the emitter of the lens flare system.
  127466. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  127467. * @param newEmitter Define the new emitter of the system
  127468. */
  127469. setEmitter(newEmitter: any): void;
  127470. /**
  127471. * Get the lens flare system emitter position.
  127472. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  127473. * @returns the position
  127474. */
  127475. getEmitterPosition(): Vector3;
  127476. /**
  127477. * @hidden
  127478. */
  127479. computeEffectivePosition(globalViewport: Viewport): boolean;
  127480. /** @hidden */
  127481. _isVisible(): boolean;
  127482. /**
  127483. * @hidden
  127484. */
  127485. render(): boolean;
  127486. /**
  127487. * Dispose and release the lens flare with its associated resources.
  127488. */
  127489. dispose(): void;
  127490. /**
  127491. * Parse a lens flare system from a JSON repressentation
  127492. * @param parsedLensFlareSystem Define the JSON to parse
  127493. * @param scene Define the scene the parsed system should be instantiated in
  127494. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  127495. * @returns the parsed system
  127496. */
  127497. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  127498. /**
  127499. * Serialize the current Lens Flare System into a JSON representation.
  127500. * @returns the serialized JSON
  127501. */
  127502. serialize(): any;
  127503. }
  127504. }
  127505. declare module BABYLON {
  127506. /**
  127507. * This represents one of the lens effect in a `lensFlareSystem`.
  127508. * It controls one of the indiviual texture used in the effect.
  127509. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127510. */
  127511. export class LensFlare {
  127512. /**
  127513. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  127514. */
  127515. size: number;
  127516. /**
  127517. * 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.
  127518. */
  127519. position: number;
  127520. /**
  127521. * Define the lens color.
  127522. */
  127523. color: Color3;
  127524. /**
  127525. * Define the lens texture.
  127526. */
  127527. texture: Nullable<Texture>;
  127528. /**
  127529. * Define the alpha mode to render this particular lens.
  127530. */
  127531. alphaMode: number;
  127532. private _system;
  127533. /**
  127534. * Creates a new Lens Flare.
  127535. * This represents one of the lens effect in a `lensFlareSystem`.
  127536. * It controls one of the indiviual texture used in the effect.
  127537. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127538. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  127539. * @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.
  127540. * @param color Define the lens color
  127541. * @param imgUrl Define the lens texture url
  127542. * @param system Define the `lensFlareSystem` this flare is part of
  127543. * @returns The newly created Lens Flare
  127544. */
  127545. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  127546. /**
  127547. * Instantiates a new Lens Flare.
  127548. * This represents one of the lens effect in a `lensFlareSystem`.
  127549. * It controls one of the indiviual texture used in the effect.
  127550. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127551. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  127552. * @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.
  127553. * @param color Define the lens color
  127554. * @param imgUrl Define the lens texture url
  127555. * @param system Define the `lensFlareSystem` this flare is part of
  127556. */
  127557. constructor(
  127558. /**
  127559. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  127560. */
  127561. size: number,
  127562. /**
  127563. * 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.
  127564. */
  127565. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  127566. /**
  127567. * Dispose and release the lens flare with its associated resources.
  127568. */
  127569. dispose(): void;
  127570. }
  127571. }
  127572. declare module BABYLON {
  127573. interface AbstractScene {
  127574. /**
  127575. * The list of lens flare system added to the scene
  127576. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127577. */
  127578. lensFlareSystems: Array<LensFlareSystem>;
  127579. /**
  127580. * Removes the given lens flare system from this scene.
  127581. * @param toRemove The lens flare system to remove
  127582. * @returns The index of the removed lens flare system
  127583. */
  127584. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  127585. /**
  127586. * Adds the given lens flare system to this scene
  127587. * @param newLensFlareSystem The lens flare system to add
  127588. */
  127589. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  127590. /**
  127591. * Gets a lens flare system using its name
  127592. * @param name defines the name to look for
  127593. * @returns the lens flare system or null if not found
  127594. */
  127595. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  127596. /**
  127597. * Gets a lens flare system using its id
  127598. * @param id defines the id to look for
  127599. * @returns the lens flare system or null if not found
  127600. */
  127601. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  127602. }
  127603. /**
  127604. * Defines the lens flare scene component responsible to manage any lens flares
  127605. * in a given scene.
  127606. */
  127607. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  127608. /**
  127609. * The component name helpfull to identify the component in the list of scene components.
  127610. */
  127611. readonly name: string;
  127612. /**
  127613. * The scene the component belongs to.
  127614. */
  127615. scene: Scene;
  127616. /**
  127617. * Creates a new instance of the component for the given scene
  127618. * @param scene Defines the scene to register the component in
  127619. */
  127620. constructor(scene: Scene);
  127621. /**
  127622. * Registers the component in a given scene
  127623. */
  127624. register(): void;
  127625. /**
  127626. * Rebuilds the elements related to this component in case of
  127627. * context lost for instance.
  127628. */
  127629. rebuild(): void;
  127630. /**
  127631. * Adds all the elements from the container to the scene
  127632. * @param container the container holding the elements
  127633. */
  127634. addFromContainer(container: AbstractScene): void;
  127635. /**
  127636. * Removes all the elements in the container from the scene
  127637. * @param container contains the elements to remove
  127638. * @param dispose if the removed element should be disposed (default: false)
  127639. */
  127640. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127641. /**
  127642. * Serializes the component data to the specified json object
  127643. * @param serializationObject The object to serialize to
  127644. */
  127645. serialize(serializationObject: any): void;
  127646. /**
  127647. * Disposes the component and the associated ressources.
  127648. */
  127649. dispose(): void;
  127650. private _draw;
  127651. }
  127652. }
  127653. declare module BABYLON {
  127654. /** @hidden */
  127655. export var depthPixelShader: {
  127656. name: string;
  127657. shader: string;
  127658. };
  127659. }
  127660. declare module BABYLON {
  127661. /** @hidden */
  127662. export var depthVertexShader: {
  127663. name: string;
  127664. shader: string;
  127665. };
  127666. }
  127667. declare module BABYLON {
  127668. /**
  127669. * This represents a depth renderer in Babylon.
  127670. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  127671. */
  127672. export class DepthRenderer {
  127673. private _scene;
  127674. private _depthMap;
  127675. private _effect;
  127676. private readonly _storeNonLinearDepth;
  127677. private readonly _clearColor;
  127678. /** Get if the depth renderer is using packed depth or not */
  127679. readonly isPacked: boolean;
  127680. private _cachedDefines;
  127681. private _camera;
  127682. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  127683. enabled: boolean;
  127684. /**
  127685. * Specifiess that the depth renderer will only be used within
  127686. * the camera it is created for.
  127687. * This can help forcing its rendering during the camera processing.
  127688. */
  127689. useOnlyInActiveCamera: boolean;
  127690. /** @hidden */
  127691. static _SceneComponentInitialization: (scene: Scene) => void;
  127692. /**
  127693. * Instantiates a depth renderer
  127694. * @param scene The scene the renderer belongs to
  127695. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  127696. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  127697. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  127698. */
  127699. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  127700. /**
  127701. * Creates the depth rendering effect and checks if the effect is ready.
  127702. * @param subMesh The submesh to be used to render the depth map of
  127703. * @param useInstances If multiple world instances should be used
  127704. * @returns if the depth renderer is ready to render the depth map
  127705. */
  127706. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127707. /**
  127708. * Gets the texture which the depth map will be written to.
  127709. * @returns The depth map texture
  127710. */
  127711. getDepthMap(): RenderTargetTexture;
  127712. /**
  127713. * Disposes of the depth renderer.
  127714. */
  127715. dispose(): void;
  127716. }
  127717. }
  127718. declare module BABYLON {
  127719. /** @hidden */
  127720. export var minmaxReduxPixelShader: {
  127721. name: string;
  127722. shader: string;
  127723. };
  127724. }
  127725. declare module BABYLON {
  127726. /**
  127727. * This class computes a min/max reduction from a texture: it means it computes the minimum
  127728. * and maximum values from all values of the texture.
  127729. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  127730. * The source values are read from the red channel of the texture.
  127731. */
  127732. export class MinMaxReducer {
  127733. /**
  127734. * Observable triggered when the computation has been performed
  127735. */
  127736. onAfterReductionPerformed: Observable<{
  127737. min: number;
  127738. max: number;
  127739. }>;
  127740. protected _camera: Camera;
  127741. protected _sourceTexture: Nullable<RenderTargetTexture>;
  127742. protected _reductionSteps: Nullable<Array<PostProcess>>;
  127743. protected _postProcessManager: PostProcessManager;
  127744. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  127745. protected _forceFullscreenViewport: boolean;
  127746. /**
  127747. * Creates a min/max reducer
  127748. * @param camera The camera to use for the post processes
  127749. */
  127750. constructor(camera: Camera);
  127751. /**
  127752. * Gets the texture used to read the values from.
  127753. */
  127754. get sourceTexture(): Nullable<RenderTargetTexture>;
  127755. /**
  127756. * Sets the source texture to read the values from.
  127757. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  127758. * because in such textures '1' value must not be taken into account to compute the maximum
  127759. * as this value is used to clear the texture.
  127760. * Note that the computation is not activated by calling this function, you must call activate() for that!
  127761. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  127762. * @param depthRedux Indicates if the texture is a depth texture or not
  127763. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  127764. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  127765. */
  127766. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  127767. /**
  127768. * Defines the refresh rate of the computation.
  127769. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127770. */
  127771. get refreshRate(): number;
  127772. set refreshRate(value: number);
  127773. protected _activated: boolean;
  127774. /**
  127775. * Gets the activation status of the reducer
  127776. */
  127777. get activated(): boolean;
  127778. /**
  127779. * Activates the reduction computation.
  127780. * When activated, the observers registered in onAfterReductionPerformed are
  127781. * called after the compuation is performed
  127782. */
  127783. activate(): void;
  127784. /**
  127785. * Deactivates the reduction computation.
  127786. */
  127787. deactivate(): void;
  127788. /**
  127789. * Disposes the min/max reducer
  127790. * @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.
  127791. */
  127792. dispose(disposeAll?: boolean): void;
  127793. }
  127794. }
  127795. declare module BABYLON {
  127796. /**
  127797. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  127798. */
  127799. export class DepthReducer extends MinMaxReducer {
  127800. private _depthRenderer;
  127801. private _depthRendererId;
  127802. /**
  127803. * Gets the depth renderer used for the computation.
  127804. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  127805. */
  127806. get depthRenderer(): Nullable<DepthRenderer>;
  127807. /**
  127808. * Creates a depth reducer
  127809. * @param camera The camera used to render the depth texture
  127810. */
  127811. constructor(camera: Camera);
  127812. /**
  127813. * Sets the depth renderer to use to generate the depth map
  127814. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  127815. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  127816. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  127817. */
  127818. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  127819. /** @hidden */
  127820. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  127821. /**
  127822. * Activates the reduction computation.
  127823. * When activated, the observers registered in onAfterReductionPerformed are
  127824. * called after the compuation is performed
  127825. */
  127826. activate(): void;
  127827. /**
  127828. * Deactivates the reduction computation.
  127829. */
  127830. deactivate(): void;
  127831. /**
  127832. * Disposes the depth reducer
  127833. * @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.
  127834. */
  127835. dispose(disposeAll?: boolean): void;
  127836. }
  127837. }
  127838. declare module BABYLON {
  127839. /**
  127840. * A CSM implementation allowing casting shadows on large scenes.
  127841. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  127842. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  127843. */
  127844. export class CascadedShadowGenerator extends ShadowGenerator {
  127845. private static readonly frustumCornersNDCSpace;
  127846. /**
  127847. * Name of the CSM class
  127848. */
  127849. static CLASSNAME: string;
  127850. /**
  127851. * Defines the default number of cascades used by the CSM.
  127852. */
  127853. static readonly DEFAULT_CASCADES_COUNT: number;
  127854. /**
  127855. * Defines the minimum number of cascades used by the CSM.
  127856. */
  127857. static readonly MIN_CASCADES_COUNT: number;
  127858. /**
  127859. * Defines the maximum number of cascades used by the CSM.
  127860. */
  127861. static readonly MAX_CASCADES_COUNT: number;
  127862. protected _validateFilter(filter: number): number;
  127863. /**
  127864. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  127865. */
  127866. penumbraDarkness: number;
  127867. private _numCascades;
  127868. /**
  127869. * Gets or set the number of cascades used by the CSM.
  127870. */
  127871. get numCascades(): number;
  127872. set numCascades(value: number);
  127873. /**
  127874. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  127875. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  127876. */
  127877. stabilizeCascades: boolean;
  127878. private _freezeShadowCastersBoundingInfo;
  127879. private _freezeShadowCastersBoundingInfoObservable;
  127880. /**
  127881. * Enables or disables the shadow casters bounding info computation.
  127882. * If your shadow casters don't move, you can disable this feature.
  127883. * If it is enabled, the bounding box computation is done every frame.
  127884. */
  127885. get freezeShadowCastersBoundingInfo(): boolean;
  127886. set freezeShadowCastersBoundingInfo(freeze: boolean);
  127887. private _scbiMin;
  127888. private _scbiMax;
  127889. protected _computeShadowCastersBoundingInfo(): void;
  127890. protected _shadowCastersBoundingInfo: BoundingInfo;
  127891. /**
  127892. * Gets or sets the shadow casters bounding info.
  127893. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  127894. * so that the system won't overwrite the bounds you provide
  127895. */
  127896. get shadowCastersBoundingInfo(): BoundingInfo;
  127897. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  127898. protected _breaksAreDirty: boolean;
  127899. protected _minDistance: number;
  127900. protected _maxDistance: number;
  127901. /**
  127902. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  127903. *
  127904. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  127905. * If you don't know these values, simply leave them to their defaults and don't call this function.
  127906. * @param min minimal distance for the breaks (default to 0.)
  127907. * @param max maximal distance for the breaks (default to 1.)
  127908. */
  127909. setMinMaxDistance(min: number, max: number): void;
  127910. /** Gets the minimal distance used in the cascade break computation */
  127911. get minDistance(): number;
  127912. /** Gets the maximal distance used in the cascade break computation */
  127913. get maxDistance(): number;
  127914. /**
  127915. * Gets the class name of that object
  127916. * @returns "CascadedShadowGenerator"
  127917. */
  127918. getClassName(): string;
  127919. private _cascadeMinExtents;
  127920. private _cascadeMaxExtents;
  127921. /**
  127922. * Gets a cascade minimum extents
  127923. * @param cascadeIndex index of the cascade
  127924. * @returns the minimum cascade extents
  127925. */
  127926. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  127927. /**
  127928. * Gets a cascade maximum extents
  127929. * @param cascadeIndex index of the cascade
  127930. * @returns the maximum cascade extents
  127931. */
  127932. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  127933. private _cascades;
  127934. private _currentLayer;
  127935. private _viewSpaceFrustumsZ;
  127936. private _viewMatrices;
  127937. private _projectionMatrices;
  127938. private _transformMatrices;
  127939. private _transformMatricesAsArray;
  127940. private _frustumLengths;
  127941. private _lightSizeUVCorrection;
  127942. private _depthCorrection;
  127943. private _frustumCornersWorldSpace;
  127944. private _frustumCenter;
  127945. private _shadowCameraPos;
  127946. private _shadowMaxZ;
  127947. /**
  127948. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  127949. * It defaults to camera.maxZ
  127950. */
  127951. get shadowMaxZ(): number;
  127952. /**
  127953. * Sets the shadow max z distance.
  127954. */
  127955. set shadowMaxZ(value: number);
  127956. protected _debug: boolean;
  127957. /**
  127958. * Gets or sets the debug flag.
  127959. * When enabled, the cascades are materialized by different colors on the screen.
  127960. */
  127961. get debug(): boolean;
  127962. set debug(dbg: boolean);
  127963. private _depthClamp;
  127964. /**
  127965. * Gets or sets the depth clamping value.
  127966. *
  127967. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  127968. * to account for the shadow casters far away.
  127969. *
  127970. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  127971. */
  127972. get depthClamp(): boolean;
  127973. set depthClamp(value: boolean);
  127974. private _cascadeBlendPercentage;
  127975. /**
  127976. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  127977. * It defaults to 0.1 (10% blending).
  127978. */
  127979. get cascadeBlendPercentage(): number;
  127980. set cascadeBlendPercentage(value: number);
  127981. private _lambda;
  127982. /**
  127983. * Gets or set the lambda parameter.
  127984. * This parameter is used to split the camera frustum and create the cascades.
  127985. * 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.
  127986. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  127987. */
  127988. get lambda(): number;
  127989. set lambda(value: number);
  127990. /**
  127991. * Gets the view matrix corresponding to a given cascade
  127992. * @param cascadeNum cascade to retrieve the view matrix from
  127993. * @returns the cascade view matrix
  127994. */
  127995. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  127996. /**
  127997. * Gets the projection matrix corresponding to a given cascade
  127998. * @param cascadeNum cascade to retrieve the projection matrix from
  127999. * @returns the cascade projection matrix
  128000. */
  128001. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  128002. /**
  128003. * Gets the transformation matrix corresponding to a given cascade
  128004. * @param cascadeNum cascade to retrieve the transformation matrix from
  128005. * @returns the cascade transformation matrix
  128006. */
  128007. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  128008. private _depthRenderer;
  128009. /**
  128010. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  128011. *
  128012. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  128013. *
  128014. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  128015. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  128016. * @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
  128017. */
  128018. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  128019. private _depthReducer;
  128020. private _autoCalcDepthBounds;
  128021. /**
  128022. * Gets or sets the autoCalcDepthBounds property.
  128023. *
  128024. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  128025. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  128026. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  128027. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  128028. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  128029. */
  128030. get autoCalcDepthBounds(): boolean;
  128031. set autoCalcDepthBounds(value: boolean);
  128032. /**
  128033. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  128034. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  128035. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  128036. * for setting the refresh rate on the renderer yourself!
  128037. */
  128038. get autoCalcDepthBoundsRefreshRate(): number;
  128039. set autoCalcDepthBoundsRefreshRate(value: number);
  128040. /**
  128041. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  128042. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  128043. * you change the camera near/far planes!
  128044. */
  128045. splitFrustum(): void;
  128046. private _splitFrustum;
  128047. private _computeMatrices;
  128048. private _computeFrustumInWorldSpace;
  128049. private _computeCascadeFrustum;
  128050. /** @hidden */
  128051. static _SceneComponentInitialization: (scene: Scene) => void;
  128052. /**
  128053. * Creates a Cascaded Shadow Generator object.
  128054. * A ShadowGenerator is the required tool to use the shadows.
  128055. * Each directional light casting shadows needs to use its own ShadowGenerator.
  128056. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  128057. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  128058. * @param light The directional light object generating the shadows.
  128059. * @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.
  128060. */
  128061. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  128062. protected _initializeGenerator(): void;
  128063. protected _createTargetRenderTexture(): void;
  128064. protected _initializeShadowMap(): void;
  128065. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  128066. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  128067. /**
  128068. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  128069. * @param defines Defines of the material we want to update
  128070. * @param lightIndex Index of the light in the enabled light list of the material
  128071. */
  128072. prepareDefines(defines: any, lightIndex: number): void;
  128073. /**
  128074. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  128075. * defined in the generator but impacting the effect).
  128076. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  128077. * @param effect The effect we are binfing the information for
  128078. */
  128079. bindShadowLight(lightIndex: string, effect: Effect): void;
  128080. /**
  128081. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  128082. * (eq to view projection * shadow projection matrices)
  128083. * @returns The transform matrix used to create the shadow map
  128084. */
  128085. getTransformMatrix(): Matrix;
  128086. /**
  128087. * Disposes the ShadowGenerator.
  128088. * Returns nothing.
  128089. */
  128090. dispose(): void;
  128091. /**
  128092. * Serializes the shadow generator setup to a json object.
  128093. * @returns The serialized JSON object
  128094. */
  128095. serialize(): any;
  128096. /**
  128097. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  128098. * @param parsedShadowGenerator The JSON object to parse
  128099. * @param scene The scene to create the shadow map for
  128100. * @returns The parsed shadow generator
  128101. */
  128102. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  128103. }
  128104. }
  128105. declare module BABYLON {
  128106. /**
  128107. * Defines the shadow generator component responsible to manage any shadow generators
  128108. * in a given scene.
  128109. */
  128110. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  128111. /**
  128112. * The component name helpfull to identify the component in the list of scene components.
  128113. */
  128114. readonly name: string;
  128115. /**
  128116. * The scene the component belongs to.
  128117. */
  128118. scene: Scene;
  128119. /**
  128120. * Creates a new instance of the component for the given scene
  128121. * @param scene Defines the scene to register the component in
  128122. */
  128123. constructor(scene: Scene);
  128124. /**
  128125. * Registers the component in a given scene
  128126. */
  128127. register(): void;
  128128. /**
  128129. * Rebuilds the elements related to this component in case of
  128130. * context lost for instance.
  128131. */
  128132. rebuild(): void;
  128133. /**
  128134. * Serializes the component data to the specified json object
  128135. * @param serializationObject The object to serialize to
  128136. */
  128137. serialize(serializationObject: any): void;
  128138. /**
  128139. * Adds all the elements from the container to the scene
  128140. * @param container the container holding the elements
  128141. */
  128142. addFromContainer(container: AbstractScene): void;
  128143. /**
  128144. * Removes all the elements in the container from the scene
  128145. * @param container contains the elements to remove
  128146. * @param dispose if the removed element should be disposed (default: false)
  128147. */
  128148. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  128149. /**
  128150. * Rebuilds the elements related to this component in case of
  128151. * context lost for instance.
  128152. */
  128153. dispose(): void;
  128154. private _gatherRenderTargets;
  128155. }
  128156. }
  128157. declare module BABYLON {
  128158. /**
  128159. * A point light is a light defined by an unique point in world space.
  128160. * The light is emitted in every direction from this point.
  128161. * A good example of a point light is a standard light bulb.
  128162. * Documentation: https://doc.babylonjs.com/babylon101/lights
  128163. */
  128164. export class PointLight extends ShadowLight {
  128165. private _shadowAngle;
  128166. /**
  128167. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  128168. * This specifies what angle the shadow will use to be created.
  128169. *
  128170. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  128171. */
  128172. get shadowAngle(): number;
  128173. /**
  128174. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  128175. * This specifies what angle the shadow will use to be created.
  128176. *
  128177. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  128178. */
  128179. set shadowAngle(value: number);
  128180. /**
  128181. * Gets the direction if it has been set.
  128182. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  128183. */
  128184. get direction(): Vector3;
  128185. /**
  128186. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  128187. */
  128188. set direction(value: Vector3);
  128189. /**
  128190. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  128191. * A PointLight emits the light in every direction.
  128192. * It can cast shadows.
  128193. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  128194. * ```javascript
  128195. * var pointLight = new PointLight("pl", camera.position, scene);
  128196. * ```
  128197. * Documentation : https://doc.babylonjs.com/babylon101/lights
  128198. * @param name The light friendly name
  128199. * @param position The position of the point light in the scene
  128200. * @param scene The scene the lights belongs to
  128201. */
  128202. constructor(name: string, position: Vector3, scene: Scene);
  128203. /**
  128204. * Returns the string "PointLight"
  128205. * @returns the class name
  128206. */
  128207. getClassName(): string;
  128208. /**
  128209. * Returns the integer 0.
  128210. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  128211. */
  128212. getTypeID(): number;
  128213. /**
  128214. * Specifies wether or not the shadowmap should be a cube texture.
  128215. * @returns true if the shadowmap needs to be a cube texture.
  128216. */
  128217. needCube(): boolean;
  128218. /**
  128219. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  128220. * @param faceIndex The index of the face we are computed the direction to generate shadow
  128221. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  128222. */
  128223. getShadowDirection(faceIndex?: number): Vector3;
  128224. /**
  128225. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  128226. * - fov = PI / 2
  128227. * - aspect ratio : 1.0
  128228. * - z-near and far equal to the active camera minZ and maxZ.
  128229. * Returns the PointLight.
  128230. */
  128231. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  128232. protected _buildUniformLayout(): void;
  128233. /**
  128234. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  128235. * @param effect The effect to update
  128236. * @param lightIndex The index of the light in the effect to update
  128237. * @returns The point light
  128238. */
  128239. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  128240. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  128241. /**
  128242. * Prepares the list of defines specific to the light type.
  128243. * @param defines the list of defines
  128244. * @param lightIndex defines the index of the light for the effect
  128245. */
  128246. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  128247. }
  128248. }
  128249. declare module BABYLON {
  128250. /**
  128251. * Header information of HDR texture files.
  128252. */
  128253. export interface HDRInfo {
  128254. /**
  128255. * The height of the texture in pixels.
  128256. */
  128257. height: number;
  128258. /**
  128259. * The width of the texture in pixels.
  128260. */
  128261. width: number;
  128262. /**
  128263. * The index of the beginning of the data in the binary file.
  128264. */
  128265. dataPosition: number;
  128266. }
  128267. /**
  128268. * This groups tools to convert HDR texture to native colors array.
  128269. */
  128270. export class HDRTools {
  128271. private static Ldexp;
  128272. private static Rgbe2float;
  128273. private static readStringLine;
  128274. /**
  128275. * Reads header information from an RGBE texture stored in a native array.
  128276. * More information on this format are available here:
  128277. * https://en.wikipedia.org/wiki/RGBE_image_format
  128278. *
  128279. * @param uint8array The binary file stored in native array.
  128280. * @return The header information.
  128281. */
  128282. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  128283. /**
  128284. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  128285. * This RGBE texture needs to store the information as a panorama.
  128286. *
  128287. * More information on this format are available here:
  128288. * https://en.wikipedia.org/wiki/RGBE_image_format
  128289. *
  128290. * @param buffer The binary file stored in an array buffer.
  128291. * @param size The expected size of the extracted cubemap.
  128292. * @return The Cube Map information.
  128293. */
  128294. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  128295. /**
  128296. * Returns the pixels data extracted from an RGBE texture.
  128297. * This pixels will be stored left to right up to down in the R G B order in one array.
  128298. *
  128299. * More information on this format are available here:
  128300. * https://en.wikipedia.org/wiki/RGBE_image_format
  128301. *
  128302. * @param uint8array The binary file stored in an array buffer.
  128303. * @param hdrInfo The header information of the file.
  128304. * @return The pixels data in RGB right to left up to down order.
  128305. */
  128306. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  128307. private static RGBE_ReadPixels_RLE;
  128308. }
  128309. }
  128310. declare module BABYLON {
  128311. /**
  128312. * This represents a texture coming from an HDR input.
  128313. *
  128314. * The only supported format is currently panorama picture stored in RGBE format.
  128315. * Example of such files can be found on HDRLib: http://hdrlib.com/
  128316. */
  128317. export class HDRCubeTexture extends BaseTexture {
  128318. private static _facesMapping;
  128319. private _generateHarmonics;
  128320. private _noMipmap;
  128321. private _textureMatrix;
  128322. private _size;
  128323. private _onLoad;
  128324. private _onError;
  128325. /**
  128326. * The texture URL.
  128327. */
  128328. url: string;
  128329. /**
  128330. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  128331. */
  128332. coordinatesMode: number;
  128333. protected _isBlocking: boolean;
  128334. /**
  128335. * Sets wether or not the texture is blocking during loading.
  128336. */
  128337. set isBlocking(value: boolean);
  128338. /**
  128339. * Gets wether or not the texture is blocking during loading.
  128340. */
  128341. get isBlocking(): boolean;
  128342. protected _rotationY: number;
  128343. /**
  128344. * Sets texture matrix rotation angle around Y axis in radians.
  128345. */
  128346. set rotationY(value: number);
  128347. /**
  128348. * Gets texture matrix rotation angle around Y axis radians.
  128349. */
  128350. get rotationY(): number;
  128351. /**
  128352. * Gets or sets the center of the bounding box associated with the cube texture
  128353. * It must define where the camera used to render the texture was set
  128354. */
  128355. boundingBoxPosition: Vector3;
  128356. private _boundingBoxSize;
  128357. /**
  128358. * Gets or sets the size of the bounding box associated with the cube texture
  128359. * When defined, the cubemap will switch to local mode
  128360. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  128361. * @example https://www.babylonjs-playground.com/#RNASML
  128362. */
  128363. set boundingBoxSize(value: Vector3);
  128364. get boundingBoxSize(): Vector3;
  128365. /**
  128366. * Instantiates an HDRTexture from the following parameters.
  128367. *
  128368. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  128369. * @param scene The scene the texture will be used in
  128370. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  128371. * @param noMipmap Forces to not generate the mipmap if true
  128372. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  128373. * @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)
  128374. * @param reserved Reserved flag for internal use.
  128375. */
  128376. 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>);
  128377. /**
  128378. * Get the current class name of the texture useful for serialization or dynamic coding.
  128379. * @returns "HDRCubeTexture"
  128380. */
  128381. getClassName(): string;
  128382. /**
  128383. * Occurs when the file is raw .hdr file.
  128384. */
  128385. private loadTexture;
  128386. clone(): HDRCubeTexture;
  128387. delayLoad(): void;
  128388. /**
  128389. * Get the texture reflection matrix used to rotate/transform the reflection.
  128390. * @returns the reflection matrix
  128391. */
  128392. getReflectionTextureMatrix(): Matrix;
  128393. /**
  128394. * Set the texture reflection matrix used to rotate/transform the reflection.
  128395. * @param value Define the reflection matrix to set
  128396. */
  128397. setReflectionTextureMatrix(value: Matrix): void;
  128398. /**
  128399. * Parses a JSON representation of an HDR Texture in order to create the texture
  128400. * @param parsedTexture Define the JSON representation
  128401. * @param scene Define the scene the texture should be created in
  128402. * @param rootUrl Define the root url in case we need to load relative dependencies
  128403. * @returns the newly created texture after parsing
  128404. */
  128405. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  128406. serialize(): any;
  128407. }
  128408. }
  128409. declare module BABYLON {
  128410. /**
  128411. * Class used to control physics engine
  128412. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  128413. */
  128414. export class PhysicsEngine implements IPhysicsEngine {
  128415. private _physicsPlugin;
  128416. /**
  128417. * Global value used to control the smallest number supported by the simulation
  128418. */
  128419. static Epsilon: number;
  128420. private _impostors;
  128421. private _joints;
  128422. private _subTimeStep;
  128423. /**
  128424. * Gets the gravity vector used by the simulation
  128425. */
  128426. gravity: Vector3;
  128427. /**
  128428. * Factory used to create the default physics plugin.
  128429. * @returns The default physics plugin
  128430. */
  128431. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  128432. /**
  128433. * Creates a new Physics Engine
  128434. * @param gravity defines the gravity vector used by the simulation
  128435. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  128436. */
  128437. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  128438. /**
  128439. * Sets the gravity vector used by the simulation
  128440. * @param gravity defines the gravity vector to use
  128441. */
  128442. setGravity(gravity: Vector3): void;
  128443. /**
  128444. * Set the time step of the physics engine.
  128445. * Default is 1/60.
  128446. * To slow it down, enter 1/600 for example.
  128447. * To speed it up, 1/30
  128448. * @param newTimeStep defines the new timestep to apply to this world.
  128449. */
  128450. setTimeStep(newTimeStep?: number): void;
  128451. /**
  128452. * Get the time step of the physics engine.
  128453. * @returns the current time step
  128454. */
  128455. getTimeStep(): number;
  128456. /**
  128457. * Set the sub time step of the physics engine.
  128458. * Default is 0 meaning there is no sub steps
  128459. * To increase physics resolution precision, set a small value (like 1 ms)
  128460. * @param subTimeStep defines the new sub timestep used for physics resolution.
  128461. */
  128462. setSubTimeStep(subTimeStep?: number): void;
  128463. /**
  128464. * Get the sub time step of the physics engine.
  128465. * @returns the current sub time step
  128466. */
  128467. getSubTimeStep(): number;
  128468. /**
  128469. * Release all resources
  128470. */
  128471. dispose(): void;
  128472. /**
  128473. * Gets the name of the current physics plugin
  128474. * @returns the name of the plugin
  128475. */
  128476. getPhysicsPluginName(): string;
  128477. /**
  128478. * Adding a new impostor for the impostor tracking.
  128479. * This will be done by the impostor itself.
  128480. * @param impostor the impostor to add
  128481. */
  128482. addImpostor(impostor: PhysicsImpostor): void;
  128483. /**
  128484. * Remove an impostor from the engine.
  128485. * This impostor and its mesh will not longer be updated by the physics engine.
  128486. * @param impostor the impostor to remove
  128487. */
  128488. removeImpostor(impostor: PhysicsImpostor): void;
  128489. /**
  128490. * Add a joint to the physics engine
  128491. * @param mainImpostor defines the main impostor to which the joint is added.
  128492. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  128493. * @param joint defines the joint that will connect both impostors.
  128494. */
  128495. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  128496. /**
  128497. * Removes a joint from the simulation
  128498. * @param mainImpostor defines the impostor used with the joint
  128499. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  128500. * @param joint defines the joint to remove
  128501. */
  128502. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  128503. /**
  128504. * Called by the scene. No need to call it.
  128505. * @param delta defines the timespam between frames
  128506. */
  128507. _step(delta: number): void;
  128508. /**
  128509. * Gets the current plugin used to run the simulation
  128510. * @returns current plugin
  128511. */
  128512. getPhysicsPlugin(): IPhysicsEnginePlugin;
  128513. /**
  128514. * Gets the list of physic impostors
  128515. * @returns an array of PhysicsImpostor
  128516. */
  128517. getImpostors(): Array<PhysicsImpostor>;
  128518. /**
  128519. * Gets the impostor for a physics enabled object
  128520. * @param object defines the object impersonated by the impostor
  128521. * @returns the PhysicsImpostor or null if not found
  128522. */
  128523. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  128524. /**
  128525. * Gets the impostor for a physics body object
  128526. * @param body defines physics body used by the impostor
  128527. * @returns the PhysicsImpostor or null if not found
  128528. */
  128529. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  128530. /**
  128531. * Does a raycast in the physics world
  128532. * @param from when should the ray start?
  128533. * @param to when should the ray end?
  128534. * @returns PhysicsRaycastResult
  128535. */
  128536. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128537. }
  128538. }
  128539. declare module BABYLON {
  128540. /** @hidden */
  128541. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  128542. private _useDeltaForWorldStep;
  128543. world: any;
  128544. name: string;
  128545. private _physicsMaterials;
  128546. private _fixedTimeStep;
  128547. private _cannonRaycastResult;
  128548. private _raycastResult;
  128549. private _physicsBodysToRemoveAfterStep;
  128550. BJSCANNON: any;
  128551. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  128552. setGravity(gravity: Vector3): void;
  128553. setTimeStep(timeStep: number): void;
  128554. getTimeStep(): number;
  128555. executeStep(delta: number): void;
  128556. private _removeMarkedPhysicsBodiesFromWorld;
  128557. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128558. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128559. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128560. private _processChildMeshes;
  128561. removePhysicsBody(impostor: PhysicsImpostor): void;
  128562. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128563. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128564. private _addMaterial;
  128565. private _checkWithEpsilon;
  128566. private _createShape;
  128567. private _createHeightmap;
  128568. private _minus90X;
  128569. private _plus90X;
  128570. private _tmpPosition;
  128571. private _tmpDeltaPosition;
  128572. private _tmpUnityRotation;
  128573. private _updatePhysicsBodyTransformation;
  128574. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128575. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128576. isSupported(): boolean;
  128577. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128578. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128579. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128580. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128581. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128582. getBodyMass(impostor: PhysicsImpostor): number;
  128583. getBodyFriction(impostor: PhysicsImpostor): number;
  128584. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128585. getBodyRestitution(impostor: PhysicsImpostor): number;
  128586. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128587. sleepBody(impostor: PhysicsImpostor): void;
  128588. wakeUpBody(impostor: PhysicsImpostor): void;
  128589. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  128590. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128591. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128592. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128593. getRadius(impostor: PhysicsImpostor): number;
  128594. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128595. dispose(): void;
  128596. private _extendNamespace;
  128597. /**
  128598. * Does a raycast in the physics world
  128599. * @param from when should the ray start?
  128600. * @param to when should the ray end?
  128601. * @returns PhysicsRaycastResult
  128602. */
  128603. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128604. }
  128605. }
  128606. declare module BABYLON {
  128607. /** @hidden */
  128608. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  128609. world: any;
  128610. name: string;
  128611. BJSOIMO: any;
  128612. private _raycastResult;
  128613. constructor(iterations?: number, oimoInjection?: any);
  128614. setGravity(gravity: Vector3): void;
  128615. setTimeStep(timeStep: number): void;
  128616. getTimeStep(): number;
  128617. private _tmpImpostorsArray;
  128618. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  128619. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128620. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128621. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128622. private _tmpPositionVector;
  128623. removePhysicsBody(impostor: PhysicsImpostor): void;
  128624. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128625. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128626. isSupported(): boolean;
  128627. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128628. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128629. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128630. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128631. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128632. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128633. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128634. getBodyMass(impostor: PhysicsImpostor): number;
  128635. getBodyFriction(impostor: PhysicsImpostor): number;
  128636. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128637. getBodyRestitution(impostor: PhysicsImpostor): number;
  128638. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128639. sleepBody(impostor: PhysicsImpostor): void;
  128640. wakeUpBody(impostor: PhysicsImpostor): void;
  128641. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128642. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  128643. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  128644. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128645. getRadius(impostor: PhysicsImpostor): number;
  128646. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128647. dispose(): void;
  128648. /**
  128649. * Does a raycast in the physics world
  128650. * @param from when should the ray start?
  128651. * @param to when should the ray end?
  128652. * @returns PhysicsRaycastResult
  128653. */
  128654. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128655. }
  128656. }
  128657. declare module BABYLON {
  128658. /**
  128659. * Class containing static functions to help procedurally build meshes
  128660. */
  128661. export class RibbonBuilder {
  128662. /**
  128663. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  128664. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  128665. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  128666. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  128667. * * 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
  128668. * * 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
  128669. * * 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
  128670. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128671. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128672. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128673. * * 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
  128674. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  128675. * * 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
  128676. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  128677. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128678. * @param name defines the name of the mesh
  128679. * @param options defines the options used to create the mesh
  128680. * @param scene defines the hosting scene
  128681. * @returns the ribbon mesh
  128682. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  128683. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128684. */
  128685. static CreateRibbon(name: string, options: {
  128686. pathArray: Vector3[][];
  128687. closeArray?: boolean;
  128688. closePath?: boolean;
  128689. offset?: number;
  128690. updatable?: boolean;
  128691. sideOrientation?: number;
  128692. frontUVs?: Vector4;
  128693. backUVs?: Vector4;
  128694. instance?: Mesh;
  128695. invertUV?: boolean;
  128696. uvs?: Vector2[];
  128697. colors?: Color4[];
  128698. }, scene?: Nullable<Scene>): Mesh;
  128699. }
  128700. }
  128701. declare module BABYLON {
  128702. /**
  128703. * Class containing static functions to help procedurally build meshes
  128704. */
  128705. export class ShapeBuilder {
  128706. /**
  128707. * 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.
  128708. * * 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.
  128709. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128710. * * 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.
  128711. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  128712. * * 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
  128713. * * 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
  128714. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  128715. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128716. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128717. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  128718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  128719. * @param name defines the name of the mesh
  128720. * @param options defines the options used to create the mesh
  128721. * @param scene defines the hosting scene
  128722. * @returns the extruded shape mesh
  128723. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128724. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128725. */
  128726. static ExtrudeShape(name: string, options: {
  128727. shape: Vector3[];
  128728. path: Vector3[];
  128729. scale?: number;
  128730. rotation?: number;
  128731. cap?: number;
  128732. updatable?: boolean;
  128733. sideOrientation?: number;
  128734. frontUVs?: Vector4;
  128735. backUVs?: Vector4;
  128736. instance?: Mesh;
  128737. invertUV?: boolean;
  128738. }, scene?: Nullable<Scene>): Mesh;
  128739. /**
  128740. * Creates an custom extruded shape mesh.
  128741. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  128742. * * 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.
  128743. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128744. * * 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
  128745. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  128746. * * 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
  128747. * * It must returns a float value that will be the scale value applied to the shape on each path point
  128748. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  128749. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  128750. * * 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
  128751. * * 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
  128752. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  128753. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128754. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128755. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128757. * @param name defines the name of the mesh
  128758. * @param options defines the options used to create the mesh
  128759. * @param scene defines the hosting scene
  128760. * @returns the custom extruded shape mesh
  128761. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  128762. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128763. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128764. */
  128765. static ExtrudeShapeCustom(name: string, options: {
  128766. shape: Vector3[];
  128767. path: Vector3[];
  128768. scaleFunction?: any;
  128769. rotationFunction?: any;
  128770. ribbonCloseArray?: boolean;
  128771. ribbonClosePath?: boolean;
  128772. cap?: number;
  128773. updatable?: boolean;
  128774. sideOrientation?: number;
  128775. frontUVs?: Vector4;
  128776. backUVs?: Vector4;
  128777. instance?: Mesh;
  128778. invertUV?: boolean;
  128779. }, scene?: Nullable<Scene>): Mesh;
  128780. private static _ExtrudeShapeGeneric;
  128781. }
  128782. }
  128783. declare module BABYLON {
  128784. /**
  128785. * AmmoJS Physics plugin
  128786. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  128787. * @see https://github.com/kripken/ammo.js/
  128788. */
  128789. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  128790. private _useDeltaForWorldStep;
  128791. /**
  128792. * Reference to the Ammo library
  128793. */
  128794. bjsAMMO: any;
  128795. /**
  128796. * Created ammoJS world which physics bodies are added to
  128797. */
  128798. world: any;
  128799. /**
  128800. * Name of the plugin
  128801. */
  128802. name: string;
  128803. private _timeStep;
  128804. private _fixedTimeStep;
  128805. private _maxSteps;
  128806. private _tmpQuaternion;
  128807. private _tmpAmmoTransform;
  128808. private _tmpAmmoQuaternion;
  128809. private _tmpAmmoConcreteContactResultCallback;
  128810. private _collisionConfiguration;
  128811. private _dispatcher;
  128812. private _overlappingPairCache;
  128813. private _solver;
  128814. private _softBodySolver;
  128815. private _tmpAmmoVectorA;
  128816. private _tmpAmmoVectorB;
  128817. private _tmpAmmoVectorC;
  128818. private _tmpAmmoVectorD;
  128819. private _tmpContactCallbackResult;
  128820. private _tmpAmmoVectorRCA;
  128821. private _tmpAmmoVectorRCB;
  128822. private _raycastResult;
  128823. private static readonly DISABLE_COLLISION_FLAG;
  128824. private static readonly KINEMATIC_FLAG;
  128825. private static readonly DISABLE_DEACTIVATION_FLAG;
  128826. /**
  128827. * Initializes the ammoJS plugin
  128828. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  128829. * @param ammoInjection can be used to inject your own ammo reference
  128830. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  128831. */
  128832. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  128833. /**
  128834. * Sets the gravity of the physics world (m/(s^2))
  128835. * @param gravity Gravity to set
  128836. */
  128837. setGravity(gravity: Vector3): void;
  128838. /**
  128839. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  128840. * @param timeStep timestep to use in seconds
  128841. */
  128842. setTimeStep(timeStep: number): void;
  128843. /**
  128844. * 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)
  128845. * @param fixedTimeStep fixedTimeStep to use in seconds
  128846. */
  128847. setFixedTimeStep(fixedTimeStep: number): void;
  128848. /**
  128849. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  128850. * @param maxSteps the maximum number of steps by the physics engine per frame
  128851. */
  128852. setMaxSteps(maxSteps: number): void;
  128853. /**
  128854. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  128855. * @returns the current timestep in seconds
  128856. */
  128857. getTimeStep(): number;
  128858. /**
  128859. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  128860. */
  128861. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  128862. private _isImpostorInContact;
  128863. private _isImpostorPairInContact;
  128864. private _stepSimulation;
  128865. /**
  128866. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  128867. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  128868. * After the step the babylon meshes are set to the position of the physics imposters
  128869. * @param delta amount of time to step forward
  128870. * @param impostors array of imposters to update before/after the step
  128871. */
  128872. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  128873. /**
  128874. * Update babylon mesh to match physics world object
  128875. * @param impostor imposter to match
  128876. */
  128877. private _afterSoftStep;
  128878. /**
  128879. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  128880. * @param impostor imposter to match
  128881. */
  128882. private _ropeStep;
  128883. /**
  128884. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  128885. * @param impostor imposter to match
  128886. */
  128887. private _softbodyOrClothStep;
  128888. private _tmpVector;
  128889. private _tmpMatrix;
  128890. /**
  128891. * Applies an impulse on the imposter
  128892. * @param impostor imposter to apply impulse to
  128893. * @param force amount of force to be applied to the imposter
  128894. * @param contactPoint the location to apply the impulse on the imposter
  128895. */
  128896. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128897. /**
  128898. * Applies a force on the imposter
  128899. * @param impostor imposter to apply force
  128900. * @param force amount of force to be applied to the imposter
  128901. * @param contactPoint the location to apply the force on the imposter
  128902. */
  128903. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128904. /**
  128905. * Creates a physics body using the plugin
  128906. * @param impostor the imposter to create the physics body on
  128907. */
  128908. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128909. /**
  128910. * Removes the physics body from the imposter and disposes of the body's memory
  128911. * @param impostor imposter to remove the physics body from
  128912. */
  128913. removePhysicsBody(impostor: PhysicsImpostor): void;
  128914. /**
  128915. * Generates a joint
  128916. * @param impostorJoint the imposter joint to create the joint with
  128917. */
  128918. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128919. /**
  128920. * Removes a joint
  128921. * @param impostorJoint the imposter joint to remove the joint from
  128922. */
  128923. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128924. private _addMeshVerts;
  128925. /**
  128926. * Initialise the soft body vertices to match its object's (mesh) vertices
  128927. * Softbody vertices (nodes) are in world space and to match this
  128928. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  128929. * @param impostor to create the softbody for
  128930. */
  128931. private _softVertexData;
  128932. /**
  128933. * Create an impostor's soft body
  128934. * @param impostor to create the softbody for
  128935. */
  128936. private _createSoftbody;
  128937. /**
  128938. * Create cloth for an impostor
  128939. * @param impostor to create the softbody for
  128940. */
  128941. private _createCloth;
  128942. /**
  128943. * Create rope for an impostor
  128944. * @param impostor to create the softbody for
  128945. */
  128946. private _createRope;
  128947. /**
  128948. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  128949. * @param impostor to create the custom physics shape for
  128950. */
  128951. private _createCustom;
  128952. private _addHullVerts;
  128953. private _createShape;
  128954. /**
  128955. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  128956. * @param impostor imposter containing the physics body and babylon object
  128957. */
  128958. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128959. /**
  128960. * Sets the babylon object's position/rotation from the physics body's position/rotation
  128961. * @param impostor imposter containing the physics body and babylon object
  128962. * @param newPosition new position
  128963. * @param newRotation new rotation
  128964. */
  128965. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128966. /**
  128967. * If this plugin is supported
  128968. * @returns true if its supported
  128969. */
  128970. isSupported(): boolean;
  128971. /**
  128972. * Sets the linear velocity of the physics body
  128973. * @param impostor imposter to set the velocity on
  128974. * @param velocity velocity to set
  128975. */
  128976. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128977. /**
  128978. * Sets the angular velocity of the physics body
  128979. * @param impostor imposter to set the velocity on
  128980. * @param velocity velocity to set
  128981. */
  128982. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128983. /**
  128984. * gets the linear velocity
  128985. * @param impostor imposter to get linear velocity from
  128986. * @returns linear velocity
  128987. */
  128988. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128989. /**
  128990. * gets the angular velocity
  128991. * @param impostor imposter to get angular velocity from
  128992. * @returns angular velocity
  128993. */
  128994. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128995. /**
  128996. * Sets the mass of physics body
  128997. * @param impostor imposter to set the mass on
  128998. * @param mass mass to set
  128999. */
  129000. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  129001. /**
  129002. * Gets the mass of the physics body
  129003. * @param impostor imposter to get the mass from
  129004. * @returns mass
  129005. */
  129006. getBodyMass(impostor: PhysicsImpostor): number;
  129007. /**
  129008. * Gets friction of the impostor
  129009. * @param impostor impostor to get friction from
  129010. * @returns friction value
  129011. */
  129012. getBodyFriction(impostor: PhysicsImpostor): number;
  129013. /**
  129014. * Sets friction of the impostor
  129015. * @param impostor impostor to set friction on
  129016. * @param friction friction value
  129017. */
  129018. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  129019. /**
  129020. * Gets restitution of the impostor
  129021. * @param impostor impostor to get restitution from
  129022. * @returns restitution value
  129023. */
  129024. getBodyRestitution(impostor: PhysicsImpostor): number;
  129025. /**
  129026. * Sets resitution of the impostor
  129027. * @param impostor impostor to set resitution on
  129028. * @param restitution resitution value
  129029. */
  129030. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  129031. /**
  129032. * Gets pressure inside the impostor
  129033. * @param impostor impostor to get pressure from
  129034. * @returns pressure value
  129035. */
  129036. getBodyPressure(impostor: PhysicsImpostor): number;
  129037. /**
  129038. * Sets pressure inside a soft body impostor
  129039. * Cloth and rope must remain 0 pressure
  129040. * @param impostor impostor to set pressure on
  129041. * @param pressure pressure value
  129042. */
  129043. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  129044. /**
  129045. * Gets stiffness of the impostor
  129046. * @param impostor impostor to get stiffness from
  129047. * @returns pressure value
  129048. */
  129049. getBodyStiffness(impostor: PhysicsImpostor): number;
  129050. /**
  129051. * Sets stiffness of the impostor
  129052. * @param impostor impostor to set stiffness on
  129053. * @param stiffness stiffness value from 0 to 1
  129054. */
  129055. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  129056. /**
  129057. * Gets velocityIterations of the impostor
  129058. * @param impostor impostor to get velocity iterations from
  129059. * @returns velocityIterations value
  129060. */
  129061. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  129062. /**
  129063. * Sets velocityIterations of the impostor
  129064. * @param impostor impostor to set velocity iterations on
  129065. * @param velocityIterations velocityIterations value
  129066. */
  129067. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  129068. /**
  129069. * Gets positionIterations of the impostor
  129070. * @param impostor impostor to get position iterations from
  129071. * @returns positionIterations value
  129072. */
  129073. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  129074. /**
  129075. * Sets positionIterations of the impostor
  129076. * @param impostor impostor to set position on
  129077. * @param positionIterations positionIterations value
  129078. */
  129079. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  129080. /**
  129081. * Append an anchor to a cloth object
  129082. * @param impostor is the cloth impostor to add anchor to
  129083. * @param otherImpostor is the rigid impostor to anchor to
  129084. * @param width ratio across width from 0 to 1
  129085. * @param height ratio up height from 0 to 1
  129086. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  129087. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  129088. */
  129089. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  129090. /**
  129091. * Append an hook to a rope object
  129092. * @param impostor is the rope impostor to add hook to
  129093. * @param otherImpostor is the rigid impostor to hook to
  129094. * @param length ratio along the rope from 0 to 1
  129095. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  129096. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  129097. */
  129098. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  129099. /**
  129100. * Sleeps the physics body and stops it from being active
  129101. * @param impostor impostor to sleep
  129102. */
  129103. sleepBody(impostor: PhysicsImpostor): void;
  129104. /**
  129105. * Activates the physics body
  129106. * @param impostor impostor to activate
  129107. */
  129108. wakeUpBody(impostor: PhysicsImpostor): void;
  129109. /**
  129110. * Updates the distance parameters of the joint
  129111. * @param joint joint to update
  129112. * @param maxDistance maximum distance of the joint
  129113. * @param minDistance minimum distance of the joint
  129114. */
  129115. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  129116. /**
  129117. * Sets a motor on the joint
  129118. * @param joint joint to set motor on
  129119. * @param speed speed of the motor
  129120. * @param maxForce maximum force of the motor
  129121. * @param motorIndex index of the motor
  129122. */
  129123. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  129124. /**
  129125. * Sets the motors limit
  129126. * @param joint joint to set limit on
  129127. * @param upperLimit upper limit
  129128. * @param lowerLimit lower limit
  129129. */
  129130. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  129131. /**
  129132. * Syncs the position and rotation of a mesh with the impostor
  129133. * @param mesh mesh to sync
  129134. * @param impostor impostor to update the mesh with
  129135. */
  129136. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  129137. /**
  129138. * Gets the radius of the impostor
  129139. * @param impostor impostor to get radius from
  129140. * @returns the radius
  129141. */
  129142. getRadius(impostor: PhysicsImpostor): number;
  129143. /**
  129144. * Gets the box size of the impostor
  129145. * @param impostor impostor to get box size from
  129146. * @param result the resulting box size
  129147. */
  129148. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  129149. /**
  129150. * Disposes of the impostor
  129151. */
  129152. dispose(): void;
  129153. /**
  129154. * Does a raycast in the physics world
  129155. * @param from when should the ray start?
  129156. * @param to when should the ray end?
  129157. * @returns PhysicsRaycastResult
  129158. */
  129159. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  129160. }
  129161. }
  129162. declare module BABYLON {
  129163. interface AbstractScene {
  129164. /**
  129165. * The list of reflection probes added to the scene
  129166. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  129167. */
  129168. reflectionProbes: Array<ReflectionProbe>;
  129169. /**
  129170. * Removes the given reflection probe from this scene.
  129171. * @param toRemove The reflection probe to remove
  129172. * @returns The index of the removed reflection probe
  129173. */
  129174. removeReflectionProbe(toRemove: ReflectionProbe): number;
  129175. /**
  129176. * Adds the given reflection probe to this scene.
  129177. * @param newReflectionProbe The reflection probe to add
  129178. */
  129179. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  129180. }
  129181. /**
  129182. * Class used to generate realtime reflection / refraction cube textures
  129183. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  129184. */
  129185. export class ReflectionProbe {
  129186. /** defines the name of the probe */
  129187. name: string;
  129188. private _scene;
  129189. private _renderTargetTexture;
  129190. private _projectionMatrix;
  129191. private _viewMatrix;
  129192. private _target;
  129193. private _add;
  129194. private _attachedMesh;
  129195. private _invertYAxis;
  129196. /** Gets or sets probe position (center of the cube map) */
  129197. position: Vector3;
  129198. /**
  129199. * Creates a new reflection probe
  129200. * @param name defines the name of the probe
  129201. * @param size defines the texture resolution (for each face)
  129202. * @param scene defines the hosting scene
  129203. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  129204. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  129205. */
  129206. constructor(
  129207. /** defines the name of the probe */
  129208. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  129209. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  129210. get samples(): number;
  129211. set samples(value: number);
  129212. /** Gets or sets the refresh rate to use (on every frame by default) */
  129213. get refreshRate(): number;
  129214. set refreshRate(value: number);
  129215. /**
  129216. * Gets the hosting scene
  129217. * @returns a Scene
  129218. */
  129219. getScene(): Scene;
  129220. /** Gets the internal CubeTexture used to render to */
  129221. get cubeTexture(): RenderTargetTexture;
  129222. /** Gets the list of meshes to render */
  129223. get renderList(): Nullable<AbstractMesh[]>;
  129224. /**
  129225. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  129226. * @param mesh defines the mesh to attach to
  129227. */
  129228. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  129229. /**
  129230. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  129231. * @param renderingGroupId The rendering group id corresponding to its index
  129232. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  129233. */
  129234. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  129235. /**
  129236. * Clean all associated resources
  129237. */
  129238. dispose(): void;
  129239. /**
  129240. * Converts the reflection probe information to a readable string for debug purpose.
  129241. * @param fullDetails Supports for multiple levels of logging within scene loading
  129242. * @returns the human readable reflection probe info
  129243. */
  129244. toString(fullDetails?: boolean): string;
  129245. /**
  129246. * Get the class name of the relfection probe.
  129247. * @returns "ReflectionProbe"
  129248. */
  129249. getClassName(): string;
  129250. /**
  129251. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  129252. * @returns The JSON representation of the texture
  129253. */
  129254. serialize(): any;
  129255. /**
  129256. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  129257. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  129258. * @param scene Define the scene the parsed reflection probe should be instantiated in
  129259. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  129260. * @returns The parsed reflection probe if successful
  129261. */
  129262. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  129263. }
  129264. }
  129265. declare module BABYLON {
  129266. /** @hidden */
  129267. export var _BabylonLoaderRegistered: boolean;
  129268. /**
  129269. * Helps setting up some configuration for the babylon file loader.
  129270. */
  129271. export class BabylonFileLoaderConfiguration {
  129272. /**
  129273. * The loader does not allow injecting custom physix engine into the plugins.
  129274. * Unfortunately in ES6, we need to manually inject them into the plugin.
  129275. * So you could set this variable to your engine import to make it work.
  129276. */
  129277. static LoaderInjectedPhysicsEngine: any;
  129278. }
  129279. }
  129280. declare module BABYLON {
  129281. /**
  129282. * The Physically based simple base material of BJS.
  129283. *
  129284. * This enables better naming and convention enforcements on top of the pbrMaterial.
  129285. * It is used as the base class for both the specGloss and metalRough conventions.
  129286. */
  129287. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  129288. /**
  129289. * Number of Simultaneous lights allowed on the material.
  129290. */
  129291. maxSimultaneousLights: number;
  129292. /**
  129293. * If sets to true, disables all the lights affecting the material.
  129294. */
  129295. disableLighting: boolean;
  129296. /**
  129297. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  129298. */
  129299. environmentTexture: BaseTexture;
  129300. /**
  129301. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  129302. */
  129303. invertNormalMapX: boolean;
  129304. /**
  129305. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  129306. */
  129307. invertNormalMapY: boolean;
  129308. /**
  129309. * Normal map used in the model.
  129310. */
  129311. normalTexture: BaseTexture;
  129312. /**
  129313. * Emissivie color used to self-illuminate the model.
  129314. */
  129315. emissiveColor: Color3;
  129316. /**
  129317. * Emissivie texture used to self-illuminate the model.
  129318. */
  129319. emissiveTexture: BaseTexture;
  129320. /**
  129321. * Occlusion Channel Strenght.
  129322. */
  129323. occlusionStrength: number;
  129324. /**
  129325. * Occlusion Texture of the material (adding extra occlusion effects).
  129326. */
  129327. occlusionTexture: BaseTexture;
  129328. /**
  129329. * Defines the alpha limits in alpha test mode.
  129330. */
  129331. alphaCutOff: number;
  129332. /**
  129333. * Gets the current double sided mode.
  129334. */
  129335. get doubleSided(): boolean;
  129336. /**
  129337. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  129338. */
  129339. set doubleSided(value: boolean);
  129340. /**
  129341. * Stores the pre-calculated light information of a mesh in a texture.
  129342. */
  129343. lightmapTexture: BaseTexture;
  129344. /**
  129345. * If true, the light map contains occlusion information instead of lighting info.
  129346. */
  129347. useLightmapAsShadowmap: boolean;
  129348. /**
  129349. * Instantiates a new PBRMaterial instance.
  129350. *
  129351. * @param name The material name
  129352. * @param scene The scene the material will be use in.
  129353. */
  129354. constructor(name: string, scene: Scene);
  129355. getClassName(): string;
  129356. }
  129357. }
  129358. declare module BABYLON {
  129359. /**
  129360. * The PBR material of BJS following the metal roughness convention.
  129361. *
  129362. * This fits to the PBR convention in the GLTF definition:
  129363. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  129364. */
  129365. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  129366. /**
  129367. * The base color has two different interpretations depending on the value of metalness.
  129368. * When the material is a metal, the base color is the specific measured reflectance value
  129369. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  129370. * of the material.
  129371. */
  129372. baseColor: Color3;
  129373. /**
  129374. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  129375. * well as opacity information in the alpha channel.
  129376. */
  129377. baseTexture: BaseTexture;
  129378. /**
  129379. * Specifies the metallic scalar value of the material.
  129380. * Can also be used to scale the metalness values of the metallic texture.
  129381. */
  129382. metallic: number;
  129383. /**
  129384. * Specifies the roughness scalar value of the material.
  129385. * Can also be used to scale the roughness values of the metallic texture.
  129386. */
  129387. roughness: number;
  129388. /**
  129389. * Texture containing both the metallic value in the B channel and the
  129390. * roughness value in the G channel to keep better precision.
  129391. */
  129392. metallicRoughnessTexture: BaseTexture;
  129393. /**
  129394. * Instantiates a new PBRMetalRoughnessMaterial instance.
  129395. *
  129396. * @param name The material name
  129397. * @param scene The scene the material will be use in.
  129398. */
  129399. constructor(name: string, scene: Scene);
  129400. /**
  129401. * Return the currrent class name of the material.
  129402. */
  129403. getClassName(): string;
  129404. /**
  129405. * Makes a duplicate of the current material.
  129406. * @param name - name to use for the new material.
  129407. */
  129408. clone(name: string): PBRMetallicRoughnessMaterial;
  129409. /**
  129410. * Serialize the material to a parsable JSON object.
  129411. */
  129412. serialize(): any;
  129413. /**
  129414. * Parses a JSON object correponding to the serialize function.
  129415. */
  129416. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  129417. }
  129418. }
  129419. declare module BABYLON {
  129420. /**
  129421. * The PBR material of BJS following the specular glossiness convention.
  129422. *
  129423. * This fits to the PBR convention in the GLTF definition:
  129424. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  129425. */
  129426. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  129427. /**
  129428. * Specifies the diffuse color of the material.
  129429. */
  129430. diffuseColor: Color3;
  129431. /**
  129432. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  129433. * channel.
  129434. */
  129435. diffuseTexture: BaseTexture;
  129436. /**
  129437. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  129438. */
  129439. specularColor: Color3;
  129440. /**
  129441. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  129442. */
  129443. glossiness: number;
  129444. /**
  129445. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  129446. */
  129447. specularGlossinessTexture: BaseTexture;
  129448. /**
  129449. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  129450. *
  129451. * @param name The material name
  129452. * @param scene The scene the material will be use in.
  129453. */
  129454. constructor(name: string, scene: Scene);
  129455. /**
  129456. * Return the currrent class name of the material.
  129457. */
  129458. getClassName(): string;
  129459. /**
  129460. * Makes a duplicate of the current material.
  129461. * @param name - name to use for the new material.
  129462. */
  129463. clone(name: string): PBRSpecularGlossinessMaterial;
  129464. /**
  129465. * Serialize the material to a parsable JSON object.
  129466. */
  129467. serialize(): any;
  129468. /**
  129469. * Parses a JSON object correponding to the serialize function.
  129470. */
  129471. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  129472. }
  129473. }
  129474. declare module BABYLON {
  129475. /**
  129476. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  129477. * It can help converting any input color in a desired output one. This can then be used to create effects
  129478. * from sepia, black and white to sixties or futuristic rendering...
  129479. *
  129480. * The only supported format is currently 3dl.
  129481. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  129482. */
  129483. export class ColorGradingTexture extends BaseTexture {
  129484. /**
  129485. * The current texture matrix. (will always be identity in color grading texture)
  129486. */
  129487. private _textureMatrix;
  129488. /**
  129489. * The texture URL.
  129490. */
  129491. url: string;
  129492. /**
  129493. * Empty line regex stored for GC.
  129494. */
  129495. private static _noneEmptyLineRegex;
  129496. private _engine;
  129497. /**
  129498. * Instantiates a ColorGradingTexture from the following parameters.
  129499. *
  129500. * @param url The location of the color gradind data (currently only supporting 3dl)
  129501. * @param scene The scene the texture will be used in
  129502. */
  129503. constructor(url: string, scene: Scene);
  129504. /**
  129505. * Returns the texture matrix used in most of the material.
  129506. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  129507. */
  129508. getTextureMatrix(): Matrix;
  129509. /**
  129510. * Occurs when the file being loaded is a .3dl LUT file.
  129511. */
  129512. private load3dlTexture;
  129513. /**
  129514. * Starts the loading process of the texture.
  129515. */
  129516. private loadTexture;
  129517. /**
  129518. * Clones the color gradind texture.
  129519. */
  129520. clone(): ColorGradingTexture;
  129521. /**
  129522. * Called during delayed load for textures.
  129523. */
  129524. delayLoad(): void;
  129525. /**
  129526. * Parses a color grading texture serialized by Babylon.
  129527. * @param parsedTexture The texture information being parsedTexture
  129528. * @param scene The scene to load the texture in
  129529. * @param rootUrl The root url of the data assets to load
  129530. * @return A color gradind texture
  129531. */
  129532. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  129533. /**
  129534. * Serializes the LUT texture to json format.
  129535. */
  129536. serialize(): any;
  129537. }
  129538. }
  129539. declare module BABYLON {
  129540. /**
  129541. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  129542. */
  129543. export class EquiRectangularCubeTexture extends BaseTexture {
  129544. /** The six faces of the cube. */
  129545. private static _FacesMapping;
  129546. private _noMipmap;
  129547. private _onLoad;
  129548. private _onError;
  129549. /** The size of the cubemap. */
  129550. private _size;
  129551. /** The buffer of the image. */
  129552. private _buffer;
  129553. /** The width of the input image. */
  129554. private _width;
  129555. /** The height of the input image. */
  129556. private _height;
  129557. /** The URL to the image. */
  129558. url: string;
  129559. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  129560. coordinatesMode: number;
  129561. /**
  129562. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  129563. * @param url The location of the image
  129564. * @param scene The scene the texture will be used in
  129565. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  129566. * @param noMipmap Forces to not generate the mipmap if true
  129567. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  129568. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  129569. * @param onLoad — defines a callback called when texture is loaded
  129570. * @param onError — defines a callback called if there is an error
  129571. */
  129572. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  129573. /**
  129574. * Load the image data, by putting the image on a canvas and extracting its buffer.
  129575. */
  129576. private loadImage;
  129577. /**
  129578. * Convert the image buffer into a cubemap and create a CubeTexture.
  129579. */
  129580. private loadTexture;
  129581. /**
  129582. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  129583. * @param buffer The ArrayBuffer that should be converted.
  129584. * @returns The buffer as Float32Array.
  129585. */
  129586. private getFloat32ArrayFromArrayBuffer;
  129587. /**
  129588. * Get the current class name of the texture useful for serialization or dynamic coding.
  129589. * @returns "EquiRectangularCubeTexture"
  129590. */
  129591. getClassName(): string;
  129592. /**
  129593. * Create a clone of the current EquiRectangularCubeTexture and return it.
  129594. * @returns A clone of the current EquiRectangularCubeTexture.
  129595. */
  129596. clone(): EquiRectangularCubeTexture;
  129597. }
  129598. }
  129599. declare module BABYLON {
  129600. /**
  129601. * Based on jsTGALoader - Javascript loader for TGA file
  129602. * By Vincent Thibault
  129603. * @see http://blog.robrowser.com/javascript-tga-loader.html
  129604. */
  129605. export class TGATools {
  129606. private static _TYPE_INDEXED;
  129607. private static _TYPE_RGB;
  129608. private static _TYPE_GREY;
  129609. private static _TYPE_RLE_INDEXED;
  129610. private static _TYPE_RLE_RGB;
  129611. private static _TYPE_RLE_GREY;
  129612. private static _ORIGIN_MASK;
  129613. private static _ORIGIN_SHIFT;
  129614. private static _ORIGIN_BL;
  129615. private static _ORIGIN_BR;
  129616. private static _ORIGIN_UL;
  129617. private static _ORIGIN_UR;
  129618. /**
  129619. * Gets the header of a TGA file
  129620. * @param data defines the TGA data
  129621. * @returns the header
  129622. */
  129623. static GetTGAHeader(data: Uint8Array): any;
  129624. /**
  129625. * Uploads TGA content to a Babylon Texture
  129626. * @hidden
  129627. */
  129628. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  129629. /** @hidden */
  129630. 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;
  129631. /** @hidden */
  129632. 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;
  129633. /** @hidden */
  129634. 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;
  129635. /** @hidden */
  129636. 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;
  129637. /** @hidden */
  129638. 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;
  129639. /** @hidden */
  129640. 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;
  129641. }
  129642. }
  129643. declare module BABYLON {
  129644. /**
  129645. * Implementation of the TGA Texture Loader.
  129646. * @hidden
  129647. */
  129648. export class _TGATextureLoader implements IInternalTextureLoader {
  129649. /**
  129650. * Defines wether the loader supports cascade loading the different faces.
  129651. */
  129652. readonly supportCascades: boolean;
  129653. /**
  129654. * This returns if the loader support the current file information.
  129655. * @param extension defines the file extension of the file being loaded
  129656. * @returns true if the loader can load the specified file
  129657. */
  129658. canLoad(extension: string): boolean;
  129659. /**
  129660. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  129661. * @param data contains the texture data
  129662. * @param texture defines the BabylonJS internal texture
  129663. * @param createPolynomials will be true if polynomials have been requested
  129664. * @param onLoad defines the callback to trigger once the texture is ready
  129665. * @param onError defines the callback to trigger in case of error
  129666. */
  129667. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129668. /**
  129669. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  129670. * @param data contains the texture data
  129671. * @param texture defines the BabylonJS internal texture
  129672. * @param callback defines the method to call once ready to upload
  129673. */
  129674. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129675. }
  129676. }
  129677. declare module BABYLON {
  129678. /**
  129679. * Info about the .basis files
  129680. */
  129681. class BasisFileInfo {
  129682. /**
  129683. * If the file has alpha
  129684. */
  129685. hasAlpha: boolean;
  129686. /**
  129687. * Info about each image of the basis file
  129688. */
  129689. images: Array<{
  129690. levels: Array<{
  129691. width: number;
  129692. height: number;
  129693. transcodedPixels: ArrayBufferView;
  129694. }>;
  129695. }>;
  129696. }
  129697. /**
  129698. * Result of transcoding a basis file
  129699. */
  129700. class TranscodeResult {
  129701. /**
  129702. * Info about the .basis file
  129703. */
  129704. fileInfo: BasisFileInfo;
  129705. /**
  129706. * Format to use when loading the file
  129707. */
  129708. format: number;
  129709. }
  129710. /**
  129711. * Configuration options for the Basis transcoder
  129712. */
  129713. export class BasisTranscodeConfiguration {
  129714. /**
  129715. * Supported compression formats used to determine the supported output format of the transcoder
  129716. */
  129717. supportedCompressionFormats?: {
  129718. /**
  129719. * etc1 compression format
  129720. */
  129721. etc1?: boolean;
  129722. /**
  129723. * s3tc compression format
  129724. */
  129725. s3tc?: boolean;
  129726. /**
  129727. * pvrtc compression format
  129728. */
  129729. pvrtc?: boolean;
  129730. /**
  129731. * etc2 compression format
  129732. */
  129733. etc2?: boolean;
  129734. };
  129735. /**
  129736. * If mipmap levels should be loaded for transcoded images (Default: true)
  129737. */
  129738. loadMipmapLevels?: boolean;
  129739. /**
  129740. * Index of a single image to load (Default: all images)
  129741. */
  129742. loadSingleImage?: number;
  129743. }
  129744. /**
  129745. * Used to load .Basis files
  129746. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  129747. */
  129748. export class BasisTools {
  129749. private static _IgnoreSupportedFormats;
  129750. /**
  129751. * URL to use when loading the basis transcoder
  129752. */
  129753. static JSModuleURL: string;
  129754. /**
  129755. * URL to use when loading the wasm module for the transcoder
  129756. */
  129757. static WasmModuleURL: string;
  129758. /**
  129759. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  129760. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  129761. * @returns internal format corresponding to the Basis format
  129762. */
  129763. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  129764. private static _WorkerPromise;
  129765. private static _Worker;
  129766. private static _actionId;
  129767. private static _CreateWorkerAsync;
  129768. /**
  129769. * Transcodes a loaded image file to compressed pixel data
  129770. * @param data image data to transcode
  129771. * @param config configuration options for the transcoding
  129772. * @returns a promise resulting in the transcoded image
  129773. */
  129774. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  129775. /**
  129776. * Loads a texture from the transcode result
  129777. * @param texture texture load to
  129778. * @param transcodeResult the result of transcoding the basis file to load from
  129779. */
  129780. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  129781. }
  129782. }
  129783. declare module BABYLON {
  129784. /**
  129785. * Loader for .basis file format
  129786. */
  129787. export class _BasisTextureLoader implements IInternalTextureLoader {
  129788. /**
  129789. * Defines whether the loader supports cascade loading the different faces.
  129790. */
  129791. readonly supportCascades: boolean;
  129792. /**
  129793. * This returns if the loader support the current file information.
  129794. * @param extension defines the file extension of the file being loaded
  129795. * @returns true if the loader can load the specified file
  129796. */
  129797. canLoad(extension: string): boolean;
  129798. /**
  129799. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  129800. * @param data contains the texture data
  129801. * @param texture defines the BabylonJS internal texture
  129802. * @param createPolynomials will be true if polynomials have been requested
  129803. * @param onLoad defines the callback to trigger once the texture is ready
  129804. * @param onError defines the callback to trigger in case of error
  129805. */
  129806. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129807. /**
  129808. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  129809. * @param data contains the texture data
  129810. * @param texture defines the BabylonJS internal texture
  129811. * @param callback defines the method to call once ready to upload
  129812. */
  129813. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129814. }
  129815. }
  129816. declare module BABYLON {
  129817. /**
  129818. * 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.
  129819. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  129820. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  129821. */
  129822. export class CustomProceduralTexture extends ProceduralTexture {
  129823. private _animate;
  129824. private _time;
  129825. private _config;
  129826. private _texturePath;
  129827. /**
  129828. * Instantiates a new Custom Procedural Texture.
  129829. * 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.
  129830. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  129831. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  129832. * @param name Define the name of the texture
  129833. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  129834. * @param size Define the size of the texture to create
  129835. * @param scene Define the scene the texture belongs to
  129836. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  129837. * @param generateMipMaps Define if the texture should creates mip maps or not
  129838. */
  129839. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  129840. private _loadJson;
  129841. /**
  129842. * Is the texture ready to be used ? (rendered at least once)
  129843. * @returns true if ready, otherwise, false.
  129844. */
  129845. isReady(): boolean;
  129846. /**
  129847. * Render the texture to its associated render target.
  129848. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  129849. */
  129850. render(useCameraPostProcess?: boolean): void;
  129851. /**
  129852. * Update the list of dependant textures samplers in the shader.
  129853. */
  129854. updateTextures(): void;
  129855. /**
  129856. * Update the uniform values of the procedural texture in the shader.
  129857. */
  129858. updateShaderUniforms(): void;
  129859. /**
  129860. * Define if the texture animates or not.
  129861. */
  129862. get animate(): boolean;
  129863. set animate(value: boolean);
  129864. }
  129865. }
  129866. declare module BABYLON {
  129867. /** @hidden */
  129868. export var noisePixelShader: {
  129869. name: string;
  129870. shader: string;
  129871. };
  129872. }
  129873. declare module BABYLON {
  129874. /**
  129875. * Class used to generate noise procedural textures
  129876. */
  129877. export class NoiseProceduralTexture extends ProceduralTexture {
  129878. private _time;
  129879. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  129880. brightness: number;
  129881. /** Defines the number of octaves to process */
  129882. octaves: number;
  129883. /** Defines the level of persistence (0.8 by default) */
  129884. persistence: number;
  129885. /** Gets or sets animation speed factor (default is 1) */
  129886. animationSpeedFactor: number;
  129887. /**
  129888. * Creates a new NoiseProceduralTexture
  129889. * @param name defines the name fo the texture
  129890. * @param size defines the size of the texture (default is 256)
  129891. * @param scene defines the hosting scene
  129892. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  129893. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  129894. */
  129895. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  129896. private _updateShaderUniforms;
  129897. protected _getDefines(): string;
  129898. /** Generate the current state of the procedural texture */
  129899. render(useCameraPostProcess?: boolean): void;
  129900. /**
  129901. * Serializes this noise procedural texture
  129902. * @returns a serialized noise procedural texture object
  129903. */
  129904. serialize(): any;
  129905. /**
  129906. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  129907. * @param parsedTexture defines parsed texture data
  129908. * @param scene defines the current scene
  129909. * @param rootUrl defines the root URL containing noise procedural texture information
  129910. * @returns a parsed NoiseProceduralTexture
  129911. */
  129912. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  129913. }
  129914. }
  129915. declare module BABYLON {
  129916. /**
  129917. * Raw cube texture where the raw buffers are passed in
  129918. */
  129919. export class RawCubeTexture extends CubeTexture {
  129920. /**
  129921. * Creates a cube texture where the raw buffers are passed in.
  129922. * @param scene defines the scene the texture is attached to
  129923. * @param data defines the array of data to use to create each face
  129924. * @param size defines the size of the textures
  129925. * @param format defines the format of the data
  129926. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  129927. * @param generateMipMaps defines if the engine should generate the mip levels
  129928. * @param invertY defines if data must be stored with Y axis inverted
  129929. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  129930. * @param compression defines the compression used (null by default)
  129931. */
  129932. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  129933. /**
  129934. * Updates the raw cube texture.
  129935. * @param data defines the data to store
  129936. * @param format defines the data format
  129937. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  129938. * @param invertY defines if data must be stored with Y axis inverted
  129939. * @param compression defines the compression used (null by default)
  129940. * @param level defines which level of the texture to update
  129941. */
  129942. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  129943. /**
  129944. * Updates a raw cube texture with RGBD encoded data.
  129945. * @param data defines the array of data [mipmap][face] to use to create each face
  129946. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  129947. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  129948. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  129949. * @returns a promsie that resolves when the operation is complete
  129950. */
  129951. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  129952. /**
  129953. * Clones the raw cube texture.
  129954. * @return a new cube texture
  129955. */
  129956. clone(): CubeTexture;
  129957. /** @hidden */
  129958. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  129959. }
  129960. }
  129961. declare module BABYLON {
  129962. /**
  129963. * Class used to store 3D textures containing user data
  129964. */
  129965. export class RawTexture3D extends Texture {
  129966. /** Gets or sets the texture format to use */
  129967. format: number;
  129968. private _engine;
  129969. /**
  129970. * Create a new RawTexture3D
  129971. * @param data defines the data of the texture
  129972. * @param width defines the width of the texture
  129973. * @param height defines the height of the texture
  129974. * @param depth defines the depth of the texture
  129975. * @param format defines the texture format to use
  129976. * @param scene defines the hosting scene
  129977. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129978. * @param invertY defines if texture must be stored with Y axis inverted
  129979. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129980. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129981. */
  129982. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129983. /** Gets or sets the texture format to use */
  129984. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129985. /**
  129986. * Update the texture with new data
  129987. * @param data defines the data to store in the texture
  129988. */
  129989. update(data: ArrayBufferView): void;
  129990. }
  129991. }
  129992. declare module BABYLON {
  129993. /**
  129994. * Class used to store 2D array textures containing user data
  129995. */
  129996. export class RawTexture2DArray extends Texture {
  129997. /** Gets or sets the texture format to use */
  129998. format: number;
  129999. private _engine;
  130000. /**
  130001. * Create a new RawTexture2DArray
  130002. * @param data defines the data of the texture
  130003. * @param width defines the width of the texture
  130004. * @param height defines the height of the texture
  130005. * @param depth defines the number of layers of the texture
  130006. * @param format defines the texture format to use
  130007. * @param scene defines the hosting scene
  130008. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  130009. * @param invertY defines if texture must be stored with Y axis inverted
  130010. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  130011. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  130012. */
  130013. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  130014. /** Gets or sets the texture format to use */
  130015. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  130016. /**
  130017. * Update the texture with new data
  130018. * @param data defines the data to store in the texture
  130019. */
  130020. update(data: ArrayBufferView): void;
  130021. }
  130022. }
  130023. declare module BABYLON {
  130024. /**
  130025. * Creates a refraction texture used by refraction channel of the standard material.
  130026. * It is like a mirror but to see through a material.
  130027. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  130028. */
  130029. export class RefractionTexture extends RenderTargetTexture {
  130030. /**
  130031. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  130032. * 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.
  130033. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  130034. */
  130035. refractionPlane: Plane;
  130036. /**
  130037. * Define how deep under the surface we should see.
  130038. */
  130039. depth: number;
  130040. /**
  130041. * Creates a refraction texture used by refraction channel of the standard material.
  130042. * It is like a mirror but to see through a material.
  130043. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  130044. * @param name Define the texture name
  130045. * @param size Define the size of the underlying texture
  130046. * @param scene Define the scene the refraction belongs to
  130047. * @param generateMipMaps Define if we need to generate mips level for the refraction
  130048. */
  130049. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  130050. /**
  130051. * Clone the refraction texture.
  130052. * @returns the cloned texture
  130053. */
  130054. clone(): RefractionTexture;
  130055. /**
  130056. * Serialize the texture to a JSON representation you could use in Parse later on
  130057. * @returns the serialized JSON representation
  130058. */
  130059. serialize(): any;
  130060. }
  130061. }
  130062. declare module BABYLON {
  130063. /**
  130064. * Defines the options related to the creation of an HtmlElementTexture
  130065. */
  130066. export interface IHtmlElementTextureOptions {
  130067. /**
  130068. * Defines wether mip maps should be created or not.
  130069. */
  130070. generateMipMaps?: boolean;
  130071. /**
  130072. * Defines the sampling mode of the texture.
  130073. */
  130074. samplingMode?: number;
  130075. /**
  130076. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  130077. */
  130078. engine: Nullable<ThinEngine>;
  130079. /**
  130080. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  130081. */
  130082. scene: Nullable<Scene>;
  130083. }
  130084. /**
  130085. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  130086. * To be as efficient as possible depending on your constraints nothing aside the first upload
  130087. * is automatically managed.
  130088. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  130089. * in your application.
  130090. *
  130091. * As the update is not automatic, you need to call them manually.
  130092. */
  130093. export class HtmlElementTexture extends BaseTexture {
  130094. /**
  130095. * The texture URL.
  130096. */
  130097. element: HTMLVideoElement | HTMLCanvasElement;
  130098. private static readonly DefaultOptions;
  130099. private _textureMatrix;
  130100. private _engine;
  130101. private _isVideo;
  130102. private _generateMipMaps;
  130103. private _samplingMode;
  130104. /**
  130105. * Instantiates a HtmlElementTexture from the following parameters.
  130106. *
  130107. * @param name Defines the name of the texture
  130108. * @param element Defines the video or canvas the texture is filled with
  130109. * @param options Defines the other none mandatory texture creation options
  130110. */
  130111. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  130112. private _createInternalTexture;
  130113. /**
  130114. * Returns the texture matrix used in most of the material.
  130115. */
  130116. getTextureMatrix(): Matrix;
  130117. /**
  130118. * Updates the content of the texture.
  130119. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  130120. */
  130121. update(invertY?: Nullable<boolean>): void;
  130122. }
  130123. }
  130124. declare module BABYLON {
  130125. /**
  130126. * Defines the basic options interface of a TexturePacker Frame
  130127. */
  130128. export interface ITexturePackerFrame {
  130129. /**
  130130. * The frame ID
  130131. */
  130132. id: number;
  130133. /**
  130134. * The frames Scale
  130135. */
  130136. scale: Vector2;
  130137. /**
  130138. * The Frames offset
  130139. */
  130140. offset: Vector2;
  130141. }
  130142. /**
  130143. * This is a support class for frame Data on texture packer sets.
  130144. */
  130145. export class TexturePackerFrame implements ITexturePackerFrame {
  130146. /**
  130147. * The frame ID
  130148. */
  130149. id: number;
  130150. /**
  130151. * The frames Scale
  130152. */
  130153. scale: Vector2;
  130154. /**
  130155. * The Frames offset
  130156. */
  130157. offset: Vector2;
  130158. /**
  130159. * Initializes a texture package frame.
  130160. * @param id The numerical frame identifier
  130161. * @param scale Scalar Vector2 for UV frame
  130162. * @param offset Vector2 for the frame position in UV units.
  130163. * @returns TexturePackerFrame
  130164. */
  130165. constructor(id: number, scale: Vector2, offset: Vector2);
  130166. }
  130167. }
  130168. declare module BABYLON {
  130169. /**
  130170. * Defines the basic options interface of a TexturePacker
  130171. */
  130172. export interface ITexturePackerOptions {
  130173. /**
  130174. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  130175. */
  130176. map?: string[];
  130177. /**
  130178. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  130179. */
  130180. uvsIn?: string;
  130181. /**
  130182. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  130183. */
  130184. uvsOut?: string;
  130185. /**
  130186. * number representing the layout style. Defaults to LAYOUT_STRIP
  130187. */
  130188. layout?: number;
  130189. /**
  130190. * number of columns if using custom column count layout(2). This defaults to 4.
  130191. */
  130192. colnum?: number;
  130193. /**
  130194. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  130195. */
  130196. updateInputMeshes?: boolean;
  130197. /**
  130198. * boolean flag to dispose all the source textures. Defaults to true.
  130199. */
  130200. disposeSources?: boolean;
  130201. /**
  130202. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  130203. */
  130204. fillBlanks?: boolean;
  130205. /**
  130206. * string value representing the context fill style color. Defaults to 'black'.
  130207. */
  130208. customFillColor?: string;
  130209. /**
  130210. * Width and Height Value of each Frame in the TexturePacker Sets
  130211. */
  130212. frameSize?: number;
  130213. /**
  130214. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  130215. */
  130216. paddingRatio?: number;
  130217. /**
  130218. * Number that declares the fill method for the padding gutter.
  130219. */
  130220. paddingMode?: number;
  130221. /**
  130222. * If in SUBUV_COLOR padding mode what color to use.
  130223. */
  130224. paddingColor?: Color3 | Color4;
  130225. }
  130226. /**
  130227. * Defines the basic interface of a TexturePacker JSON File
  130228. */
  130229. export interface ITexturePackerJSON {
  130230. /**
  130231. * The frame ID
  130232. */
  130233. name: string;
  130234. /**
  130235. * The base64 channel data
  130236. */
  130237. sets: any;
  130238. /**
  130239. * The options of the Packer
  130240. */
  130241. options: ITexturePackerOptions;
  130242. /**
  130243. * The frame data of the Packer
  130244. */
  130245. frames: Array<number>;
  130246. }
  130247. /**
  130248. * This is a support class that generates a series of packed texture sets.
  130249. * @see https://doc.babylonjs.com/babylon101/materials
  130250. */
  130251. export class TexturePacker {
  130252. /** Packer Layout Constant 0 */
  130253. static readonly LAYOUT_STRIP: number;
  130254. /** Packer Layout Constant 1 */
  130255. static readonly LAYOUT_POWER2: number;
  130256. /** Packer Layout Constant 2 */
  130257. static readonly LAYOUT_COLNUM: number;
  130258. /** Packer Layout Constant 0 */
  130259. static readonly SUBUV_WRAP: number;
  130260. /** Packer Layout Constant 1 */
  130261. static readonly SUBUV_EXTEND: number;
  130262. /** Packer Layout Constant 2 */
  130263. static readonly SUBUV_COLOR: number;
  130264. /** The Name of the Texture Package */
  130265. name: string;
  130266. /** The scene scope of the TexturePacker */
  130267. scene: Scene;
  130268. /** The Meshes to target */
  130269. meshes: AbstractMesh[];
  130270. /** Arguments passed with the Constructor */
  130271. options: ITexturePackerOptions;
  130272. /** The promise that is started upon initialization */
  130273. promise: Nullable<Promise<TexturePacker | string>>;
  130274. /** The Container object for the channel sets that are generated */
  130275. sets: object;
  130276. /** The Container array for the frames that are generated */
  130277. frames: TexturePackerFrame[];
  130278. /** The expected number of textures the system is parsing. */
  130279. private _expecting;
  130280. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  130281. private _paddingValue;
  130282. /**
  130283. * Initializes a texture package series from an array of meshes or a single mesh.
  130284. * @param name The name of the package
  130285. * @param meshes The target meshes to compose the package from
  130286. * @param options The arguments that texture packer should follow while building.
  130287. * @param scene The scene which the textures are scoped to.
  130288. * @returns TexturePacker
  130289. */
  130290. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  130291. /**
  130292. * Starts the package process
  130293. * @param resolve The promises resolution function
  130294. * @returns TexturePacker
  130295. */
  130296. private _createFrames;
  130297. /**
  130298. * Calculates the Size of the Channel Sets
  130299. * @returns Vector2
  130300. */
  130301. private _calculateSize;
  130302. /**
  130303. * Calculates the UV data for the frames.
  130304. * @param baseSize the base frameSize
  130305. * @param padding the base frame padding
  130306. * @param dtSize size of the Dynamic Texture for that channel
  130307. * @param dtUnits is 1/dtSize
  130308. * @param update flag to update the input meshes
  130309. */
  130310. private _calculateMeshUVFrames;
  130311. /**
  130312. * Calculates the frames Offset.
  130313. * @param index of the frame
  130314. * @returns Vector2
  130315. */
  130316. private _getFrameOffset;
  130317. /**
  130318. * Updates a Mesh to the frame data
  130319. * @param mesh that is the target
  130320. * @param frameID or the frame index
  130321. */
  130322. private _updateMeshUV;
  130323. /**
  130324. * Updates a Meshes materials to use the texture packer channels
  130325. * @param m is the mesh to target
  130326. * @param force all channels on the packer to be set.
  130327. */
  130328. private _updateTextureReferences;
  130329. /**
  130330. * Public method to set a Mesh to a frame
  130331. * @param m that is the target
  130332. * @param frameID or the frame index
  130333. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  130334. */
  130335. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  130336. /**
  130337. * Starts the async promise to compile the texture packer.
  130338. * @returns Promise<void>
  130339. */
  130340. processAsync(): Promise<void>;
  130341. /**
  130342. * Disposes all textures associated with this packer
  130343. */
  130344. dispose(): void;
  130345. /**
  130346. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  130347. * @param imageType is the image type to use.
  130348. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  130349. */
  130350. download(imageType?: string, quality?: number): void;
  130351. /**
  130352. * Public method to load a texturePacker JSON file.
  130353. * @param data of the JSON file in string format.
  130354. */
  130355. updateFromJSON(data: string): void;
  130356. }
  130357. }
  130358. declare module BABYLON {
  130359. /**
  130360. * Enum used to define the target of a block
  130361. */
  130362. export enum NodeMaterialBlockTargets {
  130363. /** Vertex shader */
  130364. Vertex = 1,
  130365. /** Fragment shader */
  130366. Fragment = 2,
  130367. /** Neutral */
  130368. Neutral = 4,
  130369. /** Vertex and Fragment */
  130370. VertexAndFragment = 3
  130371. }
  130372. }
  130373. declare module BABYLON {
  130374. /**
  130375. * Defines the kind of connection point for node based material
  130376. */
  130377. export enum NodeMaterialBlockConnectionPointTypes {
  130378. /** Float */
  130379. Float = 1,
  130380. /** Int */
  130381. Int = 2,
  130382. /** Vector2 */
  130383. Vector2 = 4,
  130384. /** Vector3 */
  130385. Vector3 = 8,
  130386. /** Vector4 */
  130387. Vector4 = 16,
  130388. /** Color3 */
  130389. Color3 = 32,
  130390. /** Color4 */
  130391. Color4 = 64,
  130392. /** Matrix */
  130393. Matrix = 128,
  130394. /** Detect type based on connection */
  130395. AutoDetect = 1024,
  130396. /** Output type that will be defined by input type */
  130397. BasedOnInput = 2048
  130398. }
  130399. }
  130400. declare module BABYLON {
  130401. /**
  130402. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  130403. */
  130404. export enum NodeMaterialBlockConnectionPointMode {
  130405. /** Value is an uniform */
  130406. Uniform = 0,
  130407. /** Value is a mesh attribute */
  130408. Attribute = 1,
  130409. /** Value is a varying between vertex and fragment shaders */
  130410. Varying = 2,
  130411. /** Mode is undefined */
  130412. Undefined = 3
  130413. }
  130414. }
  130415. declare module BABYLON {
  130416. /**
  130417. * Enum used to define system values e.g. values automatically provided by the system
  130418. */
  130419. export enum NodeMaterialSystemValues {
  130420. /** World */
  130421. World = 1,
  130422. /** View */
  130423. View = 2,
  130424. /** Projection */
  130425. Projection = 3,
  130426. /** ViewProjection */
  130427. ViewProjection = 4,
  130428. /** WorldView */
  130429. WorldView = 5,
  130430. /** WorldViewProjection */
  130431. WorldViewProjection = 6,
  130432. /** CameraPosition */
  130433. CameraPosition = 7,
  130434. /** Fog Color */
  130435. FogColor = 8,
  130436. /** Delta time */
  130437. DeltaTime = 9
  130438. }
  130439. }
  130440. declare module BABYLON {
  130441. /**
  130442. * Root class for all node material optimizers
  130443. */
  130444. export class NodeMaterialOptimizer {
  130445. /**
  130446. * Function used to optimize a NodeMaterial graph
  130447. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  130448. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  130449. */
  130450. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  130451. }
  130452. }
  130453. declare module BABYLON {
  130454. /**
  130455. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  130456. */
  130457. export class TransformBlock extends NodeMaterialBlock {
  130458. /**
  130459. * Defines the value to use to complement W value to transform it to a Vector4
  130460. */
  130461. complementW: number;
  130462. /**
  130463. * Defines the value to use to complement z value to transform it to a Vector4
  130464. */
  130465. complementZ: number;
  130466. /**
  130467. * Creates a new TransformBlock
  130468. * @param name defines the block name
  130469. */
  130470. constructor(name: string);
  130471. /**
  130472. * Gets the current class name
  130473. * @returns the class name
  130474. */
  130475. getClassName(): string;
  130476. /**
  130477. * Gets the vector input
  130478. */
  130479. get vector(): NodeMaterialConnectionPoint;
  130480. /**
  130481. * Gets the output component
  130482. */
  130483. get output(): NodeMaterialConnectionPoint;
  130484. /**
  130485. * Gets the xyz output component
  130486. */
  130487. get xyz(): NodeMaterialConnectionPoint;
  130488. /**
  130489. * Gets the matrix transform input
  130490. */
  130491. get transform(): NodeMaterialConnectionPoint;
  130492. protected _buildBlock(state: NodeMaterialBuildState): this;
  130493. serialize(): any;
  130494. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130495. protected _dumpPropertiesCode(): string;
  130496. }
  130497. }
  130498. declare module BABYLON {
  130499. /**
  130500. * Block used to output the vertex position
  130501. */
  130502. export class VertexOutputBlock extends NodeMaterialBlock {
  130503. /**
  130504. * Creates a new VertexOutputBlock
  130505. * @param name defines the block name
  130506. */
  130507. constructor(name: string);
  130508. /**
  130509. * Gets the current class name
  130510. * @returns the class name
  130511. */
  130512. getClassName(): string;
  130513. /**
  130514. * Gets the vector input component
  130515. */
  130516. get vector(): NodeMaterialConnectionPoint;
  130517. protected _buildBlock(state: NodeMaterialBuildState): this;
  130518. }
  130519. }
  130520. declare module BABYLON {
  130521. /**
  130522. * Block used to output the final color
  130523. */
  130524. export class FragmentOutputBlock extends NodeMaterialBlock {
  130525. /**
  130526. * Create a new FragmentOutputBlock
  130527. * @param name defines the block name
  130528. */
  130529. constructor(name: string);
  130530. /**
  130531. * Gets the current class name
  130532. * @returns the class name
  130533. */
  130534. getClassName(): string;
  130535. /**
  130536. * Gets the rgba input component
  130537. */
  130538. get rgba(): NodeMaterialConnectionPoint;
  130539. /**
  130540. * Gets the rgb input component
  130541. */
  130542. get rgb(): NodeMaterialConnectionPoint;
  130543. /**
  130544. * Gets the a input component
  130545. */
  130546. get a(): NodeMaterialConnectionPoint;
  130547. protected _buildBlock(state: NodeMaterialBuildState): this;
  130548. }
  130549. }
  130550. declare module BABYLON {
  130551. /**
  130552. * Block used to read a reflection texture from a sampler
  130553. */
  130554. export class ReflectionTextureBlock extends NodeMaterialBlock {
  130555. private _define3DName;
  130556. private _defineCubicName;
  130557. private _defineExplicitName;
  130558. private _defineProjectionName;
  130559. private _defineLocalCubicName;
  130560. private _defineSphericalName;
  130561. private _definePlanarName;
  130562. private _defineEquirectangularName;
  130563. private _defineMirroredEquirectangularFixedName;
  130564. private _defineEquirectangularFixedName;
  130565. private _defineSkyboxName;
  130566. private _cubeSamplerName;
  130567. private _2DSamplerName;
  130568. private _positionUVWName;
  130569. private _directionWName;
  130570. private _reflectionCoordsName;
  130571. private _reflection2DCoordsName;
  130572. private _reflectionColorName;
  130573. private _reflectionMatrixName;
  130574. /**
  130575. * Gets or sets the texture associated with the node
  130576. */
  130577. texture: Nullable<BaseTexture>;
  130578. /**
  130579. * Create a new TextureBlock
  130580. * @param name defines the block name
  130581. */
  130582. constructor(name: string);
  130583. /**
  130584. * Gets the current class name
  130585. * @returns the class name
  130586. */
  130587. getClassName(): string;
  130588. /**
  130589. * Gets the world position input component
  130590. */
  130591. get position(): NodeMaterialConnectionPoint;
  130592. /**
  130593. * Gets the world position input component
  130594. */
  130595. get worldPosition(): NodeMaterialConnectionPoint;
  130596. /**
  130597. * Gets the world normal input component
  130598. */
  130599. get worldNormal(): NodeMaterialConnectionPoint;
  130600. /**
  130601. * Gets the world input component
  130602. */
  130603. get world(): NodeMaterialConnectionPoint;
  130604. /**
  130605. * Gets the camera (or eye) position component
  130606. */
  130607. get cameraPosition(): NodeMaterialConnectionPoint;
  130608. /**
  130609. * Gets the view input component
  130610. */
  130611. get view(): NodeMaterialConnectionPoint;
  130612. /**
  130613. * Gets the rgb output component
  130614. */
  130615. get rgb(): NodeMaterialConnectionPoint;
  130616. /**
  130617. * Gets the r output component
  130618. */
  130619. get r(): NodeMaterialConnectionPoint;
  130620. /**
  130621. * Gets the g output component
  130622. */
  130623. get g(): NodeMaterialConnectionPoint;
  130624. /**
  130625. * Gets the b output component
  130626. */
  130627. get b(): NodeMaterialConnectionPoint;
  130628. autoConfigure(material: NodeMaterial): void;
  130629. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130630. isReady(): boolean;
  130631. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130632. private _injectVertexCode;
  130633. private _writeOutput;
  130634. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130635. protected _dumpPropertiesCode(): string;
  130636. serialize(): any;
  130637. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130638. }
  130639. }
  130640. declare module BABYLON {
  130641. /**
  130642. * Interface used to configure the node material editor
  130643. */
  130644. export interface INodeMaterialEditorOptions {
  130645. /** Define the URl to load node editor script */
  130646. editorURL?: string;
  130647. }
  130648. /** @hidden */
  130649. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  130650. NORMAL: boolean;
  130651. TANGENT: boolean;
  130652. UV1: boolean;
  130653. /** BONES */
  130654. NUM_BONE_INFLUENCERS: number;
  130655. BonesPerMesh: number;
  130656. BONETEXTURE: boolean;
  130657. /** MORPH TARGETS */
  130658. MORPHTARGETS: boolean;
  130659. MORPHTARGETS_NORMAL: boolean;
  130660. MORPHTARGETS_TANGENT: boolean;
  130661. MORPHTARGETS_UV: boolean;
  130662. NUM_MORPH_INFLUENCERS: number;
  130663. /** IMAGE PROCESSING */
  130664. IMAGEPROCESSING: boolean;
  130665. VIGNETTE: boolean;
  130666. VIGNETTEBLENDMODEMULTIPLY: boolean;
  130667. VIGNETTEBLENDMODEOPAQUE: boolean;
  130668. TONEMAPPING: boolean;
  130669. TONEMAPPING_ACES: boolean;
  130670. CONTRAST: boolean;
  130671. EXPOSURE: boolean;
  130672. COLORCURVES: boolean;
  130673. COLORGRADING: boolean;
  130674. COLORGRADING3D: boolean;
  130675. SAMPLER3DGREENDEPTH: boolean;
  130676. SAMPLER3DBGRMAP: boolean;
  130677. IMAGEPROCESSINGPOSTPROCESS: boolean;
  130678. /** MISC. */
  130679. BUMPDIRECTUV: number;
  130680. constructor();
  130681. setValue(name: string, value: boolean): void;
  130682. }
  130683. /**
  130684. * Class used to configure NodeMaterial
  130685. */
  130686. export interface INodeMaterialOptions {
  130687. /**
  130688. * Defines if blocks should emit comments
  130689. */
  130690. emitComments: boolean;
  130691. }
  130692. /**
  130693. * Class used to create a node based material built by assembling shader blocks
  130694. */
  130695. export class NodeMaterial extends PushMaterial {
  130696. private static _BuildIdGenerator;
  130697. private _options;
  130698. private _vertexCompilationState;
  130699. private _fragmentCompilationState;
  130700. private _sharedData;
  130701. private _buildId;
  130702. private _buildWasSuccessful;
  130703. private _cachedWorldViewMatrix;
  130704. private _cachedWorldViewProjectionMatrix;
  130705. private _optimizers;
  130706. private _animationFrame;
  130707. /** Define the Url to load node editor script */
  130708. static EditorURL: string;
  130709. /** Define the Url to load snippets */
  130710. static SnippetUrl: string;
  130711. private BJSNODEMATERIALEDITOR;
  130712. /** Get the inspector from bundle or global */
  130713. private _getGlobalNodeMaterialEditor;
  130714. /**
  130715. * Gets or sets data used by visual editor
  130716. * @see https://nme.babylonjs.com
  130717. */
  130718. editorData: any;
  130719. /**
  130720. * 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)
  130721. */
  130722. ignoreAlpha: boolean;
  130723. /**
  130724. * Defines the maximum number of lights that can be used in the material
  130725. */
  130726. maxSimultaneousLights: number;
  130727. /**
  130728. * Observable raised when the material is built
  130729. */
  130730. onBuildObservable: Observable<NodeMaterial>;
  130731. /**
  130732. * Gets or sets the root nodes of the material vertex shader
  130733. */
  130734. _vertexOutputNodes: NodeMaterialBlock[];
  130735. /**
  130736. * Gets or sets the root nodes of the material fragment (pixel) shader
  130737. */
  130738. _fragmentOutputNodes: NodeMaterialBlock[];
  130739. /** Gets or sets options to control the node material overall behavior */
  130740. get options(): INodeMaterialOptions;
  130741. set options(options: INodeMaterialOptions);
  130742. /**
  130743. * Default configuration related to image processing available in the standard Material.
  130744. */
  130745. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  130746. /**
  130747. * Gets the image processing configuration used either in this material.
  130748. */
  130749. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  130750. /**
  130751. * Sets the Default image processing configuration used either in the this material.
  130752. *
  130753. * If sets to null, the scene one is in use.
  130754. */
  130755. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  130756. /**
  130757. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  130758. */
  130759. attachedBlocks: NodeMaterialBlock[];
  130760. /**
  130761. * Create a new node based material
  130762. * @param name defines the material name
  130763. * @param scene defines the hosting scene
  130764. * @param options defines creation option
  130765. */
  130766. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  130767. /**
  130768. * Gets the current class name of the material e.g. "NodeMaterial"
  130769. * @returns the class name
  130770. */
  130771. getClassName(): string;
  130772. /**
  130773. * Keep track of the image processing observer to allow dispose and replace.
  130774. */
  130775. private _imageProcessingObserver;
  130776. /**
  130777. * Attaches a new image processing configuration to the Standard Material.
  130778. * @param configuration
  130779. */
  130780. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  130781. /**
  130782. * Get a block by its name
  130783. * @param name defines the name of the block to retrieve
  130784. * @returns the required block or null if not found
  130785. */
  130786. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  130787. /**
  130788. * Get a block by its name
  130789. * @param predicate defines the predicate used to find the good candidate
  130790. * @returns the required block or null if not found
  130791. */
  130792. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  130793. /**
  130794. * Get an input block by its name
  130795. * @param predicate defines the predicate used to find the good candidate
  130796. * @returns the required input block or null if not found
  130797. */
  130798. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  130799. /**
  130800. * Gets the list of input blocks attached to this material
  130801. * @returns an array of InputBlocks
  130802. */
  130803. getInputBlocks(): InputBlock[];
  130804. /**
  130805. * Adds a new optimizer to the list of optimizers
  130806. * @param optimizer defines the optimizers to add
  130807. * @returns the current material
  130808. */
  130809. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  130810. /**
  130811. * Remove an optimizer from the list of optimizers
  130812. * @param optimizer defines the optimizers to remove
  130813. * @returns the current material
  130814. */
  130815. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  130816. /**
  130817. * Add a new block to the list of output nodes
  130818. * @param node defines the node to add
  130819. * @returns the current material
  130820. */
  130821. addOutputNode(node: NodeMaterialBlock): this;
  130822. /**
  130823. * Remove a block from the list of root nodes
  130824. * @param node defines the node to remove
  130825. * @returns the current material
  130826. */
  130827. removeOutputNode(node: NodeMaterialBlock): this;
  130828. private _addVertexOutputNode;
  130829. private _removeVertexOutputNode;
  130830. private _addFragmentOutputNode;
  130831. private _removeFragmentOutputNode;
  130832. /**
  130833. * Specifies if the material will require alpha blending
  130834. * @returns a boolean specifying if alpha blending is needed
  130835. */
  130836. needAlphaBlending(): boolean;
  130837. /**
  130838. * Specifies if this material should be rendered in alpha test mode
  130839. * @returns a boolean specifying if an alpha test is needed.
  130840. */
  130841. needAlphaTesting(): boolean;
  130842. private _initializeBlock;
  130843. private _resetDualBlocks;
  130844. /**
  130845. * Remove a block from the current node material
  130846. * @param block defines the block to remove
  130847. */
  130848. removeBlock(block: NodeMaterialBlock): void;
  130849. /**
  130850. * Build the material and generates the inner effect
  130851. * @param verbose defines if the build should log activity
  130852. */
  130853. build(verbose?: boolean): void;
  130854. /**
  130855. * Runs an otpimization phase to try to improve the shader code
  130856. */
  130857. optimize(): void;
  130858. private _prepareDefinesForAttributes;
  130859. /**
  130860. * Get if the submesh is ready to be used and all its information available.
  130861. * Child classes can use it to update shaders
  130862. * @param mesh defines the mesh to check
  130863. * @param subMesh defines which submesh to check
  130864. * @param useInstances specifies that instances should be used
  130865. * @returns a boolean indicating that the submesh is ready or not
  130866. */
  130867. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  130868. /**
  130869. * Get a string representing the shaders built by the current node graph
  130870. */
  130871. get compiledShaders(): string;
  130872. /**
  130873. * Binds the world matrix to the material
  130874. * @param world defines the world transformation matrix
  130875. */
  130876. bindOnlyWorldMatrix(world: Matrix): void;
  130877. /**
  130878. * Binds the submesh to this material by preparing the effect and shader to draw
  130879. * @param world defines the world transformation matrix
  130880. * @param mesh defines the mesh containing the submesh
  130881. * @param subMesh defines the submesh to bind the material to
  130882. */
  130883. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  130884. /**
  130885. * Gets the active textures from the material
  130886. * @returns an array of textures
  130887. */
  130888. getActiveTextures(): BaseTexture[];
  130889. /**
  130890. * Gets the list of texture blocks
  130891. * @returns an array of texture blocks
  130892. */
  130893. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  130894. /**
  130895. * Specifies if the material uses a texture
  130896. * @param texture defines the texture to check against the material
  130897. * @returns a boolean specifying if the material uses the texture
  130898. */
  130899. hasTexture(texture: BaseTexture): boolean;
  130900. /**
  130901. * Disposes the material
  130902. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  130903. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  130904. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  130905. */
  130906. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  130907. /** Creates the node editor window. */
  130908. private _createNodeEditor;
  130909. /**
  130910. * Launch the node material editor
  130911. * @param config Define the configuration of the editor
  130912. * @return a promise fulfilled when the node editor is visible
  130913. */
  130914. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  130915. /**
  130916. * Clear the current material
  130917. */
  130918. clear(): void;
  130919. /**
  130920. * Clear the current material and set it to a default state
  130921. */
  130922. setToDefault(): void;
  130923. /**
  130924. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  130925. * @param url defines the url to load from
  130926. * @returns a promise that will fullfil when the material is fully loaded
  130927. */
  130928. loadAsync(url: string): Promise<void>;
  130929. private _gatherBlocks;
  130930. /**
  130931. * Generate a string containing the code declaration required to create an equivalent of this material
  130932. * @returns a string
  130933. */
  130934. generateCode(): string;
  130935. /**
  130936. * Serializes this material in a JSON representation
  130937. * @returns the serialized material object
  130938. */
  130939. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  130940. private _restoreConnections;
  130941. /**
  130942. * Clear the current graph and load a new one from a serialization object
  130943. * @param source defines the JSON representation of the material
  130944. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130945. */
  130946. loadFromSerialization(source: any, rootUrl?: string): void;
  130947. /**
  130948. * Creates a node material from parsed material data
  130949. * @param source defines the JSON representation of the material
  130950. * @param scene defines the hosting scene
  130951. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130952. * @returns a new node material
  130953. */
  130954. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  130955. /**
  130956. * Creates a node material from a snippet saved in a remote file
  130957. * @param name defines the name of the material to create
  130958. * @param url defines the url to load from
  130959. * @param scene defines the hosting scene
  130960. * @returns a promise that will resolve to the new node material
  130961. */
  130962. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  130963. /**
  130964. * Creates a node material from a snippet saved by the node material editor
  130965. * @param snippetId defines the snippet to load
  130966. * @param scene defines the hosting scene
  130967. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130968. * @returns a promise that will resolve to the new node material
  130969. */
  130970. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  130971. /**
  130972. * Creates a new node material set to default basic configuration
  130973. * @param name defines the name of the material
  130974. * @param scene defines the hosting scene
  130975. * @returns a new NodeMaterial
  130976. */
  130977. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  130978. }
  130979. }
  130980. declare module BABYLON {
  130981. /**
  130982. * Block used to read a texture from a sampler
  130983. */
  130984. export class TextureBlock extends NodeMaterialBlock {
  130985. private _defineName;
  130986. private _linearDefineName;
  130987. private _tempTextureRead;
  130988. private _samplerName;
  130989. private _transformedUVName;
  130990. private _textureTransformName;
  130991. private _textureInfoName;
  130992. private _mainUVName;
  130993. private _mainUVDefineName;
  130994. /**
  130995. * Gets or sets the texture associated with the node
  130996. */
  130997. texture: Nullable<Texture>;
  130998. /**
  130999. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  131000. */
  131001. convertToGammaSpace: boolean;
  131002. /**
  131003. * Create a new TextureBlock
  131004. * @param name defines the block name
  131005. */
  131006. constructor(name: string);
  131007. /**
  131008. * Gets the current class name
  131009. * @returns the class name
  131010. */
  131011. getClassName(): string;
  131012. /**
  131013. * Gets the uv input component
  131014. */
  131015. get uv(): NodeMaterialConnectionPoint;
  131016. /**
  131017. * Gets the rgba output component
  131018. */
  131019. get rgba(): NodeMaterialConnectionPoint;
  131020. /**
  131021. * Gets the rgb output component
  131022. */
  131023. get rgb(): NodeMaterialConnectionPoint;
  131024. /**
  131025. * Gets the r output component
  131026. */
  131027. get r(): NodeMaterialConnectionPoint;
  131028. /**
  131029. * Gets the g output component
  131030. */
  131031. get g(): NodeMaterialConnectionPoint;
  131032. /**
  131033. * Gets the b output component
  131034. */
  131035. get b(): NodeMaterialConnectionPoint;
  131036. /**
  131037. * Gets the a output component
  131038. */
  131039. get a(): NodeMaterialConnectionPoint;
  131040. get target(): NodeMaterialBlockTargets;
  131041. autoConfigure(material: NodeMaterial): void;
  131042. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131043. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131044. isReady(): boolean;
  131045. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131046. private get _isMixed();
  131047. private _injectVertexCode;
  131048. private _writeTextureRead;
  131049. private _writeOutput;
  131050. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  131051. protected _dumpPropertiesCode(): string;
  131052. serialize(): any;
  131053. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131054. }
  131055. }
  131056. declare module BABYLON {
  131057. /**
  131058. * Class used to store shared data between 2 NodeMaterialBuildState
  131059. */
  131060. export class NodeMaterialBuildStateSharedData {
  131061. /**
  131062. * Gets the list of emitted varyings
  131063. */
  131064. temps: string[];
  131065. /**
  131066. * Gets the list of emitted varyings
  131067. */
  131068. varyings: string[];
  131069. /**
  131070. * Gets the varying declaration string
  131071. */
  131072. varyingDeclaration: string;
  131073. /**
  131074. * Input blocks
  131075. */
  131076. inputBlocks: InputBlock[];
  131077. /**
  131078. * Input blocks
  131079. */
  131080. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  131081. /**
  131082. * Bindable blocks (Blocks that need to set data to the effect)
  131083. */
  131084. bindableBlocks: NodeMaterialBlock[];
  131085. /**
  131086. * List of blocks that can provide a compilation fallback
  131087. */
  131088. blocksWithFallbacks: NodeMaterialBlock[];
  131089. /**
  131090. * List of blocks that can provide a define update
  131091. */
  131092. blocksWithDefines: NodeMaterialBlock[];
  131093. /**
  131094. * List of blocks that can provide a repeatable content
  131095. */
  131096. repeatableContentBlocks: NodeMaterialBlock[];
  131097. /**
  131098. * List of blocks that can provide a dynamic list of uniforms
  131099. */
  131100. dynamicUniformBlocks: NodeMaterialBlock[];
  131101. /**
  131102. * List of blocks that can block the isReady function for the material
  131103. */
  131104. blockingBlocks: NodeMaterialBlock[];
  131105. /**
  131106. * Gets the list of animated inputs
  131107. */
  131108. animatedInputs: InputBlock[];
  131109. /**
  131110. * Build Id used to avoid multiple recompilations
  131111. */
  131112. buildId: number;
  131113. /** List of emitted variables */
  131114. variableNames: {
  131115. [key: string]: number;
  131116. };
  131117. /** List of emitted defines */
  131118. defineNames: {
  131119. [key: string]: number;
  131120. };
  131121. /** Should emit comments? */
  131122. emitComments: boolean;
  131123. /** Emit build activity */
  131124. verbose: boolean;
  131125. /** Gets or sets the hosting scene */
  131126. scene: Scene;
  131127. /**
  131128. * Gets the compilation hints emitted at compilation time
  131129. */
  131130. hints: {
  131131. needWorldViewMatrix: boolean;
  131132. needWorldViewProjectionMatrix: boolean;
  131133. needAlphaBlending: boolean;
  131134. needAlphaTesting: boolean;
  131135. };
  131136. /**
  131137. * List of compilation checks
  131138. */
  131139. checks: {
  131140. emitVertex: boolean;
  131141. emitFragment: boolean;
  131142. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  131143. };
  131144. /** Creates a new shared data */
  131145. constructor();
  131146. /**
  131147. * Emits console errors and exceptions if there is a failing check
  131148. */
  131149. emitErrors(): void;
  131150. }
  131151. }
  131152. declare module BABYLON {
  131153. /**
  131154. * Class used to store node based material build state
  131155. */
  131156. export class NodeMaterialBuildState {
  131157. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  131158. supportUniformBuffers: boolean;
  131159. /**
  131160. * Gets the list of emitted attributes
  131161. */
  131162. attributes: string[];
  131163. /**
  131164. * Gets the list of emitted uniforms
  131165. */
  131166. uniforms: string[];
  131167. /**
  131168. * Gets the list of emitted constants
  131169. */
  131170. constants: string[];
  131171. /**
  131172. * Gets the list of emitted samplers
  131173. */
  131174. samplers: string[];
  131175. /**
  131176. * Gets the list of emitted functions
  131177. */
  131178. functions: {
  131179. [key: string]: string;
  131180. };
  131181. /**
  131182. * Gets the list of emitted extensions
  131183. */
  131184. extensions: {
  131185. [key: string]: string;
  131186. };
  131187. /**
  131188. * Gets the target of the compilation state
  131189. */
  131190. target: NodeMaterialBlockTargets;
  131191. /**
  131192. * Gets the list of emitted counters
  131193. */
  131194. counters: {
  131195. [key: string]: number;
  131196. };
  131197. /**
  131198. * Shared data between multiple NodeMaterialBuildState instances
  131199. */
  131200. sharedData: NodeMaterialBuildStateSharedData;
  131201. /** @hidden */
  131202. _vertexState: NodeMaterialBuildState;
  131203. /** @hidden */
  131204. _attributeDeclaration: string;
  131205. /** @hidden */
  131206. _uniformDeclaration: string;
  131207. /** @hidden */
  131208. _constantDeclaration: string;
  131209. /** @hidden */
  131210. _samplerDeclaration: string;
  131211. /** @hidden */
  131212. _varyingTransfer: string;
  131213. private _repeatableContentAnchorIndex;
  131214. /** @hidden */
  131215. _builtCompilationString: string;
  131216. /**
  131217. * Gets the emitted compilation strings
  131218. */
  131219. compilationString: string;
  131220. /**
  131221. * Finalize the compilation strings
  131222. * @param state defines the current compilation state
  131223. */
  131224. finalize(state: NodeMaterialBuildState): void;
  131225. /** @hidden */
  131226. get _repeatableContentAnchor(): string;
  131227. /** @hidden */
  131228. _getFreeVariableName(prefix: string): string;
  131229. /** @hidden */
  131230. _getFreeDefineName(prefix: string): string;
  131231. /** @hidden */
  131232. _excludeVariableName(name: string): void;
  131233. /** @hidden */
  131234. _emit2DSampler(name: string): void;
  131235. /** @hidden */
  131236. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  131237. /** @hidden */
  131238. _emitExtension(name: string, extension: string): void;
  131239. /** @hidden */
  131240. _emitFunction(name: string, code: string, comments: string): void;
  131241. /** @hidden */
  131242. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  131243. replaceStrings?: {
  131244. search: RegExp;
  131245. replace: string;
  131246. }[];
  131247. repeatKey?: string;
  131248. }): string;
  131249. /** @hidden */
  131250. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  131251. repeatKey?: string;
  131252. removeAttributes?: boolean;
  131253. removeUniforms?: boolean;
  131254. removeVaryings?: boolean;
  131255. removeIfDef?: boolean;
  131256. replaceStrings?: {
  131257. search: RegExp;
  131258. replace: string;
  131259. }[];
  131260. }, storeKey?: string): void;
  131261. /** @hidden */
  131262. _registerTempVariable(name: string): boolean;
  131263. /** @hidden */
  131264. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  131265. /** @hidden */
  131266. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  131267. /** @hidden */
  131268. _emitFloat(value: number): string;
  131269. }
  131270. }
  131271. declare module BABYLON {
  131272. /**
  131273. * Defines a block that can be used inside a node based material
  131274. */
  131275. export class NodeMaterialBlock {
  131276. private _buildId;
  131277. private _buildTarget;
  131278. private _target;
  131279. private _isFinalMerger;
  131280. private _isInput;
  131281. protected _isUnique: boolean;
  131282. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  131283. inputsAreExclusive: boolean;
  131284. /** @hidden */
  131285. _codeVariableName: string;
  131286. /** @hidden */
  131287. _inputs: NodeMaterialConnectionPoint[];
  131288. /** @hidden */
  131289. _outputs: NodeMaterialConnectionPoint[];
  131290. /** @hidden */
  131291. _preparationId: number;
  131292. /**
  131293. * Gets or sets the name of the block
  131294. */
  131295. name: string;
  131296. /**
  131297. * Gets or sets the unique id of the node
  131298. */
  131299. uniqueId: number;
  131300. /**
  131301. * Gets or sets the comments associated with this block
  131302. */
  131303. comments: string;
  131304. /**
  131305. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  131306. */
  131307. get isUnique(): boolean;
  131308. /**
  131309. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  131310. */
  131311. get isFinalMerger(): boolean;
  131312. /**
  131313. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  131314. */
  131315. get isInput(): boolean;
  131316. /**
  131317. * Gets or sets the build Id
  131318. */
  131319. get buildId(): number;
  131320. set buildId(value: number);
  131321. /**
  131322. * Gets or sets the target of the block
  131323. */
  131324. get target(): NodeMaterialBlockTargets;
  131325. set target(value: NodeMaterialBlockTargets);
  131326. /**
  131327. * Gets the list of input points
  131328. */
  131329. get inputs(): NodeMaterialConnectionPoint[];
  131330. /** Gets the list of output points */
  131331. get outputs(): NodeMaterialConnectionPoint[];
  131332. /**
  131333. * Find an input by its name
  131334. * @param name defines the name of the input to look for
  131335. * @returns the input or null if not found
  131336. */
  131337. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  131338. /**
  131339. * Find an output by its name
  131340. * @param name defines the name of the outputto look for
  131341. * @returns the output or null if not found
  131342. */
  131343. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  131344. /**
  131345. * Creates a new NodeMaterialBlock
  131346. * @param name defines the block name
  131347. * @param target defines the target of that block (Vertex by default)
  131348. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  131349. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  131350. */
  131351. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  131352. /**
  131353. * Initialize the block and prepare the context for build
  131354. * @param state defines the state that will be used for the build
  131355. */
  131356. initialize(state: NodeMaterialBuildState): void;
  131357. /**
  131358. * Bind data to effect. Will only be called for blocks with isBindable === true
  131359. * @param effect defines the effect to bind data to
  131360. * @param nodeMaterial defines the hosting NodeMaterial
  131361. * @param mesh defines the mesh that will be rendered
  131362. */
  131363. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131364. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  131365. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  131366. protected _writeFloat(value: number): string;
  131367. /**
  131368. * Gets the current class name e.g. "NodeMaterialBlock"
  131369. * @returns the class name
  131370. */
  131371. getClassName(): string;
  131372. /**
  131373. * Register a new input. Must be called inside a block constructor
  131374. * @param name defines the connection point name
  131375. * @param type defines the connection point type
  131376. * @param isOptional defines a boolean indicating that this input can be omitted
  131377. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  131378. * @returns the current block
  131379. */
  131380. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  131381. /**
  131382. * Register a new output. Must be called inside a block constructor
  131383. * @param name defines the connection point name
  131384. * @param type defines the connection point type
  131385. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  131386. * @returns the current block
  131387. */
  131388. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  131389. /**
  131390. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  131391. * @param forOutput defines an optional connection point to check compatibility with
  131392. * @returns the first available input or null
  131393. */
  131394. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  131395. /**
  131396. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  131397. * @param forBlock defines an optional block to check compatibility with
  131398. * @returns the first available input or null
  131399. */
  131400. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  131401. /**
  131402. * Gets the sibling of the given output
  131403. * @param current defines the current output
  131404. * @returns the next output in the list or null
  131405. */
  131406. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  131407. /**
  131408. * Connect current block with another block
  131409. * @param other defines the block to connect with
  131410. * @param options define the various options to help pick the right connections
  131411. * @returns the current block
  131412. */
  131413. connectTo(other: NodeMaterialBlock, options?: {
  131414. input?: string;
  131415. output?: string;
  131416. outputSwizzle?: string;
  131417. }): this | undefined;
  131418. protected _buildBlock(state: NodeMaterialBuildState): void;
  131419. /**
  131420. * Add uniforms, samplers and uniform buffers at compilation time
  131421. * @param state defines the state to update
  131422. * @param nodeMaterial defines the node material requesting the update
  131423. * @param defines defines the material defines to update
  131424. * @param uniformBuffers defines the list of uniform buffer names
  131425. */
  131426. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  131427. /**
  131428. * Add potential fallbacks if shader compilation fails
  131429. * @param mesh defines the mesh to be rendered
  131430. * @param fallbacks defines the current prioritized list of fallbacks
  131431. */
  131432. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  131433. /**
  131434. * Initialize defines for shader compilation
  131435. * @param mesh defines the mesh to be rendered
  131436. * @param nodeMaterial defines the node material requesting the update
  131437. * @param defines defines the material defines to update
  131438. * @param useInstances specifies that instances should be used
  131439. */
  131440. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131441. /**
  131442. * Update defines for shader compilation
  131443. * @param mesh defines the mesh to be rendered
  131444. * @param nodeMaterial defines the node material requesting the update
  131445. * @param defines defines the material defines to update
  131446. * @param useInstances specifies that instances should be used
  131447. */
  131448. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131449. /**
  131450. * Lets the block try to connect some inputs automatically
  131451. * @param material defines the hosting NodeMaterial
  131452. */
  131453. autoConfigure(material: NodeMaterial): void;
  131454. /**
  131455. * Function called when a block is declared as repeatable content generator
  131456. * @param vertexShaderState defines the current compilation state for the vertex shader
  131457. * @param fragmentShaderState defines the current compilation state for the fragment shader
  131458. * @param mesh defines the mesh to be rendered
  131459. * @param defines defines the material defines to update
  131460. */
  131461. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  131462. /**
  131463. * Checks if the block is ready
  131464. * @param mesh defines the mesh to be rendered
  131465. * @param nodeMaterial defines the node material requesting the update
  131466. * @param defines defines the material defines to update
  131467. * @param useInstances specifies that instances should be used
  131468. * @returns true if the block is ready
  131469. */
  131470. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  131471. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  131472. private _processBuild;
  131473. /**
  131474. * Compile the current node and generate the shader code
  131475. * @param state defines the current compilation state (uniforms, samplers, current string)
  131476. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  131477. * @returns true if already built
  131478. */
  131479. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  131480. protected _inputRename(name: string): string;
  131481. protected _outputRename(name: string): string;
  131482. protected _dumpPropertiesCode(): string;
  131483. /** @hidden */
  131484. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  131485. /** @hidden */
  131486. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  131487. /**
  131488. * Clone the current block to a new identical block
  131489. * @param scene defines the hosting scene
  131490. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  131491. * @returns a copy of the current block
  131492. */
  131493. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  131494. /**
  131495. * Serializes this block in a JSON representation
  131496. * @returns the serialized block object
  131497. */
  131498. serialize(): any;
  131499. /** @hidden */
  131500. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131501. /**
  131502. * Release resources
  131503. */
  131504. dispose(): void;
  131505. }
  131506. }
  131507. declare module BABYLON {
  131508. /**
  131509. * Enum defining the type of animations supported by InputBlock
  131510. */
  131511. export enum AnimatedInputBlockTypes {
  131512. /** No animation */
  131513. None = 0,
  131514. /** Time based animation. Will only work for floats */
  131515. Time = 1
  131516. }
  131517. }
  131518. declare module BABYLON {
  131519. /**
  131520. * Block used to expose an input value
  131521. */
  131522. export class InputBlock extends NodeMaterialBlock {
  131523. private _mode;
  131524. private _associatedVariableName;
  131525. private _storedValue;
  131526. private _valueCallback;
  131527. private _type;
  131528. private _animationType;
  131529. /** Gets or set a value used to limit the range of float values */
  131530. min: number;
  131531. /** Gets or set a value used to limit the range of float values */
  131532. max: number;
  131533. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  131534. isBoolean: boolean;
  131535. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  131536. matrixMode: number;
  131537. /** @hidden */
  131538. _systemValue: Nullable<NodeMaterialSystemValues>;
  131539. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  131540. visibleInInspector: boolean;
  131541. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  131542. isConstant: boolean;
  131543. /** Gets or sets the group to use to display this block in the Inspector */
  131544. groupInInspector: string;
  131545. /** Gets an observable raised when the value is changed */
  131546. onValueChangedObservable: Observable<InputBlock>;
  131547. /**
  131548. * Gets or sets the connection point type (default is float)
  131549. */
  131550. get type(): NodeMaterialBlockConnectionPointTypes;
  131551. /**
  131552. * Creates a new InputBlock
  131553. * @param name defines the block name
  131554. * @param target defines the target of that block (Vertex by default)
  131555. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  131556. */
  131557. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  131558. /**
  131559. * Gets the output component
  131560. */
  131561. get output(): NodeMaterialConnectionPoint;
  131562. /**
  131563. * Set the source of this connection point to a vertex attribute
  131564. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  131565. * @returns the current connection point
  131566. */
  131567. setAsAttribute(attributeName?: string): InputBlock;
  131568. /**
  131569. * Set the source of this connection point to a system value
  131570. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  131571. * @returns the current connection point
  131572. */
  131573. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  131574. /**
  131575. * Gets or sets the value of that point.
  131576. * Please note that this value will be ignored if valueCallback is defined
  131577. */
  131578. get value(): any;
  131579. set value(value: any);
  131580. /**
  131581. * Gets or sets a callback used to get the value of that point.
  131582. * Please note that setting this value will force the connection point to ignore the value property
  131583. */
  131584. get valueCallback(): () => any;
  131585. set valueCallback(value: () => any);
  131586. /**
  131587. * Gets or sets the associated variable name in the shader
  131588. */
  131589. get associatedVariableName(): string;
  131590. set associatedVariableName(value: string);
  131591. /** Gets or sets the type of animation applied to the input */
  131592. get animationType(): AnimatedInputBlockTypes;
  131593. set animationType(value: AnimatedInputBlockTypes);
  131594. /**
  131595. * Gets a boolean indicating that this connection point not defined yet
  131596. */
  131597. get isUndefined(): boolean;
  131598. /**
  131599. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  131600. * In this case the connection point name must be the name of the uniform to use.
  131601. * Can only be set on inputs
  131602. */
  131603. get isUniform(): boolean;
  131604. set isUniform(value: boolean);
  131605. /**
  131606. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  131607. * In this case the connection point name must be the name of the attribute to use
  131608. * Can only be set on inputs
  131609. */
  131610. get isAttribute(): boolean;
  131611. set isAttribute(value: boolean);
  131612. /**
  131613. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  131614. * Can only be set on exit points
  131615. */
  131616. get isVarying(): boolean;
  131617. set isVarying(value: boolean);
  131618. /**
  131619. * Gets a boolean indicating that the current connection point is a system value
  131620. */
  131621. get isSystemValue(): boolean;
  131622. /**
  131623. * Gets or sets the current well known value or null if not defined as a system value
  131624. */
  131625. get systemValue(): Nullable<NodeMaterialSystemValues>;
  131626. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  131627. /**
  131628. * Gets the current class name
  131629. * @returns the class name
  131630. */
  131631. getClassName(): string;
  131632. /**
  131633. * Animate the input if animationType !== None
  131634. * @param scene defines the rendering scene
  131635. */
  131636. animate(scene: Scene): void;
  131637. private _emitDefine;
  131638. initialize(state: NodeMaterialBuildState): void;
  131639. /**
  131640. * Set the input block to its default value (based on its type)
  131641. */
  131642. setDefaultValue(): void;
  131643. private _emitConstant;
  131644. private _emit;
  131645. /** @hidden */
  131646. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  131647. /** @hidden */
  131648. _transmit(effect: Effect, scene: Scene): void;
  131649. protected _buildBlock(state: NodeMaterialBuildState): void;
  131650. protected _dumpPropertiesCode(): string;
  131651. dispose(): void;
  131652. serialize(): any;
  131653. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131654. }
  131655. }
  131656. declare module BABYLON {
  131657. /**
  131658. * Enum used to define the compatibility state between two connection points
  131659. */
  131660. export enum NodeMaterialConnectionPointCompatibilityStates {
  131661. /** Points are compatibles */
  131662. Compatible = 0,
  131663. /** Points are incompatible because of their types */
  131664. TypeIncompatible = 1,
  131665. /** Points are incompatible because of their targets (vertex vs fragment) */
  131666. TargetIncompatible = 2
  131667. }
  131668. /**
  131669. * Defines the direction of a connection point
  131670. */
  131671. export enum NodeMaterialConnectionPointDirection {
  131672. /** Input */
  131673. Input = 0,
  131674. /** Output */
  131675. Output = 1
  131676. }
  131677. /**
  131678. * Defines a connection point for a block
  131679. */
  131680. export class NodeMaterialConnectionPoint {
  131681. /** @hidden */
  131682. _ownerBlock: NodeMaterialBlock;
  131683. /** @hidden */
  131684. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  131685. private _endpoints;
  131686. private _associatedVariableName;
  131687. private _direction;
  131688. /** @hidden */
  131689. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  131690. /** @hidden */
  131691. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  131692. private _type;
  131693. /** @hidden */
  131694. _enforceAssociatedVariableName: boolean;
  131695. /** Gets the direction of the point */
  131696. get direction(): NodeMaterialConnectionPointDirection;
  131697. /**
  131698. * Gets or sets the additional types supported by this connection point
  131699. */
  131700. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  131701. /**
  131702. * Gets or sets the additional types excluded by this connection point
  131703. */
  131704. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  131705. /**
  131706. * Observable triggered when this point is connected
  131707. */
  131708. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  131709. /**
  131710. * Gets or sets the associated variable name in the shader
  131711. */
  131712. get associatedVariableName(): string;
  131713. set associatedVariableName(value: string);
  131714. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  131715. get innerType(): NodeMaterialBlockConnectionPointTypes;
  131716. /**
  131717. * Gets or sets the connection point type (default is float)
  131718. */
  131719. get type(): NodeMaterialBlockConnectionPointTypes;
  131720. set type(value: NodeMaterialBlockConnectionPointTypes);
  131721. /**
  131722. * Gets or sets the connection point name
  131723. */
  131724. name: string;
  131725. /**
  131726. * Gets or sets a boolean indicating that this connection point can be omitted
  131727. */
  131728. isOptional: boolean;
  131729. /**
  131730. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  131731. */
  131732. define: string;
  131733. /** @hidden */
  131734. _prioritizeVertex: boolean;
  131735. private _target;
  131736. /** Gets or sets the target of that connection point */
  131737. get target(): NodeMaterialBlockTargets;
  131738. set target(value: NodeMaterialBlockTargets);
  131739. /**
  131740. * Gets a boolean indicating that the current point is connected
  131741. */
  131742. get isConnected(): boolean;
  131743. /**
  131744. * Gets a boolean indicating that the current point is connected to an input block
  131745. */
  131746. get isConnectedToInputBlock(): boolean;
  131747. /**
  131748. * Gets a the connected input block (if any)
  131749. */
  131750. get connectInputBlock(): Nullable<InputBlock>;
  131751. /** Get the other side of the connection (if any) */
  131752. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  131753. /** Get the block that owns this connection point */
  131754. get ownerBlock(): NodeMaterialBlock;
  131755. /** Get the block connected on the other side of this connection (if any) */
  131756. get sourceBlock(): Nullable<NodeMaterialBlock>;
  131757. /** Get the block connected on the endpoints of this connection (if any) */
  131758. get connectedBlocks(): Array<NodeMaterialBlock>;
  131759. /** Gets the list of connected endpoints */
  131760. get endpoints(): NodeMaterialConnectionPoint[];
  131761. /** Gets a boolean indicating if that output point is connected to at least one input */
  131762. get hasEndpoints(): boolean;
  131763. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  131764. get isConnectedInVertexShader(): boolean;
  131765. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  131766. get isConnectedInFragmentShader(): boolean;
  131767. /**
  131768. * Creates a new connection point
  131769. * @param name defines the connection point name
  131770. * @param ownerBlock defines the block hosting this connection point
  131771. * @param direction defines the direction of the connection point
  131772. */
  131773. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  131774. /**
  131775. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  131776. * @returns the class name
  131777. */
  131778. getClassName(): string;
  131779. /**
  131780. * Gets a boolean indicating if the current point can be connected to another point
  131781. * @param connectionPoint defines the other connection point
  131782. * @returns a boolean
  131783. */
  131784. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  131785. /**
  131786. * Gets a number indicating if the current point can be connected to another point
  131787. * @param connectionPoint defines the other connection point
  131788. * @returns a number defining the compatibility state
  131789. */
  131790. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  131791. /**
  131792. * Connect this point to another connection point
  131793. * @param connectionPoint defines the other connection point
  131794. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  131795. * @returns the current connection point
  131796. */
  131797. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  131798. /**
  131799. * Disconnect this point from one of his endpoint
  131800. * @param endpoint defines the other connection point
  131801. * @returns the current connection point
  131802. */
  131803. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  131804. /**
  131805. * Serializes this point in a JSON representation
  131806. * @returns the serialized point object
  131807. */
  131808. serialize(): any;
  131809. /**
  131810. * Release resources
  131811. */
  131812. dispose(): void;
  131813. }
  131814. }
  131815. declare module BABYLON {
  131816. /**
  131817. * Block used to add support for vertex skinning (bones)
  131818. */
  131819. export class BonesBlock extends NodeMaterialBlock {
  131820. /**
  131821. * Creates a new BonesBlock
  131822. * @param name defines the block name
  131823. */
  131824. constructor(name: string);
  131825. /**
  131826. * Initialize the block and prepare the context for build
  131827. * @param state defines the state that will be used for the build
  131828. */
  131829. initialize(state: NodeMaterialBuildState): void;
  131830. /**
  131831. * Gets the current class name
  131832. * @returns the class name
  131833. */
  131834. getClassName(): string;
  131835. /**
  131836. * Gets the matrix indices input component
  131837. */
  131838. get matricesIndices(): NodeMaterialConnectionPoint;
  131839. /**
  131840. * Gets the matrix weights input component
  131841. */
  131842. get matricesWeights(): NodeMaterialConnectionPoint;
  131843. /**
  131844. * Gets the extra matrix indices input component
  131845. */
  131846. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  131847. /**
  131848. * Gets the extra matrix weights input component
  131849. */
  131850. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  131851. /**
  131852. * Gets the world input component
  131853. */
  131854. get world(): NodeMaterialConnectionPoint;
  131855. /**
  131856. * Gets the output component
  131857. */
  131858. get output(): NodeMaterialConnectionPoint;
  131859. autoConfigure(material: NodeMaterial): void;
  131860. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  131861. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131862. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131863. protected _buildBlock(state: NodeMaterialBuildState): this;
  131864. }
  131865. }
  131866. declare module BABYLON {
  131867. /**
  131868. * Block used to add support for instances
  131869. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  131870. */
  131871. export class InstancesBlock extends NodeMaterialBlock {
  131872. /**
  131873. * Creates a new InstancesBlock
  131874. * @param name defines the block name
  131875. */
  131876. constructor(name: string);
  131877. /**
  131878. * Gets the current class name
  131879. * @returns the class name
  131880. */
  131881. getClassName(): string;
  131882. /**
  131883. * Gets the first world row input component
  131884. */
  131885. get world0(): NodeMaterialConnectionPoint;
  131886. /**
  131887. * Gets the second world row input component
  131888. */
  131889. get world1(): NodeMaterialConnectionPoint;
  131890. /**
  131891. * Gets the third world row input component
  131892. */
  131893. get world2(): NodeMaterialConnectionPoint;
  131894. /**
  131895. * Gets the forth world row input component
  131896. */
  131897. get world3(): NodeMaterialConnectionPoint;
  131898. /**
  131899. * Gets the world input component
  131900. */
  131901. get world(): NodeMaterialConnectionPoint;
  131902. /**
  131903. * Gets the output component
  131904. */
  131905. get output(): NodeMaterialConnectionPoint;
  131906. /**
  131907. * Gets the isntanceID component
  131908. */
  131909. get instanceID(): NodeMaterialConnectionPoint;
  131910. autoConfigure(material: NodeMaterial): void;
  131911. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131912. protected _buildBlock(state: NodeMaterialBuildState): this;
  131913. }
  131914. }
  131915. declare module BABYLON {
  131916. /**
  131917. * Block used to add morph targets support to vertex shader
  131918. */
  131919. export class MorphTargetsBlock extends NodeMaterialBlock {
  131920. private _repeatableContentAnchor;
  131921. /**
  131922. * Create a new MorphTargetsBlock
  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 position input component
  131933. */
  131934. get position(): NodeMaterialConnectionPoint;
  131935. /**
  131936. * Gets the normal input component
  131937. */
  131938. get normal(): NodeMaterialConnectionPoint;
  131939. /**
  131940. * Gets the tangent input component
  131941. */
  131942. get tangent(): NodeMaterialConnectionPoint;
  131943. /**
  131944. * Gets the tangent input component
  131945. */
  131946. get uv(): NodeMaterialConnectionPoint;
  131947. /**
  131948. * Gets the position output component
  131949. */
  131950. get positionOutput(): NodeMaterialConnectionPoint;
  131951. /**
  131952. * Gets the normal output component
  131953. */
  131954. get normalOutput(): NodeMaterialConnectionPoint;
  131955. /**
  131956. * Gets the tangent output component
  131957. */
  131958. get tangentOutput(): NodeMaterialConnectionPoint;
  131959. /**
  131960. * Gets the tangent output component
  131961. */
  131962. get uvOutput(): NodeMaterialConnectionPoint;
  131963. initialize(state: NodeMaterialBuildState): void;
  131964. autoConfigure(material: NodeMaterial): void;
  131965. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131966. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131967. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  131968. protected _buildBlock(state: NodeMaterialBuildState): this;
  131969. }
  131970. }
  131971. declare module BABYLON {
  131972. /**
  131973. * Block used to get data information from a light
  131974. */
  131975. export class LightInformationBlock extends NodeMaterialBlock {
  131976. private _lightDataUniformName;
  131977. private _lightColorUniformName;
  131978. private _lightTypeDefineName;
  131979. /**
  131980. * Gets or sets the light associated with this block
  131981. */
  131982. light: Nullable<Light>;
  131983. /**
  131984. * Creates a new LightInformationBlock
  131985. * @param name defines the block name
  131986. */
  131987. constructor(name: string);
  131988. /**
  131989. * Gets the current class name
  131990. * @returns the class name
  131991. */
  131992. getClassName(): string;
  131993. /**
  131994. * Gets the world position input component
  131995. */
  131996. get worldPosition(): NodeMaterialConnectionPoint;
  131997. /**
  131998. * Gets the direction output component
  131999. */
  132000. get direction(): NodeMaterialConnectionPoint;
  132001. /**
  132002. * Gets the direction output component
  132003. */
  132004. get color(): NodeMaterialConnectionPoint;
  132005. /**
  132006. * Gets the direction output component
  132007. */
  132008. get intensity(): NodeMaterialConnectionPoint;
  132009. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132010. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  132011. protected _buildBlock(state: NodeMaterialBuildState): this;
  132012. serialize(): any;
  132013. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132014. }
  132015. }
  132016. declare module BABYLON {
  132017. /**
  132018. * Block used to add image processing support to fragment shader
  132019. */
  132020. export class ImageProcessingBlock extends NodeMaterialBlock {
  132021. /**
  132022. * Create a new ImageProcessingBlock
  132023. * @param name defines the block name
  132024. */
  132025. constructor(name: string);
  132026. /**
  132027. * Gets the current class name
  132028. * @returns the class name
  132029. */
  132030. getClassName(): string;
  132031. /**
  132032. * Gets the color input component
  132033. */
  132034. get color(): NodeMaterialConnectionPoint;
  132035. /**
  132036. * Gets the output component
  132037. */
  132038. get output(): NodeMaterialConnectionPoint;
  132039. /**
  132040. * Initialize the block and prepare the context for build
  132041. * @param state defines the state that will be used for the build
  132042. */
  132043. initialize(state: NodeMaterialBuildState): void;
  132044. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  132045. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  132046. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132047. protected _buildBlock(state: NodeMaterialBuildState): this;
  132048. }
  132049. }
  132050. declare module BABYLON {
  132051. /**
  132052. * Block used to pertub normals based on a normal map
  132053. */
  132054. export class PerturbNormalBlock extends NodeMaterialBlock {
  132055. private _tangentSpaceParameterName;
  132056. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  132057. invertX: boolean;
  132058. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  132059. invertY: boolean;
  132060. /**
  132061. * Create a new PerturbNormalBlock
  132062. * @param name defines the block name
  132063. */
  132064. constructor(name: string);
  132065. /**
  132066. * Gets the current class name
  132067. * @returns the class name
  132068. */
  132069. getClassName(): string;
  132070. /**
  132071. * Gets the world position input component
  132072. */
  132073. get worldPosition(): NodeMaterialConnectionPoint;
  132074. /**
  132075. * Gets the world normal input component
  132076. */
  132077. get worldNormal(): NodeMaterialConnectionPoint;
  132078. /**
  132079. * Gets the world tangent input component
  132080. */
  132081. get worldTangent(): NodeMaterialConnectionPoint;
  132082. /**
  132083. * Gets the uv input component
  132084. */
  132085. get uv(): NodeMaterialConnectionPoint;
  132086. /**
  132087. * Gets the normal map color input component
  132088. */
  132089. get normalMapColor(): NodeMaterialConnectionPoint;
  132090. /**
  132091. * Gets the strength input component
  132092. */
  132093. get strength(): NodeMaterialConnectionPoint;
  132094. /**
  132095. * Gets the output component
  132096. */
  132097. get output(): NodeMaterialConnectionPoint;
  132098. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  132099. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132100. autoConfigure(material: NodeMaterial): void;
  132101. protected _buildBlock(state: NodeMaterialBuildState): this;
  132102. protected _dumpPropertiesCode(): string;
  132103. serialize(): any;
  132104. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132105. }
  132106. }
  132107. declare module BABYLON {
  132108. /**
  132109. * Block used to discard a pixel if a value is smaller than a cutoff
  132110. */
  132111. export class DiscardBlock extends NodeMaterialBlock {
  132112. /**
  132113. * Create a new DiscardBlock
  132114. * @param name defines the block name
  132115. */
  132116. constructor(name: string);
  132117. /**
  132118. * Gets the current class name
  132119. * @returns the class name
  132120. */
  132121. getClassName(): string;
  132122. /**
  132123. * Gets the color input component
  132124. */
  132125. get value(): NodeMaterialConnectionPoint;
  132126. /**
  132127. * Gets the cutoff input component
  132128. */
  132129. get cutoff(): NodeMaterialConnectionPoint;
  132130. protected _buildBlock(state: NodeMaterialBuildState): this;
  132131. }
  132132. }
  132133. declare module BABYLON {
  132134. /**
  132135. * Block used to test if the fragment shader is front facing
  132136. */
  132137. export class FrontFacingBlock extends NodeMaterialBlock {
  132138. /**
  132139. * Creates a new FrontFacingBlock
  132140. * @param name defines the block name
  132141. */
  132142. constructor(name: string);
  132143. /**
  132144. * Gets the current class name
  132145. * @returns the class name
  132146. */
  132147. getClassName(): string;
  132148. /**
  132149. * Gets the output component
  132150. */
  132151. get output(): NodeMaterialConnectionPoint;
  132152. protected _buildBlock(state: NodeMaterialBuildState): this;
  132153. }
  132154. }
  132155. declare module BABYLON {
  132156. /**
  132157. * Block used to get the derivative value on x and y of a given input
  132158. */
  132159. export class DerivativeBlock extends NodeMaterialBlock {
  132160. /**
  132161. * Create a new DerivativeBlock
  132162. * @param name defines the block name
  132163. */
  132164. constructor(name: string);
  132165. /**
  132166. * Gets the current class name
  132167. * @returns the class name
  132168. */
  132169. getClassName(): string;
  132170. /**
  132171. * Gets the input component
  132172. */
  132173. get input(): NodeMaterialConnectionPoint;
  132174. /**
  132175. * Gets the derivative output on x
  132176. */
  132177. get dx(): NodeMaterialConnectionPoint;
  132178. /**
  132179. * Gets the derivative output on y
  132180. */
  132181. get dy(): NodeMaterialConnectionPoint;
  132182. protected _buildBlock(state: NodeMaterialBuildState): this;
  132183. }
  132184. }
  132185. declare module BABYLON {
  132186. /**
  132187. * Block used to add support for scene fog
  132188. */
  132189. export class FogBlock extends NodeMaterialBlock {
  132190. private _fogDistanceName;
  132191. private _fogParameters;
  132192. /**
  132193. * Create a new FogBlock
  132194. * @param name defines the block name
  132195. */
  132196. constructor(name: string);
  132197. /**
  132198. * Gets the current class name
  132199. * @returns the class name
  132200. */
  132201. getClassName(): string;
  132202. /**
  132203. * Gets the world position input component
  132204. */
  132205. get worldPosition(): NodeMaterialConnectionPoint;
  132206. /**
  132207. * Gets the view input component
  132208. */
  132209. get view(): NodeMaterialConnectionPoint;
  132210. /**
  132211. * Gets the color input component
  132212. */
  132213. get input(): NodeMaterialConnectionPoint;
  132214. /**
  132215. * Gets the fog color input component
  132216. */
  132217. get fogColor(): NodeMaterialConnectionPoint;
  132218. /**
  132219. * Gets the output component
  132220. */
  132221. get output(): NodeMaterialConnectionPoint;
  132222. autoConfigure(material: NodeMaterial): void;
  132223. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  132224. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132225. protected _buildBlock(state: NodeMaterialBuildState): this;
  132226. }
  132227. }
  132228. declare module BABYLON {
  132229. /**
  132230. * Block used to add light in the fragment shader
  132231. */
  132232. export class LightBlock extends NodeMaterialBlock {
  132233. private _lightId;
  132234. /**
  132235. * Gets or sets the light associated with this block
  132236. */
  132237. light: Nullable<Light>;
  132238. /**
  132239. * Create a new LightBlock
  132240. * @param name defines the block name
  132241. */
  132242. constructor(name: string);
  132243. /**
  132244. * Gets the current class name
  132245. * @returns the class name
  132246. */
  132247. getClassName(): string;
  132248. /**
  132249. * Gets the world position input component
  132250. */
  132251. get worldPosition(): NodeMaterialConnectionPoint;
  132252. /**
  132253. * Gets the world normal input component
  132254. */
  132255. get worldNormal(): NodeMaterialConnectionPoint;
  132256. /**
  132257. * Gets the camera (or eye) position component
  132258. */
  132259. get cameraPosition(): NodeMaterialConnectionPoint;
  132260. /**
  132261. * Gets the glossiness component
  132262. */
  132263. get glossiness(): NodeMaterialConnectionPoint;
  132264. /**
  132265. * Gets the glossinness power component
  132266. */
  132267. get glossPower(): NodeMaterialConnectionPoint;
  132268. /**
  132269. * Gets the diffuse color component
  132270. */
  132271. get diffuseColor(): NodeMaterialConnectionPoint;
  132272. /**
  132273. * Gets the specular color component
  132274. */
  132275. get specularColor(): NodeMaterialConnectionPoint;
  132276. /**
  132277. * Gets the diffuse output component
  132278. */
  132279. get diffuseOutput(): NodeMaterialConnectionPoint;
  132280. /**
  132281. * Gets the specular output component
  132282. */
  132283. get specularOutput(): NodeMaterialConnectionPoint;
  132284. /**
  132285. * Gets the shadow output component
  132286. */
  132287. get shadow(): NodeMaterialConnectionPoint;
  132288. autoConfigure(material: NodeMaterial): void;
  132289. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  132290. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  132291. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132292. private _injectVertexCode;
  132293. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132294. serialize(): any;
  132295. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132296. }
  132297. }
  132298. declare module BABYLON {
  132299. /**
  132300. * Block used to multiply 2 values
  132301. */
  132302. export class MultiplyBlock extends NodeMaterialBlock {
  132303. /**
  132304. * Creates a new MultiplyBlock
  132305. * @param name defines the block name
  132306. */
  132307. constructor(name: string);
  132308. /**
  132309. * Gets the current class name
  132310. * @returns the class name
  132311. */
  132312. getClassName(): string;
  132313. /**
  132314. * Gets the left operand input component
  132315. */
  132316. get left(): NodeMaterialConnectionPoint;
  132317. /**
  132318. * Gets the right operand input component
  132319. */
  132320. get right(): NodeMaterialConnectionPoint;
  132321. /**
  132322. * Gets the output component
  132323. */
  132324. get output(): NodeMaterialConnectionPoint;
  132325. protected _buildBlock(state: NodeMaterialBuildState): this;
  132326. }
  132327. }
  132328. declare module BABYLON {
  132329. /**
  132330. * Block used to add 2 vectors
  132331. */
  132332. export class AddBlock extends NodeMaterialBlock {
  132333. /**
  132334. * Creates a new AddBlock
  132335. * @param name defines the block name
  132336. */
  132337. constructor(name: string);
  132338. /**
  132339. * Gets the current class name
  132340. * @returns the class name
  132341. */
  132342. getClassName(): string;
  132343. /**
  132344. * Gets the left operand input component
  132345. */
  132346. get left(): NodeMaterialConnectionPoint;
  132347. /**
  132348. * Gets the right operand input component
  132349. */
  132350. get right(): NodeMaterialConnectionPoint;
  132351. /**
  132352. * Gets the output component
  132353. */
  132354. get output(): NodeMaterialConnectionPoint;
  132355. protected _buildBlock(state: NodeMaterialBuildState): this;
  132356. }
  132357. }
  132358. declare module BABYLON {
  132359. /**
  132360. * Block used to scale a vector by a float
  132361. */
  132362. export class ScaleBlock extends NodeMaterialBlock {
  132363. /**
  132364. * Creates a new ScaleBlock
  132365. * @param name defines the block name
  132366. */
  132367. constructor(name: string);
  132368. /**
  132369. * Gets the current class name
  132370. * @returns the class name
  132371. */
  132372. getClassName(): string;
  132373. /**
  132374. * Gets the input component
  132375. */
  132376. get input(): NodeMaterialConnectionPoint;
  132377. /**
  132378. * Gets the factor input component
  132379. */
  132380. get factor(): NodeMaterialConnectionPoint;
  132381. /**
  132382. * Gets the output component
  132383. */
  132384. get output(): NodeMaterialConnectionPoint;
  132385. protected _buildBlock(state: NodeMaterialBuildState): this;
  132386. }
  132387. }
  132388. declare module BABYLON {
  132389. /**
  132390. * Block used to clamp a float
  132391. */
  132392. export class ClampBlock extends NodeMaterialBlock {
  132393. /** Gets or sets the minimum range */
  132394. minimum: number;
  132395. /** Gets or sets the maximum range */
  132396. maximum: number;
  132397. /**
  132398. * Creates a new ClampBlock
  132399. * @param name defines the block name
  132400. */
  132401. constructor(name: string);
  132402. /**
  132403. * Gets the current class name
  132404. * @returns the class name
  132405. */
  132406. getClassName(): string;
  132407. /**
  132408. * Gets the value input component
  132409. */
  132410. get value(): NodeMaterialConnectionPoint;
  132411. /**
  132412. * Gets the output component
  132413. */
  132414. get output(): NodeMaterialConnectionPoint;
  132415. protected _buildBlock(state: NodeMaterialBuildState): this;
  132416. protected _dumpPropertiesCode(): string;
  132417. serialize(): any;
  132418. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132419. }
  132420. }
  132421. declare module BABYLON {
  132422. /**
  132423. * Block used to apply a cross product between 2 vectors
  132424. */
  132425. export class CrossBlock extends NodeMaterialBlock {
  132426. /**
  132427. * Creates a new CrossBlock
  132428. * @param name defines the block name
  132429. */
  132430. constructor(name: string);
  132431. /**
  132432. * Gets the current class name
  132433. * @returns the class name
  132434. */
  132435. getClassName(): string;
  132436. /**
  132437. * Gets the left operand input component
  132438. */
  132439. get left(): NodeMaterialConnectionPoint;
  132440. /**
  132441. * Gets the right operand input component
  132442. */
  132443. get right(): NodeMaterialConnectionPoint;
  132444. /**
  132445. * Gets the output component
  132446. */
  132447. get output(): NodeMaterialConnectionPoint;
  132448. protected _buildBlock(state: NodeMaterialBuildState): this;
  132449. }
  132450. }
  132451. declare module BABYLON {
  132452. /**
  132453. * Block used to apply a dot product between 2 vectors
  132454. */
  132455. export class DotBlock extends NodeMaterialBlock {
  132456. /**
  132457. * Creates a new DotBlock
  132458. * @param name defines the block name
  132459. */
  132460. constructor(name: string);
  132461. /**
  132462. * Gets the current class name
  132463. * @returns the class name
  132464. */
  132465. getClassName(): string;
  132466. /**
  132467. * Gets the left operand input component
  132468. */
  132469. get left(): NodeMaterialConnectionPoint;
  132470. /**
  132471. * Gets the right operand input component
  132472. */
  132473. get right(): NodeMaterialConnectionPoint;
  132474. /**
  132475. * Gets the output component
  132476. */
  132477. get output(): NodeMaterialConnectionPoint;
  132478. protected _buildBlock(state: NodeMaterialBuildState): this;
  132479. }
  132480. }
  132481. declare module BABYLON {
  132482. /**
  132483. * Block used to remap a float from a range to a new one
  132484. */
  132485. export class RemapBlock extends NodeMaterialBlock {
  132486. /**
  132487. * Gets or sets the source range
  132488. */
  132489. sourceRange: Vector2;
  132490. /**
  132491. * Gets or sets the target range
  132492. */
  132493. targetRange: Vector2;
  132494. /**
  132495. * Creates a new RemapBlock
  132496. * @param name defines the block name
  132497. */
  132498. constructor(name: string);
  132499. /**
  132500. * Gets the current class name
  132501. * @returns the class name
  132502. */
  132503. getClassName(): string;
  132504. /**
  132505. * Gets the input component
  132506. */
  132507. get input(): NodeMaterialConnectionPoint;
  132508. /**
  132509. * Gets the source min input component
  132510. */
  132511. get sourceMin(): NodeMaterialConnectionPoint;
  132512. /**
  132513. * Gets the source max input component
  132514. */
  132515. get sourceMax(): NodeMaterialConnectionPoint;
  132516. /**
  132517. * Gets the target min input component
  132518. */
  132519. get targetMin(): NodeMaterialConnectionPoint;
  132520. /**
  132521. * Gets the target max input component
  132522. */
  132523. get targetMax(): NodeMaterialConnectionPoint;
  132524. /**
  132525. * Gets the output component
  132526. */
  132527. get output(): NodeMaterialConnectionPoint;
  132528. protected _buildBlock(state: NodeMaterialBuildState): this;
  132529. protected _dumpPropertiesCode(): string;
  132530. serialize(): any;
  132531. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132532. }
  132533. }
  132534. declare module BABYLON {
  132535. /**
  132536. * Block used to normalize a vector
  132537. */
  132538. export class NormalizeBlock extends NodeMaterialBlock {
  132539. /**
  132540. * Creates a new NormalizeBlock
  132541. * @param name defines the block name
  132542. */
  132543. constructor(name: string);
  132544. /**
  132545. * Gets the current class name
  132546. * @returns the class name
  132547. */
  132548. getClassName(): string;
  132549. /**
  132550. * Gets the input component
  132551. */
  132552. get input(): NodeMaterialConnectionPoint;
  132553. /**
  132554. * Gets the output component
  132555. */
  132556. get output(): NodeMaterialConnectionPoint;
  132557. protected _buildBlock(state: NodeMaterialBuildState): this;
  132558. }
  132559. }
  132560. declare module BABYLON {
  132561. /**
  132562. * Operations supported by the Trigonometry block
  132563. */
  132564. export enum TrigonometryBlockOperations {
  132565. /** Cos */
  132566. Cos = 0,
  132567. /** Sin */
  132568. Sin = 1,
  132569. /** Abs */
  132570. Abs = 2,
  132571. /** Exp */
  132572. Exp = 3,
  132573. /** Exp2 */
  132574. Exp2 = 4,
  132575. /** Round */
  132576. Round = 5,
  132577. /** Floor */
  132578. Floor = 6,
  132579. /** Ceiling */
  132580. Ceiling = 7,
  132581. /** Square root */
  132582. Sqrt = 8,
  132583. /** Log */
  132584. Log = 9,
  132585. /** Tangent */
  132586. Tan = 10,
  132587. /** Arc tangent */
  132588. ArcTan = 11,
  132589. /** Arc cosinus */
  132590. ArcCos = 12,
  132591. /** Arc sinus */
  132592. ArcSin = 13,
  132593. /** Fraction */
  132594. Fract = 14,
  132595. /** Sign */
  132596. Sign = 15,
  132597. /** To radians (from degrees) */
  132598. Radians = 16,
  132599. /** To degrees (from radians) */
  132600. Degrees = 17
  132601. }
  132602. /**
  132603. * Block used to apply trigonometry operation to floats
  132604. */
  132605. export class TrigonometryBlock extends NodeMaterialBlock {
  132606. /**
  132607. * Gets or sets the operation applied by the block
  132608. */
  132609. operation: TrigonometryBlockOperations;
  132610. /**
  132611. * Creates a new TrigonometryBlock
  132612. * @param name defines the block name
  132613. */
  132614. constructor(name: string);
  132615. /**
  132616. * Gets the current class name
  132617. * @returns the class name
  132618. */
  132619. getClassName(): string;
  132620. /**
  132621. * Gets the input component
  132622. */
  132623. get input(): NodeMaterialConnectionPoint;
  132624. /**
  132625. * Gets the output component
  132626. */
  132627. get output(): NodeMaterialConnectionPoint;
  132628. protected _buildBlock(state: NodeMaterialBuildState): this;
  132629. serialize(): any;
  132630. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132631. protected _dumpPropertiesCode(): string;
  132632. }
  132633. }
  132634. declare module BABYLON {
  132635. /**
  132636. * Block used to create a Color3/4 out of individual inputs (one for each component)
  132637. */
  132638. export class ColorMergerBlock extends NodeMaterialBlock {
  132639. /**
  132640. * Create a new ColorMergerBlock
  132641. * @param name defines the block name
  132642. */
  132643. constructor(name: string);
  132644. /**
  132645. * Gets the current class name
  132646. * @returns the class name
  132647. */
  132648. getClassName(): string;
  132649. /**
  132650. * Gets the rgb component (input)
  132651. */
  132652. get rgbIn(): NodeMaterialConnectionPoint;
  132653. /**
  132654. * Gets the r component (input)
  132655. */
  132656. get r(): NodeMaterialConnectionPoint;
  132657. /**
  132658. * Gets the g component (input)
  132659. */
  132660. get g(): NodeMaterialConnectionPoint;
  132661. /**
  132662. * Gets the b component (input)
  132663. */
  132664. get b(): NodeMaterialConnectionPoint;
  132665. /**
  132666. * Gets the a component (input)
  132667. */
  132668. get a(): NodeMaterialConnectionPoint;
  132669. /**
  132670. * Gets the rgba component (output)
  132671. */
  132672. get rgba(): NodeMaterialConnectionPoint;
  132673. /**
  132674. * Gets the rgb component (output)
  132675. */
  132676. get rgbOut(): NodeMaterialConnectionPoint;
  132677. /**
  132678. * Gets the rgb component (output)
  132679. * @deprecated Please use rgbOut instead.
  132680. */
  132681. get rgb(): NodeMaterialConnectionPoint;
  132682. protected _buildBlock(state: NodeMaterialBuildState): this;
  132683. }
  132684. }
  132685. declare module BABYLON {
  132686. /**
  132687. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  132688. */
  132689. export class VectorMergerBlock extends NodeMaterialBlock {
  132690. /**
  132691. * Create a new VectorMergerBlock
  132692. * @param name defines the block name
  132693. */
  132694. constructor(name: string);
  132695. /**
  132696. * Gets the current class name
  132697. * @returns the class name
  132698. */
  132699. getClassName(): string;
  132700. /**
  132701. * Gets the xyz component (input)
  132702. */
  132703. get xyzIn(): NodeMaterialConnectionPoint;
  132704. /**
  132705. * Gets the xy component (input)
  132706. */
  132707. get xyIn(): NodeMaterialConnectionPoint;
  132708. /**
  132709. * Gets the x component (input)
  132710. */
  132711. get x(): NodeMaterialConnectionPoint;
  132712. /**
  132713. * Gets the y component (input)
  132714. */
  132715. get y(): NodeMaterialConnectionPoint;
  132716. /**
  132717. * Gets the z component (input)
  132718. */
  132719. get z(): NodeMaterialConnectionPoint;
  132720. /**
  132721. * Gets the w component (input)
  132722. */
  132723. get w(): NodeMaterialConnectionPoint;
  132724. /**
  132725. * Gets the xyzw component (output)
  132726. */
  132727. get xyzw(): NodeMaterialConnectionPoint;
  132728. /**
  132729. * Gets the xyz component (output)
  132730. */
  132731. get xyzOut(): NodeMaterialConnectionPoint;
  132732. /**
  132733. * Gets the xy component (output)
  132734. */
  132735. get xyOut(): NodeMaterialConnectionPoint;
  132736. /**
  132737. * Gets the xy component (output)
  132738. * @deprecated Please use xyOut instead.
  132739. */
  132740. get xy(): NodeMaterialConnectionPoint;
  132741. /**
  132742. * Gets the xyz component (output)
  132743. * @deprecated Please use xyzOut instead.
  132744. */
  132745. get xyz(): NodeMaterialConnectionPoint;
  132746. protected _buildBlock(state: NodeMaterialBuildState): this;
  132747. }
  132748. }
  132749. declare module BABYLON {
  132750. /**
  132751. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  132752. */
  132753. export class ColorSplitterBlock extends NodeMaterialBlock {
  132754. /**
  132755. * Create a new ColorSplitterBlock
  132756. * @param name defines the block name
  132757. */
  132758. constructor(name: string);
  132759. /**
  132760. * Gets the current class name
  132761. * @returns the class name
  132762. */
  132763. getClassName(): string;
  132764. /**
  132765. * Gets the rgba component (input)
  132766. */
  132767. get rgba(): NodeMaterialConnectionPoint;
  132768. /**
  132769. * Gets the rgb component (input)
  132770. */
  132771. get rgbIn(): NodeMaterialConnectionPoint;
  132772. /**
  132773. * Gets the rgb component (output)
  132774. */
  132775. get rgbOut(): NodeMaterialConnectionPoint;
  132776. /**
  132777. * Gets the r component (output)
  132778. */
  132779. get r(): NodeMaterialConnectionPoint;
  132780. /**
  132781. * Gets the g component (output)
  132782. */
  132783. get g(): NodeMaterialConnectionPoint;
  132784. /**
  132785. * Gets the b component (output)
  132786. */
  132787. get b(): NodeMaterialConnectionPoint;
  132788. /**
  132789. * Gets the a component (output)
  132790. */
  132791. get a(): NodeMaterialConnectionPoint;
  132792. protected _inputRename(name: string): string;
  132793. protected _outputRename(name: string): string;
  132794. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132795. }
  132796. }
  132797. declare module BABYLON {
  132798. /**
  132799. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  132800. */
  132801. export class VectorSplitterBlock extends NodeMaterialBlock {
  132802. /**
  132803. * Create a new VectorSplitterBlock
  132804. * @param name defines the block name
  132805. */
  132806. constructor(name: string);
  132807. /**
  132808. * Gets the current class name
  132809. * @returns the class name
  132810. */
  132811. getClassName(): string;
  132812. /**
  132813. * Gets the xyzw component (input)
  132814. */
  132815. get xyzw(): NodeMaterialConnectionPoint;
  132816. /**
  132817. * Gets the xyz component (input)
  132818. */
  132819. get xyzIn(): NodeMaterialConnectionPoint;
  132820. /**
  132821. * Gets the xy component (input)
  132822. */
  132823. get xyIn(): NodeMaterialConnectionPoint;
  132824. /**
  132825. * Gets the xyz component (output)
  132826. */
  132827. get xyzOut(): NodeMaterialConnectionPoint;
  132828. /**
  132829. * Gets the xy component (output)
  132830. */
  132831. get xyOut(): NodeMaterialConnectionPoint;
  132832. /**
  132833. * Gets the x component (output)
  132834. */
  132835. get x(): NodeMaterialConnectionPoint;
  132836. /**
  132837. * Gets the y component (output)
  132838. */
  132839. get y(): NodeMaterialConnectionPoint;
  132840. /**
  132841. * Gets the z component (output)
  132842. */
  132843. get z(): NodeMaterialConnectionPoint;
  132844. /**
  132845. * Gets the w component (output)
  132846. */
  132847. get w(): NodeMaterialConnectionPoint;
  132848. protected _inputRename(name: string): string;
  132849. protected _outputRename(name: string): string;
  132850. protected _buildBlock(state: NodeMaterialBuildState): this;
  132851. }
  132852. }
  132853. declare module BABYLON {
  132854. /**
  132855. * Block used to lerp between 2 values
  132856. */
  132857. export class LerpBlock extends NodeMaterialBlock {
  132858. /**
  132859. * Creates a new LerpBlock
  132860. * @param name defines the block name
  132861. */
  132862. constructor(name: string);
  132863. /**
  132864. * Gets the current class name
  132865. * @returns the class name
  132866. */
  132867. getClassName(): string;
  132868. /**
  132869. * Gets the left operand input component
  132870. */
  132871. get left(): NodeMaterialConnectionPoint;
  132872. /**
  132873. * Gets the right operand input component
  132874. */
  132875. get right(): NodeMaterialConnectionPoint;
  132876. /**
  132877. * Gets the gradient operand input component
  132878. */
  132879. get gradient(): NodeMaterialConnectionPoint;
  132880. /**
  132881. * Gets the output component
  132882. */
  132883. get output(): NodeMaterialConnectionPoint;
  132884. protected _buildBlock(state: NodeMaterialBuildState): this;
  132885. }
  132886. }
  132887. declare module BABYLON {
  132888. /**
  132889. * Block used to divide 2 vectors
  132890. */
  132891. export class DivideBlock extends NodeMaterialBlock {
  132892. /**
  132893. * Creates a new DivideBlock
  132894. * @param name defines the block name
  132895. */
  132896. constructor(name: string);
  132897. /**
  132898. * Gets the current class name
  132899. * @returns the class name
  132900. */
  132901. getClassName(): string;
  132902. /**
  132903. * Gets the left operand input component
  132904. */
  132905. get left(): NodeMaterialConnectionPoint;
  132906. /**
  132907. * Gets the right operand input component
  132908. */
  132909. get right(): NodeMaterialConnectionPoint;
  132910. /**
  132911. * Gets the output component
  132912. */
  132913. get output(): NodeMaterialConnectionPoint;
  132914. protected _buildBlock(state: NodeMaterialBuildState): this;
  132915. }
  132916. }
  132917. declare module BABYLON {
  132918. /**
  132919. * Block used to subtract 2 vectors
  132920. */
  132921. export class SubtractBlock extends NodeMaterialBlock {
  132922. /**
  132923. * Creates a new SubtractBlock
  132924. * @param name defines the block name
  132925. */
  132926. constructor(name: string);
  132927. /**
  132928. * Gets the current class name
  132929. * @returns the class name
  132930. */
  132931. getClassName(): string;
  132932. /**
  132933. * Gets the left operand input component
  132934. */
  132935. get left(): NodeMaterialConnectionPoint;
  132936. /**
  132937. * Gets the right operand input component
  132938. */
  132939. get right(): NodeMaterialConnectionPoint;
  132940. /**
  132941. * Gets the output component
  132942. */
  132943. get output(): NodeMaterialConnectionPoint;
  132944. protected _buildBlock(state: NodeMaterialBuildState): this;
  132945. }
  132946. }
  132947. declare module BABYLON {
  132948. /**
  132949. * Block used to step a value
  132950. */
  132951. export class StepBlock extends NodeMaterialBlock {
  132952. /**
  132953. * Creates a new StepBlock
  132954. * @param name defines the block name
  132955. */
  132956. constructor(name: string);
  132957. /**
  132958. * Gets the current class name
  132959. * @returns the class name
  132960. */
  132961. getClassName(): string;
  132962. /**
  132963. * Gets the value operand input component
  132964. */
  132965. get value(): NodeMaterialConnectionPoint;
  132966. /**
  132967. * Gets the edge operand input component
  132968. */
  132969. get edge(): NodeMaterialConnectionPoint;
  132970. /**
  132971. * Gets the output component
  132972. */
  132973. get output(): NodeMaterialConnectionPoint;
  132974. protected _buildBlock(state: NodeMaterialBuildState): this;
  132975. }
  132976. }
  132977. declare module BABYLON {
  132978. /**
  132979. * Block used to get the opposite (1 - x) of a value
  132980. */
  132981. export class OneMinusBlock extends NodeMaterialBlock {
  132982. /**
  132983. * Creates a new OneMinusBlock
  132984. * @param name defines the block name
  132985. */
  132986. constructor(name: string);
  132987. /**
  132988. * Gets the current class name
  132989. * @returns the class name
  132990. */
  132991. getClassName(): string;
  132992. /**
  132993. * Gets the input component
  132994. */
  132995. get input(): NodeMaterialConnectionPoint;
  132996. /**
  132997. * Gets the output component
  132998. */
  132999. get output(): NodeMaterialConnectionPoint;
  133000. protected _buildBlock(state: NodeMaterialBuildState): this;
  133001. }
  133002. }
  133003. declare module BABYLON {
  133004. /**
  133005. * Block used to get the view direction
  133006. */
  133007. export class ViewDirectionBlock extends NodeMaterialBlock {
  133008. /**
  133009. * Creates a new ViewDirectionBlock
  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 world position component
  133020. */
  133021. get worldPosition(): NodeMaterialConnectionPoint;
  133022. /**
  133023. * Gets the camera position component
  133024. */
  133025. get cameraPosition(): NodeMaterialConnectionPoint;
  133026. /**
  133027. * Gets the output component
  133028. */
  133029. get output(): NodeMaterialConnectionPoint;
  133030. autoConfigure(material: NodeMaterial): void;
  133031. protected _buildBlock(state: NodeMaterialBuildState): this;
  133032. }
  133033. }
  133034. declare module BABYLON {
  133035. /**
  133036. * Block used to compute fresnel value
  133037. */
  133038. export class FresnelBlock extends NodeMaterialBlock {
  133039. /**
  133040. * Create a new FresnelBlock
  133041. * @param name defines the block name
  133042. */
  133043. constructor(name: string);
  133044. /**
  133045. * Gets the current class name
  133046. * @returns the class name
  133047. */
  133048. getClassName(): string;
  133049. /**
  133050. * Gets the world normal input component
  133051. */
  133052. get worldNormal(): NodeMaterialConnectionPoint;
  133053. /**
  133054. * Gets the view direction input component
  133055. */
  133056. get viewDirection(): NodeMaterialConnectionPoint;
  133057. /**
  133058. * Gets the bias input component
  133059. */
  133060. get bias(): NodeMaterialConnectionPoint;
  133061. /**
  133062. * Gets the camera (or eye) position component
  133063. */
  133064. get power(): NodeMaterialConnectionPoint;
  133065. /**
  133066. * Gets the fresnel output component
  133067. */
  133068. get fresnel(): NodeMaterialConnectionPoint;
  133069. autoConfigure(material: NodeMaterial): void;
  133070. protected _buildBlock(state: NodeMaterialBuildState): this;
  133071. }
  133072. }
  133073. declare module BABYLON {
  133074. /**
  133075. * Block used to get the max of 2 values
  133076. */
  133077. export class MaxBlock extends NodeMaterialBlock {
  133078. /**
  133079. * Creates a new MaxBlock
  133080. * @param name defines the block name
  133081. */
  133082. constructor(name: string);
  133083. /**
  133084. * Gets the current class name
  133085. * @returns the class name
  133086. */
  133087. getClassName(): string;
  133088. /**
  133089. * Gets the left operand input component
  133090. */
  133091. get left(): NodeMaterialConnectionPoint;
  133092. /**
  133093. * Gets the right operand input component
  133094. */
  133095. get right(): NodeMaterialConnectionPoint;
  133096. /**
  133097. * Gets the output component
  133098. */
  133099. get output(): NodeMaterialConnectionPoint;
  133100. protected _buildBlock(state: NodeMaterialBuildState): this;
  133101. }
  133102. }
  133103. declare module BABYLON {
  133104. /**
  133105. * Block used to get the min of 2 values
  133106. */
  133107. export class MinBlock extends NodeMaterialBlock {
  133108. /**
  133109. * Creates a new MinBlock
  133110. * @param name defines the block name
  133111. */
  133112. constructor(name: string);
  133113. /**
  133114. * Gets the current class name
  133115. * @returns the class name
  133116. */
  133117. getClassName(): string;
  133118. /**
  133119. * Gets the left operand input component
  133120. */
  133121. get left(): NodeMaterialConnectionPoint;
  133122. /**
  133123. * Gets the right operand input component
  133124. */
  133125. get right(): NodeMaterialConnectionPoint;
  133126. /**
  133127. * Gets the output component
  133128. */
  133129. get output(): NodeMaterialConnectionPoint;
  133130. protected _buildBlock(state: NodeMaterialBuildState): this;
  133131. }
  133132. }
  133133. declare module BABYLON {
  133134. /**
  133135. * Block used to get the distance between 2 values
  133136. */
  133137. export class DistanceBlock extends NodeMaterialBlock {
  133138. /**
  133139. * Creates a new DistanceBlock
  133140. * @param name defines the block name
  133141. */
  133142. constructor(name: string);
  133143. /**
  133144. * Gets the current class name
  133145. * @returns the class name
  133146. */
  133147. getClassName(): string;
  133148. /**
  133149. * Gets the left operand input component
  133150. */
  133151. get left(): NodeMaterialConnectionPoint;
  133152. /**
  133153. * Gets the right operand input component
  133154. */
  133155. get right(): NodeMaterialConnectionPoint;
  133156. /**
  133157. * Gets the output component
  133158. */
  133159. get output(): NodeMaterialConnectionPoint;
  133160. protected _buildBlock(state: NodeMaterialBuildState): this;
  133161. }
  133162. }
  133163. declare module BABYLON {
  133164. /**
  133165. * Block used to get the length of a vector
  133166. */
  133167. export class LengthBlock extends NodeMaterialBlock {
  133168. /**
  133169. * Creates a new LengthBlock
  133170. * @param name defines the block name
  133171. */
  133172. constructor(name: string);
  133173. /**
  133174. * Gets the current class name
  133175. * @returns the class name
  133176. */
  133177. getClassName(): string;
  133178. /**
  133179. * Gets the value input component
  133180. */
  133181. get value(): NodeMaterialConnectionPoint;
  133182. /**
  133183. * Gets the output component
  133184. */
  133185. get output(): NodeMaterialConnectionPoint;
  133186. protected _buildBlock(state: NodeMaterialBuildState): this;
  133187. }
  133188. }
  133189. declare module BABYLON {
  133190. /**
  133191. * Block used to get negative version of a value (i.e. x * -1)
  133192. */
  133193. export class NegateBlock extends NodeMaterialBlock {
  133194. /**
  133195. * Creates a new NegateBlock
  133196. * @param name defines the block name
  133197. */
  133198. constructor(name: string);
  133199. /**
  133200. * Gets the current class name
  133201. * @returns the class name
  133202. */
  133203. getClassName(): string;
  133204. /**
  133205. * Gets the value input component
  133206. */
  133207. get value(): NodeMaterialConnectionPoint;
  133208. /**
  133209. * Gets the output component
  133210. */
  133211. get output(): NodeMaterialConnectionPoint;
  133212. protected _buildBlock(state: NodeMaterialBuildState): this;
  133213. }
  133214. }
  133215. declare module BABYLON {
  133216. /**
  133217. * Block used to get the value of the first parameter raised to the power of the second
  133218. */
  133219. export class PowBlock extends NodeMaterialBlock {
  133220. /**
  133221. * Creates a new PowBlock
  133222. * @param name defines the block name
  133223. */
  133224. constructor(name: string);
  133225. /**
  133226. * Gets the current class name
  133227. * @returns the class name
  133228. */
  133229. getClassName(): string;
  133230. /**
  133231. * Gets the value operand input component
  133232. */
  133233. get value(): NodeMaterialConnectionPoint;
  133234. /**
  133235. * Gets the power operand input component
  133236. */
  133237. get power(): NodeMaterialConnectionPoint;
  133238. /**
  133239. * Gets the output component
  133240. */
  133241. get output(): NodeMaterialConnectionPoint;
  133242. protected _buildBlock(state: NodeMaterialBuildState): this;
  133243. }
  133244. }
  133245. declare module BABYLON {
  133246. /**
  133247. * Block used to get a random number
  133248. */
  133249. export class RandomNumberBlock extends NodeMaterialBlock {
  133250. /**
  133251. * Creates a new RandomNumberBlock
  133252. * @param name defines the block name
  133253. */
  133254. constructor(name: string);
  133255. /**
  133256. * Gets the current class name
  133257. * @returns the class name
  133258. */
  133259. getClassName(): string;
  133260. /**
  133261. * Gets the seed input component
  133262. */
  133263. get seed(): NodeMaterialConnectionPoint;
  133264. /**
  133265. * Gets the output component
  133266. */
  133267. get output(): NodeMaterialConnectionPoint;
  133268. protected _buildBlock(state: NodeMaterialBuildState): this;
  133269. }
  133270. }
  133271. declare module BABYLON {
  133272. /**
  133273. * Block used to compute arc tangent of 2 values
  133274. */
  133275. export class ArcTan2Block extends NodeMaterialBlock {
  133276. /**
  133277. * Creates a new ArcTan2Block
  133278. * @param name defines the block name
  133279. */
  133280. constructor(name: string);
  133281. /**
  133282. * Gets the current class name
  133283. * @returns the class name
  133284. */
  133285. getClassName(): string;
  133286. /**
  133287. * Gets the x operand input component
  133288. */
  133289. get x(): NodeMaterialConnectionPoint;
  133290. /**
  133291. * Gets the y operand input component
  133292. */
  133293. get y(): NodeMaterialConnectionPoint;
  133294. /**
  133295. * Gets the output component
  133296. */
  133297. get output(): NodeMaterialConnectionPoint;
  133298. protected _buildBlock(state: NodeMaterialBuildState): this;
  133299. }
  133300. }
  133301. declare module BABYLON {
  133302. /**
  133303. * Block used to smooth step a value
  133304. */
  133305. export class SmoothStepBlock extends NodeMaterialBlock {
  133306. /**
  133307. * Creates a new SmoothStepBlock
  133308. * @param name defines the block name
  133309. */
  133310. constructor(name: string);
  133311. /**
  133312. * Gets the current class name
  133313. * @returns the class name
  133314. */
  133315. getClassName(): string;
  133316. /**
  133317. * Gets the value operand input component
  133318. */
  133319. get value(): NodeMaterialConnectionPoint;
  133320. /**
  133321. * Gets the first edge operand input component
  133322. */
  133323. get edge0(): NodeMaterialConnectionPoint;
  133324. /**
  133325. * Gets the second edge operand input component
  133326. */
  133327. get edge1(): NodeMaterialConnectionPoint;
  133328. /**
  133329. * Gets the output component
  133330. */
  133331. get output(): NodeMaterialConnectionPoint;
  133332. protected _buildBlock(state: NodeMaterialBuildState): this;
  133333. }
  133334. }
  133335. declare module BABYLON {
  133336. /**
  133337. * Block used to get the reciprocal (1 / x) of a value
  133338. */
  133339. export class ReciprocalBlock extends NodeMaterialBlock {
  133340. /**
  133341. * Creates a new ReciprocalBlock
  133342. * @param name defines the block name
  133343. */
  133344. constructor(name: string);
  133345. /**
  133346. * Gets the current class name
  133347. * @returns the class name
  133348. */
  133349. getClassName(): string;
  133350. /**
  133351. * Gets the input component
  133352. */
  133353. get input(): NodeMaterialConnectionPoint;
  133354. /**
  133355. * Gets the output component
  133356. */
  133357. get output(): NodeMaterialConnectionPoint;
  133358. protected _buildBlock(state: NodeMaterialBuildState): this;
  133359. }
  133360. }
  133361. declare module BABYLON {
  133362. /**
  133363. * Block used to replace a color by another one
  133364. */
  133365. export class ReplaceColorBlock extends NodeMaterialBlock {
  133366. /**
  133367. * Creates a new ReplaceColorBlock
  133368. * @param name defines the block name
  133369. */
  133370. constructor(name: string);
  133371. /**
  133372. * Gets the current class name
  133373. * @returns the class name
  133374. */
  133375. getClassName(): string;
  133376. /**
  133377. * Gets the value input component
  133378. */
  133379. get value(): NodeMaterialConnectionPoint;
  133380. /**
  133381. * Gets the reference input component
  133382. */
  133383. get reference(): NodeMaterialConnectionPoint;
  133384. /**
  133385. * Gets the distance input component
  133386. */
  133387. get distance(): NodeMaterialConnectionPoint;
  133388. /**
  133389. * Gets the replacement input component
  133390. */
  133391. get replacement(): NodeMaterialConnectionPoint;
  133392. /**
  133393. * Gets the output component
  133394. */
  133395. get output(): NodeMaterialConnectionPoint;
  133396. protected _buildBlock(state: NodeMaterialBuildState): this;
  133397. }
  133398. }
  133399. declare module BABYLON {
  133400. /**
  133401. * Block used to posterize a value
  133402. * @see https://en.wikipedia.org/wiki/Posterization
  133403. */
  133404. export class PosterizeBlock extends NodeMaterialBlock {
  133405. /**
  133406. * Creates a new PosterizeBlock
  133407. * @param name defines the block name
  133408. */
  133409. constructor(name: string);
  133410. /**
  133411. * Gets the current class name
  133412. * @returns the class name
  133413. */
  133414. getClassName(): string;
  133415. /**
  133416. * Gets the value input component
  133417. */
  133418. get value(): NodeMaterialConnectionPoint;
  133419. /**
  133420. * Gets the steps input component
  133421. */
  133422. get steps(): NodeMaterialConnectionPoint;
  133423. /**
  133424. * Gets the output component
  133425. */
  133426. get output(): NodeMaterialConnectionPoint;
  133427. protected _buildBlock(state: NodeMaterialBuildState): this;
  133428. }
  133429. }
  133430. declare module BABYLON {
  133431. /**
  133432. * Operations supported by the Wave block
  133433. */
  133434. export enum WaveBlockKind {
  133435. /** SawTooth */
  133436. SawTooth = 0,
  133437. /** Square */
  133438. Square = 1,
  133439. /** Triangle */
  133440. Triangle = 2
  133441. }
  133442. /**
  133443. * Block used to apply wave operation to floats
  133444. */
  133445. export class WaveBlock extends NodeMaterialBlock {
  133446. /**
  133447. * Gets or sets the kibnd of wave to be applied by the block
  133448. */
  133449. kind: WaveBlockKind;
  133450. /**
  133451. * Creates a new WaveBlock
  133452. * @param name defines the block name
  133453. */
  133454. constructor(name: string);
  133455. /**
  133456. * Gets the current class name
  133457. * @returns the class name
  133458. */
  133459. getClassName(): string;
  133460. /**
  133461. * Gets the input component
  133462. */
  133463. get input(): NodeMaterialConnectionPoint;
  133464. /**
  133465. * Gets the output component
  133466. */
  133467. get output(): NodeMaterialConnectionPoint;
  133468. protected _buildBlock(state: NodeMaterialBuildState): this;
  133469. serialize(): any;
  133470. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133471. }
  133472. }
  133473. declare module BABYLON {
  133474. /**
  133475. * Class used to store a color step for the GradientBlock
  133476. */
  133477. export class GradientBlockColorStep {
  133478. /**
  133479. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  133480. */
  133481. step: number;
  133482. /**
  133483. * Gets or sets the color associated with this step
  133484. */
  133485. color: Color3;
  133486. /**
  133487. * Creates a new GradientBlockColorStep
  133488. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  133489. * @param color defines the color associated with this step
  133490. */
  133491. constructor(
  133492. /**
  133493. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  133494. */
  133495. step: number,
  133496. /**
  133497. * Gets or sets the color associated with this step
  133498. */
  133499. color: Color3);
  133500. }
  133501. /**
  133502. * Block used to return a color from a gradient based on an input value between 0 and 1
  133503. */
  133504. export class GradientBlock extends NodeMaterialBlock {
  133505. /**
  133506. * Gets or sets the list of color steps
  133507. */
  133508. colorSteps: GradientBlockColorStep[];
  133509. /**
  133510. * Creates a new GradientBlock
  133511. * @param name defines the block name
  133512. */
  133513. constructor(name: string);
  133514. /**
  133515. * Gets the current class name
  133516. * @returns the class name
  133517. */
  133518. getClassName(): string;
  133519. /**
  133520. * Gets the gradient input component
  133521. */
  133522. get gradient(): NodeMaterialConnectionPoint;
  133523. /**
  133524. * Gets the output component
  133525. */
  133526. get output(): NodeMaterialConnectionPoint;
  133527. private _writeColorConstant;
  133528. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133529. serialize(): any;
  133530. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133531. protected _dumpPropertiesCode(): string;
  133532. }
  133533. }
  133534. declare module BABYLON {
  133535. /**
  133536. * Block used to normalize lerp between 2 values
  133537. */
  133538. export class NLerpBlock extends NodeMaterialBlock {
  133539. /**
  133540. * Creates a new NLerpBlock
  133541. * @param name defines the block name
  133542. */
  133543. constructor(name: string);
  133544. /**
  133545. * Gets the current class name
  133546. * @returns the class name
  133547. */
  133548. getClassName(): string;
  133549. /**
  133550. * Gets the left operand input component
  133551. */
  133552. get left(): NodeMaterialConnectionPoint;
  133553. /**
  133554. * Gets the right operand input component
  133555. */
  133556. get right(): NodeMaterialConnectionPoint;
  133557. /**
  133558. * Gets the gradient operand input component
  133559. */
  133560. get gradient(): NodeMaterialConnectionPoint;
  133561. /**
  133562. * Gets the output component
  133563. */
  133564. get output(): NodeMaterialConnectionPoint;
  133565. protected _buildBlock(state: NodeMaterialBuildState): this;
  133566. }
  133567. }
  133568. declare module BABYLON {
  133569. /**
  133570. * block used to Generate a Worley Noise 3D Noise Pattern
  133571. */
  133572. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  133573. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  133574. manhattanDistance: boolean;
  133575. /**
  133576. * Creates a new WorleyNoise3DBlock
  133577. * @param name defines the block name
  133578. */
  133579. constructor(name: string);
  133580. /**
  133581. * Gets the current class name
  133582. * @returns the class name
  133583. */
  133584. getClassName(): string;
  133585. /**
  133586. * Gets the seed input component
  133587. */
  133588. get seed(): NodeMaterialConnectionPoint;
  133589. /**
  133590. * Gets the jitter input component
  133591. */
  133592. get jitter(): NodeMaterialConnectionPoint;
  133593. /**
  133594. * Gets the output component
  133595. */
  133596. get output(): NodeMaterialConnectionPoint;
  133597. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133598. /**
  133599. * Exposes the properties to the UI?
  133600. */
  133601. protected _dumpPropertiesCode(): string;
  133602. /**
  133603. * Exposes the properties to the Seralize?
  133604. */
  133605. serialize(): any;
  133606. /**
  133607. * Exposes the properties to the deseralize?
  133608. */
  133609. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133610. }
  133611. }
  133612. declare module BABYLON {
  133613. /**
  133614. * block used to Generate a Simplex Perlin 3d Noise Pattern
  133615. */
  133616. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  133617. /**
  133618. * Creates a new SimplexPerlin3DBlock
  133619. * @param name defines the block name
  133620. */
  133621. constructor(name: string);
  133622. /**
  133623. * Gets the current class name
  133624. * @returns the class name
  133625. */
  133626. getClassName(): string;
  133627. /**
  133628. * Gets the seed operand input component
  133629. */
  133630. get seed(): NodeMaterialConnectionPoint;
  133631. /**
  133632. * Gets the output component
  133633. */
  133634. get output(): NodeMaterialConnectionPoint;
  133635. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133636. }
  133637. }
  133638. declare module BABYLON {
  133639. /**
  133640. * Block used to blend normals
  133641. */
  133642. export class NormalBlendBlock extends NodeMaterialBlock {
  133643. /**
  133644. * Creates a new NormalBlendBlock
  133645. * @param name defines the block name
  133646. */
  133647. constructor(name: string);
  133648. /**
  133649. * Gets the current class name
  133650. * @returns the class name
  133651. */
  133652. getClassName(): string;
  133653. /**
  133654. * Gets the first input component
  133655. */
  133656. get normalMap0(): NodeMaterialConnectionPoint;
  133657. /**
  133658. * Gets the second input component
  133659. */
  133660. get normalMap1(): NodeMaterialConnectionPoint;
  133661. /**
  133662. * Gets the output component
  133663. */
  133664. get output(): NodeMaterialConnectionPoint;
  133665. protected _buildBlock(state: NodeMaterialBuildState): this;
  133666. }
  133667. }
  133668. declare module BABYLON {
  133669. /**
  133670. * Block used to rotate a 2d vector by a given angle
  133671. */
  133672. export class Rotate2dBlock extends NodeMaterialBlock {
  133673. /**
  133674. * Creates a new Rotate2dBlock
  133675. * @param name defines the block name
  133676. */
  133677. constructor(name: string);
  133678. /**
  133679. * Gets the current class name
  133680. * @returns the class name
  133681. */
  133682. getClassName(): string;
  133683. /**
  133684. * Gets the input vector
  133685. */
  133686. get input(): NodeMaterialConnectionPoint;
  133687. /**
  133688. * Gets the input angle
  133689. */
  133690. get angle(): NodeMaterialConnectionPoint;
  133691. /**
  133692. * Gets the output component
  133693. */
  133694. get output(): NodeMaterialConnectionPoint;
  133695. autoConfigure(material: NodeMaterial): void;
  133696. protected _buildBlock(state: NodeMaterialBuildState): this;
  133697. }
  133698. }
  133699. declare module BABYLON {
  133700. /**
  133701. * Block used to get the reflected vector from a direction and a normal
  133702. */
  133703. export class ReflectBlock extends NodeMaterialBlock {
  133704. /**
  133705. * Creates a new ReflectBlock
  133706. * @param name defines the block name
  133707. */
  133708. constructor(name: string);
  133709. /**
  133710. * Gets the current class name
  133711. * @returns the class name
  133712. */
  133713. getClassName(): string;
  133714. /**
  133715. * Gets the incident component
  133716. */
  133717. get incident(): NodeMaterialConnectionPoint;
  133718. /**
  133719. * Gets the normal component
  133720. */
  133721. get normal(): NodeMaterialConnectionPoint;
  133722. /**
  133723. * Gets the output component
  133724. */
  133725. get output(): NodeMaterialConnectionPoint;
  133726. protected _buildBlock(state: NodeMaterialBuildState): this;
  133727. }
  133728. }
  133729. declare module BABYLON {
  133730. /**
  133731. * Block used to get the refracted vector from a direction and a normal
  133732. */
  133733. export class RefractBlock extends NodeMaterialBlock {
  133734. /**
  133735. * Creates a new RefractBlock
  133736. * @param name defines the block name
  133737. */
  133738. constructor(name: string);
  133739. /**
  133740. * Gets the current class name
  133741. * @returns the class name
  133742. */
  133743. getClassName(): string;
  133744. /**
  133745. * Gets the incident component
  133746. */
  133747. get incident(): NodeMaterialConnectionPoint;
  133748. /**
  133749. * Gets the normal component
  133750. */
  133751. get normal(): NodeMaterialConnectionPoint;
  133752. /**
  133753. * Gets the index of refraction component
  133754. */
  133755. get ior(): NodeMaterialConnectionPoint;
  133756. /**
  133757. * Gets the output component
  133758. */
  133759. get output(): NodeMaterialConnectionPoint;
  133760. protected _buildBlock(state: NodeMaterialBuildState): this;
  133761. }
  133762. }
  133763. declare module BABYLON {
  133764. /**
  133765. * Block used to desaturate a color
  133766. */
  133767. export class DesaturateBlock extends NodeMaterialBlock {
  133768. /**
  133769. * Creates a new DesaturateBlock
  133770. * @param name defines the block name
  133771. */
  133772. constructor(name: string);
  133773. /**
  133774. * Gets the current class name
  133775. * @returns the class name
  133776. */
  133777. getClassName(): string;
  133778. /**
  133779. * Gets the color operand input component
  133780. */
  133781. get color(): NodeMaterialConnectionPoint;
  133782. /**
  133783. * Gets the level operand input component
  133784. */
  133785. get level(): NodeMaterialConnectionPoint;
  133786. /**
  133787. * Gets the output component
  133788. */
  133789. get output(): NodeMaterialConnectionPoint;
  133790. protected _buildBlock(state: NodeMaterialBuildState): this;
  133791. }
  133792. }
  133793. declare module BABYLON {
  133794. /**
  133795. * Effect Render Options
  133796. */
  133797. export interface IEffectRendererOptions {
  133798. /**
  133799. * Defines the vertices positions.
  133800. */
  133801. positions?: number[];
  133802. /**
  133803. * Defines the indices.
  133804. */
  133805. indices?: number[];
  133806. }
  133807. /**
  133808. * Helper class to render one or more effects
  133809. */
  133810. export class EffectRenderer {
  133811. private engine;
  133812. private static _DefaultOptions;
  133813. private _vertexBuffers;
  133814. private _indexBuffer;
  133815. private _ringBufferIndex;
  133816. private _ringScreenBuffer;
  133817. private _fullscreenViewport;
  133818. private _getNextFrameBuffer;
  133819. /**
  133820. * Creates an effect renderer
  133821. * @param engine the engine to use for rendering
  133822. * @param options defines the options of the effect renderer
  133823. */
  133824. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  133825. /**
  133826. * Sets the current viewport in normalized coordinates 0-1
  133827. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  133828. */
  133829. setViewport(viewport?: Viewport): void;
  133830. /**
  133831. * Binds the embedded attributes buffer to the effect.
  133832. * @param effect Defines the effect to bind the attributes for
  133833. */
  133834. bindBuffers(effect: Effect): void;
  133835. /**
  133836. * Sets the current effect wrapper to use during draw.
  133837. * The effect needs to be ready before calling this api.
  133838. * This also sets the default full screen position attribute.
  133839. * @param effectWrapper Defines the effect to draw with
  133840. */
  133841. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  133842. /**
  133843. * Draws a full screen quad.
  133844. */
  133845. draw(): void;
  133846. /**
  133847. * renders one or more effects to a specified texture
  133848. * @param effectWrappers list of effects to renderer
  133849. * @param outputTexture texture to draw to, if null it will render to the screen
  133850. */
  133851. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  133852. /**
  133853. * Disposes of the effect renderer
  133854. */
  133855. dispose(): void;
  133856. }
  133857. /**
  133858. * Options to create an EffectWrapper
  133859. */
  133860. interface EffectWrapperCreationOptions {
  133861. /**
  133862. * Engine to use to create the effect
  133863. */
  133864. engine: ThinEngine;
  133865. /**
  133866. * Fragment shader for the effect
  133867. */
  133868. fragmentShader: string;
  133869. /**
  133870. * Vertex shader for the effect
  133871. */
  133872. vertexShader?: string;
  133873. /**
  133874. * Attributes to use in the shader
  133875. */
  133876. attributeNames?: Array<string>;
  133877. /**
  133878. * Uniforms to use in the shader
  133879. */
  133880. uniformNames?: Array<string>;
  133881. /**
  133882. * Texture sampler names to use in the shader
  133883. */
  133884. samplerNames?: Array<string>;
  133885. /**
  133886. * The friendly name of the effect displayed in Spector.
  133887. */
  133888. name?: string;
  133889. }
  133890. /**
  133891. * Wraps an effect to be used for rendering
  133892. */
  133893. export class EffectWrapper {
  133894. /**
  133895. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  133896. */
  133897. onApplyObservable: Observable<{}>;
  133898. /**
  133899. * The underlying effect
  133900. */
  133901. effect: Effect;
  133902. /**
  133903. * Creates an effect to be renderer
  133904. * @param creationOptions options to create the effect
  133905. */
  133906. constructor(creationOptions: EffectWrapperCreationOptions);
  133907. /**
  133908. * Disposes of the effect wrapper
  133909. */
  133910. dispose(): void;
  133911. }
  133912. }
  133913. declare module BABYLON {
  133914. /**
  133915. * Helper class to push actions to a pool of workers.
  133916. */
  133917. export class WorkerPool implements IDisposable {
  133918. private _workerInfos;
  133919. private _pendingActions;
  133920. /**
  133921. * Constructor
  133922. * @param workers Array of workers to use for actions
  133923. */
  133924. constructor(workers: Array<Worker>);
  133925. /**
  133926. * Terminates all workers and clears any pending actions.
  133927. */
  133928. dispose(): void;
  133929. /**
  133930. * Pushes an action to the worker pool. If all the workers are active, the action will be
  133931. * pended until a worker has completed its action.
  133932. * @param action The action to perform. Call onComplete when the action is complete.
  133933. */
  133934. push(action: (worker: Worker, onComplete: () => void) => void): void;
  133935. private _execute;
  133936. }
  133937. }
  133938. declare module BABYLON {
  133939. /**
  133940. * Configuration for Draco compression
  133941. */
  133942. export interface IDracoCompressionConfiguration {
  133943. /**
  133944. * Configuration for the decoder.
  133945. */
  133946. decoder: {
  133947. /**
  133948. * The url to the WebAssembly module.
  133949. */
  133950. wasmUrl?: string;
  133951. /**
  133952. * The url to the WebAssembly binary.
  133953. */
  133954. wasmBinaryUrl?: string;
  133955. /**
  133956. * The url to the fallback JavaScript module.
  133957. */
  133958. fallbackUrl?: string;
  133959. };
  133960. }
  133961. /**
  133962. * Draco compression (https://google.github.io/draco/)
  133963. *
  133964. * This class wraps the Draco module.
  133965. *
  133966. * **Encoder**
  133967. *
  133968. * The encoder is not currently implemented.
  133969. *
  133970. * **Decoder**
  133971. *
  133972. * 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.
  133973. *
  133974. * To update the configuration, use the following code:
  133975. * ```javascript
  133976. * DracoCompression.Configuration = {
  133977. * decoder: {
  133978. * wasmUrl: "<url to the WebAssembly library>",
  133979. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  133980. * fallbackUrl: "<url to the fallback JavaScript library>",
  133981. * }
  133982. * };
  133983. * ```
  133984. *
  133985. * 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.
  133986. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  133987. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  133988. *
  133989. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  133990. * ```javascript
  133991. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  133992. * ```
  133993. *
  133994. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  133995. */
  133996. export class DracoCompression implements IDisposable {
  133997. private _workerPoolPromise?;
  133998. private _decoderModulePromise?;
  133999. /**
  134000. * The configuration. Defaults to the following urls:
  134001. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  134002. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  134003. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  134004. */
  134005. static Configuration: IDracoCompressionConfiguration;
  134006. /**
  134007. * Returns true if the decoder configuration is available.
  134008. */
  134009. static get DecoderAvailable(): boolean;
  134010. /**
  134011. * Default number of workers to create when creating the draco compression object.
  134012. */
  134013. static DefaultNumWorkers: number;
  134014. private static GetDefaultNumWorkers;
  134015. private static _Default;
  134016. /**
  134017. * Default instance for the draco compression object.
  134018. */
  134019. static get Default(): DracoCompression;
  134020. /**
  134021. * Constructor
  134022. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  134023. */
  134024. constructor(numWorkers?: number);
  134025. /**
  134026. * Stop all async operations and release resources.
  134027. */
  134028. dispose(): void;
  134029. /**
  134030. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  134031. * @returns a promise that resolves when ready
  134032. */
  134033. whenReadyAsync(): Promise<void>;
  134034. /**
  134035. * Decode Draco compressed mesh data to vertex data.
  134036. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  134037. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  134038. * @returns A promise that resolves with the decoded vertex data
  134039. */
  134040. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  134041. [kind: string]: number;
  134042. }): Promise<VertexData>;
  134043. }
  134044. }
  134045. declare module BABYLON {
  134046. /**
  134047. * Class for building Constructive Solid Geometry
  134048. */
  134049. export class CSG {
  134050. private polygons;
  134051. /**
  134052. * The world matrix
  134053. */
  134054. matrix: Matrix;
  134055. /**
  134056. * Stores the position
  134057. */
  134058. position: Vector3;
  134059. /**
  134060. * Stores the rotation
  134061. */
  134062. rotation: Vector3;
  134063. /**
  134064. * Stores the rotation quaternion
  134065. */
  134066. rotationQuaternion: Nullable<Quaternion>;
  134067. /**
  134068. * Stores the scaling vector
  134069. */
  134070. scaling: Vector3;
  134071. /**
  134072. * Convert the Mesh to CSG
  134073. * @param mesh The Mesh to convert to CSG
  134074. * @returns A new CSG from the Mesh
  134075. */
  134076. static FromMesh(mesh: Mesh): CSG;
  134077. /**
  134078. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  134079. * @param polygons Polygons used to construct a CSG solid
  134080. */
  134081. private static FromPolygons;
  134082. /**
  134083. * Clones, or makes a deep copy, of the CSG
  134084. * @returns A new CSG
  134085. */
  134086. clone(): CSG;
  134087. /**
  134088. * Unions this CSG with another CSG
  134089. * @param csg The CSG to union against this CSG
  134090. * @returns The unioned CSG
  134091. */
  134092. union(csg: CSG): CSG;
  134093. /**
  134094. * Unions this CSG with another CSG in place
  134095. * @param csg The CSG to union against this CSG
  134096. */
  134097. unionInPlace(csg: CSG): void;
  134098. /**
  134099. * Subtracts this CSG with another CSG
  134100. * @param csg The CSG to subtract against this CSG
  134101. * @returns A new CSG
  134102. */
  134103. subtract(csg: CSG): CSG;
  134104. /**
  134105. * Subtracts this CSG with another CSG in place
  134106. * @param csg The CSG to subtact against this CSG
  134107. */
  134108. subtractInPlace(csg: CSG): void;
  134109. /**
  134110. * Intersect this CSG with another CSG
  134111. * @param csg The CSG to intersect against this CSG
  134112. * @returns A new CSG
  134113. */
  134114. intersect(csg: CSG): CSG;
  134115. /**
  134116. * Intersects this CSG with another CSG in place
  134117. * @param csg The CSG to intersect against this CSG
  134118. */
  134119. intersectInPlace(csg: CSG): void;
  134120. /**
  134121. * Return a new CSG solid with solid and empty space switched. This solid is
  134122. * not modified.
  134123. * @returns A new CSG solid with solid and empty space switched
  134124. */
  134125. inverse(): CSG;
  134126. /**
  134127. * Inverses the CSG in place
  134128. */
  134129. inverseInPlace(): void;
  134130. /**
  134131. * This is used to keep meshes transformations so they can be restored
  134132. * when we build back a Babylon Mesh
  134133. * NB : All CSG operations are performed in world coordinates
  134134. * @param csg The CSG to copy the transform attributes from
  134135. * @returns This CSG
  134136. */
  134137. copyTransformAttributes(csg: CSG): CSG;
  134138. /**
  134139. * Build Raw mesh from CSG
  134140. * Coordinates here are in world space
  134141. * @param name The name of the mesh geometry
  134142. * @param scene The Scene
  134143. * @param keepSubMeshes Specifies if the submeshes should be kept
  134144. * @returns A new Mesh
  134145. */
  134146. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  134147. /**
  134148. * Build Mesh from CSG taking material and transforms into account
  134149. * @param name The name of the Mesh
  134150. * @param material The material of the Mesh
  134151. * @param scene The Scene
  134152. * @param keepSubMeshes Specifies if submeshes should be kept
  134153. * @returns The new Mesh
  134154. */
  134155. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  134156. }
  134157. }
  134158. declare module BABYLON {
  134159. /**
  134160. * Class used to create a trail following a mesh
  134161. */
  134162. export class TrailMesh extends Mesh {
  134163. private _generator;
  134164. private _autoStart;
  134165. private _running;
  134166. private _diameter;
  134167. private _length;
  134168. private _sectionPolygonPointsCount;
  134169. private _sectionVectors;
  134170. private _sectionNormalVectors;
  134171. private _beforeRenderObserver;
  134172. /**
  134173. * @constructor
  134174. * @param name The value used by scene.getMeshByName() to do a lookup.
  134175. * @param generator The mesh or transform node to generate a trail.
  134176. * @param scene The scene to add this mesh to.
  134177. * @param diameter Diameter of trailing mesh. Default is 1.
  134178. * @param length Length of trailing mesh. Default is 60.
  134179. * @param autoStart Automatically start trailing mesh. Default true.
  134180. */
  134181. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  134182. /**
  134183. * "TrailMesh"
  134184. * @returns "TrailMesh"
  134185. */
  134186. getClassName(): string;
  134187. private _createMesh;
  134188. /**
  134189. * Start trailing mesh.
  134190. */
  134191. start(): void;
  134192. /**
  134193. * Stop trailing mesh.
  134194. */
  134195. stop(): void;
  134196. /**
  134197. * Update trailing mesh geometry.
  134198. */
  134199. update(): void;
  134200. /**
  134201. * Returns a new TrailMesh object.
  134202. * @param name is a string, the name given to the new mesh
  134203. * @param newGenerator use new generator object for cloned trail mesh
  134204. * @returns a new mesh
  134205. */
  134206. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  134207. /**
  134208. * Serializes this trail mesh
  134209. * @param serializationObject object to write serialization to
  134210. */
  134211. serialize(serializationObject: any): void;
  134212. /**
  134213. * Parses a serialized trail mesh
  134214. * @param parsedMesh the serialized mesh
  134215. * @param scene the scene to create the trail mesh in
  134216. * @returns the created trail mesh
  134217. */
  134218. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  134219. }
  134220. }
  134221. declare module BABYLON {
  134222. /**
  134223. * Class containing static functions to help procedurally build meshes
  134224. */
  134225. export class TiledBoxBuilder {
  134226. /**
  134227. * Creates a box mesh
  134228. * 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)
  134229. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134230. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134231. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134233. * @param name defines the name of the mesh
  134234. * @param options defines the options used to create the mesh
  134235. * @param scene defines the hosting scene
  134236. * @returns the box mesh
  134237. */
  134238. static CreateTiledBox(name: string, options: {
  134239. pattern?: number;
  134240. width?: number;
  134241. height?: number;
  134242. depth?: number;
  134243. tileSize?: number;
  134244. tileWidth?: number;
  134245. tileHeight?: number;
  134246. alignHorizontal?: number;
  134247. alignVertical?: number;
  134248. faceUV?: Vector4[];
  134249. faceColors?: Color4[];
  134250. sideOrientation?: number;
  134251. updatable?: boolean;
  134252. }, scene?: Nullable<Scene>): Mesh;
  134253. }
  134254. }
  134255. declare module BABYLON {
  134256. /**
  134257. * Class containing static functions to help procedurally build meshes
  134258. */
  134259. export class TorusKnotBuilder {
  134260. /**
  134261. * Creates a torus knot mesh
  134262. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  134263. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  134264. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  134265. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  134266. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134267. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134269. * @param name defines the name of the mesh
  134270. * @param options defines the options used to create the mesh
  134271. * @param scene defines the hosting scene
  134272. * @returns the torus knot mesh
  134273. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  134274. */
  134275. static CreateTorusKnot(name: string, options: {
  134276. radius?: number;
  134277. tube?: number;
  134278. radialSegments?: number;
  134279. tubularSegments?: number;
  134280. p?: number;
  134281. q?: number;
  134282. updatable?: boolean;
  134283. sideOrientation?: number;
  134284. frontUVs?: Vector4;
  134285. backUVs?: Vector4;
  134286. }, scene: any): Mesh;
  134287. }
  134288. }
  134289. declare module BABYLON {
  134290. /**
  134291. * Polygon
  134292. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  134293. */
  134294. export class Polygon {
  134295. /**
  134296. * Creates a rectangle
  134297. * @param xmin bottom X coord
  134298. * @param ymin bottom Y coord
  134299. * @param xmax top X coord
  134300. * @param ymax top Y coord
  134301. * @returns points that make the resulting rectation
  134302. */
  134303. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  134304. /**
  134305. * Creates a circle
  134306. * @param radius radius of circle
  134307. * @param cx scale in x
  134308. * @param cy scale in y
  134309. * @param numberOfSides number of sides that make up the circle
  134310. * @returns points that make the resulting circle
  134311. */
  134312. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  134313. /**
  134314. * Creates a polygon from input string
  134315. * @param input Input polygon data
  134316. * @returns the parsed points
  134317. */
  134318. static Parse(input: string): Vector2[];
  134319. /**
  134320. * Starts building a polygon from x and y coordinates
  134321. * @param x x coordinate
  134322. * @param y y coordinate
  134323. * @returns the started path2
  134324. */
  134325. static StartingAt(x: number, y: number): Path2;
  134326. }
  134327. /**
  134328. * Builds a polygon
  134329. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  134330. */
  134331. export class PolygonMeshBuilder {
  134332. private _points;
  134333. private _outlinepoints;
  134334. private _holes;
  134335. private _name;
  134336. private _scene;
  134337. private _epoints;
  134338. private _eholes;
  134339. private _addToepoint;
  134340. /**
  134341. * Babylon reference to the earcut plugin.
  134342. */
  134343. bjsEarcut: any;
  134344. /**
  134345. * Creates a PolygonMeshBuilder
  134346. * @param name name of the builder
  134347. * @param contours Path of the polygon
  134348. * @param scene scene to add to when creating the mesh
  134349. * @param earcutInjection can be used to inject your own earcut reference
  134350. */
  134351. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  134352. /**
  134353. * Adds a whole within the polygon
  134354. * @param hole Array of points defining the hole
  134355. * @returns this
  134356. */
  134357. addHole(hole: Vector2[]): PolygonMeshBuilder;
  134358. /**
  134359. * Creates the polygon
  134360. * @param updatable If the mesh should be updatable
  134361. * @param depth The depth of the mesh created
  134362. * @returns the created mesh
  134363. */
  134364. build(updatable?: boolean, depth?: number): Mesh;
  134365. /**
  134366. * Creates the polygon
  134367. * @param depth The depth of the mesh created
  134368. * @returns the created VertexData
  134369. */
  134370. buildVertexData(depth?: number): VertexData;
  134371. /**
  134372. * Adds a side to the polygon
  134373. * @param positions points that make the polygon
  134374. * @param normals normals of the polygon
  134375. * @param uvs uvs of the polygon
  134376. * @param indices indices of the polygon
  134377. * @param bounds bounds of the polygon
  134378. * @param points points of the polygon
  134379. * @param depth depth of the polygon
  134380. * @param flip flip of the polygon
  134381. */
  134382. private addSide;
  134383. }
  134384. }
  134385. declare module BABYLON {
  134386. /**
  134387. * Class containing static functions to help procedurally build meshes
  134388. */
  134389. export class PolygonBuilder {
  134390. /**
  134391. * Creates a polygon mesh
  134392. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  134393. * * 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
  134394. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134396. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  134397. * * Remember you can only change the shape positions, not their number when updating a polygon
  134398. * @param name defines the name of the mesh
  134399. * @param options defines the options used to create the mesh
  134400. * @param scene defines the hosting scene
  134401. * @param earcutInjection can be used to inject your own earcut reference
  134402. * @returns the polygon mesh
  134403. */
  134404. static CreatePolygon(name: string, options: {
  134405. shape: Vector3[];
  134406. holes?: Vector3[][];
  134407. depth?: number;
  134408. faceUV?: Vector4[];
  134409. faceColors?: Color4[];
  134410. updatable?: boolean;
  134411. sideOrientation?: number;
  134412. frontUVs?: Vector4;
  134413. backUVs?: Vector4;
  134414. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134415. /**
  134416. * Creates an extruded polygon mesh, with depth in the Y direction.
  134417. * * 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)
  134418. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134419. * @param name defines the name of the mesh
  134420. * @param options defines the options used to create the mesh
  134421. * @param scene defines the hosting scene
  134422. * @param earcutInjection can be used to inject your own earcut reference
  134423. * @returns the polygon mesh
  134424. */
  134425. static ExtrudePolygon(name: string, options: {
  134426. shape: Vector3[];
  134427. holes?: Vector3[][];
  134428. depth?: number;
  134429. faceUV?: Vector4[];
  134430. faceColors?: Color4[];
  134431. updatable?: boolean;
  134432. sideOrientation?: number;
  134433. frontUVs?: Vector4;
  134434. backUVs?: Vector4;
  134435. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134436. }
  134437. }
  134438. declare module BABYLON {
  134439. /**
  134440. * Class containing static functions to help procedurally build meshes
  134441. */
  134442. export class LatheBuilder {
  134443. /**
  134444. * Creates lathe mesh.
  134445. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  134446. * * 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
  134447. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  134448. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  134449. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  134450. * * 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
  134451. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  134452. * * 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
  134453. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134454. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134455. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134456. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134457. * @param name defines the name of the mesh
  134458. * @param options defines the options used to create the mesh
  134459. * @param scene defines the hosting scene
  134460. * @returns the lathe mesh
  134461. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  134462. */
  134463. static CreateLathe(name: string, options: {
  134464. shape: Vector3[];
  134465. radius?: number;
  134466. tessellation?: number;
  134467. clip?: number;
  134468. arc?: number;
  134469. closed?: boolean;
  134470. updatable?: boolean;
  134471. sideOrientation?: number;
  134472. frontUVs?: Vector4;
  134473. backUVs?: Vector4;
  134474. cap?: number;
  134475. invertUV?: boolean;
  134476. }, scene?: Nullable<Scene>): Mesh;
  134477. }
  134478. }
  134479. declare module BABYLON {
  134480. /**
  134481. * Class containing static functions to help procedurally build meshes
  134482. */
  134483. export class TiledPlaneBuilder {
  134484. /**
  134485. * Creates a tiled plane mesh
  134486. * * The parameter `pattern` will, depending on value, do nothing or
  134487. * * * flip (reflect about central vertical) alternate tiles across and up
  134488. * * * flip every tile on alternate rows
  134489. * * * rotate (180 degs) alternate tiles across and up
  134490. * * * rotate every tile on alternate rows
  134491. * * * flip and rotate alternate tiles across and up
  134492. * * * flip and rotate every tile on alternate rows
  134493. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  134494. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  134495. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134496. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134497. * * 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)
  134498. * * 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)
  134499. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134500. * @param name defines the name of the mesh
  134501. * @param options defines the options used to create the mesh
  134502. * @param scene defines the hosting scene
  134503. * @returns the box mesh
  134504. */
  134505. static CreateTiledPlane(name: string, options: {
  134506. pattern?: number;
  134507. tileSize?: number;
  134508. tileWidth?: number;
  134509. tileHeight?: number;
  134510. size?: number;
  134511. width?: number;
  134512. height?: number;
  134513. alignHorizontal?: number;
  134514. alignVertical?: number;
  134515. sideOrientation?: number;
  134516. frontUVs?: Vector4;
  134517. backUVs?: Vector4;
  134518. updatable?: boolean;
  134519. }, scene?: Nullable<Scene>): Mesh;
  134520. }
  134521. }
  134522. declare module BABYLON {
  134523. /**
  134524. * Class containing static functions to help procedurally build meshes
  134525. */
  134526. export class TubeBuilder {
  134527. /**
  134528. * Creates a tube mesh.
  134529. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134530. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  134531. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  134532. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  134533. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  134534. * * 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)
  134535. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  134536. * * 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
  134537. * * 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
  134538. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134539. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134540. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134542. * @param name defines the name of the mesh
  134543. * @param options defines the options used to create the mesh
  134544. * @param scene defines the hosting scene
  134545. * @returns the tube mesh
  134546. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134547. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  134548. */
  134549. static CreateTube(name: string, options: {
  134550. path: Vector3[];
  134551. radius?: number;
  134552. tessellation?: number;
  134553. radiusFunction?: {
  134554. (i: number, distance: number): number;
  134555. };
  134556. cap?: number;
  134557. arc?: number;
  134558. updatable?: boolean;
  134559. sideOrientation?: number;
  134560. frontUVs?: Vector4;
  134561. backUVs?: Vector4;
  134562. instance?: Mesh;
  134563. invertUV?: boolean;
  134564. }, scene?: Nullable<Scene>): Mesh;
  134565. }
  134566. }
  134567. declare module BABYLON {
  134568. /**
  134569. * Class containing static functions to help procedurally build meshes
  134570. */
  134571. export class IcoSphereBuilder {
  134572. /**
  134573. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  134574. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  134575. * * 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`)
  134576. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  134577. * * 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
  134578. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134579. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134580. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134581. * @param name defines the name of the mesh
  134582. * @param options defines the options used to create the mesh
  134583. * @param scene defines the hosting scene
  134584. * @returns the icosahedron mesh
  134585. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  134586. */
  134587. static CreateIcoSphere(name: string, options: {
  134588. radius?: number;
  134589. radiusX?: number;
  134590. radiusY?: number;
  134591. radiusZ?: number;
  134592. flat?: boolean;
  134593. subdivisions?: number;
  134594. sideOrientation?: number;
  134595. frontUVs?: Vector4;
  134596. backUVs?: Vector4;
  134597. updatable?: boolean;
  134598. }, scene?: Nullable<Scene>): Mesh;
  134599. }
  134600. }
  134601. declare module BABYLON {
  134602. /**
  134603. * Class containing static functions to help procedurally build meshes
  134604. */
  134605. export class DecalBuilder {
  134606. /**
  134607. * Creates a decal mesh.
  134608. * 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
  134609. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  134610. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  134611. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  134612. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  134613. * @param name defines the name of the mesh
  134614. * @param sourceMesh defines the mesh where the decal must be applied
  134615. * @param options defines the options used to create the mesh
  134616. * @param scene defines the hosting scene
  134617. * @returns the decal mesh
  134618. * @see https://doc.babylonjs.com/how_to/decals
  134619. */
  134620. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  134621. position?: Vector3;
  134622. normal?: Vector3;
  134623. size?: Vector3;
  134624. angle?: number;
  134625. }): Mesh;
  134626. }
  134627. }
  134628. declare module BABYLON {
  134629. /**
  134630. * Class containing static functions to help procedurally build meshes
  134631. */
  134632. export class MeshBuilder {
  134633. /**
  134634. * Creates a box mesh
  134635. * * The parameter `size` sets the size (float) of each box side (default 1)
  134636. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  134637. * * 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)
  134638. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134639. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134640. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134642. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134643. * @param name defines the name of the mesh
  134644. * @param options defines the options used to create the mesh
  134645. * @param scene defines the hosting scene
  134646. * @returns the box mesh
  134647. */
  134648. static CreateBox(name: string, options: {
  134649. size?: number;
  134650. width?: number;
  134651. height?: number;
  134652. depth?: number;
  134653. faceUV?: Vector4[];
  134654. faceColors?: Color4[];
  134655. sideOrientation?: number;
  134656. frontUVs?: Vector4;
  134657. backUVs?: Vector4;
  134658. updatable?: boolean;
  134659. }, scene?: Nullable<Scene>): Mesh;
  134660. /**
  134661. * Creates a tiled box mesh
  134662. * * faceTiles sets the pattern, tile size and number of tiles for a face
  134663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134664. * @param name defines the name of the mesh
  134665. * @param options defines the options used to create the mesh
  134666. * @param scene defines the hosting scene
  134667. * @returns the tiled box mesh
  134668. */
  134669. static CreateTiledBox(name: string, options: {
  134670. pattern?: number;
  134671. size?: number;
  134672. width?: number;
  134673. height?: number;
  134674. depth: number;
  134675. tileSize?: number;
  134676. tileWidth?: number;
  134677. tileHeight?: number;
  134678. faceUV?: Vector4[];
  134679. faceColors?: Color4[];
  134680. alignHorizontal?: number;
  134681. alignVertical?: number;
  134682. sideOrientation?: number;
  134683. updatable?: boolean;
  134684. }, scene?: Nullable<Scene>): Mesh;
  134685. /**
  134686. * Creates a sphere mesh
  134687. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  134688. * * 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`)
  134689. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  134690. * * 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
  134691. * * 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)
  134692. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134693. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134694. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134695. * @param name defines the name of the mesh
  134696. * @param options defines the options used to create the mesh
  134697. * @param scene defines the hosting scene
  134698. * @returns the sphere mesh
  134699. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  134700. */
  134701. static CreateSphere(name: string, options: {
  134702. segments?: number;
  134703. diameter?: number;
  134704. diameterX?: number;
  134705. diameterY?: number;
  134706. diameterZ?: number;
  134707. arc?: number;
  134708. slice?: number;
  134709. sideOrientation?: number;
  134710. frontUVs?: Vector4;
  134711. backUVs?: Vector4;
  134712. updatable?: boolean;
  134713. }, scene?: Nullable<Scene>): Mesh;
  134714. /**
  134715. * Creates a plane polygonal mesh. By default, this is a disc
  134716. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  134717. * * 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
  134718. * * 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
  134719. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134720. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134722. * @param name defines the name of the mesh
  134723. * @param options defines the options used to create the mesh
  134724. * @param scene defines the hosting scene
  134725. * @returns the plane polygonal mesh
  134726. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  134727. */
  134728. static CreateDisc(name: string, options: {
  134729. radius?: number;
  134730. tessellation?: number;
  134731. arc?: number;
  134732. updatable?: boolean;
  134733. sideOrientation?: number;
  134734. frontUVs?: Vector4;
  134735. backUVs?: Vector4;
  134736. }, scene?: Nullable<Scene>): Mesh;
  134737. /**
  134738. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  134739. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  134740. * * 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`)
  134741. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  134742. * * 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
  134743. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134744. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134745. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134746. * @param name defines the name of the mesh
  134747. * @param options defines the options used to create the mesh
  134748. * @param scene defines the hosting scene
  134749. * @returns the icosahedron mesh
  134750. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  134751. */
  134752. static CreateIcoSphere(name: string, options: {
  134753. radius?: number;
  134754. radiusX?: number;
  134755. radiusY?: number;
  134756. radiusZ?: number;
  134757. flat?: boolean;
  134758. subdivisions?: number;
  134759. sideOrientation?: number;
  134760. frontUVs?: Vector4;
  134761. backUVs?: Vector4;
  134762. updatable?: boolean;
  134763. }, scene?: Nullable<Scene>): Mesh;
  134764. /**
  134765. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134766. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  134767. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  134768. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  134769. * * 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
  134770. * * 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
  134771. * * 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
  134772. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134773. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134774. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134775. * * 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
  134776. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  134777. * * 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
  134778. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  134779. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134780. * @param name defines the name of the mesh
  134781. * @param options defines the options used to create the mesh
  134782. * @param scene defines the hosting scene
  134783. * @returns the ribbon mesh
  134784. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  134785. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134786. */
  134787. static CreateRibbon(name: string, options: {
  134788. pathArray: Vector3[][];
  134789. closeArray?: boolean;
  134790. closePath?: boolean;
  134791. offset?: number;
  134792. updatable?: boolean;
  134793. sideOrientation?: number;
  134794. frontUVs?: Vector4;
  134795. backUVs?: Vector4;
  134796. instance?: Mesh;
  134797. invertUV?: boolean;
  134798. uvs?: Vector2[];
  134799. colors?: Color4[];
  134800. }, scene?: Nullable<Scene>): Mesh;
  134801. /**
  134802. * Creates a cylinder or a cone mesh
  134803. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  134804. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  134805. * * 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.
  134806. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  134807. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  134808. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  134809. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  134810. * * 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).
  134811. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  134812. * * 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).
  134813. * * 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
  134814. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  134815. * * 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
  134816. * * 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.
  134817. * * If `enclose` is false, a ring surface is one element.
  134818. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  134819. * * 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
  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 mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134823. * @param name defines the name of the mesh
  134824. * @param options defines the options used to create the mesh
  134825. * @param scene defines the hosting scene
  134826. * @returns the cylinder mesh
  134827. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  134828. */
  134829. static CreateCylinder(name: string, options: {
  134830. height?: number;
  134831. diameterTop?: number;
  134832. diameterBottom?: number;
  134833. diameter?: number;
  134834. tessellation?: number;
  134835. subdivisions?: number;
  134836. arc?: number;
  134837. faceColors?: Color4[];
  134838. faceUV?: Vector4[];
  134839. updatable?: boolean;
  134840. hasRings?: boolean;
  134841. enclose?: boolean;
  134842. cap?: number;
  134843. sideOrientation?: number;
  134844. frontUVs?: Vector4;
  134845. backUVs?: Vector4;
  134846. }, scene?: Nullable<Scene>): Mesh;
  134847. /**
  134848. * Creates a torus mesh
  134849. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  134850. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  134851. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  134852. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134853. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134854. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134855. * @param name defines the name of the mesh
  134856. * @param options defines the options used to create the mesh
  134857. * @param scene defines the hosting scene
  134858. * @returns the torus mesh
  134859. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  134860. */
  134861. static CreateTorus(name: string, options: {
  134862. diameter?: number;
  134863. thickness?: number;
  134864. tessellation?: number;
  134865. updatable?: boolean;
  134866. sideOrientation?: number;
  134867. frontUVs?: Vector4;
  134868. backUVs?: Vector4;
  134869. }, scene?: Nullable<Scene>): Mesh;
  134870. /**
  134871. * Creates a torus knot mesh
  134872. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  134873. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  134874. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  134875. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  134876. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134877. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134878. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134879. * @param name defines the name of the mesh
  134880. * @param options defines the options used to create the mesh
  134881. * @param scene defines the hosting scene
  134882. * @returns the torus knot mesh
  134883. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  134884. */
  134885. static CreateTorusKnot(name: string, options: {
  134886. radius?: number;
  134887. tube?: number;
  134888. radialSegments?: number;
  134889. tubularSegments?: number;
  134890. p?: number;
  134891. q?: number;
  134892. updatable?: boolean;
  134893. sideOrientation?: number;
  134894. frontUVs?: Vector4;
  134895. backUVs?: Vector4;
  134896. }, scene?: Nullable<Scene>): Mesh;
  134897. /**
  134898. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  134899. * * 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
  134900. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  134901. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  134902. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  134903. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  134904. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  134905. * * 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
  134906. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  134907. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134908. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  134909. * @param name defines the name of the new line system
  134910. * @param options defines the options used to create the line system
  134911. * @param scene defines the hosting scene
  134912. * @returns a new line system mesh
  134913. */
  134914. static CreateLineSystem(name: string, options: {
  134915. lines: Vector3[][];
  134916. updatable?: boolean;
  134917. instance?: Nullable<LinesMesh>;
  134918. colors?: Nullable<Color4[][]>;
  134919. useVertexAlpha?: boolean;
  134920. }, scene: Nullable<Scene>): LinesMesh;
  134921. /**
  134922. * Creates a line mesh
  134923. * 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
  134924. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134925. * * The parameter `points` is an array successive Vector3
  134926. * * 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
  134927. * * The optional parameter `colors` is an array of successive Color4, one per line point
  134928. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  134929. * * When updating an instance, remember that only point positions can change, not the number of points
  134930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134931. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  134932. * @param name defines the name of the new line system
  134933. * @param options defines the options used to create the line system
  134934. * @param scene defines the hosting scene
  134935. * @returns a new line mesh
  134936. */
  134937. static CreateLines(name: string, options: {
  134938. points: Vector3[];
  134939. updatable?: boolean;
  134940. instance?: Nullable<LinesMesh>;
  134941. colors?: Color4[];
  134942. useVertexAlpha?: boolean;
  134943. }, scene?: Nullable<Scene>): LinesMesh;
  134944. /**
  134945. * Creates a dashed line mesh
  134946. * * 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
  134947. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134948. * * The parameter `points` is an array successive Vector3
  134949. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  134950. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  134951. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  134952. * * 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
  134953. * * When updating an instance, remember that only point positions can change, not the number of points
  134954. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134955. * @param name defines the name of the mesh
  134956. * @param options defines the options used to create the mesh
  134957. * @param scene defines the hosting scene
  134958. * @returns the dashed line mesh
  134959. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  134960. */
  134961. static CreateDashedLines(name: string, options: {
  134962. points: Vector3[];
  134963. dashSize?: number;
  134964. gapSize?: number;
  134965. dashNb?: number;
  134966. updatable?: boolean;
  134967. instance?: LinesMesh;
  134968. }, scene?: Nullable<Scene>): LinesMesh;
  134969. /**
  134970. * 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.
  134971. * * 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.
  134972. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134973. * * 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.
  134974. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  134975. * * 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
  134976. * * 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
  134977. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  134978. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134979. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134980. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  134981. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134982. * @param name defines the name of the mesh
  134983. * @param options defines the options used to create the mesh
  134984. * @param scene defines the hosting scene
  134985. * @returns the extruded shape mesh
  134986. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134987. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134988. */
  134989. static ExtrudeShape(name: string, options: {
  134990. shape: Vector3[];
  134991. path: Vector3[];
  134992. scale?: number;
  134993. rotation?: number;
  134994. cap?: number;
  134995. updatable?: boolean;
  134996. sideOrientation?: number;
  134997. frontUVs?: Vector4;
  134998. backUVs?: Vector4;
  134999. instance?: Mesh;
  135000. invertUV?: boolean;
  135001. }, scene?: Nullable<Scene>): Mesh;
  135002. /**
  135003. * Creates an custom extruded shape mesh.
  135004. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  135005. * * 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.
  135006. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  135007. * * 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
  135008. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  135009. * * 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
  135010. * * It must returns a float value that will be the scale value applied to the shape on each path point
  135011. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  135012. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  135013. * * 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
  135014. * * 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
  135015. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  135016. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135017. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135018. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135019. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135020. * @param name defines the name of the mesh
  135021. * @param options defines the options used to create the mesh
  135022. * @param scene defines the hosting scene
  135023. * @returns the custom extruded shape mesh
  135024. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  135025. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135026. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  135027. */
  135028. static ExtrudeShapeCustom(name: string, options: {
  135029. shape: Vector3[];
  135030. path: Vector3[];
  135031. scaleFunction?: any;
  135032. rotationFunction?: any;
  135033. ribbonCloseArray?: boolean;
  135034. ribbonClosePath?: boolean;
  135035. cap?: number;
  135036. updatable?: boolean;
  135037. sideOrientation?: number;
  135038. frontUVs?: Vector4;
  135039. backUVs?: Vector4;
  135040. instance?: Mesh;
  135041. invertUV?: boolean;
  135042. }, scene?: Nullable<Scene>): Mesh;
  135043. /**
  135044. * Creates lathe mesh.
  135045. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  135046. * * 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
  135047. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  135048. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  135049. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  135050. * * 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
  135051. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  135052. * * 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
  135053. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135054. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135055. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135057. * @param name defines the name of the mesh
  135058. * @param options defines the options used to create the mesh
  135059. * @param scene defines the hosting scene
  135060. * @returns the lathe mesh
  135061. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  135062. */
  135063. static CreateLathe(name: string, options: {
  135064. shape: Vector3[];
  135065. radius?: number;
  135066. tessellation?: number;
  135067. clip?: number;
  135068. arc?: number;
  135069. closed?: boolean;
  135070. updatable?: boolean;
  135071. sideOrientation?: number;
  135072. frontUVs?: Vector4;
  135073. backUVs?: Vector4;
  135074. cap?: number;
  135075. invertUV?: boolean;
  135076. }, scene?: Nullable<Scene>): Mesh;
  135077. /**
  135078. * Creates a tiled plane mesh
  135079. * * You can set a limited pattern arrangement with the tiles
  135080. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135081. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135082. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135083. * @param name defines the name of the mesh
  135084. * @param options defines the options used to create the mesh
  135085. * @param scene defines the hosting scene
  135086. * @returns the plane mesh
  135087. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  135088. */
  135089. static CreateTiledPlane(name: string, options: {
  135090. pattern?: number;
  135091. tileSize?: number;
  135092. tileWidth?: number;
  135093. tileHeight?: number;
  135094. size?: number;
  135095. width?: number;
  135096. height?: number;
  135097. alignHorizontal?: number;
  135098. alignVertical?: number;
  135099. sideOrientation?: number;
  135100. frontUVs?: Vector4;
  135101. backUVs?: Vector4;
  135102. updatable?: boolean;
  135103. }, scene?: Nullable<Scene>): Mesh;
  135104. /**
  135105. * Creates a plane mesh
  135106. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  135107. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  135108. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  135109. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135110. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135111. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135112. * @param name defines the name of the mesh
  135113. * @param options defines the options used to create the mesh
  135114. * @param scene defines the hosting scene
  135115. * @returns the plane mesh
  135116. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  135117. */
  135118. static CreatePlane(name: string, options: {
  135119. size?: number;
  135120. width?: number;
  135121. height?: number;
  135122. sideOrientation?: number;
  135123. frontUVs?: Vector4;
  135124. backUVs?: Vector4;
  135125. updatable?: boolean;
  135126. sourcePlane?: Plane;
  135127. }, scene?: Nullable<Scene>): Mesh;
  135128. /**
  135129. * Creates a ground mesh
  135130. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  135131. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  135132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135133. * @param name defines the name of the mesh
  135134. * @param options defines the options used to create the mesh
  135135. * @param scene defines the hosting scene
  135136. * @returns the ground mesh
  135137. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  135138. */
  135139. static CreateGround(name: string, options: {
  135140. width?: number;
  135141. height?: number;
  135142. subdivisions?: number;
  135143. subdivisionsX?: number;
  135144. subdivisionsY?: number;
  135145. updatable?: boolean;
  135146. }, scene?: Nullable<Scene>): Mesh;
  135147. /**
  135148. * Creates a tiled ground mesh
  135149. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  135150. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  135151. * * 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
  135152. * * 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
  135153. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  135154. * @param name defines the name of the mesh
  135155. * @param options defines the options used to create the mesh
  135156. * @param scene defines the hosting scene
  135157. * @returns the tiled ground mesh
  135158. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  135159. */
  135160. static CreateTiledGround(name: string, options: {
  135161. xmin: number;
  135162. zmin: number;
  135163. xmax: number;
  135164. zmax: number;
  135165. subdivisions?: {
  135166. w: number;
  135167. h: number;
  135168. };
  135169. precision?: {
  135170. w: number;
  135171. h: number;
  135172. };
  135173. updatable?: boolean;
  135174. }, scene?: Nullable<Scene>): Mesh;
  135175. /**
  135176. * Creates a ground mesh from a height map
  135177. * * The parameter `url` sets the URL of the height map image resource.
  135178. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  135179. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  135180. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  135181. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  135182. * * 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.
  135183. * * 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).
  135184. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  135185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  135186. * @param name defines the name of the mesh
  135187. * @param url defines the url to the height map
  135188. * @param options defines the options used to create the mesh
  135189. * @param scene defines the hosting scene
  135190. * @returns the ground mesh
  135191. * @see https://doc.babylonjs.com/babylon101/height_map
  135192. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  135193. */
  135194. static CreateGroundFromHeightMap(name: string, url: string, options: {
  135195. width?: number;
  135196. height?: number;
  135197. subdivisions?: number;
  135198. minHeight?: number;
  135199. maxHeight?: number;
  135200. colorFilter?: Color3;
  135201. alphaFilter?: number;
  135202. updatable?: boolean;
  135203. onReady?: (mesh: GroundMesh) => void;
  135204. }, scene?: Nullable<Scene>): GroundMesh;
  135205. /**
  135206. * Creates a polygon mesh
  135207. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  135208. * * 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
  135209. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  135210. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135211. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  135212. * * Remember you can only change the shape positions, not their number when updating a polygon
  135213. * @param name defines the name of the mesh
  135214. * @param options defines the options used to create the mesh
  135215. * @param scene defines the hosting scene
  135216. * @param earcutInjection can be used to inject your own earcut reference
  135217. * @returns the polygon mesh
  135218. */
  135219. static CreatePolygon(name: string, options: {
  135220. shape: Vector3[];
  135221. holes?: Vector3[][];
  135222. depth?: number;
  135223. faceUV?: Vector4[];
  135224. faceColors?: Color4[];
  135225. updatable?: boolean;
  135226. sideOrientation?: number;
  135227. frontUVs?: Vector4;
  135228. backUVs?: Vector4;
  135229. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  135230. /**
  135231. * Creates an extruded polygon mesh, with depth in the Y direction.
  135232. * * 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)
  135233. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  135234. * @param name defines the name of the mesh
  135235. * @param options defines the options used to create the mesh
  135236. * @param scene defines the hosting scene
  135237. * @param earcutInjection can be used to inject your own earcut reference
  135238. * @returns the polygon mesh
  135239. */
  135240. static ExtrudePolygon(name: string, options: {
  135241. shape: Vector3[];
  135242. holes?: Vector3[][];
  135243. depth?: number;
  135244. faceUV?: Vector4[];
  135245. faceColors?: Color4[];
  135246. updatable?: boolean;
  135247. sideOrientation?: number;
  135248. frontUVs?: Vector4;
  135249. backUVs?: Vector4;
  135250. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  135251. /**
  135252. * Creates a tube mesh.
  135253. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  135254. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  135255. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  135256. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  135257. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  135258. * * 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)
  135259. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  135260. * * 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
  135261. * * 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
  135262. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135263. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135264. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135265. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135266. * @param name defines the name of the mesh
  135267. * @param options defines the options used to create the mesh
  135268. * @param scene defines the hosting scene
  135269. * @returns the tube mesh
  135270. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135271. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  135272. */
  135273. static CreateTube(name: string, options: {
  135274. path: Vector3[];
  135275. radius?: number;
  135276. tessellation?: number;
  135277. radiusFunction?: {
  135278. (i: number, distance: number): number;
  135279. };
  135280. cap?: number;
  135281. arc?: number;
  135282. updatable?: boolean;
  135283. sideOrientation?: number;
  135284. frontUVs?: Vector4;
  135285. backUVs?: Vector4;
  135286. instance?: Mesh;
  135287. invertUV?: boolean;
  135288. }, scene?: Nullable<Scene>): Mesh;
  135289. /**
  135290. * Creates a polyhedron mesh
  135291. * * 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
  135292. * * The parameter `size` (positive float, default 1) sets the polygon size
  135293. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  135294. * * 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`
  135295. * * 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
  135296. * * 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)`)
  135297. * * 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
  135298. * * 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
  135299. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135300. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135302. * @param name defines the name of the mesh
  135303. * @param options defines the options used to create the mesh
  135304. * @param scene defines the hosting scene
  135305. * @returns the polyhedron mesh
  135306. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  135307. */
  135308. static CreatePolyhedron(name: string, options: {
  135309. type?: number;
  135310. size?: number;
  135311. sizeX?: number;
  135312. sizeY?: number;
  135313. sizeZ?: number;
  135314. custom?: any;
  135315. faceUV?: Vector4[];
  135316. faceColors?: Color4[];
  135317. flat?: boolean;
  135318. updatable?: boolean;
  135319. sideOrientation?: number;
  135320. frontUVs?: Vector4;
  135321. backUVs?: Vector4;
  135322. }, scene?: Nullable<Scene>): Mesh;
  135323. /**
  135324. * Creates a decal mesh.
  135325. * 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
  135326. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  135327. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  135328. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  135329. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  135330. * @param name defines the name of the mesh
  135331. * @param sourceMesh defines the mesh where the decal must be applied
  135332. * @param options defines the options used to create the mesh
  135333. * @param scene defines the hosting scene
  135334. * @returns the decal mesh
  135335. * @see https://doc.babylonjs.com/how_to/decals
  135336. */
  135337. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  135338. position?: Vector3;
  135339. normal?: Vector3;
  135340. size?: Vector3;
  135341. angle?: number;
  135342. }): Mesh;
  135343. }
  135344. }
  135345. declare module BABYLON {
  135346. /**
  135347. * A simplifier interface for future simplification implementations
  135348. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135349. */
  135350. export interface ISimplifier {
  135351. /**
  135352. * Simplification of a given mesh according to the given settings.
  135353. * Since this requires computation, it is assumed that the function runs async.
  135354. * @param settings The settings of the simplification, including quality and distance
  135355. * @param successCallback A callback that will be called after the mesh was simplified.
  135356. * @param errorCallback in case of an error, this callback will be called. optional.
  135357. */
  135358. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  135359. }
  135360. /**
  135361. * Expected simplification settings.
  135362. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  135363. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135364. */
  135365. export interface ISimplificationSettings {
  135366. /**
  135367. * Gets or sets the expected quality
  135368. */
  135369. quality: number;
  135370. /**
  135371. * Gets or sets the distance when this optimized version should be used
  135372. */
  135373. distance: number;
  135374. /**
  135375. * Gets an already optimized mesh
  135376. */
  135377. optimizeMesh?: boolean;
  135378. }
  135379. /**
  135380. * Class used to specify simplification options
  135381. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135382. */
  135383. export class SimplificationSettings implements ISimplificationSettings {
  135384. /** expected quality */
  135385. quality: number;
  135386. /** distance when this optimized version should be used */
  135387. distance: number;
  135388. /** already optimized mesh */
  135389. optimizeMesh?: boolean | undefined;
  135390. /**
  135391. * Creates a SimplificationSettings
  135392. * @param quality expected quality
  135393. * @param distance distance when this optimized version should be used
  135394. * @param optimizeMesh already optimized mesh
  135395. */
  135396. constructor(
  135397. /** expected quality */
  135398. quality: number,
  135399. /** distance when this optimized version should be used */
  135400. distance: number,
  135401. /** already optimized mesh */
  135402. optimizeMesh?: boolean | undefined);
  135403. }
  135404. /**
  135405. * Interface used to define a simplification task
  135406. */
  135407. export interface ISimplificationTask {
  135408. /**
  135409. * Array of settings
  135410. */
  135411. settings: Array<ISimplificationSettings>;
  135412. /**
  135413. * Simplification type
  135414. */
  135415. simplificationType: SimplificationType;
  135416. /**
  135417. * Mesh to simplify
  135418. */
  135419. mesh: Mesh;
  135420. /**
  135421. * Callback called on success
  135422. */
  135423. successCallback?: () => void;
  135424. /**
  135425. * Defines if parallel processing can be used
  135426. */
  135427. parallelProcessing: boolean;
  135428. }
  135429. /**
  135430. * Queue used to order the simplification tasks
  135431. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135432. */
  135433. export class SimplificationQueue {
  135434. private _simplificationArray;
  135435. /**
  135436. * Gets a boolean indicating that the process is still running
  135437. */
  135438. running: boolean;
  135439. /**
  135440. * Creates a new queue
  135441. */
  135442. constructor();
  135443. /**
  135444. * Adds a new simplification task
  135445. * @param task defines a task to add
  135446. */
  135447. addTask(task: ISimplificationTask): void;
  135448. /**
  135449. * Execute next task
  135450. */
  135451. executeNext(): void;
  135452. /**
  135453. * Execute a simplification task
  135454. * @param task defines the task to run
  135455. */
  135456. runSimplification(task: ISimplificationTask): void;
  135457. private getSimplifier;
  135458. }
  135459. /**
  135460. * The implemented types of simplification
  135461. * At the moment only Quadratic Error Decimation is implemented
  135462. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135463. */
  135464. export enum SimplificationType {
  135465. /** Quadratic error decimation */
  135466. QUADRATIC = 0
  135467. }
  135468. /**
  135469. * An implementation of the Quadratic Error simplification algorithm.
  135470. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  135471. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  135472. * @author RaananW
  135473. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135474. */
  135475. export class QuadraticErrorSimplification implements ISimplifier {
  135476. private _mesh;
  135477. private triangles;
  135478. private vertices;
  135479. private references;
  135480. private _reconstructedMesh;
  135481. /** Gets or sets the number pf sync interations */
  135482. syncIterations: number;
  135483. /** Gets or sets the aggressiveness of the simplifier */
  135484. aggressiveness: number;
  135485. /** Gets or sets the number of allowed iterations for decimation */
  135486. decimationIterations: number;
  135487. /** Gets or sets the espilon to use for bounding box computation */
  135488. boundingBoxEpsilon: number;
  135489. /**
  135490. * Creates a new QuadraticErrorSimplification
  135491. * @param _mesh defines the target mesh
  135492. */
  135493. constructor(_mesh: Mesh);
  135494. /**
  135495. * Simplification of a given mesh according to the given settings.
  135496. * Since this requires computation, it is assumed that the function runs async.
  135497. * @param settings The settings of the simplification, including quality and distance
  135498. * @param successCallback A callback that will be called after the mesh was simplified.
  135499. */
  135500. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  135501. private runDecimation;
  135502. private initWithMesh;
  135503. private init;
  135504. private reconstructMesh;
  135505. private initDecimatedMesh;
  135506. private isFlipped;
  135507. private updateTriangles;
  135508. private identifyBorder;
  135509. private updateMesh;
  135510. private vertexError;
  135511. private calculateError;
  135512. }
  135513. }
  135514. declare module BABYLON {
  135515. interface Scene {
  135516. /** @hidden (Backing field) */
  135517. _simplificationQueue: SimplificationQueue;
  135518. /**
  135519. * Gets or sets the simplification queue attached to the scene
  135520. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135521. */
  135522. simplificationQueue: SimplificationQueue;
  135523. }
  135524. interface Mesh {
  135525. /**
  135526. * Simplify the mesh according to the given array of settings.
  135527. * Function will return immediately and will simplify async
  135528. * @param settings a collection of simplification settings
  135529. * @param parallelProcessing should all levels calculate parallel or one after the other
  135530. * @param simplificationType the type of simplification to run
  135531. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  135532. * @returns the current mesh
  135533. */
  135534. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  135535. }
  135536. /**
  135537. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  135538. * created in a scene
  135539. */
  135540. export class SimplicationQueueSceneComponent implements ISceneComponent {
  135541. /**
  135542. * The component name helpfull to identify the component in the list of scene components.
  135543. */
  135544. readonly name: string;
  135545. /**
  135546. * The scene the component belongs to.
  135547. */
  135548. scene: Scene;
  135549. /**
  135550. * Creates a new instance of the component for the given scene
  135551. * @param scene Defines the scene to register the component in
  135552. */
  135553. constructor(scene: Scene);
  135554. /**
  135555. * Registers the component in a given scene
  135556. */
  135557. register(): void;
  135558. /**
  135559. * Rebuilds the elements related to this component in case of
  135560. * context lost for instance.
  135561. */
  135562. rebuild(): void;
  135563. /**
  135564. * Disposes the component and the associated ressources
  135565. */
  135566. dispose(): void;
  135567. private _beforeCameraUpdate;
  135568. }
  135569. }
  135570. declare module BABYLON {
  135571. /**
  135572. * Navigation plugin interface to add navigation constrained by a navigation mesh
  135573. */
  135574. export interface INavigationEnginePlugin {
  135575. /**
  135576. * plugin name
  135577. */
  135578. name: string;
  135579. /**
  135580. * Creates a navigation mesh
  135581. * @param meshes array of all the geometry used to compute the navigatio mesh
  135582. * @param parameters bunch of parameters used to filter geometry
  135583. */
  135584. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  135585. /**
  135586. * Create a navigation mesh debug mesh
  135587. * @param scene is where the mesh will be added
  135588. * @returns debug display mesh
  135589. */
  135590. createDebugNavMesh(scene: Scene): Mesh;
  135591. /**
  135592. * Get a navigation mesh constrained position, closest to the parameter position
  135593. * @param position world position
  135594. * @returns the closest point to position constrained by the navigation mesh
  135595. */
  135596. getClosestPoint(position: Vector3): Vector3;
  135597. /**
  135598. * Get a navigation mesh constrained position, within a particular radius
  135599. * @param position world position
  135600. * @param maxRadius the maximum distance to the constrained world position
  135601. * @returns the closest point to position constrained by the navigation mesh
  135602. */
  135603. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  135604. /**
  135605. * Compute the final position from a segment made of destination-position
  135606. * @param position world position
  135607. * @param destination world position
  135608. * @returns the resulting point along the navmesh
  135609. */
  135610. moveAlong(position: Vector3, destination: Vector3): Vector3;
  135611. /**
  135612. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  135613. * @param start world position
  135614. * @param end world position
  135615. * @returns array containing world position composing the path
  135616. */
  135617. computePath(start: Vector3, end: Vector3): Vector3[];
  135618. /**
  135619. * If this plugin is supported
  135620. * @returns true if plugin is supported
  135621. */
  135622. isSupported(): boolean;
  135623. /**
  135624. * Create a new Crowd so you can add agents
  135625. * @param maxAgents the maximum agent count in the crowd
  135626. * @param maxAgentRadius the maximum radius an agent can have
  135627. * @param scene to attach the crowd to
  135628. * @returns the crowd you can add agents to
  135629. */
  135630. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  135631. /**
  135632. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135633. * The queries will try to find a solution within those bounds
  135634. * default is (1,1,1)
  135635. * @param extent x,y,z value that define the extent around the queries point of reference
  135636. */
  135637. setDefaultQueryExtent(extent: Vector3): void;
  135638. /**
  135639. * Get the Bounding box extent specified by setDefaultQueryExtent
  135640. * @returns the box extent values
  135641. */
  135642. getDefaultQueryExtent(): Vector3;
  135643. /**
  135644. * Release all resources
  135645. */
  135646. dispose(): void;
  135647. }
  135648. /**
  135649. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  135650. */
  135651. export interface ICrowd {
  135652. /**
  135653. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  135654. * You can attach anything to that node. The node position is updated in the scene update tick.
  135655. * @param pos world position that will be constrained by the navigation mesh
  135656. * @param parameters agent parameters
  135657. * @param transform hooked to the agent that will be update by the scene
  135658. * @returns agent index
  135659. */
  135660. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  135661. /**
  135662. * Returns the agent position in world space
  135663. * @param index agent index returned by addAgent
  135664. * @returns world space position
  135665. */
  135666. getAgentPosition(index: number): Vector3;
  135667. /**
  135668. * Gets the agent velocity in world space
  135669. * @param index agent index returned by addAgent
  135670. * @returns world space velocity
  135671. */
  135672. getAgentVelocity(index: number): Vector3;
  135673. /**
  135674. * remove a particular agent previously created
  135675. * @param index agent index returned by addAgent
  135676. */
  135677. removeAgent(index: number): void;
  135678. /**
  135679. * get the list of all agents attached to this crowd
  135680. * @returns list of agent indices
  135681. */
  135682. getAgents(): number[];
  135683. /**
  135684. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  135685. * @param deltaTime in seconds
  135686. */
  135687. update(deltaTime: number): void;
  135688. /**
  135689. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  135690. * @param index agent index returned by addAgent
  135691. * @param destination targeted world position
  135692. */
  135693. agentGoto(index: number, destination: Vector3): void;
  135694. /**
  135695. * Teleport the agent to a new position
  135696. * @param index agent index returned by addAgent
  135697. * @param destination targeted world position
  135698. */
  135699. agentTeleport(index: number, destination: Vector3): void;
  135700. /**
  135701. * Update agent parameters
  135702. * @param index agent index returned by addAgent
  135703. * @param parameters agent parameters
  135704. */
  135705. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  135706. /**
  135707. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135708. * The queries will try to find a solution within those bounds
  135709. * default is (1,1,1)
  135710. * @param extent x,y,z value that define the extent around the queries point of reference
  135711. */
  135712. setDefaultQueryExtent(extent: Vector3): void;
  135713. /**
  135714. * Get the Bounding box extent specified by setDefaultQueryExtent
  135715. * @returns the box extent values
  135716. */
  135717. getDefaultQueryExtent(): Vector3;
  135718. /**
  135719. * Release all resources
  135720. */
  135721. dispose(): void;
  135722. }
  135723. /**
  135724. * Configures an agent
  135725. */
  135726. export interface IAgentParameters {
  135727. /**
  135728. * Agent radius. [Limit: >= 0]
  135729. */
  135730. radius: number;
  135731. /**
  135732. * Agent height. [Limit: > 0]
  135733. */
  135734. height: number;
  135735. /**
  135736. * Maximum allowed acceleration. [Limit: >= 0]
  135737. */
  135738. maxAcceleration: number;
  135739. /**
  135740. * Maximum allowed speed. [Limit: >= 0]
  135741. */
  135742. maxSpeed: number;
  135743. /**
  135744. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  135745. */
  135746. collisionQueryRange: number;
  135747. /**
  135748. * The path visibility optimization range. [Limit: > 0]
  135749. */
  135750. pathOptimizationRange: number;
  135751. /**
  135752. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  135753. */
  135754. separationWeight: number;
  135755. }
  135756. /**
  135757. * Configures the navigation mesh creation
  135758. */
  135759. export interface INavMeshParameters {
  135760. /**
  135761. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  135762. */
  135763. cs: number;
  135764. /**
  135765. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  135766. */
  135767. ch: number;
  135768. /**
  135769. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  135770. */
  135771. walkableSlopeAngle: number;
  135772. /**
  135773. * Minimum floor to 'ceiling' height that will still allow the floor area to
  135774. * be considered walkable. [Limit: >= 3] [Units: vx]
  135775. */
  135776. walkableHeight: number;
  135777. /**
  135778. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  135779. */
  135780. walkableClimb: number;
  135781. /**
  135782. * The distance to erode/shrink the walkable area of the heightfield away from
  135783. * obstructions. [Limit: >=0] [Units: vx]
  135784. */
  135785. walkableRadius: number;
  135786. /**
  135787. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  135788. */
  135789. maxEdgeLen: number;
  135790. /**
  135791. * The maximum distance a simplfied contour's border edges should deviate
  135792. * the original raw contour. [Limit: >=0] [Units: vx]
  135793. */
  135794. maxSimplificationError: number;
  135795. /**
  135796. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  135797. */
  135798. minRegionArea: number;
  135799. /**
  135800. * Any regions with a span count smaller than this value will, if possible,
  135801. * be merged with larger regions. [Limit: >=0] [Units: vx]
  135802. */
  135803. mergeRegionArea: number;
  135804. /**
  135805. * The maximum number of vertices allowed for polygons generated during the
  135806. * contour to polygon conversion process. [Limit: >= 3]
  135807. */
  135808. maxVertsPerPoly: number;
  135809. /**
  135810. * Sets the sampling distance to use when generating the detail mesh.
  135811. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  135812. */
  135813. detailSampleDist: number;
  135814. /**
  135815. * The maximum distance the detail mesh surface should deviate from heightfield
  135816. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  135817. */
  135818. detailSampleMaxError: number;
  135819. }
  135820. }
  135821. declare module BABYLON {
  135822. /**
  135823. * RecastJS navigation plugin
  135824. */
  135825. export class RecastJSPlugin implements INavigationEnginePlugin {
  135826. /**
  135827. * Reference to the Recast library
  135828. */
  135829. bjsRECAST: any;
  135830. /**
  135831. * plugin name
  135832. */
  135833. name: string;
  135834. /**
  135835. * the first navmesh created. We might extend this to support multiple navmeshes
  135836. */
  135837. navMesh: any;
  135838. /**
  135839. * Initializes the recastJS plugin
  135840. * @param recastInjection can be used to inject your own recast reference
  135841. */
  135842. constructor(recastInjection?: any);
  135843. /**
  135844. * Creates a navigation mesh
  135845. * @param meshes array of all the geometry used to compute the navigatio mesh
  135846. * @param parameters bunch of parameters used to filter geometry
  135847. */
  135848. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  135849. /**
  135850. * Create a navigation mesh debug mesh
  135851. * @param scene is where the mesh will be added
  135852. * @returns debug display mesh
  135853. */
  135854. createDebugNavMesh(scene: Scene): Mesh;
  135855. /**
  135856. * Get a navigation mesh constrained position, closest to the parameter position
  135857. * @param position world position
  135858. * @returns the closest point to position constrained by the navigation mesh
  135859. */
  135860. getClosestPoint(position: Vector3): Vector3;
  135861. /**
  135862. * Get a navigation mesh constrained position, within a particular radius
  135863. * @param position world position
  135864. * @param maxRadius the maximum distance to the constrained world position
  135865. * @returns the closest point to position constrained by the navigation mesh
  135866. */
  135867. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  135868. /**
  135869. * Compute the final position from a segment made of destination-position
  135870. * @param position world position
  135871. * @param destination world position
  135872. * @returns the resulting point along the navmesh
  135873. */
  135874. moveAlong(position: Vector3, destination: Vector3): Vector3;
  135875. /**
  135876. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  135877. * @param start world position
  135878. * @param end world position
  135879. * @returns array containing world position composing the path
  135880. */
  135881. computePath(start: Vector3, end: Vector3): Vector3[];
  135882. /**
  135883. * Create a new Crowd so you can add agents
  135884. * @param maxAgents the maximum agent count in the crowd
  135885. * @param maxAgentRadius the maximum radius an agent can have
  135886. * @param scene to attach the crowd to
  135887. * @returns the crowd you can add agents to
  135888. */
  135889. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  135890. /**
  135891. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135892. * The queries will try to find a solution within those bounds
  135893. * default is (1,1,1)
  135894. * @param extent x,y,z value that define the extent around the queries point of reference
  135895. */
  135896. setDefaultQueryExtent(extent: Vector3): void;
  135897. /**
  135898. * Get the Bounding box extent specified by setDefaultQueryExtent
  135899. * @returns the box extent values
  135900. */
  135901. getDefaultQueryExtent(): Vector3;
  135902. /**
  135903. * Disposes
  135904. */
  135905. dispose(): void;
  135906. /**
  135907. * If this plugin is supported
  135908. * @returns true if plugin is supported
  135909. */
  135910. isSupported(): boolean;
  135911. }
  135912. /**
  135913. * Recast detour crowd implementation
  135914. */
  135915. export class RecastJSCrowd implements ICrowd {
  135916. /**
  135917. * Recast/detour plugin
  135918. */
  135919. bjsRECASTPlugin: RecastJSPlugin;
  135920. /**
  135921. * Link to the detour crowd
  135922. */
  135923. recastCrowd: any;
  135924. /**
  135925. * One transform per agent
  135926. */
  135927. transforms: TransformNode[];
  135928. /**
  135929. * All agents created
  135930. */
  135931. agents: number[];
  135932. /**
  135933. * Link to the scene is kept to unregister the crowd from the scene
  135934. */
  135935. private _scene;
  135936. /**
  135937. * Observer for crowd updates
  135938. */
  135939. private _onBeforeAnimationsObserver;
  135940. /**
  135941. * Constructor
  135942. * @param plugin recastJS plugin
  135943. * @param maxAgents the maximum agent count in the crowd
  135944. * @param maxAgentRadius the maximum radius an agent can have
  135945. * @param scene to attach the crowd to
  135946. * @returns the crowd you can add agents to
  135947. */
  135948. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  135949. /**
  135950. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  135951. * You can attach anything to that node. The node position is updated in the scene update tick.
  135952. * @param pos world position that will be constrained by the navigation mesh
  135953. * @param parameters agent parameters
  135954. * @param transform hooked to the agent that will be update by the scene
  135955. * @returns agent index
  135956. */
  135957. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  135958. /**
  135959. * Returns the agent position in world space
  135960. * @param index agent index returned by addAgent
  135961. * @returns world space position
  135962. */
  135963. getAgentPosition(index: number): Vector3;
  135964. /**
  135965. * Returns the agent velocity in world space
  135966. * @param index agent index returned by addAgent
  135967. * @returns world space velocity
  135968. */
  135969. getAgentVelocity(index: number): Vector3;
  135970. /**
  135971. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  135972. * @param index agent index returned by addAgent
  135973. * @param destination targeted world position
  135974. */
  135975. agentGoto(index: number, destination: Vector3): void;
  135976. /**
  135977. * Teleport the agent to a new position
  135978. * @param index agent index returned by addAgent
  135979. * @param destination targeted world position
  135980. */
  135981. agentTeleport(index: number, destination: Vector3): void;
  135982. /**
  135983. * Update agent parameters
  135984. * @param index agent index returned by addAgent
  135985. * @param parameters agent parameters
  135986. */
  135987. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  135988. /**
  135989. * remove a particular agent previously created
  135990. * @param index agent index returned by addAgent
  135991. */
  135992. removeAgent(index: number): void;
  135993. /**
  135994. * get the list of all agents attached to this crowd
  135995. * @returns list of agent indices
  135996. */
  135997. getAgents(): number[];
  135998. /**
  135999. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  136000. * @param deltaTime in seconds
  136001. */
  136002. update(deltaTime: number): void;
  136003. /**
  136004. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  136005. * The queries will try to find a solution within those bounds
  136006. * default is (1,1,1)
  136007. * @param extent x,y,z value that define the extent around the queries point of reference
  136008. */
  136009. setDefaultQueryExtent(extent: Vector3): void;
  136010. /**
  136011. * Get the Bounding box extent specified by setDefaultQueryExtent
  136012. * @returns the box extent values
  136013. */
  136014. getDefaultQueryExtent(): Vector3;
  136015. /**
  136016. * Release all resources
  136017. */
  136018. dispose(): void;
  136019. }
  136020. }
  136021. declare module BABYLON {
  136022. /**
  136023. * Class used to enable access to IndexedDB
  136024. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  136025. */
  136026. export class Database implements IOfflineProvider {
  136027. private _callbackManifestChecked;
  136028. private _currentSceneUrl;
  136029. private _db;
  136030. private _enableSceneOffline;
  136031. private _enableTexturesOffline;
  136032. private _manifestVersionFound;
  136033. private _mustUpdateRessources;
  136034. private _hasReachedQuota;
  136035. private _isSupported;
  136036. private _idbFactory;
  136037. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  136038. private static IsUASupportingBlobStorage;
  136039. /**
  136040. * Gets a boolean indicating if Database storate is enabled (off by default)
  136041. */
  136042. static IDBStorageEnabled: boolean;
  136043. /**
  136044. * Gets a boolean indicating if scene must be saved in the database
  136045. */
  136046. get enableSceneOffline(): boolean;
  136047. /**
  136048. * Gets a boolean indicating if textures must be saved in the database
  136049. */
  136050. get enableTexturesOffline(): boolean;
  136051. /**
  136052. * Creates a new Database
  136053. * @param urlToScene defines the url to load the scene
  136054. * @param callbackManifestChecked defines the callback to use when manifest is checked
  136055. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  136056. */
  136057. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  136058. private static _ParseURL;
  136059. private static _ReturnFullUrlLocation;
  136060. private _checkManifestFile;
  136061. /**
  136062. * Open the database and make it available
  136063. * @param successCallback defines the callback to call on success
  136064. * @param errorCallback defines the callback to call on error
  136065. */
  136066. open(successCallback: () => void, errorCallback: () => void): void;
  136067. /**
  136068. * Loads an image from the database
  136069. * @param url defines the url to load from
  136070. * @param image defines the target DOM image
  136071. */
  136072. loadImage(url: string, image: HTMLImageElement): void;
  136073. private _loadImageFromDBAsync;
  136074. private _saveImageIntoDBAsync;
  136075. private _checkVersionFromDB;
  136076. private _loadVersionFromDBAsync;
  136077. private _saveVersionIntoDBAsync;
  136078. /**
  136079. * Loads a file from database
  136080. * @param url defines the URL to load from
  136081. * @param sceneLoaded defines a callback to call on success
  136082. * @param progressCallBack defines a callback to call when progress changed
  136083. * @param errorCallback defines a callback to call on error
  136084. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  136085. */
  136086. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  136087. private _loadFileAsync;
  136088. private _saveFileAsync;
  136089. /**
  136090. * Validates if xhr data is correct
  136091. * @param xhr defines the request to validate
  136092. * @param dataType defines the expected data type
  136093. * @returns true if data is correct
  136094. */
  136095. private static _ValidateXHRData;
  136096. }
  136097. }
  136098. declare module BABYLON {
  136099. /** @hidden */
  136100. export var gpuUpdateParticlesPixelShader: {
  136101. name: string;
  136102. shader: string;
  136103. };
  136104. }
  136105. declare module BABYLON {
  136106. /** @hidden */
  136107. export var gpuUpdateParticlesVertexShader: {
  136108. name: string;
  136109. shader: string;
  136110. };
  136111. }
  136112. declare module BABYLON {
  136113. /** @hidden */
  136114. export var clipPlaneFragmentDeclaration2: {
  136115. name: string;
  136116. shader: string;
  136117. };
  136118. }
  136119. declare module BABYLON {
  136120. /** @hidden */
  136121. export var gpuRenderParticlesPixelShader: {
  136122. name: string;
  136123. shader: string;
  136124. };
  136125. }
  136126. declare module BABYLON {
  136127. /** @hidden */
  136128. export var clipPlaneVertexDeclaration2: {
  136129. name: string;
  136130. shader: string;
  136131. };
  136132. }
  136133. declare module BABYLON {
  136134. /** @hidden */
  136135. export var gpuRenderParticlesVertexShader: {
  136136. name: string;
  136137. shader: string;
  136138. };
  136139. }
  136140. declare module BABYLON {
  136141. /**
  136142. * This represents a GPU particle system in Babylon
  136143. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  136144. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  136145. */
  136146. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  136147. /**
  136148. * The layer mask we are rendering the particles through.
  136149. */
  136150. layerMask: number;
  136151. private _capacity;
  136152. private _activeCount;
  136153. private _currentActiveCount;
  136154. private _accumulatedCount;
  136155. private _renderEffect;
  136156. private _updateEffect;
  136157. private _buffer0;
  136158. private _buffer1;
  136159. private _spriteBuffer;
  136160. private _updateVAO;
  136161. private _renderVAO;
  136162. private _targetIndex;
  136163. private _sourceBuffer;
  136164. private _targetBuffer;
  136165. private _engine;
  136166. private _currentRenderId;
  136167. private _started;
  136168. private _stopped;
  136169. private _timeDelta;
  136170. private _randomTexture;
  136171. private _randomTexture2;
  136172. private _attributesStrideSize;
  136173. private _updateEffectOptions;
  136174. private _randomTextureSize;
  136175. private _actualFrame;
  136176. private readonly _rawTextureWidth;
  136177. /**
  136178. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  136179. */
  136180. static get IsSupported(): boolean;
  136181. /**
  136182. * An event triggered when the system is disposed.
  136183. */
  136184. onDisposeObservable: Observable<GPUParticleSystem>;
  136185. /**
  136186. * Gets the maximum number of particles active at the same time.
  136187. * @returns The max number of active particles.
  136188. */
  136189. getCapacity(): number;
  136190. /**
  136191. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  136192. * to override the particles.
  136193. */
  136194. forceDepthWrite: boolean;
  136195. /**
  136196. * Gets or set the number of active particles
  136197. */
  136198. get activeParticleCount(): number;
  136199. set activeParticleCount(value: number);
  136200. private _preWarmDone;
  136201. /**
  136202. * Specifies if the particles are updated in emitter local space or world space.
  136203. * This is always false for GPU particles
  136204. */
  136205. get isLocal(): boolean;
  136206. set isLocal(value: boolean);
  136207. /**
  136208. * Is this system ready to be used/rendered
  136209. * @return true if the system is ready
  136210. */
  136211. isReady(): boolean;
  136212. /**
  136213. * Gets if the system has been started. (Note: this will still be true after stop is called)
  136214. * @returns True if it has been started, otherwise false.
  136215. */
  136216. isStarted(): boolean;
  136217. /**
  136218. * Starts the particle system and begins to emit
  136219. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  136220. */
  136221. start(delay?: number): void;
  136222. /**
  136223. * Stops the particle system.
  136224. */
  136225. stop(): void;
  136226. /**
  136227. * Remove all active particles
  136228. */
  136229. reset(): void;
  136230. /**
  136231. * Returns the string "GPUParticleSystem"
  136232. * @returns a string containing the class name
  136233. */
  136234. getClassName(): string;
  136235. private _colorGradientsTexture;
  136236. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  136237. /**
  136238. * Adds a new color gradient
  136239. * @param gradient defines the gradient to use (between 0 and 1)
  136240. * @param color1 defines the color to affect to the specified gradient
  136241. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  136242. * @returns the current particle system
  136243. */
  136244. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  136245. /**
  136246. * Remove a specific color gradient
  136247. * @param gradient defines the gradient to remove
  136248. * @returns the current particle system
  136249. */
  136250. removeColorGradient(gradient: number): GPUParticleSystem;
  136251. private _angularSpeedGradientsTexture;
  136252. private _sizeGradientsTexture;
  136253. private _velocityGradientsTexture;
  136254. private _limitVelocityGradientsTexture;
  136255. private _dragGradientsTexture;
  136256. private _addFactorGradient;
  136257. /**
  136258. * Adds a new size gradient
  136259. * @param gradient defines the gradient to use (between 0 and 1)
  136260. * @param factor defines the size factor to affect to the specified gradient
  136261. * @returns the current particle system
  136262. */
  136263. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  136264. /**
  136265. * Remove a specific size gradient
  136266. * @param gradient defines the gradient to remove
  136267. * @returns the current particle system
  136268. */
  136269. removeSizeGradient(gradient: number): GPUParticleSystem;
  136270. /**
  136271. * Adds a new angular speed gradient
  136272. * @param gradient defines the gradient to use (between 0 and 1)
  136273. * @param factor defines the angular speed to affect to the specified gradient
  136274. * @returns the current particle system
  136275. */
  136276. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  136277. /**
  136278. * Remove a specific angular speed gradient
  136279. * @param gradient defines the gradient to remove
  136280. * @returns the current particle system
  136281. */
  136282. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  136283. /**
  136284. * Adds a new velocity gradient
  136285. * @param gradient defines the gradient to use (between 0 and 1)
  136286. * @param factor defines the velocity to affect to the specified gradient
  136287. * @returns the current particle system
  136288. */
  136289. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  136290. /**
  136291. * Remove a specific velocity gradient
  136292. * @param gradient defines the gradient to remove
  136293. * @returns the current particle system
  136294. */
  136295. removeVelocityGradient(gradient: number): GPUParticleSystem;
  136296. /**
  136297. * Adds a new limit velocity gradient
  136298. * @param gradient defines the gradient to use (between 0 and 1)
  136299. * @param factor defines the limit velocity value to affect to the specified gradient
  136300. * @returns the current particle system
  136301. */
  136302. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  136303. /**
  136304. * Remove a specific limit velocity gradient
  136305. * @param gradient defines the gradient to remove
  136306. * @returns the current particle system
  136307. */
  136308. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  136309. /**
  136310. * Adds a new drag gradient
  136311. * @param gradient defines the gradient to use (between 0 and 1)
  136312. * @param factor defines the drag value to affect to the specified gradient
  136313. * @returns the current particle system
  136314. */
  136315. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  136316. /**
  136317. * Remove a specific drag gradient
  136318. * @param gradient defines the gradient to remove
  136319. * @returns the current particle system
  136320. */
  136321. removeDragGradient(gradient: number): GPUParticleSystem;
  136322. /**
  136323. * Not supported by GPUParticleSystem
  136324. * @param gradient defines the gradient to use (between 0 and 1)
  136325. * @param factor defines the emit rate value to affect to the specified gradient
  136326. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  136327. * @returns the current particle system
  136328. */
  136329. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  136330. /**
  136331. * Not supported by GPUParticleSystem
  136332. * @param gradient defines the gradient to remove
  136333. * @returns the current particle system
  136334. */
  136335. removeEmitRateGradient(gradient: number): IParticleSystem;
  136336. /**
  136337. * Not supported by GPUParticleSystem
  136338. * @param gradient defines the gradient to use (between 0 and 1)
  136339. * @param factor defines the start size value to affect to the specified gradient
  136340. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  136341. * @returns the current particle system
  136342. */
  136343. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  136344. /**
  136345. * Not supported by GPUParticleSystem
  136346. * @param gradient defines the gradient to remove
  136347. * @returns the current particle system
  136348. */
  136349. removeStartSizeGradient(gradient: number): IParticleSystem;
  136350. /**
  136351. * Not supported by GPUParticleSystem
  136352. * @param gradient defines the gradient to use (between 0 and 1)
  136353. * @param min defines the color remap minimal range
  136354. * @param max defines the color remap maximal range
  136355. * @returns the current particle system
  136356. */
  136357. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  136358. /**
  136359. * Not supported by GPUParticleSystem
  136360. * @param gradient defines the gradient to remove
  136361. * @returns the current particle system
  136362. */
  136363. removeColorRemapGradient(): IParticleSystem;
  136364. /**
  136365. * Not supported by GPUParticleSystem
  136366. * @param gradient defines the gradient to use (between 0 and 1)
  136367. * @param min defines the alpha remap minimal range
  136368. * @param max defines the alpha remap maximal range
  136369. * @returns the current particle system
  136370. */
  136371. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  136372. /**
  136373. * Not supported by GPUParticleSystem
  136374. * @param gradient defines the gradient to remove
  136375. * @returns the current particle system
  136376. */
  136377. removeAlphaRemapGradient(): IParticleSystem;
  136378. /**
  136379. * Not supported by GPUParticleSystem
  136380. * @param gradient defines the gradient to use (between 0 and 1)
  136381. * @param color defines the color to affect to the specified gradient
  136382. * @returns the current particle system
  136383. */
  136384. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  136385. /**
  136386. * Not supported by GPUParticleSystem
  136387. * @param gradient defines the gradient to remove
  136388. * @returns the current particle system
  136389. */
  136390. removeRampGradient(): IParticleSystem;
  136391. /**
  136392. * Not supported by GPUParticleSystem
  136393. * @returns the list of ramp gradients
  136394. */
  136395. getRampGradients(): Nullable<Array<Color3Gradient>>;
  136396. /**
  136397. * Not supported by GPUParticleSystem
  136398. * Gets or sets a boolean indicating that ramp gradients must be used
  136399. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  136400. */
  136401. get useRampGradients(): boolean;
  136402. set useRampGradients(value: boolean);
  136403. /**
  136404. * Not supported by GPUParticleSystem
  136405. * @param gradient defines the gradient to use (between 0 and 1)
  136406. * @param factor defines the life time factor to affect to the specified gradient
  136407. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  136408. * @returns the current particle system
  136409. */
  136410. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  136411. /**
  136412. * Not supported by GPUParticleSystem
  136413. * @param gradient defines the gradient to remove
  136414. * @returns the current particle system
  136415. */
  136416. removeLifeTimeGradient(gradient: number): IParticleSystem;
  136417. /**
  136418. * Instantiates a GPU particle system.
  136419. * 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.
  136420. * @param name The name of the particle system
  136421. * @param options The options used to create the system
  136422. * @param scene The scene the particle system belongs to
  136423. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  136424. */
  136425. constructor(name: string, options: Partial<{
  136426. capacity: number;
  136427. randomTextureSize: number;
  136428. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  136429. protected _reset(): void;
  136430. private _createUpdateVAO;
  136431. private _createRenderVAO;
  136432. private _initialize;
  136433. /** @hidden */
  136434. _recreateUpdateEffect(): void;
  136435. /** @hidden */
  136436. _recreateRenderEffect(): void;
  136437. /**
  136438. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  136439. * @param preWarm defines if we are in the pre-warmimg phase
  136440. */
  136441. animate(preWarm?: boolean): void;
  136442. private _createFactorGradientTexture;
  136443. private _createSizeGradientTexture;
  136444. private _createAngularSpeedGradientTexture;
  136445. private _createVelocityGradientTexture;
  136446. private _createLimitVelocityGradientTexture;
  136447. private _createDragGradientTexture;
  136448. private _createColorGradientTexture;
  136449. /**
  136450. * Renders the particle system in its current state
  136451. * @param preWarm defines if the system should only update the particles but not render them
  136452. * @returns the current number of particles
  136453. */
  136454. render(preWarm?: boolean): number;
  136455. /**
  136456. * Rebuilds the particle system
  136457. */
  136458. rebuild(): void;
  136459. private _releaseBuffers;
  136460. private _releaseVAOs;
  136461. /**
  136462. * Disposes the particle system and free the associated resources
  136463. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  136464. */
  136465. dispose(disposeTexture?: boolean): void;
  136466. /**
  136467. * Clones the particle system.
  136468. * @param name The name of the cloned object
  136469. * @param newEmitter The new emitter to use
  136470. * @returns the cloned particle system
  136471. */
  136472. clone(name: string, newEmitter: any): GPUParticleSystem;
  136473. /**
  136474. * Serializes the particle system to a JSON object.
  136475. * @returns the JSON object
  136476. */
  136477. serialize(): any;
  136478. /**
  136479. * Parses a JSON object to create a GPU particle system.
  136480. * @param parsedParticleSystem The JSON object to parse
  136481. * @param scene The scene to create the particle system in
  136482. * @param rootUrl The root url to use to load external dependencies like texture
  136483. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  136484. * @returns the parsed GPU particle system
  136485. */
  136486. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  136487. }
  136488. }
  136489. declare module BABYLON {
  136490. /**
  136491. * Represents a set of particle systems working together to create a specific effect
  136492. */
  136493. export class ParticleSystemSet implements IDisposable {
  136494. /**
  136495. * Gets or sets base Assets URL
  136496. */
  136497. static BaseAssetsUrl: string;
  136498. private _emitterCreationOptions;
  136499. private _emitterNode;
  136500. /**
  136501. * Gets the particle system list
  136502. */
  136503. systems: IParticleSystem[];
  136504. /**
  136505. * Gets the emitter node used with this set
  136506. */
  136507. get emitterNode(): Nullable<TransformNode>;
  136508. /**
  136509. * Creates a new emitter mesh as a sphere
  136510. * @param options defines the options used to create the sphere
  136511. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  136512. * @param scene defines the hosting scene
  136513. */
  136514. setEmitterAsSphere(options: {
  136515. diameter: number;
  136516. segments: number;
  136517. color: Color3;
  136518. }, renderingGroupId: number, scene: Scene): void;
  136519. /**
  136520. * Starts all particle systems of the set
  136521. * @param emitter defines an optional mesh to use as emitter for the particle systems
  136522. */
  136523. start(emitter?: AbstractMesh): void;
  136524. /**
  136525. * Release all associated resources
  136526. */
  136527. dispose(): void;
  136528. /**
  136529. * Serialize the set into a JSON compatible object
  136530. * @returns a JSON compatible representation of the set
  136531. */
  136532. serialize(): any;
  136533. /**
  136534. * Parse a new ParticleSystemSet from a serialized source
  136535. * @param data defines a JSON compatible representation of the set
  136536. * @param scene defines the hosting scene
  136537. * @param gpu defines if we want GPU particles or CPU particles
  136538. * @returns a new ParticleSystemSet
  136539. */
  136540. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  136541. }
  136542. }
  136543. declare module BABYLON {
  136544. /**
  136545. * This class is made for on one-liner static method to help creating particle system set.
  136546. */
  136547. export class ParticleHelper {
  136548. /**
  136549. * Gets or sets base Assets URL
  136550. */
  136551. static BaseAssetsUrl: string;
  136552. /**
  136553. * Create a default particle system that you can tweak
  136554. * @param emitter defines the emitter to use
  136555. * @param capacity defines the system capacity (default is 500 particles)
  136556. * @param scene defines the hosting scene
  136557. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  136558. * @returns the new Particle system
  136559. */
  136560. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  136561. /**
  136562. * This is the main static method (one-liner) of this helper to create different particle systems
  136563. * @param type This string represents the type to the particle system to create
  136564. * @param scene The scene where the particle system should live
  136565. * @param gpu If the system will use gpu
  136566. * @returns the ParticleSystemSet created
  136567. */
  136568. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  136569. /**
  136570. * Static function used to export a particle system to a ParticleSystemSet variable.
  136571. * Please note that the emitter shape is not exported
  136572. * @param systems defines the particle systems to export
  136573. * @returns the created particle system set
  136574. */
  136575. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  136576. }
  136577. }
  136578. declare module BABYLON {
  136579. interface Engine {
  136580. /**
  136581. * Create an effect to use with particle systems.
  136582. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  136583. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  136584. * @param uniformsNames defines a list of attribute names
  136585. * @param samplers defines an array of string used to represent textures
  136586. * @param defines defines the string containing the defines to use to compile the shaders
  136587. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  136588. * @param onCompiled defines a function to call when the effect creation is successful
  136589. * @param onError defines a function to call when the effect creation has failed
  136590. * @returns the new Effect
  136591. */
  136592. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  136593. }
  136594. interface Mesh {
  136595. /**
  136596. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  136597. * @returns an array of IParticleSystem
  136598. */
  136599. getEmittedParticleSystems(): IParticleSystem[];
  136600. /**
  136601. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  136602. * @returns an array of IParticleSystem
  136603. */
  136604. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  136605. }
  136606. /**
  136607. * @hidden
  136608. */
  136609. export var _IDoNeedToBeInTheBuild: number;
  136610. }
  136611. declare module BABYLON {
  136612. /** Defines the 4 color options */
  136613. export enum PointColor {
  136614. /** color value */
  136615. Color = 2,
  136616. /** uv value */
  136617. UV = 1,
  136618. /** random value */
  136619. Random = 0,
  136620. /** stated value */
  136621. Stated = 3
  136622. }
  136623. /**
  136624. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  136625. * 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.
  136626. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  136627. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  136628. *
  136629. * Full documentation here : TO BE ENTERED
  136630. */
  136631. export class PointsCloudSystem implements IDisposable {
  136632. /**
  136633. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  136634. * Example : var p = SPS.particles[i];
  136635. */
  136636. particles: CloudPoint[];
  136637. /**
  136638. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  136639. */
  136640. nbParticles: number;
  136641. /**
  136642. * This a counter for your own usage. It's not set by any SPS functions.
  136643. */
  136644. counter: number;
  136645. /**
  136646. * The PCS name. This name is also given to the underlying mesh.
  136647. */
  136648. name: string;
  136649. /**
  136650. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  136651. */
  136652. mesh: Mesh;
  136653. /**
  136654. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  136655. * Please read :
  136656. */
  136657. vars: any;
  136658. /**
  136659. * @hidden
  136660. */
  136661. _size: number;
  136662. private _scene;
  136663. private _promises;
  136664. private _positions;
  136665. private _indices;
  136666. private _normals;
  136667. private _colors;
  136668. private _uvs;
  136669. private _indices32;
  136670. private _positions32;
  136671. private _colors32;
  136672. private _uvs32;
  136673. private _updatable;
  136674. private _isVisibilityBoxLocked;
  136675. private _alwaysVisible;
  136676. private _groups;
  136677. private _groupCounter;
  136678. private _computeParticleColor;
  136679. private _computeParticleTexture;
  136680. private _computeParticleRotation;
  136681. private _computeBoundingBox;
  136682. private _isReady;
  136683. /**
  136684. * Creates a PCS (Points Cloud System) object
  136685. * @param name (String) is the PCS name, this will be the underlying mesh name
  136686. * @param pointSize (number) is the size for each point
  136687. * @param scene (Scene) is the scene in which the PCS is added
  136688. * @param options defines the options of the PCS e.g.
  136689. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  136690. */
  136691. constructor(name: string, pointSize: number, scene: Scene, options?: {
  136692. updatable?: boolean;
  136693. });
  136694. /**
  136695. * Builds the PCS underlying mesh. Returns a standard Mesh.
  136696. * If no points were added to the PCS, the returned mesh is just a single point.
  136697. * @returns a promise for the created mesh
  136698. */
  136699. buildMeshAsync(): Promise<Mesh>;
  136700. /**
  136701. * @hidden
  136702. */
  136703. private _buildMesh;
  136704. private _addParticle;
  136705. private _randomUnitVector;
  136706. private _getColorIndicesForCoord;
  136707. private _setPointsColorOrUV;
  136708. private _colorFromTexture;
  136709. private _calculateDensity;
  136710. /**
  136711. * Adds points to the PCS in random positions within a unit sphere
  136712. * @param nb (positive integer) the number of particles to be created from this model
  136713. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  136714. * @returns the number of groups in the system
  136715. */
  136716. addPoints(nb: number, pointFunction?: any): number;
  136717. /**
  136718. * Adds points to the PCS from the surface of the model shape
  136719. * @param mesh is any Mesh object that will be used as a surface model for the points
  136720. * @param nb (positive integer) the number of particles to be created from this model
  136721. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  136722. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  136723. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  136724. * @returns the number of groups in the system
  136725. */
  136726. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  136727. /**
  136728. * Adds points to the PCS inside the model shape
  136729. * @param mesh is any Mesh object that will be used as a surface model for the points
  136730. * @param nb (positive integer) the number of particles to be created from this model
  136731. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  136732. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  136733. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  136734. * @returns the number of groups in the system
  136735. */
  136736. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  136737. /**
  136738. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  136739. * This method calls `updateParticle()` for each particle of the SPS.
  136740. * For an animated SPS, it is usually called within the render loop.
  136741. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  136742. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  136743. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  136744. * @returns the PCS.
  136745. */
  136746. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  136747. /**
  136748. * Disposes the PCS.
  136749. */
  136750. dispose(): void;
  136751. /**
  136752. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  136753. * doc :
  136754. * @returns the PCS.
  136755. */
  136756. refreshVisibleSize(): PointsCloudSystem;
  136757. /**
  136758. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  136759. * @param size the size (float) of the visibility box
  136760. * note : this doesn't lock the PCS mesh bounding box.
  136761. * doc :
  136762. */
  136763. setVisibilityBox(size: number): void;
  136764. /**
  136765. * Gets whether the PCS is always visible or not
  136766. * doc :
  136767. */
  136768. get isAlwaysVisible(): boolean;
  136769. /**
  136770. * Sets the PCS as always visible or not
  136771. * doc :
  136772. */
  136773. set isAlwaysVisible(val: boolean);
  136774. /**
  136775. * Tells to `setParticles()` to compute the particle rotations or not
  136776. * Default value : false. The PCS is faster when it's set to false
  136777. * Note : particle rotations are only applied to parent particles
  136778. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  136779. */
  136780. set computeParticleRotation(val: boolean);
  136781. /**
  136782. * Tells to `setParticles()` to compute the particle colors or not.
  136783. * Default value : true. The PCS is faster when it's set to false.
  136784. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  136785. */
  136786. set computeParticleColor(val: boolean);
  136787. set computeParticleTexture(val: boolean);
  136788. /**
  136789. * Gets if `setParticles()` computes the particle colors or not.
  136790. * Default value : false. The PCS is faster when it's set to false.
  136791. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  136792. */
  136793. get computeParticleColor(): boolean;
  136794. /**
  136795. * Gets if `setParticles()` computes the particle textures or not.
  136796. * Default value : false. The PCS is faster when it's set to false.
  136797. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  136798. */
  136799. get computeParticleTexture(): boolean;
  136800. /**
  136801. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  136802. */
  136803. set computeBoundingBox(val: boolean);
  136804. /**
  136805. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  136806. */
  136807. get computeBoundingBox(): boolean;
  136808. /**
  136809. * This function does nothing. It may be overwritten to set all the particle first values.
  136810. * The PCS doesn't call this function, you may have to call it by your own.
  136811. * doc :
  136812. */
  136813. initParticles(): void;
  136814. /**
  136815. * This function does nothing. It may be overwritten to recycle a particle
  136816. * The PCS doesn't call this function, you can to call it
  136817. * doc :
  136818. * @param particle The particle to recycle
  136819. * @returns the recycled particle
  136820. */
  136821. recycleParticle(particle: CloudPoint): CloudPoint;
  136822. /**
  136823. * Updates a particle : this function should be overwritten by the user.
  136824. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  136825. * doc :
  136826. * @example : just set a particle position or velocity and recycle conditions
  136827. * @param particle The particle to update
  136828. * @returns the updated particle
  136829. */
  136830. updateParticle(particle: CloudPoint): CloudPoint;
  136831. /**
  136832. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  136833. * This does nothing and may be overwritten by the user.
  136834. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  136835. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  136836. * @param update the boolean update value actually passed to setParticles()
  136837. */
  136838. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  136839. /**
  136840. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  136841. * This will be passed three parameters.
  136842. * This does nothing and may be overwritten by the user.
  136843. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  136844. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  136845. * @param update the boolean update value actually passed to setParticles()
  136846. */
  136847. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  136848. }
  136849. }
  136850. declare module BABYLON {
  136851. /**
  136852. * Represents one particle of a points cloud system.
  136853. */
  136854. export class CloudPoint {
  136855. /**
  136856. * particle global index
  136857. */
  136858. idx: number;
  136859. /**
  136860. * The color of the particle
  136861. */
  136862. color: Nullable<Color4>;
  136863. /**
  136864. * The world space position of the particle.
  136865. */
  136866. position: Vector3;
  136867. /**
  136868. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  136869. */
  136870. rotation: Vector3;
  136871. /**
  136872. * The world space rotation quaternion of the particle.
  136873. */
  136874. rotationQuaternion: Nullable<Quaternion>;
  136875. /**
  136876. * The uv of the particle.
  136877. */
  136878. uv: Nullable<Vector2>;
  136879. /**
  136880. * The current speed of the particle.
  136881. */
  136882. velocity: Vector3;
  136883. /**
  136884. * The pivot point in the particle local space.
  136885. */
  136886. pivot: Vector3;
  136887. /**
  136888. * Must the particle be translated from its pivot point in its local space ?
  136889. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  136890. * Default : false
  136891. */
  136892. translateFromPivot: boolean;
  136893. /**
  136894. * Index of this particle in the global "positions" array (Internal use)
  136895. * @hidden
  136896. */
  136897. _pos: number;
  136898. /**
  136899. * @hidden Index of this particle in the global "indices" array (Internal use)
  136900. */
  136901. _ind: number;
  136902. /**
  136903. * Group this particle belongs to
  136904. */
  136905. _group: PointsGroup;
  136906. /**
  136907. * Group id of this particle
  136908. */
  136909. groupId: number;
  136910. /**
  136911. * Index of the particle in its group id (Internal use)
  136912. */
  136913. idxInGroup: number;
  136914. /**
  136915. * @hidden Particle BoundingInfo object (Internal use)
  136916. */
  136917. _boundingInfo: BoundingInfo;
  136918. /**
  136919. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  136920. */
  136921. _pcs: PointsCloudSystem;
  136922. /**
  136923. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  136924. */
  136925. _stillInvisible: boolean;
  136926. /**
  136927. * @hidden Last computed particle rotation matrix
  136928. */
  136929. _rotationMatrix: number[];
  136930. /**
  136931. * Parent particle Id, if any.
  136932. * Default null.
  136933. */
  136934. parentId: Nullable<number>;
  136935. /**
  136936. * @hidden Internal global position in the PCS.
  136937. */
  136938. _globalPosition: Vector3;
  136939. /**
  136940. * Creates a Point Cloud object.
  136941. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  136942. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  136943. * @param group (PointsGroup) is the group the particle belongs to
  136944. * @param groupId (integer) is the group identifier in the PCS.
  136945. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  136946. * @param pcs defines the PCS it is associated to
  136947. */
  136948. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  136949. /**
  136950. * get point size
  136951. */
  136952. get size(): Vector3;
  136953. /**
  136954. * Set point size
  136955. */
  136956. set size(scale: Vector3);
  136957. /**
  136958. * Legacy support, changed quaternion to rotationQuaternion
  136959. */
  136960. get quaternion(): Nullable<Quaternion>;
  136961. /**
  136962. * Legacy support, changed quaternion to rotationQuaternion
  136963. */
  136964. set quaternion(q: Nullable<Quaternion>);
  136965. /**
  136966. * Returns a boolean. True if the particle intersects a mesh, else false
  136967. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  136968. * @param target is the object (point or mesh) what the intersection is computed against
  136969. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  136970. * @returns true if it intersects
  136971. */
  136972. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  136973. /**
  136974. * get the rotation matrix of the particle
  136975. * @hidden
  136976. */
  136977. getRotationMatrix(m: Matrix): void;
  136978. }
  136979. /**
  136980. * Represents a group of points in a points cloud system
  136981. * * PCS internal tool, don't use it manually.
  136982. */
  136983. export class PointsGroup {
  136984. /**
  136985. * The group id
  136986. * @hidden
  136987. */
  136988. groupID: number;
  136989. /**
  136990. * image data for group (internal use)
  136991. * @hidden
  136992. */
  136993. _groupImageData: Nullable<ArrayBufferView>;
  136994. /**
  136995. * Image Width (internal use)
  136996. * @hidden
  136997. */
  136998. _groupImgWidth: number;
  136999. /**
  137000. * Image Height (internal use)
  137001. * @hidden
  137002. */
  137003. _groupImgHeight: number;
  137004. /**
  137005. * Custom position function (internal use)
  137006. * @hidden
  137007. */
  137008. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  137009. /**
  137010. * density per facet for surface points
  137011. * @hidden
  137012. */
  137013. _groupDensity: number[];
  137014. /**
  137015. * Only when points are colored by texture carries pointer to texture list array
  137016. * @hidden
  137017. */
  137018. _textureNb: number;
  137019. /**
  137020. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  137021. * PCS internal tool, don't use it manually.
  137022. * @hidden
  137023. */
  137024. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  137025. }
  137026. }
  137027. declare module BABYLON {
  137028. interface Scene {
  137029. /** @hidden (Backing field) */
  137030. _physicsEngine: Nullable<IPhysicsEngine>;
  137031. /** @hidden */
  137032. _physicsTimeAccumulator: number;
  137033. /**
  137034. * Gets the current physics engine
  137035. * @returns a IPhysicsEngine or null if none attached
  137036. */
  137037. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  137038. /**
  137039. * Enables physics to the current scene
  137040. * @param gravity defines the scene's gravity for the physics engine
  137041. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  137042. * @return a boolean indicating if the physics engine was initialized
  137043. */
  137044. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  137045. /**
  137046. * Disables and disposes the physics engine associated with the scene
  137047. */
  137048. disablePhysicsEngine(): void;
  137049. /**
  137050. * Gets a boolean indicating if there is an active physics engine
  137051. * @returns a boolean indicating if there is an active physics engine
  137052. */
  137053. isPhysicsEnabled(): boolean;
  137054. /**
  137055. * Deletes a physics compound impostor
  137056. * @param compound defines the compound to delete
  137057. */
  137058. deleteCompoundImpostor(compound: any): void;
  137059. /**
  137060. * An event triggered when physic simulation is about to be run
  137061. */
  137062. onBeforePhysicsObservable: Observable<Scene>;
  137063. /**
  137064. * An event triggered when physic simulation has been done
  137065. */
  137066. onAfterPhysicsObservable: Observable<Scene>;
  137067. }
  137068. interface AbstractMesh {
  137069. /** @hidden */
  137070. _physicsImpostor: Nullable<PhysicsImpostor>;
  137071. /**
  137072. * Gets or sets impostor used for physic simulation
  137073. * @see http://doc.babylonjs.com/features/physics_engine
  137074. */
  137075. physicsImpostor: Nullable<PhysicsImpostor>;
  137076. /**
  137077. * Gets the current physics impostor
  137078. * @see http://doc.babylonjs.com/features/physics_engine
  137079. * @returns a physics impostor or null
  137080. */
  137081. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  137082. /** Apply a physic impulse to the mesh
  137083. * @param force defines the force to apply
  137084. * @param contactPoint defines where to apply the force
  137085. * @returns the current mesh
  137086. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  137087. */
  137088. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  137089. /**
  137090. * Creates a physic joint between two meshes
  137091. * @param otherMesh defines the other mesh to use
  137092. * @param pivot1 defines the pivot to use on this mesh
  137093. * @param pivot2 defines the pivot to use on the other mesh
  137094. * @param options defines additional options (can be plugin dependent)
  137095. * @returns the current mesh
  137096. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  137097. */
  137098. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  137099. /** @hidden */
  137100. _disposePhysicsObserver: Nullable<Observer<Node>>;
  137101. }
  137102. /**
  137103. * Defines the physics engine scene component responsible to manage a physics engine
  137104. */
  137105. export class PhysicsEngineSceneComponent implements ISceneComponent {
  137106. /**
  137107. * The component name helpful to identify the component in the list of scene components.
  137108. */
  137109. readonly name: string;
  137110. /**
  137111. * The scene the component belongs to.
  137112. */
  137113. scene: Scene;
  137114. /**
  137115. * Creates a new instance of the component for the given scene
  137116. * @param scene Defines the scene to register the component in
  137117. */
  137118. constructor(scene: Scene);
  137119. /**
  137120. * Registers the component in a given scene
  137121. */
  137122. register(): void;
  137123. /**
  137124. * Rebuilds the elements related to this component in case of
  137125. * context lost for instance.
  137126. */
  137127. rebuild(): void;
  137128. /**
  137129. * Disposes the component and the associated ressources
  137130. */
  137131. dispose(): void;
  137132. }
  137133. }
  137134. declare module BABYLON {
  137135. /**
  137136. * A helper for physics simulations
  137137. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137138. */
  137139. export class PhysicsHelper {
  137140. private _scene;
  137141. private _physicsEngine;
  137142. /**
  137143. * Initializes the Physics helper
  137144. * @param scene Babylon.js scene
  137145. */
  137146. constructor(scene: Scene);
  137147. /**
  137148. * Applies a radial explosion impulse
  137149. * @param origin the origin of the explosion
  137150. * @param radiusOrEventOptions the radius or the options of radial explosion
  137151. * @param strength the explosion strength
  137152. * @param falloff possible options: Constant & Linear. Defaults to Constant
  137153. * @returns A physics radial explosion event, or null
  137154. */
  137155. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  137156. /**
  137157. * Applies a radial explosion force
  137158. * @param origin the origin of the explosion
  137159. * @param radiusOrEventOptions the radius or the options of radial explosion
  137160. * @param strength the explosion strength
  137161. * @param falloff possible options: Constant & Linear. Defaults to Constant
  137162. * @returns A physics radial explosion event, or null
  137163. */
  137164. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  137165. /**
  137166. * Creates a gravitational field
  137167. * @param origin the origin of the explosion
  137168. * @param radiusOrEventOptions the radius or the options of radial explosion
  137169. * @param strength the explosion strength
  137170. * @param falloff possible options: Constant & Linear. Defaults to Constant
  137171. * @returns A physics gravitational field event, or null
  137172. */
  137173. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  137174. /**
  137175. * Creates a physics updraft event
  137176. * @param origin the origin of the updraft
  137177. * @param radiusOrEventOptions the radius or the options of the updraft
  137178. * @param strength the strength of the updraft
  137179. * @param height the height of the updraft
  137180. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  137181. * @returns A physics updraft event, or null
  137182. */
  137183. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  137184. /**
  137185. * Creates a physics vortex event
  137186. * @param origin the of the vortex
  137187. * @param radiusOrEventOptions the radius or the options of the vortex
  137188. * @param strength the strength of the vortex
  137189. * @param height the height of the vortex
  137190. * @returns a Physics vortex event, or null
  137191. * A physics vortex event or null
  137192. */
  137193. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  137194. }
  137195. /**
  137196. * Represents a physics radial explosion event
  137197. */
  137198. class PhysicsRadialExplosionEvent {
  137199. private _scene;
  137200. private _options;
  137201. private _sphere;
  137202. private _dataFetched;
  137203. /**
  137204. * Initializes a radial explosioin event
  137205. * @param _scene BabylonJS scene
  137206. * @param _options The options for the vortex event
  137207. */
  137208. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  137209. /**
  137210. * Returns the data related to the radial explosion event (sphere).
  137211. * @returns The radial explosion event data
  137212. */
  137213. getData(): PhysicsRadialExplosionEventData;
  137214. /**
  137215. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  137216. * @param impostor A physics imposter
  137217. * @param origin the origin of the explosion
  137218. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  137219. */
  137220. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  137221. /**
  137222. * Triggers affecterd impostors callbacks
  137223. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  137224. */
  137225. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  137226. /**
  137227. * Disposes the sphere.
  137228. * @param force Specifies if the sphere should be disposed by force
  137229. */
  137230. dispose(force?: boolean): void;
  137231. /*** Helpers ***/
  137232. private _prepareSphere;
  137233. private _intersectsWithSphere;
  137234. }
  137235. /**
  137236. * Represents a gravitational field event
  137237. */
  137238. class PhysicsGravitationalFieldEvent {
  137239. private _physicsHelper;
  137240. private _scene;
  137241. private _origin;
  137242. private _options;
  137243. private _tickCallback;
  137244. private _sphere;
  137245. private _dataFetched;
  137246. /**
  137247. * Initializes the physics gravitational field event
  137248. * @param _physicsHelper A physics helper
  137249. * @param _scene BabylonJS scene
  137250. * @param _origin The origin position of the gravitational field event
  137251. * @param _options The options for the vortex event
  137252. */
  137253. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  137254. /**
  137255. * Returns the data related to the gravitational field event (sphere).
  137256. * @returns A gravitational field event
  137257. */
  137258. getData(): PhysicsGravitationalFieldEventData;
  137259. /**
  137260. * Enables the gravitational field.
  137261. */
  137262. enable(): void;
  137263. /**
  137264. * Disables the gravitational field.
  137265. */
  137266. disable(): void;
  137267. /**
  137268. * Disposes the sphere.
  137269. * @param force The force to dispose from the gravitational field event
  137270. */
  137271. dispose(force?: boolean): void;
  137272. private _tick;
  137273. }
  137274. /**
  137275. * Represents a physics updraft event
  137276. */
  137277. class PhysicsUpdraftEvent {
  137278. private _scene;
  137279. private _origin;
  137280. private _options;
  137281. private _physicsEngine;
  137282. private _originTop;
  137283. private _originDirection;
  137284. private _tickCallback;
  137285. private _cylinder;
  137286. private _cylinderPosition;
  137287. private _dataFetched;
  137288. /**
  137289. * Initializes the physics updraft event
  137290. * @param _scene BabylonJS scene
  137291. * @param _origin The origin position of the updraft
  137292. * @param _options The options for the updraft event
  137293. */
  137294. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  137295. /**
  137296. * Returns the data related to the updraft event (cylinder).
  137297. * @returns A physics updraft event
  137298. */
  137299. getData(): PhysicsUpdraftEventData;
  137300. /**
  137301. * Enables the updraft.
  137302. */
  137303. enable(): void;
  137304. /**
  137305. * Disables the updraft.
  137306. */
  137307. disable(): void;
  137308. /**
  137309. * Disposes the cylinder.
  137310. * @param force Specifies if the updraft should be disposed by force
  137311. */
  137312. dispose(force?: boolean): void;
  137313. private getImpostorHitData;
  137314. private _tick;
  137315. /*** Helpers ***/
  137316. private _prepareCylinder;
  137317. private _intersectsWithCylinder;
  137318. }
  137319. /**
  137320. * Represents a physics vortex event
  137321. */
  137322. class PhysicsVortexEvent {
  137323. private _scene;
  137324. private _origin;
  137325. private _options;
  137326. private _physicsEngine;
  137327. private _originTop;
  137328. private _tickCallback;
  137329. private _cylinder;
  137330. private _cylinderPosition;
  137331. private _dataFetched;
  137332. /**
  137333. * Initializes the physics vortex event
  137334. * @param _scene The BabylonJS scene
  137335. * @param _origin The origin position of the vortex
  137336. * @param _options The options for the vortex event
  137337. */
  137338. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  137339. /**
  137340. * Returns the data related to the vortex event (cylinder).
  137341. * @returns The physics vortex event data
  137342. */
  137343. getData(): PhysicsVortexEventData;
  137344. /**
  137345. * Enables the vortex.
  137346. */
  137347. enable(): void;
  137348. /**
  137349. * Disables the cortex.
  137350. */
  137351. disable(): void;
  137352. /**
  137353. * Disposes the sphere.
  137354. * @param force
  137355. */
  137356. dispose(force?: boolean): void;
  137357. private getImpostorHitData;
  137358. private _tick;
  137359. /*** Helpers ***/
  137360. private _prepareCylinder;
  137361. private _intersectsWithCylinder;
  137362. }
  137363. /**
  137364. * Options fot the radial explosion event
  137365. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137366. */
  137367. export class PhysicsRadialExplosionEventOptions {
  137368. /**
  137369. * The radius of the sphere for the radial explosion.
  137370. */
  137371. radius: number;
  137372. /**
  137373. * The strenth of the explosion.
  137374. */
  137375. strength: number;
  137376. /**
  137377. * The strenght of the force in correspondence to the distance of the affected object
  137378. */
  137379. falloff: PhysicsRadialImpulseFalloff;
  137380. /**
  137381. * Sphere options for the radial explosion.
  137382. */
  137383. sphere: {
  137384. segments: number;
  137385. diameter: number;
  137386. };
  137387. /**
  137388. * Sphere options for the radial explosion.
  137389. */
  137390. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  137391. }
  137392. /**
  137393. * Options fot the updraft event
  137394. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137395. */
  137396. export class PhysicsUpdraftEventOptions {
  137397. /**
  137398. * The radius of the cylinder for the vortex
  137399. */
  137400. radius: number;
  137401. /**
  137402. * The strenth of the updraft.
  137403. */
  137404. strength: number;
  137405. /**
  137406. * The height of the cylinder for the updraft.
  137407. */
  137408. height: number;
  137409. /**
  137410. * The mode for the the updraft.
  137411. */
  137412. updraftMode: PhysicsUpdraftMode;
  137413. }
  137414. /**
  137415. * Options fot the vortex event
  137416. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137417. */
  137418. export class PhysicsVortexEventOptions {
  137419. /**
  137420. * The radius of the cylinder for the vortex
  137421. */
  137422. radius: number;
  137423. /**
  137424. * The strenth of the vortex.
  137425. */
  137426. strength: number;
  137427. /**
  137428. * The height of the cylinder for the vortex.
  137429. */
  137430. height: number;
  137431. /**
  137432. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  137433. */
  137434. centripetalForceThreshold: number;
  137435. /**
  137436. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  137437. */
  137438. centripetalForceMultiplier: number;
  137439. /**
  137440. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  137441. */
  137442. centrifugalForceMultiplier: number;
  137443. /**
  137444. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  137445. */
  137446. updraftForceMultiplier: number;
  137447. }
  137448. /**
  137449. * The strenght of the force in correspondence to the distance of the affected object
  137450. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137451. */
  137452. export enum PhysicsRadialImpulseFalloff {
  137453. /** Defines that impulse is constant in strength across it's whole radius */
  137454. Constant = 0,
  137455. /** Defines that impulse gets weaker if it's further from the origin */
  137456. Linear = 1
  137457. }
  137458. /**
  137459. * The strength of the force in correspondence to the distance of the affected object
  137460. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137461. */
  137462. export enum PhysicsUpdraftMode {
  137463. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  137464. Center = 0,
  137465. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  137466. Perpendicular = 1
  137467. }
  137468. /**
  137469. * Interface for a physics hit data
  137470. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137471. */
  137472. export interface PhysicsHitData {
  137473. /**
  137474. * The force applied at the contact point
  137475. */
  137476. force: Vector3;
  137477. /**
  137478. * The contact point
  137479. */
  137480. contactPoint: Vector3;
  137481. /**
  137482. * The distance from the origin to the contact point
  137483. */
  137484. distanceFromOrigin: number;
  137485. }
  137486. /**
  137487. * Interface for radial explosion event data
  137488. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137489. */
  137490. export interface PhysicsRadialExplosionEventData {
  137491. /**
  137492. * A sphere used for the radial explosion event
  137493. */
  137494. sphere: Mesh;
  137495. }
  137496. /**
  137497. * Interface for gravitational field event data
  137498. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137499. */
  137500. export interface PhysicsGravitationalFieldEventData {
  137501. /**
  137502. * A sphere mesh used for the gravitational field event
  137503. */
  137504. sphere: Mesh;
  137505. }
  137506. /**
  137507. * Interface for updraft event data
  137508. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137509. */
  137510. export interface PhysicsUpdraftEventData {
  137511. /**
  137512. * A cylinder used for the updraft event
  137513. */
  137514. cylinder: Mesh;
  137515. }
  137516. /**
  137517. * Interface for vortex event data
  137518. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137519. */
  137520. export interface PhysicsVortexEventData {
  137521. /**
  137522. * A cylinder used for the vortex event
  137523. */
  137524. cylinder: Mesh;
  137525. }
  137526. /**
  137527. * Interface for an affected physics impostor
  137528. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137529. */
  137530. export interface PhysicsAffectedImpostorWithData {
  137531. /**
  137532. * The impostor affected by the effect
  137533. */
  137534. impostor: PhysicsImpostor;
  137535. /**
  137536. * The data about the hit/horce from the explosion
  137537. */
  137538. hitData: PhysicsHitData;
  137539. }
  137540. }
  137541. declare module BABYLON {
  137542. /** @hidden */
  137543. export var blackAndWhitePixelShader: {
  137544. name: string;
  137545. shader: string;
  137546. };
  137547. }
  137548. declare module BABYLON {
  137549. /**
  137550. * Post process used to render in black and white
  137551. */
  137552. export class BlackAndWhitePostProcess extends PostProcess {
  137553. /**
  137554. * Linear about to convert he result to black and white (default: 1)
  137555. */
  137556. degree: number;
  137557. /**
  137558. * Creates a black and white post process
  137559. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  137560. * @param name The name of the effect.
  137561. * @param options The required width/height ratio to downsize to before computing the render pass.
  137562. * @param camera The camera to apply the render pass to.
  137563. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137564. * @param engine The engine which the post process will be applied. (default: current engine)
  137565. * @param reusable If the post process can be reused on the same frame. (default: false)
  137566. */
  137567. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137568. }
  137569. }
  137570. declare module BABYLON {
  137571. /**
  137572. * This represents a set of one or more post processes in Babylon.
  137573. * A post process can be used to apply a shader to a texture after it is rendered.
  137574. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137575. */
  137576. export class PostProcessRenderEffect {
  137577. private _postProcesses;
  137578. private _getPostProcesses;
  137579. private _singleInstance;
  137580. private _cameras;
  137581. private _indicesForCamera;
  137582. /**
  137583. * Name of the effect
  137584. * @hidden
  137585. */
  137586. _name: string;
  137587. /**
  137588. * Instantiates a post process render effect.
  137589. * A post process can be used to apply a shader to a texture after it is rendered.
  137590. * @param engine The engine the effect is tied to
  137591. * @param name The name of the effect
  137592. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  137593. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  137594. */
  137595. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  137596. /**
  137597. * Checks if all the post processes in the effect are supported.
  137598. */
  137599. get isSupported(): boolean;
  137600. /**
  137601. * Updates the current state of the effect
  137602. * @hidden
  137603. */
  137604. _update(): void;
  137605. /**
  137606. * Attaches the effect on cameras
  137607. * @param cameras The camera to attach to.
  137608. * @hidden
  137609. */
  137610. _attachCameras(cameras: Camera): void;
  137611. /**
  137612. * Attaches the effect on cameras
  137613. * @param cameras The camera to attach to.
  137614. * @hidden
  137615. */
  137616. _attachCameras(cameras: Camera[]): void;
  137617. /**
  137618. * Detaches the effect on cameras
  137619. * @param cameras The camera to detatch from.
  137620. * @hidden
  137621. */
  137622. _detachCameras(cameras: Camera): void;
  137623. /**
  137624. * Detatches the effect on cameras
  137625. * @param cameras The camera to detatch from.
  137626. * @hidden
  137627. */
  137628. _detachCameras(cameras: Camera[]): void;
  137629. /**
  137630. * Enables the effect on given cameras
  137631. * @param cameras The camera to enable.
  137632. * @hidden
  137633. */
  137634. _enable(cameras: Camera): void;
  137635. /**
  137636. * Enables the effect on given cameras
  137637. * @param cameras The camera to enable.
  137638. * @hidden
  137639. */
  137640. _enable(cameras: Nullable<Camera[]>): void;
  137641. /**
  137642. * Disables the effect on the given cameras
  137643. * @param cameras The camera to disable.
  137644. * @hidden
  137645. */
  137646. _disable(cameras: Camera): void;
  137647. /**
  137648. * Disables the effect on the given cameras
  137649. * @param cameras The camera to disable.
  137650. * @hidden
  137651. */
  137652. _disable(cameras: Nullable<Camera[]>): void;
  137653. /**
  137654. * Gets a list of the post processes contained in the effect.
  137655. * @param camera The camera to get the post processes on.
  137656. * @returns The list of the post processes in the effect.
  137657. */
  137658. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  137659. }
  137660. }
  137661. declare module BABYLON {
  137662. /** @hidden */
  137663. export var extractHighlightsPixelShader: {
  137664. name: string;
  137665. shader: string;
  137666. };
  137667. }
  137668. declare module BABYLON {
  137669. /**
  137670. * 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.
  137671. */
  137672. export class ExtractHighlightsPostProcess extends PostProcess {
  137673. /**
  137674. * The luminance threshold, pixels below this value will be set to black.
  137675. */
  137676. threshold: number;
  137677. /** @hidden */
  137678. _exposure: number;
  137679. /**
  137680. * Post process which has the input texture to be used when performing highlight extraction
  137681. * @hidden
  137682. */
  137683. _inputPostProcess: Nullable<PostProcess>;
  137684. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137685. }
  137686. }
  137687. declare module BABYLON {
  137688. /** @hidden */
  137689. export var bloomMergePixelShader: {
  137690. name: string;
  137691. shader: string;
  137692. };
  137693. }
  137694. declare module BABYLON {
  137695. /**
  137696. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  137697. */
  137698. export class BloomMergePostProcess extends PostProcess {
  137699. /** Weight of the bloom to be added to the original input. */
  137700. weight: number;
  137701. /**
  137702. * Creates a new instance of @see BloomMergePostProcess
  137703. * @param name The name of the effect.
  137704. * @param originalFromInput Post process which's input will be used for the merge.
  137705. * @param blurred Blurred highlights post process which's output will be used.
  137706. * @param weight Weight of the bloom to be added to the original input.
  137707. * @param options The required width/height ratio to downsize to before computing the render pass.
  137708. * @param camera The camera to apply the render pass to.
  137709. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137710. * @param engine The engine which the post process will be applied. (default: current engine)
  137711. * @param reusable If the post process can be reused on the same frame. (default: false)
  137712. * @param textureType Type of textures used when performing the post process. (default: 0)
  137713. * @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)
  137714. */
  137715. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  137716. /** Weight of the bloom to be added to the original input. */
  137717. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137718. }
  137719. }
  137720. declare module BABYLON {
  137721. /**
  137722. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  137723. */
  137724. export class BloomEffect extends PostProcessRenderEffect {
  137725. private bloomScale;
  137726. /**
  137727. * @hidden Internal
  137728. */
  137729. _effects: Array<PostProcess>;
  137730. /**
  137731. * @hidden Internal
  137732. */
  137733. _downscale: ExtractHighlightsPostProcess;
  137734. private _blurX;
  137735. private _blurY;
  137736. private _merge;
  137737. /**
  137738. * The luminance threshold to find bright areas of the image to bloom.
  137739. */
  137740. get threshold(): number;
  137741. set threshold(value: number);
  137742. /**
  137743. * The strength of the bloom.
  137744. */
  137745. get weight(): number;
  137746. set weight(value: number);
  137747. /**
  137748. * Specifies the size of the bloom blur kernel, relative to the final output size
  137749. */
  137750. get kernel(): number;
  137751. set kernel(value: number);
  137752. /**
  137753. * Creates a new instance of @see BloomEffect
  137754. * @param scene The scene the effect belongs to.
  137755. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  137756. * @param bloomKernel The size of the kernel to be used when applying the blur.
  137757. * @param bloomWeight The the strength of bloom.
  137758. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  137759. * @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)
  137760. */
  137761. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  137762. /**
  137763. * Disposes each of the internal effects for a given camera.
  137764. * @param camera The camera to dispose the effect on.
  137765. */
  137766. disposeEffects(camera: Camera): void;
  137767. /**
  137768. * @hidden Internal
  137769. */
  137770. _updateEffects(): void;
  137771. /**
  137772. * Internal
  137773. * @returns if all the contained post processes are ready.
  137774. * @hidden
  137775. */
  137776. _isReady(): boolean;
  137777. }
  137778. }
  137779. declare module BABYLON {
  137780. /** @hidden */
  137781. export var chromaticAberrationPixelShader: {
  137782. name: string;
  137783. shader: string;
  137784. };
  137785. }
  137786. declare module BABYLON {
  137787. /**
  137788. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  137789. */
  137790. export class ChromaticAberrationPostProcess extends PostProcess {
  137791. /**
  137792. * The amount of seperation of rgb channels (default: 30)
  137793. */
  137794. aberrationAmount: number;
  137795. /**
  137796. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  137797. */
  137798. radialIntensity: number;
  137799. /**
  137800. * 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))
  137801. */
  137802. direction: Vector2;
  137803. /**
  137804. * 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))
  137805. */
  137806. centerPosition: Vector2;
  137807. /**
  137808. * Creates a new instance ChromaticAberrationPostProcess
  137809. * @param name The name of the effect.
  137810. * @param screenWidth The width of the screen to apply the effect on.
  137811. * @param screenHeight The height of the screen to apply the effect on.
  137812. * @param options The required width/height ratio to downsize to before computing the render pass.
  137813. * @param camera The camera to apply the render pass to.
  137814. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137815. * @param engine The engine which the post process will be applied. (default: current engine)
  137816. * @param reusable If the post process can be reused on the same frame. (default: false)
  137817. * @param textureType Type of textures used when performing the post process. (default: 0)
  137818. * @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)
  137819. */
  137820. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137821. }
  137822. }
  137823. declare module BABYLON {
  137824. /** @hidden */
  137825. export var circleOfConfusionPixelShader: {
  137826. name: string;
  137827. shader: string;
  137828. };
  137829. }
  137830. declare module BABYLON {
  137831. /**
  137832. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  137833. */
  137834. export class CircleOfConfusionPostProcess extends PostProcess {
  137835. /**
  137836. * 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.
  137837. */
  137838. lensSize: number;
  137839. /**
  137840. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  137841. */
  137842. fStop: number;
  137843. /**
  137844. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  137845. */
  137846. focusDistance: number;
  137847. /**
  137848. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  137849. */
  137850. focalLength: number;
  137851. private _depthTexture;
  137852. /**
  137853. * Creates a new instance CircleOfConfusionPostProcess
  137854. * @param name The name of the effect.
  137855. * @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.
  137856. * @param options The required width/height ratio to downsize to before computing the render pass.
  137857. * @param camera The camera to apply the render pass to.
  137858. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137859. * @param engine The engine which the post process will be applied. (default: current engine)
  137860. * @param reusable If the post process can be reused on the same frame. (default: false)
  137861. * @param textureType Type of textures used when performing the post process. (default: 0)
  137862. * @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)
  137863. */
  137864. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137865. /**
  137866. * 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.
  137867. */
  137868. set depthTexture(value: RenderTargetTexture);
  137869. }
  137870. }
  137871. declare module BABYLON {
  137872. /** @hidden */
  137873. export var colorCorrectionPixelShader: {
  137874. name: string;
  137875. shader: string;
  137876. };
  137877. }
  137878. declare module BABYLON {
  137879. /**
  137880. *
  137881. * This post-process allows the modification of rendered colors by using
  137882. * a 'look-up table' (LUT). This effect is also called Color Grading.
  137883. *
  137884. * The object needs to be provided an url to a texture containing the color
  137885. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  137886. * Use an image editing software to tweak the LUT to match your needs.
  137887. *
  137888. * For an example of a color LUT, see here:
  137889. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  137890. * For explanations on color grading, see here:
  137891. * @see http://udn.epicgames.com/Three/ColorGrading.html
  137892. *
  137893. */
  137894. export class ColorCorrectionPostProcess extends PostProcess {
  137895. private _colorTableTexture;
  137896. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137897. }
  137898. }
  137899. declare module BABYLON {
  137900. /** @hidden */
  137901. export var convolutionPixelShader: {
  137902. name: string;
  137903. shader: string;
  137904. };
  137905. }
  137906. declare module BABYLON {
  137907. /**
  137908. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  137909. * input texture to perform effects such as edge detection or sharpening
  137910. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  137911. */
  137912. export class ConvolutionPostProcess extends PostProcess {
  137913. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  137914. kernel: number[];
  137915. /**
  137916. * Creates a new instance ConvolutionPostProcess
  137917. * @param name The name of the effect.
  137918. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  137919. * @param options The required width/height ratio to downsize to before computing the render pass.
  137920. * @param camera The camera to apply the render pass to.
  137921. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137922. * @param engine The engine which the post process will be applied. (default: current engine)
  137923. * @param reusable If the post process can be reused on the same frame. (default: false)
  137924. * @param textureType Type of textures used when performing the post process. (default: 0)
  137925. */
  137926. constructor(name: string,
  137927. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  137928. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137929. /**
  137930. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137931. */
  137932. static EdgeDetect0Kernel: number[];
  137933. /**
  137934. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137935. */
  137936. static EdgeDetect1Kernel: number[];
  137937. /**
  137938. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137939. */
  137940. static EdgeDetect2Kernel: number[];
  137941. /**
  137942. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137943. */
  137944. static SharpenKernel: number[];
  137945. /**
  137946. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137947. */
  137948. static EmbossKernel: number[];
  137949. /**
  137950. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137951. */
  137952. static GaussianKernel: number[];
  137953. }
  137954. }
  137955. declare module BABYLON {
  137956. /**
  137957. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  137958. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  137959. * based on samples that have a large difference in distance than the center pixel.
  137960. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  137961. */
  137962. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  137963. direction: Vector2;
  137964. /**
  137965. * Creates a new instance CircleOfConfusionPostProcess
  137966. * @param name The name of the effect.
  137967. * @param scene The scene the effect belongs to.
  137968. * @param direction The direction the blur should be applied.
  137969. * @param kernel The size of the kernel used to blur.
  137970. * @param options The required width/height ratio to downsize to before computing the render pass.
  137971. * @param camera The camera to apply the render pass to.
  137972. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  137973. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  137974. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137975. * @param engine The engine which the post process will be applied. (default: current engine)
  137976. * @param reusable If the post process can be reused on the same frame. (default: false)
  137977. * @param textureType Type of textures used when performing the post process. (default: 0)
  137978. * @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)
  137979. */
  137980. 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);
  137981. }
  137982. }
  137983. declare module BABYLON {
  137984. /** @hidden */
  137985. export var depthOfFieldMergePixelShader: {
  137986. name: string;
  137987. shader: string;
  137988. };
  137989. }
  137990. declare module BABYLON {
  137991. /**
  137992. * Options to be set when merging outputs from the default pipeline.
  137993. */
  137994. export class DepthOfFieldMergePostProcessOptions {
  137995. /**
  137996. * The original image to merge on top of
  137997. */
  137998. originalFromInput: PostProcess;
  137999. /**
  138000. * Parameters to perform the merge of the depth of field effect
  138001. */
  138002. depthOfField?: {
  138003. circleOfConfusion: PostProcess;
  138004. blurSteps: Array<PostProcess>;
  138005. };
  138006. /**
  138007. * Parameters to perform the merge of bloom effect
  138008. */
  138009. bloom?: {
  138010. blurred: PostProcess;
  138011. weight: number;
  138012. };
  138013. }
  138014. /**
  138015. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  138016. */
  138017. export class DepthOfFieldMergePostProcess extends PostProcess {
  138018. private blurSteps;
  138019. /**
  138020. * Creates a new instance of DepthOfFieldMergePostProcess
  138021. * @param name The name of the effect.
  138022. * @param originalFromInput Post process which's input will be used for the merge.
  138023. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  138024. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  138025. * @param options The required width/height ratio to downsize to before computing the render pass.
  138026. * @param camera The camera to apply the render pass to.
  138027. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138028. * @param engine The engine which the post process will be applied. (default: current engine)
  138029. * @param reusable If the post process can be reused on the same frame. (default: false)
  138030. * @param textureType Type of textures used when performing the post process. (default: 0)
  138031. * @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)
  138032. */
  138033. 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);
  138034. /**
  138035. * Updates the effect with the current post process compile time values and recompiles the shader.
  138036. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  138037. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  138038. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  138039. * @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
  138040. * @param onCompiled Called when the shader has been compiled.
  138041. * @param onError Called if there is an error when compiling a shader.
  138042. */
  138043. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  138044. }
  138045. }
  138046. declare module BABYLON {
  138047. /**
  138048. * Specifies the level of max blur that should be applied when using the depth of field effect
  138049. */
  138050. export enum DepthOfFieldEffectBlurLevel {
  138051. /**
  138052. * Subtle blur
  138053. */
  138054. Low = 0,
  138055. /**
  138056. * Medium blur
  138057. */
  138058. Medium = 1,
  138059. /**
  138060. * Large blur
  138061. */
  138062. High = 2
  138063. }
  138064. /**
  138065. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  138066. */
  138067. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  138068. private _circleOfConfusion;
  138069. /**
  138070. * @hidden Internal, blurs from high to low
  138071. */
  138072. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  138073. private _depthOfFieldBlurY;
  138074. private _dofMerge;
  138075. /**
  138076. * @hidden Internal post processes in depth of field effect
  138077. */
  138078. _effects: Array<PostProcess>;
  138079. /**
  138080. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  138081. */
  138082. set focalLength(value: number);
  138083. get focalLength(): number;
  138084. /**
  138085. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  138086. */
  138087. set fStop(value: number);
  138088. get fStop(): number;
  138089. /**
  138090. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  138091. */
  138092. set focusDistance(value: number);
  138093. get focusDistance(): number;
  138094. /**
  138095. * 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.
  138096. */
  138097. set lensSize(value: number);
  138098. get lensSize(): number;
  138099. /**
  138100. * Creates a new instance DepthOfFieldEffect
  138101. * @param scene The scene the effect belongs to.
  138102. * @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.
  138103. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  138104. * @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)
  138105. */
  138106. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  138107. /**
  138108. * Get the current class name of the current effet
  138109. * @returns "DepthOfFieldEffect"
  138110. */
  138111. getClassName(): string;
  138112. /**
  138113. * 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.
  138114. */
  138115. set depthTexture(value: RenderTargetTexture);
  138116. /**
  138117. * Disposes each of the internal effects for a given camera.
  138118. * @param camera The camera to dispose the effect on.
  138119. */
  138120. disposeEffects(camera: Camera): void;
  138121. /**
  138122. * @hidden Internal
  138123. */
  138124. _updateEffects(): void;
  138125. /**
  138126. * Internal
  138127. * @returns if all the contained post processes are ready.
  138128. * @hidden
  138129. */
  138130. _isReady(): boolean;
  138131. }
  138132. }
  138133. declare module BABYLON {
  138134. /** @hidden */
  138135. export var displayPassPixelShader: {
  138136. name: string;
  138137. shader: string;
  138138. };
  138139. }
  138140. declare module BABYLON {
  138141. /**
  138142. * DisplayPassPostProcess which produces an output the same as it's input
  138143. */
  138144. export class DisplayPassPostProcess extends PostProcess {
  138145. /**
  138146. * Creates the DisplayPassPostProcess
  138147. * @param name The name of the effect.
  138148. * @param options The required width/height ratio to downsize to before computing the render pass.
  138149. * @param camera The camera to apply the render pass to.
  138150. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138151. * @param engine The engine which the post process will be applied. (default: current engine)
  138152. * @param reusable If the post process can be reused on the same frame. (default: false)
  138153. */
  138154. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  138155. }
  138156. }
  138157. declare module BABYLON {
  138158. /** @hidden */
  138159. export var filterPixelShader: {
  138160. name: string;
  138161. shader: string;
  138162. };
  138163. }
  138164. declare module BABYLON {
  138165. /**
  138166. * Applies a kernel filter to the image
  138167. */
  138168. export class FilterPostProcess extends PostProcess {
  138169. /** The matrix to be applied to the image */
  138170. kernelMatrix: Matrix;
  138171. /**
  138172. *
  138173. * @param name The name of the effect.
  138174. * @param kernelMatrix The matrix to be applied to the image
  138175. * @param options The required width/height ratio to downsize to before computing the render pass.
  138176. * @param camera The camera to apply the render pass to.
  138177. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138178. * @param engine The engine which the post process will be applied. (default: current engine)
  138179. * @param reusable If the post process can be reused on the same frame. (default: false)
  138180. */
  138181. constructor(name: string,
  138182. /** The matrix to be applied to the image */
  138183. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  138184. }
  138185. }
  138186. declare module BABYLON {
  138187. /** @hidden */
  138188. export var fxaaPixelShader: {
  138189. name: string;
  138190. shader: string;
  138191. };
  138192. }
  138193. declare module BABYLON {
  138194. /** @hidden */
  138195. export var fxaaVertexShader: {
  138196. name: string;
  138197. shader: string;
  138198. };
  138199. }
  138200. declare module BABYLON {
  138201. /**
  138202. * Fxaa post process
  138203. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  138204. */
  138205. export class FxaaPostProcess extends PostProcess {
  138206. /** @hidden */
  138207. texelWidth: number;
  138208. /** @hidden */
  138209. texelHeight: number;
  138210. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  138211. private _getDefines;
  138212. }
  138213. }
  138214. declare module BABYLON {
  138215. /** @hidden */
  138216. export var grainPixelShader: {
  138217. name: string;
  138218. shader: string;
  138219. };
  138220. }
  138221. declare module BABYLON {
  138222. /**
  138223. * The GrainPostProcess adds noise to the image at mid luminance levels
  138224. */
  138225. export class GrainPostProcess extends PostProcess {
  138226. /**
  138227. * The intensity of the grain added (default: 30)
  138228. */
  138229. intensity: number;
  138230. /**
  138231. * If the grain should be randomized on every frame
  138232. */
  138233. animated: boolean;
  138234. /**
  138235. * Creates a new instance of @see GrainPostProcess
  138236. * @param name The name of the effect.
  138237. * @param options The required width/height ratio to downsize to before computing the render pass.
  138238. * @param camera The camera to apply the render pass to.
  138239. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138240. * @param engine The engine which the post process will be applied. (default: current engine)
  138241. * @param reusable If the post process can be reused on the same frame. (default: false)
  138242. * @param textureType Type of textures used when performing the post process. (default: 0)
  138243. * @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)
  138244. */
  138245. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138246. }
  138247. }
  138248. declare module BABYLON {
  138249. /** @hidden */
  138250. export var highlightsPixelShader: {
  138251. name: string;
  138252. shader: string;
  138253. };
  138254. }
  138255. declare module BABYLON {
  138256. /**
  138257. * Extracts highlights from the image
  138258. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  138259. */
  138260. export class HighlightsPostProcess extends PostProcess {
  138261. /**
  138262. * Extracts highlights from the image
  138263. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  138264. * @param name The name of the effect.
  138265. * @param options The required width/height ratio to downsize to before computing the render pass.
  138266. * @param camera The camera to apply the render pass to.
  138267. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138268. * @param engine The engine which the post process will be applied. (default: current engine)
  138269. * @param reusable If the post process can be reused on the same frame. (default: false)
  138270. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  138271. */
  138272. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  138273. }
  138274. }
  138275. declare module BABYLON {
  138276. /** @hidden */
  138277. export var mrtFragmentDeclaration: {
  138278. name: string;
  138279. shader: string;
  138280. };
  138281. }
  138282. declare module BABYLON {
  138283. /** @hidden */
  138284. export var geometryPixelShader: {
  138285. name: string;
  138286. shader: string;
  138287. };
  138288. }
  138289. declare module BABYLON {
  138290. /** @hidden */
  138291. export var geometryVertexShader: {
  138292. name: string;
  138293. shader: string;
  138294. };
  138295. }
  138296. declare module BABYLON {
  138297. /** @hidden */
  138298. interface ISavedTransformationMatrix {
  138299. world: Matrix;
  138300. viewProjection: Matrix;
  138301. }
  138302. /**
  138303. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  138304. */
  138305. export class GeometryBufferRenderer {
  138306. /**
  138307. * Constant used to retrieve the position texture index in the G-Buffer textures array
  138308. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  138309. */
  138310. static readonly POSITION_TEXTURE_TYPE: number;
  138311. /**
  138312. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  138313. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  138314. */
  138315. static readonly VELOCITY_TEXTURE_TYPE: number;
  138316. /**
  138317. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  138318. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  138319. */
  138320. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  138321. /**
  138322. * Dictionary used to store the previous transformation matrices of each rendered mesh
  138323. * in order to compute objects velocities when enableVelocity is set to "true"
  138324. * @hidden
  138325. */
  138326. _previousTransformationMatrices: {
  138327. [index: number]: ISavedTransformationMatrix;
  138328. };
  138329. /**
  138330. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  138331. * in order to compute objects velocities when enableVelocity is set to "true"
  138332. * @hidden
  138333. */
  138334. _previousBonesTransformationMatrices: {
  138335. [index: number]: Float32Array;
  138336. };
  138337. /**
  138338. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  138339. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  138340. */
  138341. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  138342. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  138343. renderTransparentMeshes: boolean;
  138344. private _scene;
  138345. private _multiRenderTarget;
  138346. private _ratio;
  138347. private _enablePosition;
  138348. private _enableVelocity;
  138349. private _enableReflectivity;
  138350. private _positionIndex;
  138351. private _velocityIndex;
  138352. private _reflectivityIndex;
  138353. protected _effect: Effect;
  138354. protected _cachedDefines: string;
  138355. /**
  138356. * Set the render list (meshes to be rendered) used in the G buffer.
  138357. */
  138358. set renderList(meshes: Mesh[]);
  138359. /**
  138360. * Gets wether or not G buffer are supported by the running hardware.
  138361. * This requires draw buffer supports
  138362. */
  138363. get isSupported(): boolean;
  138364. /**
  138365. * Returns the index of the given texture type in the G-Buffer textures array
  138366. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  138367. * @returns the index of the given texture type in the G-Buffer textures array
  138368. */
  138369. getTextureIndex(textureType: number): number;
  138370. /**
  138371. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  138372. */
  138373. get enablePosition(): boolean;
  138374. /**
  138375. * Sets whether or not objects positions are enabled for the G buffer.
  138376. */
  138377. set enablePosition(enable: boolean);
  138378. /**
  138379. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  138380. */
  138381. get enableVelocity(): boolean;
  138382. /**
  138383. * Sets wether or not objects velocities are enabled for the G buffer.
  138384. */
  138385. set enableVelocity(enable: boolean);
  138386. /**
  138387. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  138388. */
  138389. get enableReflectivity(): boolean;
  138390. /**
  138391. * Sets wether or not objects roughness are enabled for the G buffer.
  138392. */
  138393. set enableReflectivity(enable: boolean);
  138394. /**
  138395. * Gets the scene associated with the buffer.
  138396. */
  138397. get scene(): Scene;
  138398. /**
  138399. * Gets the ratio used by the buffer during its creation.
  138400. * How big is the buffer related to the main canvas.
  138401. */
  138402. get ratio(): number;
  138403. /** @hidden */
  138404. static _SceneComponentInitialization: (scene: Scene) => void;
  138405. /**
  138406. * Creates a new G Buffer for the scene
  138407. * @param scene The scene the buffer belongs to
  138408. * @param ratio How big is the buffer related to the main canvas.
  138409. */
  138410. constructor(scene: Scene, ratio?: number);
  138411. /**
  138412. * Checks wether everything is ready to render a submesh to the G buffer.
  138413. * @param subMesh the submesh to check readiness for
  138414. * @param useInstances is the mesh drawn using instance or not
  138415. * @returns true if ready otherwise false
  138416. */
  138417. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  138418. /**
  138419. * Gets the current underlying G Buffer.
  138420. * @returns the buffer
  138421. */
  138422. getGBuffer(): MultiRenderTarget;
  138423. /**
  138424. * Gets the number of samples used to render the buffer (anti aliasing).
  138425. */
  138426. get samples(): number;
  138427. /**
  138428. * Sets the number of samples used to render the buffer (anti aliasing).
  138429. */
  138430. set samples(value: number);
  138431. /**
  138432. * Disposes the renderer and frees up associated resources.
  138433. */
  138434. dispose(): void;
  138435. protected _createRenderTargets(): void;
  138436. private _copyBonesTransformationMatrices;
  138437. }
  138438. }
  138439. declare module BABYLON {
  138440. interface Scene {
  138441. /** @hidden (Backing field) */
  138442. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  138443. /**
  138444. * Gets or Sets the current geometry buffer associated to the scene.
  138445. */
  138446. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  138447. /**
  138448. * Enables a GeometryBufferRender and associates it with the scene
  138449. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  138450. * @returns the GeometryBufferRenderer
  138451. */
  138452. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  138453. /**
  138454. * Disables the GeometryBufferRender associated with the scene
  138455. */
  138456. disableGeometryBufferRenderer(): void;
  138457. }
  138458. /**
  138459. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  138460. * in several rendering techniques.
  138461. */
  138462. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  138463. /**
  138464. * The component name helpful to identify the component in the list of scene components.
  138465. */
  138466. readonly name: string;
  138467. /**
  138468. * The scene the component belongs to.
  138469. */
  138470. scene: Scene;
  138471. /**
  138472. * Creates a new instance of the component for the given scene
  138473. * @param scene Defines the scene to register the component in
  138474. */
  138475. constructor(scene: Scene);
  138476. /**
  138477. * Registers the component in a given scene
  138478. */
  138479. register(): void;
  138480. /**
  138481. * Rebuilds the elements related to this component in case of
  138482. * context lost for instance.
  138483. */
  138484. rebuild(): void;
  138485. /**
  138486. * Disposes the component and the associated ressources
  138487. */
  138488. dispose(): void;
  138489. private _gatherRenderTargets;
  138490. }
  138491. }
  138492. declare module BABYLON {
  138493. /** @hidden */
  138494. export var motionBlurPixelShader: {
  138495. name: string;
  138496. shader: string;
  138497. };
  138498. }
  138499. declare module BABYLON {
  138500. /**
  138501. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  138502. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  138503. * As an example, all you have to do is to create the post-process:
  138504. * var mb = new BABYLON.MotionBlurPostProcess(
  138505. * 'mb', // The name of the effect.
  138506. * scene, // The scene containing the objects to blur according to their velocity.
  138507. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  138508. * camera // The camera to apply the render pass to.
  138509. * );
  138510. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  138511. */
  138512. export class MotionBlurPostProcess extends PostProcess {
  138513. /**
  138514. * Defines how much the image is blurred by the movement. Default value is equal to 1
  138515. */
  138516. motionStrength: number;
  138517. /**
  138518. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  138519. */
  138520. get motionBlurSamples(): number;
  138521. /**
  138522. * Sets the number of iterations to be used for motion blur quality
  138523. */
  138524. set motionBlurSamples(samples: number);
  138525. private _motionBlurSamples;
  138526. private _geometryBufferRenderer;
  138527. /**
  138528. * Creates a new instance MotionBlurPostProcess
  138529. * @param name The name of the effect.
  138530. * @param scene The scene containing the objects to blur according to their velocity.
  138531. * @param options The required width/height ratio to downsize to before computing the render pass.
  138532. * @param camera The camera to apply the render pass to.
  138533. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138534. * @param engine The engine which the post process will be applied. (default: current engine)
  138535. * @param reusable If the post process can be reused on the same frame. (default: false)
  138536. * @param textureType Type of textures used when performing the post process. (default: 0)
  138537. * @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)
  138538. */
  138539. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138540. /**
  138541. * Excludes the given skinned mesh from computing bones velocities.
  138542. * 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.
  138543. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  138544. */
  138545. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  138546. /**
  138547. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  138548. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  138549. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  138550. */
  138551. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  138552. /**
  138553. * Disposes the post process.
  138554. * @param camera The camera to dispose the post process on.
  138555. */
  138556. dispose(camera?: Camera): void;
  138557. }
  138558. }
  138559. declare module BABYLON {
  138560. /** @hidden */
  138561. export var refractionPixelShader: {
  138562. name: string;
  138563. shader: string;
  138564. };
  138565. }
  138566. declare module BABYLON {
  138567. /**
  138568. * Post process which applies a refractin texture
  138569. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  138570. */
  138571. export class RefractionPostProcess extends PostProcess {
  138572. /** the base color of the refraction (used to taint the rendering) */
  138573. color: Color3;
  138574. /** simulated refraction depth */
  138575. depth: number;
  138576. /** the coefficient of the base color (0 to remove base color tainting) */
  138577. colorLevel: number;
  138578. private _refTexture;
  138579. private _ownRefractionTexture;
  138580. /**
  138581. * Gets or sets the refraction texture
  138582. * Please note that you are responsible for disposing the texture if you set it manually
  138583. */
  138584. get refractionTexture(): Texture;
  138585. set refractionTexture(value: Texture);
  138586. /**
  138587. * Initializes the RefractionPostProcess
  138588. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  138589. * @param name The name of the effect.
  138590. * @param refractionTextureUrl Url of the refraction texture to use
  138591. * @param color the base color of the refraction (used to taint the rendering)
  138592. * @param depth simulated refraction depth
  138593. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  138594. * @param camera The camera to apply the render pass to.
  138595. * @param options The required width/height ratio to downsize to before computing the render pass.
  138596. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138597. * @param engine The engine which the post process will be applied. (default: current engine)
  138598. * @param reusable If the post process can be reused on the same frame. (default: false)
  138599. */
  138600. constructor(name: string, refractionTextureUrl: string,
  138601. /** the base color of the refraction (used to taint the rendering) */
  138602. color: Color3,
  138603. /** simulated refraction depth */
  138604. depth: number,
  138605. /** the coefficient of the base color (0 to remove base color tainting) */
  138606. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  138607. /**
  138608. * Disposes of the post process
  138609. * @param camera Camera to dispose post process on
  138610. */
  138611. dispose(camera: Camera): void;
  138612. }
  138613. }
  138614. declare module BABYLON {
  138615. /** @hidden */
  138616. export var sharpenPixelShader: {
  138617. name: string;
  138618. shader: string;
  138619. };
  138620. }
  138621. declare module BABYLON {
  138622. /**
  138623. * The SharpenPostProcess applies a sharpen kernel to every pixel
  138624. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  138625. */
  138626. export class SharpenPostProcess extends PostProcess {
  138627. /**
  138628. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  138629. */
  138630. colorAmount: number;
  138631. /**
  138632. * How much sharpness should be applied (default: 0.3)
  138633. */
  138634. edgeAmount: number;
  138635. /**
  138636. * Creates a new instance ConvolutionPostProcess
  138637. * @param name The name of the effect.
  138638. * @param options The required width/height ratio to downsize to before computing the render pass.
  138639. * @param camera The camera to apply the render pass to.
  138640. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138641. * @param engine The engine which the post process will be applied. (default: current engine)
  138642. * @param reusable If the post process can be reused on the same frame. (default: false)
  138643. * @param textureType Type of textures used when performing the post process. (default: 0)
  138644. * @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)
  138645. */
  138646. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138647. }
  138648. }
  138649. declare module BABYLON {
  138650. /**
  138651. * PostProcessRenderPipeline
  138652. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138653. */
  138654. export class PostProcessRenderPipeline {
  138655. private engine;
  138656. private _renderEffects;
  138657. private _renderEffectsForIsolatedPass;
  138658. /**
  138659. * List of inspectable custom properties (used by the Inspector)
  138660. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  138661. */
  138662. inspectableCustomProperties: IInspectable[];
  138663. /**
  138664. * @hidden
  138665. */
  138666. protected _cameras: Camera[];
  138667. /** @hidden */
  138668. _name: string;
  138669. /**
  138670. * Gets pipeline name
  138671. */
  138672. get name(): string;
  138673. /** Gets the list of attached cameras */
  138674. get cameras(): Camera[];
  138675. /**
  138676. * Initializes a PostProcessRenderPipeline
  138677. * @param engine engine to add the pipeline to
  138678. * @param name name of the pipeline
  138679. */
  138680. constructor(engine: Engine, name: string);
  138681. /**
  138682. * Gets the class name
  138683. * @returns "PostProcessRenderPipeline"
  138684. */
  138685. getClassName(): string;
  138686. /**
  138687. * If all the render effects in the pipeline are supported
  138688. */
  138689. get isSupported(): boolean;
  138690. /**
  138691. * Adds an effect to the pipeline
  138692. * @param renderEffect the effect to add
  138693. */
  138694. addEffect(renderEffect: PostProcessRenderEffect): void;
  138695. /** @hidden */
  138696. _rebuild(): void;
  138697. /** @hidden */
  138698. _enableEffect(renderEffectName: string, cameras: Camera): void;
  138699. /** @hidden */
  138700. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  138701. /** @hidden */
  138702. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  138703. /** @hidden */
  138704. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  138705. /** @hidden */
  138706. _attachCameras(cameras: Camera, unique: boolean): void;
  138707. /** @hidden */
  138708. _attachCameras(cameras: Camera[], unique: boolean): void;
  138709. /** @hidden */
  138710. _detachCameras(cameras: Camera): void;
  138711. /** @hidden */
  138712. _detachCameras(cameras: Nullable<Camera[]>): void;
  138713. /** @hidden */
  138714. _update(): void;
  138715. /** @hidden */
  138716. _reset(): void;
  138717. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  138718. /**
  138719. * Disposes of the pipeline
  138720. */
  138721. dispose(): void;
  138722. }
  138723. }
  138724. declare module BABYLON {
  138725. /**
  138726. * PostProcessRenderPipelineManager class
  138727. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138728. */
  138729. export class PostProcessRenderPipelineManager {
  138730. private _renderPipelines;
  138731. /**
  138732. * Initializes a PostProcessRenderPipelineManager
  138733. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138734. */
  138735. constructor();
  138736. /**
  138737. * Gets the list of supported render pipelines
  138738. */
  138739. get supportedPipelines(): PostProcessRenderPipeline[];
  138740. /**
  138741. * Adds a pipeline to the manager
  138742. * @param renderPipeline The pipeline to add
  138743. */
  138744. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  138745. /**
  138746. * Attaches a camera to the pipeline
  138747. * @param renderPipelineName The name of the pipeline to attach to
  138748. * @param cameras the camera to attach
  138749. * @param unique if the camera can be attached multiple times to the pipeline
  138750. */
  138751. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  138752. /**
  138753. * Detaches a camera from the pipeline
  138754. * @param renderPipelineName The name of the pipeline to detach from
  138755. * @param cameras the camera to detach
  138756. */
  138757. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  138758. /**
  138759. * Enables an effect by name on a pipeline
  138760. * @param renderPipelineName the name of the pipeline to enable the effect in
  138761. * @param renderEffectName the name of the effect to enable
  138762. * @param cameras the cameras that the effect should be enabled on
  138763. */
  138764. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  138765. /**
  138766. * Disables an effect by name on a pipeline
  138767. * @param renderPipelineName the name of the pipeline to disable the effect in
  138768. * @param renderEffectName the name of the effect to disable
  138769. * @param cameras the cameras that the effect should be disabled on
  138770. */
  138771. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  138772. /**
  138773. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  138774. */
  138775. update(): void;
  138776. /** @hidden */
  138777. _rebuild(): void;
  138778. /**
  138779. * Disposes of the manager and pipelines
  138780. */
  138781. dispose(): void;
  138782. }
  138783. }
  138784. declare module BABYLON {
  138785. interface Scene {
  138786. /** @hidden (Backing field) */
  138787. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  138788. /**
  138789. * Gets the postprocess render pipeline manager
  138790. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138791. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  138792. */
  138793. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  138794. }
  138795. /**
  138796. * Defines the Render Pipeline scene component responsible to rendering pipelines
  138797. */
  138798. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  138799. /**
  138800. * The component name helpfull to identify the component in the list of scene components.
  138801. */
  138802. readonly name: string;
  138803. /**
  138804. * The scene the component belongs to.
  138805. */
  138806. scene: Scene;
  138807. /**
  138808. * Creates a new instance of the component for the given scene
  138809. * @param scene Defines the scene to register the component in
  138810. */
  138811. constructor(scene: Scene);
  138812. /**
  138813. * Registers the component in a given scene
  138814. */
  138815. register(): void;
  138816. /**
  138817. * Rebuilds the elements related to this component in case of
  138818. * context lost for instance.
  138819. */
  138820. rebuild(): void;
  138821. /**
  138822. * Disposes the component and the associated ressources
  138823. */
  138824. dispose(): void;
  138825. private _gatherRenderTargets;
  138826. }
  138827. }
  138828. declare module BABYLON {
  138829. /**
  138830. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  138831. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  138832. */
  138833. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  138834. private _scene;
  138835. private _camerasToBeAttached;
  138836. /**
  138837. * ID of the sharpen post process,
  138838. */
  138839. private readonly SharpenPostProcessId;
  138840. /**
  138841. * @ignore
  138842. * ID of the image processing post process;
  138843. */
  138844. readonly ImageProcessingPostProcessId: string;
  138845. /**
  138846. * @ignore
  138847. * ID of the Fast Approximate Anti-Aliasing post process;
  138848. */
  138849. readonly FxaaPostProcessId: string;
  138850. /**
  138851. * ID of the chromatic aberration post process,
  138852. */
  138853. private readonly ChromaticAberrationPostProcessId;
  138854. /**
  138855. * ID of the grain post process
  138856. */
  138857. private readonly GrainPostProcessId;
  138858. /**
  138859. * Sharpen post process which will apply a sharpen convolution to enhance edges
  138860. */
  138861. sharpen: SharpenPostProcess;
  138862. private _sharpenEffect;
  138863. private bloom;
  138864. /**
  138865. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  138866. */
  138867. depthOfField: DepthOfFieldEffect;
  138868. /**
  138869. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  138870. */
  138871. fxaa: FxaaPostProcess;
  138872. /**
  138873. * Image post processing pass used to perform operations such as tone mapping or color grading.
  138874. */
  138875. imageProcessing: ImageProcessingPostProcess;
  138876. /**
  138877. * Chromatic aberration post process which will shift rgb colors in the image
  138878. */
  138879. chromaticAberration: ChromaticAberrationPostProcess;
  138880. private _chromaticAberrationEffect;
  138881. /**
  138882. * Grain post process which add noise to the image
  138883. */
  138884. grain: GrainPostProcess;
  138885. private _grainEffect;
  138886. /**
  138887. * Glow post process which adds a glow to emissive areas of the image
  138888. */
  138889. private _glowLayer;
  138890. /**
  138891. * Animations which can be used to tweak settings over a period of time
  138892. */
  138893. animations: Animation[];
  138894. private _imageProcessingConfigurationObserver;
  138895. private _sharpenEnabled;
  138896. private _bloomEnabled;
  138897. private _depthOfFieldEnabled;
  138898. private _depthOfFieldBlurLevel;
  138899. private _fxaaEnabled;
  138900. private _imageProcessingEnabled;
  138901. private _defaultPipelineTextureType;
  138902. private _bloomScale;
  138903. private _chromaticAberrationEnabled;
  138904. private _grainEnabled;
  138905. private _buildAllowed;
  138906. /**
  138907. * Gets active scene
  138908. */
  138909. get scene(): Scene;
  138910. /**
  138911. * Enable or disable the sharpen process from the pipeline
  138912. */
  138913. set sharpenEnabled(enabled: boolean);
  138914. get sharpenEnabled(): boolean;
  138915. private _resizeObserver;
  138916. private _hardwareScaleLevel;
  138917. private _bloomKernel;
  138918. /**
  138919. * Specifies the size of the bloom blur kernel, relative to the final output size
  138920. */
  138921. get bloomKernel(): number;
  138922. set bloomKernel(value: number);
  138923. /**
  138924. * Specifies the weight of the bloom in the final rendering
  138925. */
  138926. private _bloomWeight;
  138927. /**
  138928. * Specifies the luma threshold for the area that will be blurred by the bloom
  138929. */
  138930. private _bloomThreshold;
  138931. private _hdr;
  138932. /**
  138933. * The strength of the bloom.
  138934. */
  138935. set bloomWeight(value: number);
  138936. get bloomWeight(): number;
  138937. /**
  138938. * The strength of the bloom.
  138939. */
  138940. set bloomThreshold(value: number);
  138941. get bloomThreshold(): number;
  138942. /**
  138943. * The scale of the bloom, lower value will provide better performance.
  138944. */
  138945. set bloomScale(value: number);
  138946. get bloomScale(): number;
  138947. /**
  138948. * Enable or disable the bloom from the pipeline
  138949. */
  138950. set bloomEnabled(enabled: boolean);
  138951. get bloomEnabled(): boolean;
  138952. private _rebuildBloom;
  138953. /**
  138954. * If the depth of field is enabled.
  138955. */
  138956. get depthOfFieldEnabled(): boolean;
  138957. set depthOfFieldEnabled(enabled: boolean);
  138958. /**
  138959. * Blur level of the depth of field effect. (Higher blur will effect performance)
  138960. */
  138961. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  138962. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  138963. /**
  138964. * If the anti aliasing is enabled.
  138965. */
  138966. set fxaaEnabled(enabled: boolean);
  138967. get fxaaEnabled(): boolean;
  138968. private _samples;
  138969. /**
  138970. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  138971. */
  138972. set samples(sampleCount: number);
  138973. get samples(): number;
  138974. /**
  138975. * If image processing is enabled.
  138976. */
  138977. set imageProcessingEnabled(enabled: boolean);
  138978. get imageProcessingEnabled(): boolean;
  138979. /**
  138980. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  138981. */
  138982. set glowLayerEnabled(enabled: boolean);
  138983. get glowLayerEnabled(): boolean;
  138984. /**
  138985. * Gets the glow layer (or null if not defined)
  138986. */
  138987. get glowLayer(): Nullable<GlowLayer>;
  138988. /**
  138989. * Enable or disable the chromaticAberration process from the pipeline
  138990. */
  138991. set chromaticAberrationEnabled(enabled: boolean);
  138992. get chromaticAberrationEnabled(): boolean;
  138993. /**
  138994. * Enable or disable the grain process from the pipeline
  138995. */
  138996. set grainEnabled(enabled: boolean);
  138997. get grainEnabled(): boolean;
  138998. /**
  138999. * @constructor
  139000. * @param name - The rendering pipeline name (default: "")
  139001. * @param hdr - If high dynamic range textures should be used (default: true)
  139002. * @param scene - The scene linked to this pipeline (default: the last created scene)
  139003. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  139004. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  139005. */
  139006. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  139007. /**
  139008. * Get the class name
  139009. * @returns "DefaultRenderingPipeline"
  139010. */
  139011. getClassName(): string;
  139012. /**
  139013. * Force the compilation of the entire pipeline.
  139014. */
  139015. prepare(): void;
  139016. private _hasCleared;
  139017. private _prevPostProcess;
  139018. private _prevPrevPostProcess;
  139019. private _setAutoClearAndTextureSharing;
  139020. private _depthOfFieldSceneObserver;
  139021. private _buildPipeline;
  139022. private _disposePostProcesses;
  139023. /**
  139024. * Adds a camera to the pipeline
  139025. * @param camera the camera to be added
  139026. */
  139027. addCamera(camera: Camera): void;
  139028. /**
  139029. * Removes a camera from the pipeline
  139030. * @param camera the camera to remove
  139031. */
  139032. removeCamera(camera: Camera): void;
  139033. /**
  139034. * Dispose of the pipeline and stop all post processes
  139035. */
  139036. dispose(): void;
  139037. /**
  139038. * Serialize the rendering pipeline (Used when exporting)
  139039. * @returns the serialized object
  139040. */
  139041. serialize(): any;
  139042. /**
  139043. * Parse the serialized pipeline
  139044. * @param source Source pipeline.
  139045. * @param scene The scene to load the pipeline to.
  139046. * @param rootUrl The URL of the serialized pipeline.
  139047. * @returns An instantiated pipeline from the serialized object.
  139048. */
  139049. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  139050. }
  139051. }
  139052. declare module BABYLON {
  139053. /** @hidden */
  139054. export var lensHighlightsPixelShader: {
  139055. name: string;
  139056. shader: string;
  139057. };
  139058. }
  139059. declare module BABYLON {
  139060. /** @hidden */
  139061. export var depthOfFieldPixelShader: {
  139062. name: string;
  139063. shader: string;
  139064. };
  139065. }
  139066. declare module BABYLON {
  139067. /**
  139068. * BABYLON.JS Chromatic Aberration GLSL Shader
  139069. * Author: Olivier Guyot
  139070. * Separates very slightly R, G and B colors on the edges of the screen
  139071. * Inspired by Francois Tarlier & Martins Upitis
  139072. */
  139073. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  139074. /**
  139075. * @ignore
  139076. * The chromatic aberration PostProcess id in the pipeline
  139077. */
  139078. LensChromaticAberrationEffect: string;
  139079. /**
  139080. * @ignore
  139081. * The highlights enhancing PostProcess id in the pipeline
  139082. */
  139083. HighlightsEnhancingEffect: string;
  139084. /**
  139085. * @ignore
  139086. * The depth-of-field PostProcess id in the pipeline
  139087. */
  139088. LensDepthOfFieldEffect: string;
  139089. private _scene;
  139090. private _depthTexture;
  139091. private _grainTexture;
  139092. private _chromaticAberrationPostProcess;
  139093. private _highlightsPostProcess;
  139094. private _depthOfFieldPostProcess;
  139095. private _edgeBlur;
  139096. private _grainAmount;
  139097. private _chromaticAberration;
  139098. private _distortion;
  139099. private _highlightsGain;
  139100. private _highlightsThreshold;
  139101. private _dofDistance;
  139102. private _dofAperture;
  139103. private _dofDarken;
  139104. private _dofPentagon;
  139105. private _blurNoise;
  139106. /**
  139107. * @constructor
  139108. *
  139109. * Effect parameters are as follow:
  139110. * {
  139111. * chromatic_aberration: number; // from 0 to x (1 for realism)
  139112. * edge_blur: number; // from 0 to x (1 for realism)
  139113. * distortion: number; // from 0 to x (1 for realism)
  139114. * grain_amount: number; // from 0 to 1
  139115. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  139116. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  139117. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  139118. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  139119. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  139120. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  139121. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  139122. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  139123. * }
  139124. * Note: if an effect parameter is unset, effect is disabled
  139125. *
  139126. * @param name The rendering pipeline name
  139127. * @param parameters - An object containing all parameters (see above)
  139128. * @param scene The scene linked to this pipeline
  139129. * @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)
  139130. * @param cameras The array of cameras that the rendering pipeline will be attached to
  139131. */
  139132. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  139133. /**
  139134. * Get the class name
  139135. * @returns "LensRenderingPipeline"
  139136. */
  139137. getClassName(): string;
  139138. /**
  139139. * Gets associated scene
  139140. */
  139141. get scene(): Scene;
  139142. /**
  139143. * Gets or sets the edge blur
  139144. */
  139145. get edgeBlur(): number;
  139146. set edgeBlur(value: number);
  139147. /**
  139148. * Gets or sets the grain amount
  139149. */
  139150. get grainAmount(): number;
  139151. set grainAmount(value: number);
  139152. /**
  139153. * Gets or sets the chromatic aberration amount
  139154. */
  139155. get chromaticAberration(): number;
  139156. set chromaticAberration(value: number);
  139157. /**
  139158. * Gets or sets the depth of field aperture
  139159. */
  139160. get dofAperture(): number;
  139161. set dofAperture(value: number);
  139162. /**
  139163. * Gets or sets the edge distortion
  139164. */
  139165. get edgeDistortion(): number;
  139166. set edgeDistortion(value: number);
  139167. /**
  139168. * Gets or sets the depth of field distortion
  139169. */
  139170. get dofDistortion(): number;
  139171. set dofDistortion(value: number);
  139172. /**
  139173. * Gets or sets the darken out of focus amount
  139174. */
  139175. get darkenOutOfFocus(): number;
  139176. set darkenOutOfFocus(value: number);
  139177. /**
  139178. * Gets or sets a boolean indicating if blur noise is enabled
  139179. */
  139180. get blurNoise(): boolean;
  139181. set blurNoise(value: boolean);
  139182. /**
  139183. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  139184. */
  139185. get pentagonBokeh(): boolean;
  139186. set pentagonBokeh(value: boolean);
  139187. /**
  139188. * Gets or sets the highlight grain amount
  139189. */
  139190. get highlightsGain(): number;
  139191. set highlightsGain(value: number);
  139192. /**
  139193. * Gets or sets the highlight threshold
  139194. */
  139195. get highlightsThreshold(): number;
  139196. set highlightsThreshold(value: number);
  139197. /**
  139198. * Sets the amount of blur at the edges
  139199. * @param amount blur amount
  139200. */
  139201. setEdgeBlur(amount: number): void;
  139202. /**
  139203. * Sets edge blur to 0
  139204. */
  139205. disableEdgeBlur(): void;
  139206. /**
  139207. * Sets the amout of grain
  139208. * @param amount Amount of grain
  139209. */
  139210. setGrainAmount(amount: number): void;
  139211. /**
  139212. * Set grain amount to 0
  139213. */
  139214. disableGrain(): void;
  139215. /**
  139216. * Sets the chromatic aberration amount
  139217. * @param amount amount of chromatic aberration
  139218. */
  139219. setChromaticAberration(amount: number): void;
  139220. /**
  139221. * Sets chromatic aberration amount to 0
  139222. */
  139223. disableChromaticAberration(): void;
  139224. /**
  139225. * Sets the EdgeDistortion amount
  139226. * @param amount amount of EdgeDistortion
  139227. */
  139228. setEdgeDistortion(amount: number): void;
  139229. /**
  139230. * Sets edge distortion to 0
  139231. */
  139232. disableEdgeDistortion(): void;
  139233. /**
  139234. * Sets the FocusDistance amount
  139235. * @param amount amount of FocusDistance
  139236. */
  139237. setFocusDistance(amount: number): void;
  139238. /**
  139239. * Disables depth of field
  139240. */
  139241. disableDepthOfField(): void;
  139242. /**
  139243. * Sets the Aperture amount
  139244. * @param amount amount of Aperture
  139245. */
  139246. setAperture(amount: number): void;
  139247. /**
  139248. * Sets the DarkenOutOfFocus amount
  139249. * @param amount amount of DarkenOutOfFocus
  139250. */
  139251. setDarkenOutOfFocus(amount: number): void;
  139252. private _pentagonBokehIsEnabled;
  139253. /**
  139254. * Creates a pentagon bokeh effect
  139255. */
  139256. enablePentagonBokeh(): void;
  139257. /**
  139258. * Disables the pentagon bokeh effect
  139259. */
  139260. disablePentagonBokeh(): void;
  139261. /**
  139262. * Enables noise blur
  139263. */
  139264. enableNoiseBlur(): void;
  139265. /**
  139266. * Disables noise blur
  139267. */
  139268. disableNoiseBlur(): void;
  139269. /**
  139270. * Sets the HighlightsGain amount
  139271. * @param amount amount of HighlightsGain
  139272. */
  139273. setHighlightsGain(amount: number): void;
  139274. /**
  139275. * Sets the HighlightsThreshold amount
  139276. * @param amount amount of HighlightsThreshold
  139277. */
  139278. setHighlightsThreshold(amount: number): void;
  139279. /**
  139280. * Disables highlights
  139281. */
  139282. disableHighlights(): void;
  139283. /**
  139284. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  139285. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  139286. */
  139287. dispose(disableDepthRender?: boolean): void;
  139288. private _createChromaticAberrationPostProcess;
  139289. private _createHighlightsPostProcess;
  139290. private _createDepthOfFieldPostProcess;
  139291. private _createGrainTexture;
  139292. }
  139293. }
  139294. declare module BABYLON {
  139295. /** @hidden */
  139296. export var ssao2PixelShader: {
  139297. name: string;
  139298. shader: string;
  139299. };
  139300. }
  139301. declare module BABYLON {
  139302. /** @hidden */
  139303. export var ssaoCombinePixelShader: {
  139304. name: string;
  139305. shader: string;
  139306. };
  139307. }
  139308. declare module BABYLON {
  139309. /**
  139310. * Render pipeline to produce ssao effect
  139311. */
  139312. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  139313. /**
  139314. * @ignore
  139315. * The PassPostProcess id in the pipeline that contains the original scene color
  139316. */
  139317. SSAOOriginalSceneColorEffect: string;
  139318. /**
  139319. * @ignore
  139320. * The SSAO PostProcess id in the pipeline
  139321. */
  139322. SSAORenderEffect: string;
  139323. /**
  139324. * @ignore
  139325. * The horizontal blur PostProcess id in the pipeline
  139326. */
  139327. SSAOBlurHRenderEffect: string;
  139328. /**
  139329. * @ignore
  139330. * The vertical blur PostProcess id in the pipeline
  139331. */
  139332. SSAOBlurVRenderEffect: string;
  139333. /**
  139334. * @ignore
  139335. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  139336. */
  139337. SSAOCombineRenderEffect: string;
  139338. /**
  139339. * The output strength of the SSAO post-process. Default value is 1.0.
  139340. */
  139341. totalStrength: number;
  139342. /**
  139343. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  139344. */
  139345. maxZ: number;
  139346. /**
  139347. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  139348. */
  139349. minZAspect: number;
  139350. private _samples;
  139351. /**
  139352. * Number of samples used for the SSAO calculations. Default value is 8
  139353. */
  139354. set samples(n: number);
  139355. get samples(): number;
  139356. private _textureSamples;
  139357. /**
  139358. * Number of samples to use for antialiasing
  139359. */
  139360. set textureSamples(n: number);
  139361. get textureSamples(): number;
  139362. /**
  139363. * Ratio object used for SSAO ratio and blur ratio
  139364. */
  139365. private _ratio;
  139366. /**
  139367. * Dynamically generated sphere sampler.
  139368. */
  139369. private _sampleSphere;
  139370. /**
  139371. * Blur filter offsets
  139372. */
  139373. private _samplerOffsets;
  139374. private _expensiveBlur;
  139375. /**
  139376. * If bilateral blur should be used
  139377. */
  139378. set expensiveBlur(b: boolean);
  139379. get expensiveBlur(): boolean;
  139380. /**
  139381. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  139382. */
  139383. radius: number;
  139384. /**
  139385. * The base color of the SSAO post-process
  139386. * The final result is "base + ssao" between [0, 1]
  139387. */
  139388. base: number;
  139389. /**
  139390. * Support test.
  139391. */
  139392. static get IsSupported(): boolean;
  139393. private _scene;
  139394. private _depthTexture;
  139395. private _normalTexture;
  139396. private _randomTexture;
  139397. private _originalColorPostProcess;
  139398. private _ssaoPostProcess;
  139399. private _blurHPostProcess;
  139400. private _blurVPostProcess;
  139401. private _ssaoCombinePostProcess;
  139402. /**
  139403. * Gets active scene
  139404. */
  139405. get scene(): Scene;
  139406. /**
  139407. * @constructor
  139408. * @param name The rendering pipeline name
  139409. * @param scene The scene linked to this pipeline
  139410. * @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 }
  139411. * @param cameras The array of cameras that the rendering pipeline will be attached to
  139412. */
  139413. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  139414. /**
  139415. * Get the class name
  139416. * @returns "SSAO2RenderingPipeline"
  139417. */
  139418. getClassName(): string;
  139419. /**
  139420. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  139421. */
  139422. dispose(disableGeometryBufferRenderer?: boolean): void;
  139423. private _createBlurPostProcess;
  139424. /** @hidden */
  139425. _rebuild(): void;
  139426. private _bits;
  139427. private _radicalInverse_VdC;
  139428. private _hammersley;
  139429. private _hemisphereSample_uniform;
  139430. private _generateHemisphere;
  139431. private _createSSAOPostProcess;
  139432. private _createSSAOCombinePostProcess;
  139433. private _createRandomTexture;
  139434. /**
  139435. * Serialize the rendering pipeline (Used when exporting)
  139436. * @returns the serialized object
  139437. */
  139438. serialize(): any;
  139439. /**
  139440. * Parse the serialized pipeline
  139441. * @param source Source pipeline.
  139442. * @param scene The scene to load the pipeline to.
  139443. * @param rootUrl The URL of the serialized pipeline.
  139444. * @returns An instantiated pipeline from the serialized object.
  139445. */
  139446. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  139447. }
  139448. }
  139449. declare module BABYLON {
  139450. /** @hidden */
  139451. export var ssaoPixelShader: {
  139452. name: string;
  139453. shader: string;
  139454. };
  139455. }
  139456. declare module BABYLON {
  139457. /**
  139458. * Render pipeline to produce ssao effect
  139459. */
  139460. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  139461. /**
  139462. * @ignore
  139463. * The PassPostProcess id in the pipeline that contains the original scene color
  139464. */
  139465. SSAOOriginalSceneColorEffect: string;
  139466. /**
  139467. * @ignore
  139468. * The SSAO PostProcess id in the pipeline
  139469. */
  139470. SSAORenderEffect: string;
  139471. /**
  139472. * @ignore
  139473. * The horizontal blur PostProcess id in the pipeline
  139474. */
  139475. SSAOBlurHRenderEffect: string;
  139476. /**
  139477. * @ignore
  139478. * The vertical blur PostProcess id in the pipeline
  139479. */
  139480. SSAOBlurVRenderEffect: string;
  139481. /**
  139482. * @ignore
  139483. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  139484. */
  139485. SSAOCombineRenderEffect: string;
  139486. /**
  139487. * The output strength of the SSAO post-process. Default value is 1.0.
  139488. */
  139489. totalStrength: number;
  139490. /**
  139491. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  139492. */
  139493. radius: number;
  139494. /**
  139495. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  139496. * Must not be equal to fallOff and superior to fallOff.
  139497. * Default value is 0.0075
  139498. */
  139499. area: number;
  139500. /**
  139501. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  139502. * Must not be equal to area and inferior to area.
  139503. * Default value is 0.000001
  139504. */
  139505. fallOff: number;
  139506. /**
  139507. * The base color of the SSAO post-process
  139508. * The final result is "base + ssao" between [0, 1]
  139509. */
  139510. base: number;
  139511. private _scene;
  139512. private _depthTexture;
  139513. private _randomTexture;
  139514. private _originalColorPostProcess;
  139515. private _ssaoPostProcess;
  139516. private _blurHPostProcess;
  139517. private _blurVPostProcess;
  139518. private _ssaoCombinePostProcess;
  139519. private _firstUpdate;
  139520. /**
  139521. * Gets active scene
  139522. */
  139523. get scene(): Scene;
  139524. /**
  139525. * @constructor
  139526. * @param name - The rendering pipeline name
  139527. * @param scene - The scene linked to this pipeline
  139528. * @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 }
  139529. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  139530. */
  139531. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  139532. /**
  139533. * Get the class name
  139534. * @returns "SSAORenderingPipeline"
  139535. */
  139536. getClassName(): string;
  139537. /**
  139538. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  139539. */
  139540. dispose(disableDepthRender?: boolean): void;
  139541. private _createBlurPostProcess;
  139542. /** @hidden */
  139543. _rebuild(): void;
  139544. private _createSSAOPostProcess;
  139545. private _createSSAOCombinePostProcess;
  139546. private _createRandomTexture;
  139547. }
  139548. }
  139549. declare module BABYLON {
  139550. /** @hidden */
  139551. export var screenSpaceReflectionPixelShader: {
  139552. name: string;
  139553. shader: string;
  139554. };
  139555. }
  139556. declare module BABYLON {
  139557. /**
  139558. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  139559. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  139560. */
  139561. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  139562. /**
  139563. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  139564. */
  139565. threshold: number;
  139566. /**
  139567. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  139568. */
  139569. strength: number;
  139570. /**
  139571. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  139572. */
  139573. reflectionSpecularFalloffExponent: number;
  139574. /**
  139575. * 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]
  139576. */
  139577. step: number;
  139578. /**
  139579. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  139580. */
  139581. roughnessFactor: number;
  139582. private _geometryBufferRenderer;
  139583. private _enableSmoothReflections;
  139584. private _reflectionSamples;
  139585. private _smoothSteps;
  139586. /**
  139587. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  139588. * @param name The name of the effect.
  139589. * @param scene The scene containing the objects to calculate reflections.
  139590. * @param options The required width/height ratio to downsize to before computing the render pass.
  139591. * @param camera The camera to apply the render pass to.
  139592. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139593. * @param engine The engine which the post process will be applied. (default: current engine)
  139594. * @param reusable If the post process can be reused on the same frame. (default: false)
  139595. * @param textureType Type of textures used when performing the post process. (default: 0)
  139596. * @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)
  139597. */
  139598. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139599. /**
  139600. * Gets wether or not smoothing reflections is enabled.
  139601. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  139602. */
  139603. get enableSmoothReflections(): boolean;
  139604. /**
  139605. * Sets wether or not smoothing reflections is enabled.
  139606. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  139607. */
  139608. set enableSmoothReflections(enabled: boolean);
  139609. /**
  139610. * Gets the number of samples taken while computing reflections. More samples count is high,
  139611. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  139612. */
  139613. get reflectionSamples(): number;
  139614. /**
  139615. * Sets the number of samples taken while computing reflections. More samples count is high,
  139616. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  139617. */
  139618. set reflectionSamples(samples: number);
  139619. /**
  139620. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  139621. * more the post-process will require GPU power and can generate a drop in FPS.
  139622. * Default value (5.0) work pretty well in all cases but can be adjusted.
  139623. */
  139624. get smoothSteps(): number;
  139625. set smoothSteps(steps: number);
  139626. private _updateEffectDefines;
  139627. }
  139628. }
  139629. declare module BABYLON {
  139630. /** @hidden */
  139631. export var standardPixelShader: {
  139632. name: string;
  139633. shader: string;
  139634. };
  139635. }
  139636. declare module BABYLON {
  139637. /**
  139638. * Standard rendering pipeline
  139639. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  139640. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  139641. */
  139642. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  139643. /**
  139644. * Public members
  139645. */
  139646. /**
  139647. * Post-process which contains the original scene color before the pipeline applies all the effects
  139648. */
  139649. originalPostProcess: Nullable<PostProcess>;
  139650. /**
  139651. * Post-process used to down scale an image x4
  139652. */
  139653. downSampleX4PostProcess: Nullable<PostProcess>;
  139654. /**
  139655. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  139656. */
  139657. brightPassPostProcess: Nullable<PostProcess>;
  139658. /**
  139659. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  139660. */
  139661. blurHPostProcesses: PostProcess[];
  139662. /**
  139663. * Post-process array storing all the vertical blur post-processes used by the pipeline
  139664. */
  139665. blurVPostProcesses: PostProcess[];
  139666. /**
  139667. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  139668. */
  139669. textureAdderPostProcess: Nullable<PostProcess>;
  139670. /**
  139671. * Post-process used to create volumetric lighting effect
  139672. */
  139673. volumetricLightPostProcess: Nullable<PostProcess>;
  139674. /**
  139675. * Post-process used to smooth the previous volumetric light post-process on the X axis
  139676. */
  139677. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  139678. /**
  139679. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  139680. */
  139681. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  139682. /**
  139683. * Post-process used to merge the volumetric light effect and the real scene color
  139684. */
  139685. volumetricLightMergePostProces: Nullable<PostProcess>;
  139686. /**
  139687. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  139688. */
  139689. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  139690. /**
  139691. * Base post-process used to calculate the average luminance of the final image for HDR
  139692. */
  139693. luminancePostProcess: Nullable<PostProcess>;
  139694. /**
  139695. * Post-processes used to create down sample post-processes in order to get
  139696. * the average luminance of the final image for HDR
  139697. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  139698. */
  139699. luminanceDownSamplePostProcesses: PostProcess[];
  139700. /**
  139701. * Post-process used to create a HDR effect (light adaptation)
  139702. */
  139703. hdrPostProcess: Nullable<PostProcess>;
  139704. /**
  139705. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  139706. */
  139707. textureAdderFinalPostProcess: Nullable<PostProcess>;
  139708. /**
  139709. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  139710. */
  139711. lensFlareFinalPostProcess: Nullable<PostProcess>;
  139712. /**
  139713. * Post-process used to merge the final HDR post-process and the real scene color
  139714. */
  139715. hdrFinalPostProcess: Nullable<PostProcess>;
  139716. /**
  139717. * Post-process used to create a lens flare effect
  139718. */
  139719. lensFlarePostProcess: Nullable<PostProcess>;
  139720. /**
  139721. * Post-process that merges the result of the lens flare post-process and the real scene color
  139722. */
  139723. lensFlareComposePostProcess: Nullable<PostProcess>;
  139724. /**
  139725. * Post-process used to create a motion blur effect
  139726. */
  139727. motionBlurPostProcess: Nullable<PostProcess>;
  139728. /**
  139729. * Post-process used to create a depth of field effect
  139730. */
  139731. depthOfFieldPostProcess: Nullable<PostProcess>;
  139732. /**
  139733. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  139734. */
  139735. fxaaPostProcess: Nullable<FxaaPostProcess>;
  139736. /**
  139737. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  139738. */
  139739. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  139740. /**
  139741. * Represents the brightness threshold in order to configure the illuminated surfaces
  139742. */
  139743. brightThreshold: number;
  139744. /**
  139745. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  139746. */
  139747. blurWidth: number;
  139748. /**
  139749. * Sets if the blur for highlighted surfaces must be only horizontal
  139750. */
  139751. horizontalBlur: boolean;
  139752. /**
  139753. * Gets the overall exposure used by the pipeline
  139754. */
  139755. get exposure(): number;
  139756. /**
  139757. * Sets the overall exposure used by the pipeline
  139758. */
  139759. set exposure(value: number);
  139760. /**
  139761. * Texture used typically to simulate "dirty" on camera lens
  139762. */
  139763. lensTexture: Nullable<Texture>;
  139764. /**
  139765. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  139766. */
  139767. volumetricLightCoefficient: number;
  139768. /**
  139769. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  139770. */
  139771. volumetricLightPower: number;
  139772. /**
  139773. * Used the set the blur intensity to smooth the volumetric lights
  139774. */
  139775. volumetricLightBlurScale: number;
  139776. /**
  139777. * Light (spot or directional) used to generate the volumetric lights rays
  139778. * The source light must have a shadow generate so the pipeline can get its
  139779. * depth map
  139780. */
  139781. sourceLight: Nullable<SpotLight | DirectionalLight>;
  139782. /**
  139783. * For eye adaptation, represents the minimum luminance the eye can see
  139784. */
  139785. hdrMinimumLuminance: number;
  139786. /**
  139787. * For eye adaptation, represents the decrease luminance speed
  139788. */
  139789. hdrDecreaseRate: number;
  139790. /**
  139791. * For eye adaptation, represents the increase luminance speed
  139792. */
  139793. hdrIncreaseRate: number;
  139794. /**
  139795. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  139796. */
  139797. get hdrAutoExposure(): boolean;
  139798. /**
  139799. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  139800. */
  139801. set hdrAutoExposure(value: boolean);
  139802. /**
  139803. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  139804. */
  139805. lensColorTexture: Nullable<Texture>;
  139806. /**
  139807. * The overall strengh for the lens flare effect
  139808. */
  139809. lensFlareStrength: number;
  139810. /**
  139811. * Dispersion coefficient for lens flare ghosts
  139812. */
  139813. lensFlareGhostDispersal: number;
  139814. /**
  139815. * Main lens flare halo width
  139816. */
  139817. lensFlareHaloWidth: number;
  139818. /**
  139819. * Based on the lens distortion effect, defines how much the lens flare result
  139820. * is distorted
  139821. */
  139822. lensFlareDistortionStrength: number;
  139823. /**
  139824. * Configures the blur intensity used for for lens flare (halo)
  139825. */
  139826. lensFlareBlurWidth: number;
  139827. /**
  139828. * Lens star texture must be used to simulate rays on the flares and is available
  139829. * in the documentation
  139830. */
  139831. lensStarTexture: Nullable<Texture>;
  139832. /**
  139833. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  139834. * flare effect by taking account of the dirt texture
  139835. */
  139836. lensFlareDirtTexture: Nullable<Texture>;
  139837. /**
  139838. * Represents the focal length for the depth of field effect
  139839. */
  139840. depthOfFieldDistance: number;
  139841. /**
  139842. * Represents the blur intensity for the blurred part of the depth of field effect
  139843. */
  139844. depthOfFieldBlurWidth: number;
  139845. /**
  139846. * Gets how much the image is blurred by the movement while using the motion blur post-process
  139847. */
  139848. get motionStrength(): number;
  139849. /**
  139850. * Sets how much the image is blurred by the movement while using the motion blur post-process
  139851. */
  139852. set motionStrength(strength: number);
  139853. /**
  139854. * Gets wether or not the motion blur post-process is object based or screen based.
  139855. */
  139856. get objectBasedMotionBlur(): boolean;
  139857. /**
  139858. * Sets wether or not the motion blur post-process should be object based or screen based
  139859. */
  139860. set objectBasedMotionBlur(value: boolean);
  139861. /**
  139862. * List of animations for the pipeline (IAnimatable implementation)
  139863. */
  139864. animations: Animation[];
  139865. /**
  139866. * Private members
  139867. */
  139868. private _scene;
  139869. private _currentDepthOfFieldSource;
  139870. private _basePostProcess;
  139871. private _fixedExposure;
  139872. private _currentExposure;
  139873. private _hdrAutoExposure;
  139874. private _hdrCurrentLuminance;
  139875. private _motionStrength;
  139876. private _isObjectBasedMotionBlur;
  139877. private _floatTextureType;
  139878. private _camerasToBeAttached;
  139879. private _ratio;
  139880. private _bloomEnabled;
  139881. private _depthOfFieldEnabled;
  139882. private _vlsEnabled;
  139883. private _lensFlareEnabled;
  139884. private _hdrEnabled;
  139885. private _motionBlurEnabled;
  139886. private _fxaaEnabled;
  139887. private _screenSpaceReflectionsEnabled;
  139888. private _motionBlurSamples;
  139889. private _volumetricLightStepsCount;
  139890. private _samples;
  139891. /**
  139892. * @ignore
  139893. * Specifies if the bloom pipeline is enabled
  139894. */
  139895. get BloomEnabled(): boolean;
  139896. set BloomEnabled(enabled: boolean);
  139897. /**
  139898. * @ignore
  139899. * Specifies if the depth of field pipeline is enabed
  139900. */
  139901. get DepthOfFieldEnabled(): boolean;
  139902. set DepthOfFieldEnabled(enabled: boolean);
  139903. /**
  139904. * @ignore
  139905. * Specifies if the lens flare pipeline is enabed
  139906. */
  139907. get LensFlareEnabled(): boolean;
  139908. set LensFlareEnabled(enabled: boolean);
  139909. /**
  139910. * @ignore
  139911. * Specifies if the HDR pipeline is enabled
  139912. */
  139913. get HDREnabled(): boolean;
  139914. set HDREnabled(enabled: boolean);
  139915. /**
  139916. * @ignore
  139917. * Specifies if the volumetric lights scattering effect is enabled
  139918. */
  139919. get VLSEnabled(): boolean;
  139920. set VLSEnabled(enabled: boolean);
  139921. /**
  139922. * @ignore
  139923. * Specifies if the motion blur effect is enabled
  139924. */
  139925. get MotionBlurEnabled(): boolean;
  139926. set MotionBlurEnabled(enabled: boolean);
  139927. /**
  139928. * Specifies if anti-aliasing is enabled
  139929. */
  139930. get fxaaEnabled(): boolean;
  139931. set fxaaEnabled(enabled: boolean);
  139932. /**
  139933. * Specifies if screen space reflections are enabled.
  139934. */
  139935. get screenSpaceReflectionsEnabled(): boolean;
  139936. set screenSpaceReflectionsEnabled(enabled: boolean);
  139937. /**
  139938. * Specifies the number of steps used to calculate the volumetric lights
  139939. * Typically in interval [50, 200]
  139940. */
  139941. get volumetricLightStepsCount(): number;
  139942. set volumetricLightStepsCount(count: number);
  139943. /**
  139944. * Specifies the number of samples used for the motion blur effect
  139945. * Typically in interval [16, 64]
  139946. */
  139947. get motionBlurSamples(): number;
  139948. set motionBlurSamples(samples: number);
  139949. /**
  139950. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  139951. */
  139952. get samples(): number;
  139953. set samples(sampleCount: number);
  139954. /**
  139955. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  139956. * @constructor
  139957. * @param name The rendering pipeline name
  139958. * @param scene The scene linked to this pipeline
  139959. * @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)
  139960. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  139961. * @param cameras The array of cameras that the rendering pipeline will be attached to
  139962. */
  139963. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  139964. private _buildPipeline;
  139965. private _createDownSampleX4PostProcess;
  139966. private _createBrightPassPostProcess;
  139967. private _createBlurPostProcesses;
  139968. private _createTextureAdderPostProcess;
  139969. private _createVolumetricLightPostProcess;
  139970. private _createLuminancePostProcesses;
  139971. private _createHdrPostProcess;
  139972. private _createLensFlarePostProcess;
  139973. private _createDepthOfFieldPostProcess;
  139974. private _createMotionBlurPostProcess;
  139975. private _getDepthTexture;
  139976. private _disposePostProcesses;
  139977. /**
  139978. * Dispose of the pipeline and stop all post processes
  139979. */
  139980. dispose(): void;
  139981. /**
  139982. * Serialize the rendering pipeline (Used when exporting)
  139983. * @returns the serialized object
  139984. */
  139985. serialize(): any;
  139986. /**
  139987. * Parse the serialized pipeline
  139988. * @param source Source pipeline.
  139989. * @param scene The scene to load the pipeline to.
  139990. * @param rootUrl The URL of the serialized pipeline.
  139991. * @returns An instantiated pipeline from the serialized object.
  139992. */
  139993. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  139994. /**
  139995. * Luminance steps
  139996. */
  139997. static LuminanceSteps: number;
  139998. }
  139999. }
  140000. declare module BABYLON {
  140001. /** @hidden */
  140002. export var tonemapPixelShader: {
  140003. name: string;
  140004. shader: string;
  140005. };
  140006. }
  140007. declare module BABYLON {
  140008. /** Defines operator used for tonemapping */
  140009. export enum TonemappingOperator {
  140010. /** Hable */
  140011. Hable = 0,
  140012. /** Reinhard */
  140013. Reinhard = 1,
  140014. /** HejiDawson */
  140015. HejiDawson = 2,
  140016. /** Photographic */
  140017. Photographic = 3
  140018. }
  140019. /**
  140020. * Defines a post process to apply tone mapping
  140021. */
  140022. export class TonemapPostProcess extends PostProcess {
  140023. private _operator;
  140024. /** Defines the required exposure adjustement */
  140025. exposureAdjustment: number;
  140026. /**
  140027. * Creates a new TonemapPostProcess
  140028. * @param name defines the name of the postprocess
  140029. * @param _operator defines the operator to use
  140030. * @param exposureAdjustment defines the required exposure adjustement
  140031. * @param camera defines the camera to use (can be null)
  140032. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  140033. * @param engine defines the hosting engine (can be ignore if camera is set)
  140034. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  140035. */
  140036. constructor(name: string, _operator: TonemappingOperator,
  140037. /** Defines the required exposure adjustement */
  140038. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  140039. }
  140040. }
  140041. declare module BABYLON {
  140042. /** @hidden */
  140043. export var volumetricLightScatteringPixelShader: {
  140044. name: string;
  140045. shader: string;
  140046. };
  140047. }
  140048. declare module BABYLON {
  140049. /** @hidden */
  140050. export var volumetricLightScatteringPassVertexShader: {
  140051. name: string;
  140052. shader: string;
  140053. };
  140054. }
  140055. declare module BABYLON {
  140056. /** @hidden */
  140057. export var volumetricLightScatteringPassPixelShader: {
  140058. name: string;
  140059. shader: string;
  140060. };
  140061. }
  140062. declare module BABYLON {
  140063. /**
  140064. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  140065. */
  140066. export class VolumetricLightScatteringPostProcess extends PostProcess {
  140067. private _volumetricLightScatteringPass;
  140068. private _volumetricLightScatteringRTT;
  140069. private _viewPort;
  140070. private _screenCoordinates;
  140071. private _cachedDefines;
  140072. /**
  140073. * If not undefined, the mesh position is computed from the attached node position
  140074. */
  140075. attachedNode: {
  140076. position: Vector3;
  140077. };
  140078. /**
  140079. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  140080. */
  140081. customMeshPosition: Vector3;
  140082. /**
  140083. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  140084. */
  140085. useCustomMeshPosition: boolean;
  140086. /**
  140087. * If the post-process should inverse the light scattering direction
  140088. */
  140089. invert: boolean;
  140090. /**
  140091. * The internal mesh used by the post-process
  140092. */
  140093. mesh: Mesh;
  140094. /**
  140095. * @hidden
  140096. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  140097. */
  140098. get useDiffuseColor(): boolean;
  140099. set useDiffuseColor(useDiffuseColor: boolean);
  140100. /**
  140101. * Array containing the excluded meshes not rendered in the internal pass
  140102. */
  140103. excludedMeshes: AbstractMesh[];
  140104. /**
  140105. * Controls the overall intensity of the post-process
  140106. */
  140107. exposure: number;
  140108. /**
  140109. * Dissipates each sample's contribution in range [0, 1]
  140110. */
  140111. decay: number;
  140112. /**
  140113. * Controls the overall intensity of each sample
  140114. */
  140115. weight: number;
  140116. /**
  140117. * Controls the density of each sample
  140118. */
  140119. density: number;
  140120. /**
  140121. * @constructor
  140122. * @param name The post-process name
  140123. * @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)
  140124. * @param camera The camera that the post-process will be attached to
  140125. * @param mesh The mesh used to create the light scattering
  140126. * @param samples The post-process quality, default 100
  140127. * @param samplingModeThe post-process filtering mode
  140128. * @param engine The babylon engine
  140129. * @param reusable If the post-process is reusable
  140130. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  140131. */
  140132. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  140133. /**
  140134. * Returns the string "VolumetricLightScatteringPostProcess"
  140135. * @returns "VolumetricLightScatteringPostProcess"
  140136. */
  140137. getClassName(): string;
  140138. private _isReady;
  140139. /**
  140140. * Sets the new light position for light scattering effect
  140141. * @param position The new custom light position
  140142. */
  140143. setCustomMeshPosition(position: Vector3): void;
  140144. /**
  140145. * Returns the light position for light scattering effect
  140146. * @return Vector3 The custom light position
  140147. */
  140148. getCustomMeshPosition(): Vector3;
  140149. /**
  140150. * Disposes the internal assets and detaches the post-process from the camera
  140151. */
  140152. dispose(camera: Camera): void;
  140153. /**
  140154. * Returns the render target texture used by the post-process
  140155. * @return the render target texture used by the post-process
  140156. */
  140157. getPass(): RenderTargetTexture;
  140158. private _meshExcluded;
  140159. private _createPass;
  140160. private _updateMeshScreenCoordinates;
  140161. /**
  140162. * Creates a default mesh for the Volumeric Light Scattering post-process
  140163. * @param name The mesh name
  140164. * @param scene The scene where to create the mesh
  140165. * @return the default mesh
  140166. */
  140167. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  140168. }
  140169. }
  140170. declare module BABYLON {
  140171. interface Scene {
  140172. /** @hidden (Backing field) */
  140173. _boundingBoxRenderer: BoundingBoxRenderer;
  140174. /** @hidden (Backing field) */
  140175. _forceShowBoundingBoxes: boolean;
  140176. /**
  140177. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  140178. */
  140179. forceShowBoundingBoxes: boolean;
  140180. /**
  140181. * Gets the bounding box renderer associated with the scene
  140182. * @returns a BoundingBoxRenderer
  140183. */
  140184. getBoundingBoxRenderer(): BoundingBoxRenderer;
  140185. }
  140186. interface AbstractMesh {
  140187. /** @hidden (Backing field) */
  140188. _showBoundingBox: boolean;
  140189. /**
  140190. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  140191. */
  140192. showBoundingBox: boolean;
  140193. }
  140194. /**
  140195. * Component responsible of rendering the bounding box of the meshes in a scene.
  140196. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  140197. */
  140198. export class BoundingBoxRenderer implements ISceneComponent {
  140199. /**
  140200. * The component name helpfull to identify the component in the list of scene components.
  140201. */
  140202. readonly name: string;
  140203. /**
  140204. * The scene the component belongs to.
  140205. */
  140206. scene: Scene;
  140207. /**
  140208. * Color of the bounding box lines placed in front of an object
  140209. */
  140210. frontColor: Color3;
  140211. /**
  140212. * Color of the bounding box lines placed behind an object
  140213. */
  140214. backColor: Color3;
  140215. /**
  140216. * Defines if the renderer should show the back lines or not
  140217. */
  140218. showBackLines: boolean;
  140219. /**
  140220. * @hidden
  140221. */
  140222. renderList: SmartArray<BoundingBox>;
  140223. private _colorShader;
  140224. private _vertexBuffers;
  140225. private _indexBuffer;
  140226. private _fillIndexBuffer;
  140227. private _fillIndexData;
  140228. /**
  140229. * Instantiates a new bounding box renderer in a scene.
  140230. * @param scene the scene the renderer renders in
  140231. */
  140232. constructor(scene: Scene);
  140233. /**
  140234. * Registers the component in a given scene
  140235. */
  140236. register(): void;
  140237. private _evaluateSubMesh;
  140238. private _activeMesh;
  140239. private _prepareRessources;
  140240. private _createIndexBuffer;
  140241. /**
  140242. * Rebuilds the elements related to this component in case of
  140243. * context lost for instance.
  140244. */
  140245. rebuild(): void;
  140246. /**
  140247. * @hidden
  140248. */
  140249. reset(): void;
  140250. /**
  140251. * Render the bounding boxes of a specific rendering group
  140252. * @param renderingGroupId defines the rendering group to render
  140253. */
  140254. render(renderingGroupId: number): void;
  140255. /**
  140256. * In case of occlusion queries, we can render the occlusion bounding box through this method
  140257. * @param mesh Define the mesh to render the occlusion bounding box for
  140258. */
  140259. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  140260. /**
  140261. * Dispose and release the resources attached to this renderer.
  140262. */
  140263. dispose(): void;
  140264. }
  140265. }
  140266. declare module BABYLON {
  140267. interface Scene {
  140268. /** @hidden (Backing field) */
  140269. _depthRenderer: {
  140270. [id: string]: DepthRenderer;
  140271. };
  140272. /**
  140273. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  140274. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  140275. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  140276. * @returns the created depth renderer
  140277. */
  140278. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  140279. /**
  140280. * Disables a depth renderer for a given camera
  140281. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  140282. */
  140283. disableDepthRenderer(camera?: Nullable<Camera>): void;
  140284. }
  140285. /**
  140286. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  140287. * in several rendering techniques.
  140288. */
  140289. export class DepthRendererSceneComponent implements ISceneComponent {
  140290. /**
  140291. * The component name helpfull to identify the component in the list of scene components.
  140292. */
  140293. readonly name: string;
  140294. /**
  140295. * The scene the component belongs to.
  140296. */
  140297. scene: Scene;
  140298. /**
  140299. * Creates a new instance of the component for the given scene
  140300. * @param scene Defines the scene to register the component in
  140301. */
  140302. constructor(scene: Scene);
  140303. /**
  140304. * Registers the component in a given scene
  140305. */
  140306. register(): void;
  140307. /**
  140308. * Rebuilds the elements related to this component in case of
  140309. * context lost for instance.
  140310. */
  140311. rebuild(): void;
  140312. /**
  140313. * Disposes the component and the associated ressources
  140314. */
  140315. dispose(): void;
  140316. private _gatherRenderTargets;
  140317. private _gatherActiveCameraRenderTargets;
  140318. }
  140319. }
  140320. declare module BABYLON {
  140321. /** @hidden */
  140322. export var outlinePixelShader: {
  140323. name: string;
  140324. shader: string;
  140325. };
  140326. }
  140327. declare module BABYLON {
  140328. /** @hidden */
  140329. export var outlineVertexShader: {
  140330. name: string;
  140331. shader: string;
  140332. };
  140333. }
  140334. declare module BABYLON {
  140335. interface Scene {
  140336. /** @hidden */
  140337. _outlineRenderer: OutlineRenderer;
  140338. /**
  140339. * Gets the outline renderer associated with the scene
  140340. * @returns a OutlineRenderer
  140341. */
  140342. getOutlineRenderer(): OutlineRenderer;
  140343. }
  140344. interface AbstractMesh {
  140345. /** @hidden (Backing field) */
  140346. _renderOutline: boolean;
  140347. /**
  140348. * Gets or sets a boolean indicating if the outline must be rendered as well
  140349. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  140350. */
  140351. renderOutline: boolean;
  140352. /** @hidden (Backing field) */
  140353. _renderOverlay: boolean;
  140354. /**
  140355. * Gets or sets a boolean indicating if the overlay must be rendered as well
  140356. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  140357. */
  140358. renderOverlay: boolean;
  140359. }
  140360. /**
  140361. * This class is responsible to draw bothe outline/overlay of meshes.
  140362. * It should not be used directly but through the available method on mesh.
  140363. */
  140364. export class OutlineRenderer implements ISceneComponent {
  140365. /**
  140366. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  140367. */
  140368. private static _StencilReference;
  140369. /**
  140370. * The name of the component. Each component must have a unique name.
  140371. */
  140372. name: string;
  140373. /**
  140374. * The scene the component belongs to.
  140375. */
  140376. scene: Scene;
  140377. /**
  140378. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  140379. */
  140380. zOffset: number;
  140381. private _engine;
  140382. private _effect;
  140383. private _cachedDefines;
  140384. private _savedDepthWrite;
  140385. /**
  140386. * Instantiates a new outline renderer. (There could be only one per scene).
  140387. * @param scene Defines the scene it belongs to
  140388. */
  140389. constructor(scene: Scene);
  140390. /**
  140391. * Register the component to one instance of a scene.
  140392. */
  140393. register(): void;
  140394. /**
  140395. * Rebuilds the elements related to this component in case of
  140396. * context lost for instance.
  140397. */
  140398. rebuild(): void;
  140399. /**
  140400. * Disposes the component and the associated ressources.
  140401. */
  140402. dispose(): void;
  140403. /**
  140404. * Renders the outline in the canvas.
  140405. * @param subMesh Defines the sumesh to render
  140406. * @param batch Defines the batch of meshes in case of instances
  140407. * @param useOverlay Defines if the rendering is for the overlay or the outline
  140408. */
  140409. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  140410. /**
  140411. * Returns whether or not the outline renderer is ready for a given submesh.
  140412. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  140413. * @param subMesh Defines the submesh to check readyness for
  140414. * @param useInstances Defines wheter wee are trying to render instances or not
  140415. * @returns true if ready otherwise false
  140416. */
  140417. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140418. private _beforeRenderingMesh;
  140419. private _afterRenderingMesh;
  140420. }
  140421. }
  140422. declare module BABYLON {
  140423. /**
  140424. * Defines the basic options interface of a Sprite Frame Source Size.
  140425. */
  140426. export interface ISpriteJSONSpriteSourceSize {
  140427. /**
  140428. * number of the original width of the Frame
  140429. */
  140430. w: number;
  140431. /**
  140432. * number of the original height of the Frame
  140433. */
  140434. h: number;
  140435. }
  140436. /**
  140437. * Defines the basic options interface of a Sprite Frame Data.
  140438. */
  140439. export interface ISpriteJSONSpriteFrameData {
  140440. /**
  140441. * number of the x offset of the Frame
  140442. */
  140443. x: number;
  140444. /**
  140445. * number of the y offset of the Frame
  140446. */
  140447. y: number;
  140448. /**
  140449. * number of the width of the Frame
  140450. */
  140451. w: number;
  140452. /**
  140453. * number of the height of the Frame
  140454. */
  140455. h: number;
  140456. }
  140457. /**
  140458. * Defines the basic options interface of a JSON Sprite.
  140459. */
  140460. export interface ISpriteJSONSprite {
  140461. /**
  140462. * string name of the Frame
  140463. */
  140464. filename: string;
  140465. /**
  140466. * ISpriteJSONSpriteFrame basic object of the frame data
  140467. */
  140468. frame: ISpriteJSONSpriteFrameData;
  140469. /**
  140470. * boolean to flag is the frame was rotated.
  140471. */
  140472. rotated: boolean;
  140473. /**
  140474. * boolean to flag is the frame was trimmed.
  140475. */
  140476. trimmed: boolean;
  140477. /**
  140478. * ISpriteJSONSpriteFrame basic object of the source data
  140479. */
  140480. spriteSourceSize: ISpriteJSONSpriteFrameData;
  140481. /**
  140482. * ISpriteJSONSpriteFrame basic object of the source data
  140483. */
  140484. sourceSize: ISpriteJSONSpriteSourceSize;
  140485. }
  140486. /**
  140487. * Defines the basic options interface of a JSON atlas.
  140488. */
  140489. export interface ISpriteJSONAtlas {
  140490. /**
  140491. * Array of objects that contain the frame data.
  140492. */
  140493. frames: Array<ISpriteJSONSprite>;
  140494. /**
  140495. * object basic object containing the sprite meta data.
  140496. */
  140497. meta?: object;
  140498. }
  140499. }
  140500. declare module BABYLON {
  140501. /** @hidden */
  140502. export var spriteMapPixelShader: {
  140503. name: string;
  140504. shader: string;
  140505. };
  140506. }
  140507. declare module BABYLON {
  140508. /** @hidden */
  140509. export var spriteMapVertexShader: {
  140510. name: string;
  140511. shader: string;
  140512. };
  140513. }
  140514. declare module BABYLON {
  140515. /**
  140516. * Defines the basic options interface of a SpriteMap
  140517. */
  140518. export interface ISpriteMapOptions {
  140519. /**
  140520. * Vector2 of the number of cells in the grid.
  140521. */
  140522. stageSize?: Vector2;
  140523. /**
  140524. * Vector2 of the size of the output plane in World Units.
  140525. */
  140526. outputSize?: Vector2;
  140527. /**
  140528. * Vector3 of the position of the output plane in World Units.
  140529. */
  140530. outputPosition?: Vector3;
  140531. /**
  140532. * Vector3 of the rotation of the output plane.
  140533. */
  140534. outputRotation?: Vector3;
  140535. /**
  140536. * number of layers that the system will reserve in resources.
  140537. */
  140538. layerCount?: number;
  140539. /**
  140540. * number of max animation frames a single cell will reserve in resources.
  140541. */
  140542. maxAnimationFrames?: number;
  140543. /**
  140544. * number cell index of the base tile when the system compiles.
  140545. */
  140546. baseTile?: number;
  140547. /**
  140548. * boolean flip the sprite after its been repositioned by the framing data.
  140549. */
  140550. flipU?: boolean;
  140551. /**
  140552. * Vector3 scalar of the global RGB values of the SpriteMap.
  140553. */
  140554. colorMultiply?: Vector3;
  140555. }
  140556. /**
  140557. * Defines the IDisposable interface in order to be cleanable from resources.
  140558. */
  140559. export interface ISpriteMap extends IDisposable {
  140560. /**
  140561. * String name of the SpriteMap.
  140562. */
  140563. name: string;
  140564. /**
  140565. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  140566. */
  140567. atlasJSON: ISpriteJSONAtlas;
  140568. /**
  140569. * Texture of the SpriteMap.
  140570. */
  140571. spriteSheet: Texture;
  140572. /**
  140573. * The parameters to initialize the SpriteMap with.
  140574. */
  140575. options: ISpriteMapOptions;
  140576. }
  140577. /**
  140578. * Class used to manage a grid restricted sprite deployment on an Output plane.
  140579. */
  140580. export class SpriteMap implements ISpriteMap {
  140581. /** The Name of the spriteMap */
  140582. name: string;
  140583. /** The JSON file with the frame and meta data */
  140584. atlasJSON: ISpriteJSONAtlas;
  140585. /** The systems Sprite Sheet Texture */
  140586. spriteSheet: Texture;
  140587. /** Arguments passed with the Constructor */
  140588. options: ISpriteMapOptions;
  140589. /** Public Sprite Storage array, parsed from atlasJSON */
  140590. sprites: Array<ISpriteJSONSprite>;
  140591. /** Returns the Number of Sprites in the System */
  140592. get spriteCount(): number;
  140593. /** Returns the Position of Output Plane*/
  140594. get position(): Vector3;
  140595. /** Returns the Position of Output Plane*/
  140596. set position(v: Vector3);
  140597. /** Returns the Rotation of Output Plane*/
  140598. get rotation(): Vector3;
  140599. /** Returns the Rotation of Output Plane*/
  140600. set rotation(v: Vector3);
  140601. /** Sets the AnimationMap*/
  140602. get animationMap(): RawTexture;
  140603. /** Sets the AnimationMap*/
  140604. set animationMap(v: RawTexture);
  140605. /** Scene that the SpriteMap was created in */
  140606. private _scene;
  140607. /** Texture Buffer of Float32 that holds tile frame data*/
  140608. private _frameMap;
  140609. /** Texture Buffers of Float32 that holds tileMap data*/
  140610. private _tileMaps;
  140611. /** Texture Buffer of Float32 that holds Animation Data*/
  140612. private _animationMap;
  140613. /** Custom ShaderMaterial Central to the System*/
  140614. private _material;
  140615. /** Custom ShaderMaterial Central to the System*/
  140616. private _output;
  140617. /** Systems Time Ticker*/
  140618. private _time;
  140619. /**
  140620. * Creates a new SpriteMap
  140621. * @param name defines the SpriteMaps Name
  140622. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  140623. * @param spriteSheet is the Texture that the Sprites are on.
  140624. * @param options a basic deployment configuration
  140625. * @param scene The Scene that the map is deployed on
  140626. */
  140627. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  140628. /**
  140629. * Returns tileID location
  140630. * @returns Vector2 the cell position ID
  140631. */
  140632. getTileID(): Vector2;
  140633. /**
  140634. * Gets the UV location of the mouse over the SpriteMap.
  140635. * @returns Vector2 the UV position of the mouse interaction
  140636. */
  140637. getMousePosition(): Vector2;
  140638. /**
  140639. * Creates the "frame" texture Buffer
  140640. * -------------------------------------
  140641. * Structure of frames
  140642. * "filename": "Falling-Water-2.png",
  140643. * "frame": {"x":69,"y":103,"w":24,"h":32},
  140644. * "rotated": true,
  140645. * "trimmed": true,
  140646. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  140647. * "sourceSize": {"w":32,"h":32}
  140648. * @returns RawTexture of the frameMap
  140649. */
  140650. private _createFrameBuffer;
  140651. /**
  140652. * Creates the tileMap texture Buffer
  140653. * @param buffer normally and array of numbers, or a false to generate from scratch
  140654. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  140655. * @returns RawTexture of the tileMap
  140656. */
  140657. private _createTileBuffer;
  140658. /**
  140659. * Modifies the data of the tileMaps
  140660. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  140661. * @param pos is the iVector2 Coordinates of the Tile
  140662. * @param tile The SpriteIndex of the new Tile
  140663. */
  140664. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  140665. /**
  140666. * Creates the animationMap texture Buffer
  140667. * @param buffer normally and array of numbers, or a false to generate from scratch
  140668. * @returns RawTexture of the animationMap
  140669. */
  140670. private _createTileAnimationBuffer;
  140671. /**
  140672. * Modifies the data of the animationMap
  140673. * @param cellID is the Index of the Sprite
  140674. * @param _frame is the target Animation frame
  140675. * @param toCell is the Target Index of the next frame of the animation
  140676. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  140677. * @param speed is a global scalar of the time variable on the map.
  140678. */
  140679. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  140680. /**
  140681. * Exports the .tilemaps file
  140682. */
  140683. saveTileMaps(): void;
  140684. /**
  140685. * Imports the .tilemaps file
  140686. * @param url of the .tilemaps file
  140687. */
  140688. loadTileMaps(url: string): void;
  140689. /**
  140690. * Release associated resources
  140691. */
  140692. dispose(): void;
  140693. }
  140694. }
  140695. declare module BABYLON {
  140696. /**
  140697. * Class used to manage multiple sprites of different sizes on the same spritesheet
  140698. * @see http://doc.babylonjs.com/babylon101/sprites
  140699. */
  140700. export class SpritePackedManager extends SpriteManager {
  140701. /** defines the packed manager's name */
  140702. name: string;
  140703. /**
  140704. * Creates a new sprite manager from a packed sprite sheet
  140705. * @param name defines the manager's name
  140706. * @param imgUrl defines the sprite sheet url
  140707. * @param capacity defines the maximum allowed number of sprites
  140708. * @param scene defines the hosting scene
  140709. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  140710. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  140711. * @param samplingMode defines the smapling mode to use with spritesheet
  140712. * @param fromPacked set to true; do not alter
  140713. */
  140714. constructor(
  140715. /** defines the packed manager's name */
  140716. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  140717. }
  140718. }
  140719. declare module BABYLON {
  140720. /**
  140721. * Defines the list of states available for a task inside a AssetsManager
  140722. */
  140723. export enum AssetTaskState {
  140724. /**
  140725. * Initialization
  140726. */
  140727. INIT = 0,
  140728. /**
  140729. * Running
  140730. */
  140731. RUNNING = 1,
  140732. /**
  140733. * Done
  140734. */
  140735. DONE = 2,
  140736. /**
  140737. * Error
  140738. */
  140739. ERROR = 3
  140740. }
  140741. /**
  140742. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  140743. */
  140744. export abstract class AbstractAssetTask {
  140745. /**
  140746. * Task name
  140747. */ name: string;
  140748. /**
  140749. * Callback called when the task is successful
  140750. */
  140751. onSuccess: (task: any) => void;
  140752. /**
  140753. * Callback called when the task is not successful
  140754. */
  140755. onError: (task: any, message?: string, exception?: any) => void;
  140756. /**
  140757. * Creates a new AssetsManager
  140758. * @param name defines the name of the task
  140759. */
  140760. constructor(
  140761. /**
  140762. * Task name
  140763. */ name: string);
  140764. private _isCompleted;
  140765. private _taskState;
  140766. private _errorObject;
  140767. /**
  140768. * Get if the task is completed
  140769. */
  140770. get isCompleted(): boolean;
  140771. /**
  140772. * Gets the current state of the task
  140773. */
  140774. get taskState(): AssetTaskState;
  140775. /**
  140776. * Gets the current error object (if task is in error)
  140777. */
  140778. get errorObject(): {
  140779. message?: string;
  140780. exception?: any;
  140781. };
  140782. /**
  140783. * Internal only
  140784. * @hidden
  140785. */
  140786. _setErrorObject(message?: string, exception?: any): void;
  140787. /**
  140788. * Execute the current task
  140789. * @param scene defines the scene where you want your assets to be loaded
  140790. * @param onSuccess is a callback called when the task is successfully executed
  140791. * @param onError is a callback called if an error occurs
  140792. */
  140793. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140794. /**
  140795. * Execute the current task
  140796. * @param scene defines the scene where you want your assets to be loaded
  140797. * @param onSuccess is a callback called when the task is successfully executed
  140798. * @param onError is a callback called if an error occurs
  140799. */
  140800. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140801. /**
  140802. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  140803. * This can be used with failed tasks that have the reason for failure fixed.
  140804. */
  140805. reset(): void;
  140806. private onErrorCallback;
  140807. private onDoneCallback;
  140808. }
  140809. /**
  140810. * Define the interface used by progress events raised during assets loading
  140811. */
  140812. export interface IAssetsProgressEvent {
  140813. /**
  140814. * Defines the number of remaining tasks to process
  140815. */
  140816. remainingCount: number;
  140817. /**
  140818. * Defines the total number of tasks
  140819. */
  140820. totalCount: number;
  140821. /**
  140822. * Defines the task that was just processed
  140823. */
  140824. task: AbstractAssetTask;
  140825. }
  140826. /**
  140827. * Class used to share progress information about assets loading
  140828. */
  140829. export class AssetsProgressEvent implements IAssetsProgressEvent {
  140830. /**
  140831. * Defines the number of remaining tasks to process
  140832. */
  140833. remainingCount: number;
  140834. /**
  140835. * Defines the total number of tasks
  140836. */
  140837. totalCount: number;
  140838. /**
  140839. * Defines the task that was just processed
  140840. */
  140841. task: AbstractAssetTask;
  140842. /**
  140843. * Creates a AssetsProgressEvent
  140844. * @param remainingCount defines the number of remaining tasks to process
  140845. * @param totalCount defines the total number of tasks
  140846. * @param task defines the task that was just processed
  140847. */
  140848. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  140849. }
  140850. /**
  140851. * Define a task used by AssetsManager to load meshes
  140852. */
  140853. export class MeshAssetTask extends AbstractAssetTask {
  140854. /**
  140855. * Defines the name of the task
  140856. */
  140857. name: string;
  140858. /**
  140859. * Defines the list of mesh's names you want to load
  140860. */
  140861. meshesNames: any;
  140862. /**
  140863. * Defines the root url to use as a base to load your meshes and associated resources
  140864. */
  140865. rootUrl: string;
  140866. /**
  140867. * Defines the filename of the scene to load from
  140868. */
  140869. sceneFilename: string;
  140870. /**
  140871. * Gets the list of loaded meshes
  140872. */
  140873. loadedMeshes: Array<AbstractMesh>;
  140874. /**
  140875. * Gets the list of loaded particle systems
  140876. */
  140877. loadedParticleSystems: Array<IParticleSystem>;
  140878. /**
  140879. * Gets the list of loaded skeletons
  140880. */
  140881. loadedSkeletons: Array<Skeleton>;
  140882. /**
  140883. * Gets the list of loaded animation groups
  140884. */
  140885. loadedAnimationGroups: Array<AnimationGroup>;
  140886. /**
  140887. * Callback called when the task is successful
  140888. */
  140889. onSuccess: (task: MeshAssetTask) => void;
  140890. /**
  140891. * Callback called when the task is successful
  140892. */
  140893. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  140894. /**
  140895. * Creates a new MeshAssetTask
  140896. * @param name defines the name of the task
  140897. * @param meshesNames defines the list of mesh's names you want to load
  140898. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  140899. * @param sceneFilename defines the filename of the scene to load from
  140900. */
  140901. constructor(
  140902. /**
  140903. * Defines the name of the task
  140904. */
  140905. name: string,
  140906. /**
  140907. * Defines the list of mesh's names you want to load
  140908. */
  140909. meshesNames: any,
  140910. /**
  140911. * Defines the root url to use as a base to load your meshes and associated resources
  140912. */
  140913. rootUrl: string,
  140914. /**
  140915. * Defines the filename of the scene to load from
  140916. */
  140917. sceneFilename: string);
  140918. /**
  140919. * Execute the current task
  140920. * @param scene defines the scene where you want your assets to be loaded
  140921. * @param onSuccess is a callback called when the task is successfully executed
  140922. * @param onError is a callback called if an error occurs
  140923. */
  140924. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140925. }
  140926. /**
  140927. * Define a task used by AssetsManager to load text content
  140928. */
  140929. export class TextFileAssetTask extends AbstractAssetTask {
  140930. /**
  140931. * Defines the name of the task
  140932. */
  140933. name: string;
  140934. /**
  140935. * Defines the location of the file to load
  140936. */
  140937. url: string;
  140938. /**
  140939. * Gets the loaded text string
  140940. */
  140941. text: string;
  140942. /**
  140943. * Callback called when the task is successful
  140944. */
  140945. onSuccess: (task: TextFileAssetTask) => void;
  140946. /**
  140947. * Callback called when the task is successful
  140948. */
  140949. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  140950. /**
  140951. * Creates a new TextFileAssetTask object
  140952. * @param name defines the name of the task
  140953. * @param url defines the location of the file to load
  140954. */
  140955. constructor(
  140956. /**
  140957. * Defines the name of the task
  140958. */
  140959. name: string,
  140960. /**
  140961. * Defines the location of the file to load
  140962. */
  140963. url: string);
  140964. /**
  140965. * Execute the current task
  140966. * @param scene defines the scene where you want your assets to be loaded
  140967. * @param onSuccess is a callback called when the task is successfully executed
  140968. * @param onError is a callback called if an error occurs
  140969. */
  140970. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140971. }
  140972. /**
  140973. * Define a task used by AssetsManager to load binary data
  140974. */
  140975. export class BinaryFileAssetTask extends AbstractAssetTask {
  140976. /**
  140977. * Defines the name of the task
  140978. */
  140979. name: string;
  140980. /**
  140981. * Defines the location of the file to load
  140982. */
  140983. url: string;
  140984. /**
  140985. * Gets the lodaded data (as an array buffer)
  140986. */
  140987. data: ArrayBuffer;
  140988. /**
  140989. * Callback called when the task is successful
  140990. */
  140991. onSuccess: (task: BinaryFileAssetTask) => void;
  140992. /**
  140993. * Callback called when the task is successful
  140994. */
  140995. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  140996. /**
  140997. * Creates a new BinaryFileAssetTask object
  140998. * @param name defines the name of the new task
  140999. * @param url defines the location of the file to load
  141000. */
  141001. constructor(
  141002. /**
  141003. * Defines the name of the task
  141004. */
  141005. name: string,
  141006. /**
  141007. * Defines the location of the file to load
  141008. */
  141009. url: string);
  141010. /**
  141011. * Execute the current task
  141012. * @param scene defines the scene where you want your assets to be loaded
  141013. * @param onSuccess is a callback called when the task is successfully executed
  141014. * @param onError is a callback called if an error occurs
  141015. */
  141016. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  141017. }
  141018. /**
  141019. * Define a task used by AssetsManager to load images
  141020. */
  141021. export class ImageAssetTask extends AbstractAssetTask {
  141022. /**
  141023. * Defines the name of the task
  141024. */
  141025. name: string;
  141026. /**
  141027. * Defines the location of the image to load
  141028. */
  141029. url: string;
  141030. /**
  141031. * Gets the loaded images
  141032. */
  141033. image: HTMLImageElement;
  141034. /**
  141035. * Callback called when the task is successful
  141036. */
  141037. onSuccess: (task: ImageAssetTask) => void;
  141038. /**
  141039. * Callback called when the task is successful
  141040. */
  141041. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  141042. /**
  141043. * Creates a new ImageAssetTask
  141044. * @param name defines the name of the task
  141045. * @param url defines the location of the image to load
  141046. */
  141047. constructor(
  141048. /**
  141049. * Defines the name of the task
  141050. */
  141051. name: string,
  141052. /**
  141053. * Defines the location of the image to load
  141054. */
  141055. url: string);
  141056. /**
  141057. * Execute the current task
  141058. * @param scene defines the scene where you want your assets to be loaded
  141059. * @param onSuccess is a callback called when the task is successfully executed
  141060. * @param onError is a callback called if an error occurs
  141061. */
  141062. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  141063. }
  141064. /**
  141065. * Defines the interface used by texture loading tasks
  141066. */
  141067. export interface ITextureAssetTask<TEX extends BaseTexture> {
  141068. /**
  141069. * Gets the loaded texture
  141070. */
  141071. texture: TEX;
  141072. }
  141073. /**
  141074. * Define a task used by AssetsManager to load 2D textures
  141075. */
  141076. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  141077. /**
  141078. * Defines the name of the task
  141079. */
  141080. name: string;
  141081. /**
  141082. * Defines the location of the file to load
  141083. */
  141084. url: string;
  141085. /**
  141086. * Defines if mipmap should not be generated (default is false)
  141087. */
  141088. noMipmap?: boolean | undefined;
  141089. /**
  141090. * Defines if texture must be inverted on Y axis (default is false)
  141091. */
  141092. invertY?: boolean | undefined;
  141093. /**
  141094. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  141095. */
  141096. samplingMode: number;
  141097. /**
  141098. * Gets the loaded texture
  141099. */
  141100. texture: Texture;
  141101. /**
  141102. * Callback called when the task is successful
  141103. */
  141104. onSuccess: (task: TextureAssetTask) => void;
  141105. /**
  141106. * Callback called when the task is successful
  141107. */
  141108. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  141109. /**
  141110. * Creates a new TextureAssetTask object
  141111. * @param name defines the name of the task
  141112. * @param url defines the location of the file to load
  141113. * @param noMipmap defines if mipmap should not be generated (default is false)
  141114. * @param invertY defines if texture must be inverted on Y axis (default is false)
  141115. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  141116. */
  141117. constructor(
  141118. /**
  141119. * Defines the name of the task
  141120. */
  141121. name: string,
  141122. /**
  141123. * Defines the location of the file to load
  141124. */
  141125. url: string,
  141126. /**
  141127. * Defines if mipmap should not be generated (default is false)
  141128. */
  141129. noMipmap?: boolean | undefined,
  141130. /**
  141131. * Defines if texture must be inverted on Y axis (default is false)
  141132. */
  141133. invertY?: boolean | undefined,
  141134. /**
  141135. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  141136. */
  141137. samplingMode?: number);
  141138. /**
  141139. * Execute the current task
  141140. * @param scene defines the scene where you want your assets to be loaded
  141141. * @param onSuccess is a callback called when the task is successfully executed
  141142. * @param onError is a callback called if an error occurs
  141143. */
  141144. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  141145. }
  141146. /**
  141147. * Define a task used by AssetsManager to load cube textures
  141148. */
  141149. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  141150. /**
  141151. * Defines the name of the task
  141152. */
  141153. name: string;
  141154. /**
  141155. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  141156. */
  141157. url: string;
  141158. /**
  141159. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  141160. */
  141161. extensions?: string[] | undefined;
  141162. /**
  141163. * Defines if mipmaps should not be generated (default is false)
  141164. */
  141165. noMipmap?: boolean | undefined;
  141166. /**
  141167. * Defines the explicit list of files (undefined by default)
  141168. */
  141169. files?: string[] | undefined;
  141170. /**
  141171. * Gets the loaded texture
  141172. */
  141173. texture: CubeTexture;
  141174. /**
  141175. * Callback called when the task is successful
  141176. */
  141177. onSuccess: (task: CubeTextureAssetTask) => void;
  141178. /**
  141179. * Callback called when the task is successful
  141180. */
  141181. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  141182. /**
  141183. * Creates a new CubeTextureAssetTask
  141184. * @param name defines the name of the task
  141185. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  141186. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  141187. * @param noMipmap defines if mipmaps should not be generated (default is false)
  141188. * @param files defines the explicit list of files (undefined by default)
  141189. */
  141190. constructor(
  141191. /**
  141192. * Defines the name of the task
  141193. */
  141194. name: string,
  141195. /**
  141196. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  141197. */
  141198. url: string,
  141199. /**
  141200. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  141201. */
  141202. extensions?: string[] | undefined,
  141203. /**
  141204. * Defines if mipmaps should not be generated (default is false)
  141205. */
  141206. noMipmap?: boolean | undefined,
  141207. /**
  141208. * Defines the explicit list of files (undefined by default)
  141209. */
  141210. files?: string[] | undefined);
  141211. /**
  141212. * Execute the current task
  141213. * @param scene defines the scene where you want your assets to be loaded
  141214. * @param onSuccess is a callback called when the task is successfully executed
  141215. * @param onError is a callback called if an error occurs
  141216. */
  141217. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  141218. }
  141219. /**
  141220. * Define a task used by AssetsManager to load HDR cube textures
  141221. */
  141222. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  141223. /**
  141224. * Defines the name of the task
  141225. */
  141226. name: string;
  141227. /**
  141228. * Defines the location of the file to load
  141229. */
  141230. url: string;
  141231. /**
  141232. * Defines the desired size (the more it increases the longer the generation will be)
  141233. */
  141234. size: number;
  141235. /**
  141236. * Defines if mipmaps should not be generated (default is false)
  141237. */
  141238. noMipmap: boolean;
  141239. /**
  141240. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  141241. */
  141242. generateHarmonics: boolean;
  141243. /**
  141244. * 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)
  141245. */
  141246. gammaSpace: boolean;
  141247. /**
  141248. * Internal Use Only
  141249. */
  141250. reserved: boolean;
  141251. /**
  141252. * Gets the loaded texture
  141253. */
  141254. texture: HDRCubeTexture;
  141255. /**
  141256. * Callback called when the task is successful
  141257. */
  141258. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  141259. /**
  141260. * Callback called when the task is successful
  141261. */
  141262. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  141263. /**
  141264. * Creates a new HDRCubeTextureAssetTask object
  141265. * @param name defines the name of the task
  141266. * @param url defines the location of the file to load
  141267. * @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.
  141268. * @param noMipmap defines if mipmaps should not be generated (default is false)
  141269. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  141270. * @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)
  141271. * @param reserved Internal use only
  141272. */
  141273. constructor(
  141274. /**
  141275. * Defines the name of the task
  141276. */
  141277. name: string,
  141278. /**
  141279. * Defines the location of the file to load
  141280. */
  141281. url: string,
  141282. /**
  141283. * Defines the desired size (the more it increases the longer the generation will be)
  141284. */
  141285. size: number,
  141286. /**
  141287. * Defines if mipmaps should not be generated (default is false)
  141288. */
  141289. noMipmap?: boolean,
  141290. /**
  141291. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  141292. */
  141293. generateHarmonics?: boolean,
  141294. /**
  141295. * 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)
  141296. */
  141297. gammaSpace?: boolean,
  141298. /**
  141299. * Internal Use Only
  141300. */
  141301. reserved?: boolean);
  141302. /**
  141303. * Execute the current task
  141304. * @param scene defines the scene where you want your assets to be loaded
  141305. * @param onSuccess is a callback called when the task is successfully executed
  141306. * @param onError is a callback called if an error occurs
  141307. */
  141308. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  141309. }
  141310. /**
  141311. * Define a task used by AssetsManager to load Equirectangular cube textures
  141312. */
  141313. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  141314. /**
  141315. * Defines the name of the task
  141316. */
  141317. name: string;
  141318. /**
  141319. * Defines the location of the file to load
  141320. */
  141321. url: string;
  141322. /**
  141323. * Defines the desired size (the more it increases the longer the generation will be)
  141324. */
  141325. size: number;
  141326. /**
  141327. * Defines if mipmaps should not be generated (default is false)
  141328. */
  141329. noMipmap: boolean;
  141330. /**
  141331. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  141332. * but the standard material would require them in Gamma space) (default is true)
  141333. */
  141334. gammaSpace: boolean;
  141335. /**
  141336. * Gets the loaded texture
  141337. */
  141338. texture: EquiRectangularCubeTexture;
  141339. /**
  141340. * Callback called when the task is successful
  141341. */
  141342. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  141343. /**
  141344. * Callback called when the task is successful
  141345. */
  141346. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  141347. /**
  141348. * Creates a new EquiRectangularCubeTextureAssetTask object
  141349. * @param name defines the name of the task
  141350. * @param url defines the location of the file to load
  141351. * @param size defines the desired size (the more it increases the longer the generation will be)
  141352. * If the size is omitted this implies you are using a preprocessed cubemap.
  141353. * @param noMipmap defines if mipmaps should not be generated (default is false)
  141354. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  141355. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  141356. * (default is true)
  141357. */
  141358. constructor(
  141359. /**
  141360. * Defines the name of the task
  141361. */
  141362. name: string,
  141363. /**
  141364. * Defines the location of the file to load
  141365. */
  141366. url: string,
  141367. /**
  141368. * Defines the desired size (the more it increases the longer the generation will be)
  141369. */
  141370. size: number,
  141371. /**
  141372. * Defines if mipmaps should not be generated (default is false)
  141373. */
  141374. noMipmap?: boolean,
  141375. /**
  141376. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  141377. * but the standard material would require them in Gamma space) (default is true)
  141378. */
  141379. gammaSpace?: boolean);
  141380. /**
  141381. * Execute the current task
  141382. * @param scene defines the scene where you want your assets to be loaded
  141383. * @param onSuccess is a callback called when the task is successfully executed
  141384. * @param onError is a callback called if an error occurs
  141385. */
  141386. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  141387. }
  141388. /**
  141389. * This class can be used to easily import assets into a scene
  141390. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  141391. */
  141392. export class AssetsManager {
  141393. private _scene;
  141394. private _isLoading;
  141395. protected _tasks: AbstractAssetTask[];
  141396. protected _waitingTasksCount: number;
  141397. protected _totalTasksCount: number;
  141398. /**
  141399. * Callback called when all tasks are processed
  141400. */
  141401. onFinish: (tasks: AbstractAssetTask[]) => void;
  141402. /**
  141403. * Callback called when a task is successful
  141404. */
  141405. onTaskSuccess: (task: AbstractAssetTask) => void;
  141406. /**
  141407. * Callback called when a task had an error
  141408. */
  141409. onTaskError: (task: AbstractAssetTask) => void;
  141410. /**
  141411. * Callback called when a task is done (whatever the result is)
  141412. */
  141413. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  141414. /**
  141415. * Observable called when all tasks are processed
  141416. */
  141417. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  141418. /**
  141419. * Observable called when a task had an error
  141420. */
  141421. onTaskErrorObservable: Observable<AbstractAssetTask>;
  141422. /**
  141423. * Observable called when all tasks were executed
  141424. */
  141425. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  141426. /**
  141427. * Observable called when a task is done (whatever the result is)
  141428. */
  141429. onProgressObservable: Observable<IAssetsProgressEvent>;
  141430. /**
  141431. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  141432. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  141433. */
  141434. useDefaultLoadingScreen: boolean;
  141435. /**
  141436. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  141437. * when all assets have been downloaded.
  141438. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  141439. */
  141440. autoHideLoadingUI: boolean;
  141441. /**
  141442. * Creates a new AssetsManager
  141443. * @param scene defines the scene to work on
  141444. */
  141445. constructor(scene: Scene);
  141446. /**
  141447. * Add a MeshAssetTask to the list of active tasks
  141448. * @param taskName defines the name of the new task
  141449. * @param meshesNames defines the name of meshes to load
  141450. * @param rootUrl defines the root url to use to locate files
  141451. * @param sceneFilename defines the filename of the scene file
  141452. * @returns a new MeshAssetTask object
  141453. */
  141454. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  141455. /**
  141456. * Add a TextFileAssetTask to the list of active tasks
  141457. * @param taskName defines the name of the new task
  141458. * @param url defines the url of the file to load
  141459. * @returns a new TextFileAssetTask object
  141460. */
  141461. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  141462. /**
  141463. * Add a BinaryFileAssetTask to the list of active tasks
  141464. * @param taskName defines the name of the new task
  141465. * @param url defines the url of the file to load
  141466. * @returns a new BinaryFileAssetTask object
  141467. */
  141468. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  141469. /**
  141470. * Add a ImageAssetTask to the list of active tasks
  141471. * @param taskName defines the name of the new task
  141472. * @param url defines the url of the file to load
  141473. * @returns a new ImageAssetTask object
  141474. */
  141475. addImageTask(taskName: string, url: string): ImageAssetTask;
  141476. /**
  141477. * Add a TextureAssetTask to the list of active tasks
  141478. * @param taskName defines the name of the new task
  141479. * @param url defines the url of the file to load
  141480. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141481. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  141482. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  141483. * @returns a new TextureAssetTask object
  141484. */
  141485. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  141486. /**
  141487. * Add a CubeTextureAssetTask to the list of active tasks
  141488. * @param taskName defines the name of the new task
  141489. * @param url defines the url of the file to load
  141490. * @param extensions defines the extension to use to load the cube map (can be null)
  141491. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141492. * @param files defines the list of files to load (can be null)
  141493. * @returns a new CubeTextureAssetTask object
  141494. */
  141495. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  141496. /**
  141497. *
  141498. * Add a HDRCubeTextureAssetTask to the list of active tasks
  141499. * @param taskName defines the name of the new task
  141500. * @param url defines the url of the file to load
  141501. * @param size defines the size you want for the cubemap (can be null)
  141502. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141503. * @param generateHarmonics defines if you want to automatically generate (true by default)
  141504. * @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)
  141505. * @param reserved Internal use only
  141506. * @returns a new HDRCubeTextureAssetTask object
  141507. */
  141508. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  141509. /**
  141510. *
  141511. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  141512. * @param taskName defines the name of the new task
  141513. * @param url defines the url of the file to load
  141514. * @param size defines the size you want for the cubemap (can be null)
  141515. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141516. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  141517. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  141518. * @returns a new EquiRectangularCubeTextureAssetTask object
  141519. */
  141520. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  141521. /**
  141522. * Remove a task from the assets manager.
  141523. * @param task the task to remove
  141524. */
  141525. removeTask(task: AbstractAssetTask): void;
  141526. private _decreaseWaitingTasksCount;
  141527. private _runTask;
  141528. /**
  141529. * Reset the AssetsManager and remove all tasks
  141530. * @return the current instance of the AssetsManager
  141531. */
  141532. reset(): AssetsManager;
  141533. /**
  141534. * Start the loading process
  141535. * @return the current instance of the AssetsManager
  141536. */
  141537. load(): AssetsManager;
  141538. /**
  141539. * Start the loading process as an async operation
  141540. * @return a promise returning the list of failed tasks
  141541. */
  141542. loadAsync(): Promise<void>;
  141543. }
  141544. }
  141545. declare module BABYLON {
  141546. /**
  141547. * Wrapper class for promise with external resolve and reject.
  141548. */
  141549. export class Deferred<T> {
  141550. /**
  141551. * The promise associated with this deferred object.
  141552. */
  141553. readonly promise: Promise<T>;
  141554. private _resolve;
  141555. private _reject;
  141556. /**
  141557. * The resolve method of the promise associated with this deferred object.
  141558. */
  141559. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  141560. /**
  141561. * The reject method of the promise associated with this deferred object.
  141562. */
  141563. get reject(): (reason?: any) => void;
  141564. /**
  141565. * Constructor for this deferred object.
  141566. */
  141567. constructor();
  141568. }
  141569. }
  141570. declare module BABYLON {
  141571. /**
  141572. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  141573. */
  141574. export class MeshExploder {
  141575. private _centerMesh;
  141576. private _meshes;
  141577. private _meshesOrigins;
  141578. private _toCenterVectors;
  141579. private _scaledDirection;
  141580. private _newPosition;
  141581. private _centerPosition;
  141582. /**
  141583. * Explodes meshes from a center mesh.
  141584. * @param meshes The meshes to explode.
  141585. * @param centerMesh The mesh to be center of explosion.
  141586. */
  141587. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  141588. private _setCenterMesh;
  141589. /**
  141590. * Get class name
  141591. * @returns "MeshExploder"
  141592. */
  141593. getClassName(): string;
  141594. /**
  141595. * "Exploded meshes"
  141596. * @returns Array of meshes with the centerMesh at index 0.
  141597. */
  141598. getMeshes(): Array<Mesh>;
  141599. /**
  141600. * Explodes meshes giving a specific direction
  141601. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  141602. */
  141603. explode(direction?: number): void;
  141604. }
  141605. }
  141606. declare module BABYLON {
  141607. /**
  141608. * Class used to help managing file picking and drag'n'drop
  141609. */
  141610. export class FilesInput {
  141611. /**
  141612. * List of files ready to be loaded
  141613. */
  141614. static get FilesToLoad(): {
  141615. [key: string]: File;
  141616. };
  141617. /**
  141618. * Callback called when a file is processed
  141619. */
  141620. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  141621. private _engine;
  141622. private _currentScene;
  141623. private _sceneLoadedCallback;
  141624. private _progressCallback;
  141625. private _additionalRenderLoopLogicCallback;
  141626. private _textureLoadingCallback;
  141627. private _startingProcessingFilesCallback;
  141628. private _onReloadCallback;
  141629. private _errorCallback;
  141630. private _elementToMonitor;
  141631. private _sceneFileToLoad;
  141632. private _filesToLoad;
  141633. /**
  141634. * Creates a new FilesInput
  141635. * @param engine defines the rendering engine
  141636. * @param scene defines the hosting scene
  141637. * @param sceneLoadedCallback callback called when scene is loaded
  141638. * @param progressCallback callback called to track progress
  141639. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  141640. * @param textureLoadingCallback callback called when a texture is loading
  141641. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  141642. * @param onReloadCallback callback called when a reload is requested
  141643. * @param errorCallback callback call if an error occurs
  141644. */
  141645. 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);
  141646. private _dragEnterHandler;
  141647. private _dragOverHandler;
  141648. private _dropHandler;
  141649. /**
  141650. * Calls this function to listen to drag'n'drop events on a specific DOM element
  141651. * @param elementToMonitor defines the DOM element to track
  141652. */
  141653. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  141654. /**
  141655. * Release all associated resources
  141656. */
  141657. dispose(): void;
  141658. private renderFunction;
  141659. private drag;
  141660. private drop;
  141661. private _traverseFolder;
  141662. private _processFiles;
  141663. /**
  141664. * Load files from a drop event
  141665. * @param event defines the drop event to use as source
  141666. */
  141667. loadFiles(event: any): void;
  141668. private _processReload;
  141669. /**
  141670. * Reload the current scene from the loaded files
  141671. */
  141672. reload(): void;
  141673. }
  141674. }
  141675. declare module BABYLON {
  141676. /**
  141677. * Defines the root class used to create scene optimization to use with SceneOptimizer
  141678. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141679. */
  141680. export class SceneOptimization {
  141681. /**
  141682. * Defines the priority of this optimization (0 by default which means first in the list)
  141683. */
  141684. priority: number;
  141685. /**
  141686. * Gets a string describing the action executed by the current optimization
  141687. * @returns description string
  141688. */
  141689. getDescription(): string;
  141690. /**
  141691. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141692. * @param scene defines the current scene where to apply this optimization
  141693. * @param optimizer defines the current optimizer
  141694. * @returns true if everything that can be done was applied
  141695. */
  141696. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141697. /**
  141698. * Creates the SceneOptimization object
  141699. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141700. * @param desc defines the description associated with the optimization
  141701. */
  141702. constructor(
  141703. /**
  141704. * Defines the priority of this optimization (0 by default which means first in the list)
  141705. */
  141706. priority?: number);
  141707. }
  141708. /**
  141709. * Defines an optimization used to reduce the size of render target textures
  141710. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141711. */
  141712. export class TextureOptimization extends SceneOptimization {
  141713. /**
  141714. * Defines the priority of this optimization (0 by default which means first in the list)
  141715. */
  141716. priority: number;
  141717. /**
  141718. * 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
  141719. */
  141720. maximumSize: number;
  141721. /**
  141722. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141723. */
  141724. step: number;
  141725. /**
  141726. * Gets a string describing the action executed by the current optimization
  141727. * @returns description string
  141728. */
  141729. getDescription(): string;
  141730. /**
  141731. * Creates the TextureOptimization object
  141732. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141733. * @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
  141734. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141735. */
  141736. constructor(
  141737. /**
  141738. * Defines the priority of this optimization (0 by default which means first in the list)
  141739. */
  141740. priority?: number,
  141741. /**
  141742. * 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
  141743. */
  141744. maximumSize?: number,
  141745. /**
  141746. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141747. */
  141748. step?: number);
  141749. /**
  141750. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141751. * @param scene defines the current scene where to apply this optimization
  141752. * @param optimizer defines the current optimizer
  141753. * @returns true if everything that can be done was applied
  141754. */
  141755. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141756. }
  141757. /**
  141758. * Defines an optimization used to increase or decrease the rendering resolution
  141759. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141760. */
  141761. export class HardwareScalingOptimization extends SceneOptimization {
  141762. /**
  141763. * Defines the priority of this optimization (0 by default which means first in the list)
  141764. */
  141765. priority: number;
  141766. /**
  141767. * Defines the maximum scale to use (2 by default)
  141768. */
  141769. maximumScale: number;
  141770. /**
  141771. * Defines the step to use between two passes (0.5 by default)
  141772. */
  141773. step: number;
  141774. private _currentScale;
  141775. private _directionOffset;
  141776. /**
  141777. * Gets a string describing the action executed by the current optimization
  141778. * @return description string
  141779. */
  141780. getDescription(): string;
  141781. /**
  141782. * Creates the HardwareScalingOptimization object
  141783. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141784. * @param maximumScale defines the maximum scale to use (2 by default)
  141785. * @param step defines the step to use between two passes (0.5 by default)
  141786. */
  141787. constructor(
  141788. /**
  141789. * Defines the priority of this optimization (0 by default which means first in the list)
  141790. */
  141791. priority?: number,
  141792. /**
  141793. * Defines the maximum scale to use (2 by default)
  141794. */
  141795. maximumScale?: number,
  141796. /**
  141797. * Defines the step to use between two passes (0.5 by default)
  141798. */
  141799. step?: number);
  141800. /**
  141801. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141802. * @param scene defines the current scene where to apply this optimization
  141803. * @param optimizer defines the current optimizer
  141804. * @returns true if everything that can be done was applied
  141805. */
  141806. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141807. }
  141808. /**
  141809. * Defines an optimization used to remove shadows
  141810. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141811. */
  141812. export class ShadowsOptimization extends SceneOptimization {
  141813. /**
  141814. * Gets a string describing the action executed by the current optimization
  141815. * @return description string
  141816. */
  141817. getDescription(): string;
  141818. /**
  141819. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141820. * @param scene defines the current scene where to apply this optimization
  141821. * @param optimizer defines the current optimizer
  141822. * @returns true if everything that can be done was applied
  141823. */
  141824. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141825. }
  141826. /**
  141827. * Defines an optimization used to turn post-processes off
  141828. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141829. */
  141830. export class PostProcessesOptimization extends SceneOptimization {
  141831. /**
  141832. * Gets a string describing the action executed by the current optimization
  141833. * @return description string
  141834. */
  141835. getDescription(): string;
  141836. /**
  141837. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141838. * @param scene defines the current scene where to apply this optimization
  141839. * @param optimizer defines the current optimizer
  141840. * @returns true if everything that can be done was applied
  141841. */
  141842. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141843. }
  141844. /**
  141845. * Defines an optimization used to turn lens flares off
  141846. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141847. */
  141848. export class LensFlaresOptimization extends SceneOptimization {
  141849. /**
  141850. * Gets a string describing the action executed by the current optimization
  141851. * @return description string
  141852. */
  141853. getDescription(): string;
  141854. /**
  141855. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141856. * @param scene defines the current scene where to apply this optimization
  141857. * @param optimizer defines the current optimizer
  141858. * @returns true if everything that can be done was applied
  141859. */
  141860. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141861. }
  141862. /**
  141863. * Defines an optimization based on user defined callback.
  141864. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141865. */
  141866. export class CustomOptimization extends SceneOptimization {
  141867. /**
  141868. * Callback called to apply the custom optimization.
  141869. */
  141870. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  141871. /**
  141872. * Callback called to get custom description
  141873. */
  141874. onGetDescription: () => string;
  141875. /**
  141876. * Gets a string describing the action executed by the current optimization
  141877. * @returns description string
  141878. */
  141879. getDescription(): string;
  141880. /**
  141881. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141882. * @param scene defines the current scene where to apply this optimization
  141883. * @param optimizer defines the current optimizer
  141884. * @returns true if everything that can be done was applied
  141885. */
  141886. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141887. }
  141888. /**
  141889. * Defines an optimization used to turn particles off
  141890. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141891. */
  141892. export class ParticlesOptimization extends SceneOptimization {
  141893. /**
  141894. * Gets a string describing the action executed by the current optimization
  141895. * @return description string
  141896. */
  141897. getDescription(): string;
  141898. /**
  141899. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141900. * @param scene defines the current scene where to apply this optimization
  141901. * @param optimizer defines the current optimizer
  141902. * @returns true if everything that can be done was applied
  141903. */
  141904. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141905. }
  141906. /**
  141907. * Defines an optimization used to turn render targets off
  141908. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141909. */
  141910. export class RenderTargetsOptimization extends SceneOptimization {
  141911. /**
  141912. * Gets a string describing the action executed by the current optimization
  141913. * @return description string
  141914. */
  141915. getDescription(): string;
  141916. /**
  141917. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141918. * @param scene defines the current scene where to apply this optimization
  141919. * @param optimizer defines the current optimizer
  141920. * @returns true if everything that can be done was applied
  141921. */
  141922. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141923. }
  141924. /**
  141925. * Defines an optimization used to merge meshes with compatible materials
  141926. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141927. */
  141928. export class MergeMeshesOptimization extends SceneOptimization {
  141929. private static _UpdateSelectionTree;
  141930. /**
  141931. * Gets or sets a boolean which defines if optimization octree has to be updated
  141932. */
  141933. static get UpdateSelectionTree(): boolean;
  141934. /**
  141935. * Gets or sets a boolean which defines if optimization octree has to be updated
  141936. */
  141937. static set UpdateSelectionTree(value: boolean);
  141938. /**
  141939. * Gets a string describing the action executed by the current optimization
  141940. * @return description string
  141941. */
  141942. getDescription(): string;
  141943. private _canBeMerged;
  141944. /**
  141945. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141946. * @param scene defines the current scene where to apply this optimization
  141947. * @param optimizer defines the current optimizer
  141948. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  141949. * @returns true if everything that can be done was applied
  141950. */
  141951. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  141952. }
  141953. /**
  141954. * Defines a list of options used by SceneOptimizer
  141955. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141956. */
  141957. export class SceneOptimizerOptions {
  141958. /**
  141959. * Defines the target frame rate to reach (60 by default)
  141960. */
  141961. targetFrameRate: number;
  141962. /**
  141963. * Defines the interval between two checkes (2000ms by default)
  141964. */
  141965. trackerDuration: number;
  141966. /**
  141967. * Gets the list of optimizations to apply
  141968. */
  141969. optimizations: SceneOptimization[];
  141970. /**
  141971. * Creates a new list of options used by SceneOptimizer
  141972. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  141973. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  141974. */
  141975. constructor(
  141976. /**
  141977. * Defines the target frame rate to reach (60 by default)
  141978. */
  141979. targetFrameRate?: number,
  141980. /**
  141981. * Defines the interval between two checkes (2000ms by default)
  141982. */
  141983. trackerDuration?: number);
  141984. /**
  141985. * Add a new optimization
  141986. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  141987. * @returns the current SceneOptimizerOptions
  141988. */
  141989. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  141990. /**
  141991. * Add a new custom optimization
  141992. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  141993. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  141994. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141995. * @returns the current SceneOptimizerOptions
  141996. */
  141997. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  141998. /**
  141999. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  142000. * @param targetFrameRate defines the target frame rate (60 by default)
  142001. * @returns a SceneOptimizerOptions object
  142002. */
  142003. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  142004. /**
  142005. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  142006. * @param targetFrameRate defines the target frame rate (60 by default)
  142007. * @returns a SceneOptimizerOptions object
  142008. */
  142009. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  142010. /**
  142011. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  142012. * @param targetFrameRate defines the target frame rate (60 by default)
  142013. * @returns a SceneOptimizerOptions object
  142014. */
  142015. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  142016. }
  142017. /**
  142018. * Class used to run optimizations in order to reach a target frame rate
  142019. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  142020. */
  142021. export class SceneOptimizer implements IDisposable {
  142022. private _isRunning;
  142023. private _options;
  142024. private _scene;
  142025. private _currentPriorityLevel;
  142026. private _targetFrameRate;
  142027. private _trackerDuration;
  142028. private _currentFrameRate;
  142029. private _sceneDisposeObserver;
  142030. private _improvementMode;
  142031. /**
  142032. * Defines an observable called when the optimizer reaches the target frame rate
  142033. */
  142034. onSuccessObservable: Observable<SceneOptimizer>;
  142035. /**
  142036. * Defines an observable called when the optimizer enables an optimization
  142037. */
  142038. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  142039. /**
  142040. * Defines an observable called when the optimizer is not able to reach the target frame rate
  142041. */
  142042. onFailureObservable: Observable<SceneOptimizer>;
  142043. /**
  142044. * Gets a boolean indicating if the optimizer is in improvement mode
  142045. */
  142046. get isInImprovementMode(): boolean;
  142047. /**
  142048. * Gets the current priority level (0 at start)
  142049. */
  142050. get currentPriorityLevel(): number;
  142051. /**
  142052. * Gets the current frame rate checked by the SceneOptimizer
  142053. */
  142054. get currentFrameRate(): number;
  142055. /**
  142056. * Gets or sets the current target frame rate (60 by default)
  142057. */
  142058. get targetFrameRate(): number;
  142059. /**
  142060. * Gets or sets the current target frame rate (60 by default)
  142061. */
  142062. set targetFrameRate(value: number);
  142063. /**
  142064. * Gets or sets the current interval between two checks (every 2000ms by default)
  142065. */
  142066. get trackerDuration(): number;
  142067. /**
  142068. * Gets or sets the current interval between two checks (every 2000ms by default)
  142069. */
  142070. set trackerDuration(value: number);
  142071. /**
  142072. * Gets the list of active optimizations
  142073. */
  142074. get optimizations(): SceneOptimization[];
  142075. /**
  142076. * Creates a new SceneOptimizer
  142077. * @param scene defines the scene to work on
  142078. * @param options defines the options to use with the SceneOptimizer
  142079. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  142080. * @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)
  142081. */
  142082. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  142083. /**
  142084. * Stops the current optimizer
  142085. */
  142086. stop(): void;
  142087. /**
  142088. * Reset the optimizer to initial step (current priority level = 0)
  142089. */
  142090. reset(): void;
  142091. /**
  142092. * Start the optimizer. By default it will try to reach a specific framerate
  142093. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  142094. */
  142095. start(): void;
  142096. private _checkCurrentState;
  142097. /**
  142098. * Release all resources
  142099. */
  142100. dispose(): void;
  142101. /**
  142102. * Helper function to create a SceneOptimizer with one single line of code
  142103. * @param scene defines the scene to work on
  142104. * @param options defines the options to use with the SceneOptimizer
  142105. * @param onSuccess defines a callback to call on success
  142106. * @param onFailure defines a callback to call on failure
  142107. * @returns the new SceneOptimizer object
  142108. */
  142109. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  142110. }
  142111. }
  142112. declare module BABYLON {
  142113. /**
  142114. * Class used to serialize a scene into a string
  142115. */
  142116. export class SceneSerializer {
  142117. /**
  142118. * Clear cache used by a previous serialization
  142119. */
  142120. static ClearCache(): void;
  142121. /**
  142122. * Serialize a scene into a JSON compatible object
  142123. * @param scene defines the scene to serialize
  142124. * @returns a JSON compatible object
  142125. */
  142126. static Serialize(scene: Scene): any;
  142127. /**
  142128. * Serialize a mesh into a JSON compatible object
  142129. * @param toSerialize defines the mesh to serialize
  142130. * @param withParents defines if parents must be serialized as well
  142131. * @param withChildren defines if children must be serialized as well
  142132. * @returns a JSON compatible object
  142133. */
  142134. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  142135. }
  142136. }
  142137. declare module BABYLON {
  142138. /**
  142139. * Class used to host texture specific utilities
  142140. */
  142141. export class TextureTools {
  142142. /**
  142143. * Uses the GPU to create a copy texture rescaled at a given size
  142144. * @param texture Texture to copy from
  142145. * @param width defines the desired width
  142146. * @param height defines the desired height
  142147. * @param useBilinearMode defines if bilinear mode has to be used
  142148. * @return the generated texture
  142149. */
  142150. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  142151. }
  142152. }
  142153. declare module BABYLON {
  142154. /**
  142155. * This represents the different options available for the video capture.
  142156. */
  142157. export interface VideoRecorderOptions {
  142158. /** Defines the mime type of the video. */
  142159. mimeType: string;
  142160. /** Defines the FPS the video should be recorded at. */
  142161. fps: number;
  142162. /** Defines the chunk size for the recording data. */
  142163. recordChunckSize: number;
  142164. /** The audio tracks to attach to the recording. */
  142165. audioTracks?: MediaStreamTrack[];
  142166. }
  142167. /**
  142168. * This can help with recording videos from BabylonJS.
  142169. * This is based on the available WebRTC functionalities of the browser.
  142170. *
  142171. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  142172. */
  142173. export class VideoRecorder {
  142174. private static readonly _defaultOptions;
  142175. /**
  142176. * Returns whether or not the VideoRecorder is available in your browser.
  142177. * @param engine Defines the Babylon Engine.
  142178. * @returns true if supported otherwise false.
  142179. */
  142180. static IsSupported(engine: Engine): boolean;
  142181. private readonly _options;
  142182. private _canvas;
  142183. private _mediaRecorder;
  142184. private _recordedChunks;
  142185. private _fileName;
  142186. private _resolve;
  142187. private _reject;
  142188. /**
  142189. * True when a recording is already in progress.
  142190. */
  142191. get isRecording(): boolean;
  142192. /**
  142193. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  142194. * @param engine Defines the BabylonJS Engine you wish to record.
  142195. * @param options Defines options that can be used to customize the capture.
  142196. */
  142197. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  142198. /**
  142199. * Stops the current recording before the default capture timeout passed in the startRecording function.
  142200. */
  142201. stopRecording(): void;
  142202. /**
  142203. * Starts recording the canvas for a max duration specified in parameters.
  142204. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  142205. * If null no automatic download will start and you can rely on the promise to get the data back.
  142206. * @param maxDuration Defines the maximum recording time in seconds.
  142207. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  142208. * @return A promise callback at the end of the recording with the video data in Blob.
  142209. */
  142210. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  142211. /**
  142212. * Releases internal resources used during the recording.
  142213. */
  142214. dispose(): void;
  142215. private _handleDataAvailable;
  142216. private _handleError;
  142217. private _handleStop;
  142218. }
  142219. }
  142220. declare module BABYLON {
  142221. /**
  142222. * Class containing a set of static utilities functions for screenshots
  142223. */
  142224. export class ScreenshotTools {
  142225. /**
  142226. * Captures a screenshot of the current rendering
  142227. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  142228. * @param engine defines the rendering engine
  142229. * @param camera defines the source camera
  142230. * @param size This parameter can be set to a single number or to an object with the
  142231. * following (optional) properties: precision, width, height. If a single number is passed,
  142232. * it will be used for both width and height. If an object is passed, the screenshot size
  142233. * will be derived from the parameters. The precision property is a multiplier allowing
  142234. * rendering at a higher or lower resolution
  142235. * @param successCallback defines the callback receives a single parameter which contains the
  142236. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  142237. * src parameter of an <img> to display it
  142238. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  142239. * Check your browser for supported MIME types
  142240. */
  142241. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  142242. /**
  142243. * Captures a screenshot of the current rendering
  142244. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  142245. * @param engine defines the rendering engine
  142246. * @param camera defines the source camera
  142247. * @param size This parameter can be set to a single number or to an object with the
  142248. * following (optional) properties: precision, width, height. If a single number is passed,
  142249. * it will be used for both width and height. If an object is passed, the screenshot size
  142250. * will be derived from the parameters. The precision property is a multiplier allowing
  142251. * rendering at a higher or lower resolution
  142252. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  142253. * Check your browser for supported MIME types
  142254. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  142255. * to the src parameter of an <img> to display it
  142256. */
  142257. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  142258. /**
  142259. * Generates an image screenshot from the specified camera.
  142260. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  142261. * @param engine The engine to use for rendering
  142262. * @param camera The camera to use for rendering
  142263. * @param size This parameter can be set to a single number or to an object with the
  142264. * following (optional) properties: precision, width, height. If a single number is passed,
  142265. * it will be used for both width and height. If an object is passed, the screenshot size
  142266. * will be derived from the parameters. The precision property is a multiplier allowing
  142267. * rendering at a higher or lower resolution
  142268. * @param successCallback The callback receives a single parameter which contains the
  142269. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  142270. * src parameter of an <img> to display it
  142271. * @param mimeType The MIME type of the screenshot image (default: image/png).
  142272. * Check your browser for supported MIME types
  142273. * @param samples Texture samples (default: 1)
  142274. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  142275. * @param fileName A name for for the downloaded file.
  142276. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  142277. */
  142278. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  142279. /**
  142280. * Generates an image screenshot from the specified camera.
  142281. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  142282. * @param engine The engine to use for rendering
  142283. * @param camera The camera to use for rendering
  142284. * @param size This parameter can be set to a single number or to an object with the
  142285. * following (optional) properties: precision, width, height. If a single number is passed,
  142286. * it will be used for both width and height. If an object is passed, the screenshot size
  142287. * will be derived from the parameters. The precision property is a multiplier allowing
  142288. * rendering at a higher or lower resolution
  142289. * @param mimeType The MIME type of the screenshot image (default: image/png).
  142290. * Check your browser for supported MIME types
  142291. * @param samples Texture samples (default: 1)
  142292. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  142293. * @param fileName A name for for the downloaded file.
  142294. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  142295. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  142296. * to the src parameter of an <img> to display it
  142297. */
  142298. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  142299. /**
  142300. * Gets height and width for screenshot size
  142301. * @private
  142302. */
  142303. private static _getScreenshotSize;
  142304. }
  142305. }
  142306. declare module BABYLON {
  142307. /**
  142308. * Interface for a data buffer
  142309. */
  142310. export interface IDataBuffer {
  142311. /**
  142312. * Reads bytes from the data buffer.
  142313. * @param byteOffset The byte offset to read
  142314. * @param byteLength The byte length to read
  142315. * @returns A promise that resolves when the bytes are read
  142316. */
  142317. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  142318. /**
  142319. * The byte length of the buffer.
  142320. */
  142321. readonly byteLength: number;
  142322. }
  142323. /**
  142324. * Utility class for reading from a data buffer
  142325. */
  142326. export class DataReader {
  142327. /**
  142328. * The data buffer associated with this data reader.
  142329. */
  142330. readonly buffer: IDataBuffer;
  142331. /**
  142332. * The current byte offset from the beginning of the data buffer.
  142333. */
  142334. byteOffset: number;
  142335. private _dataView;
  142336. private _dataByteOffset;
  142337. /**
  142338. * Constructor
  142339. * @param buffer The buffer to read
  142340. */
  142341. constructor(buffer: IDataBuffer);
  142342. /**
  142343. * Loads the given byte length.
  142344. * @param byteLength The byte length to load
  142345. * @returns A promise that resolves when the load is complete
  142346. */
  142347. loadAsync(byteLength: number): Promise<void>;
  142348. /**
  142349. * Read a unsigned 32-bit integer from the currently loaded data range.
  142350. * @returns The 32-bit integer read
  142351. */
  142352. readUint32(): number;
  142353. /**
  142354. * Read a byte array from the currently loaded data range.
  142355. * @param byteLength The byte length to read
  142356. * @returns The byte array read
  142357. */
  142358. readUint8Array(byteLength: number): Uint8Array;
  142359. /**
  142360. * Read a string from the currently loaded data range.
  142361. * @param byteLength The byte length to read
  142362. * @returns The string read
  142363. */
  142364. readString(byteLength: number): string;
  142365. /**
  142366. * Skips the given byte length the currently loaded data range.
  142367. * @param byteLength The byte length to skip
  142368. */
  142369. skipBytes(byteLength: number): void;
  142370. }
  142371. }
  142372. declare module BABYLON {
  142373. /**
  142374. * Class for storing data to local storage if available or in-memory storage otherwise
  142375. */
  142376. export class DataStorage {
  142377. private static _Storage;
  142378. private static _GetStorage;
  142379. /**
  142380. * Reads a string from the data storage
  142381. * @param key The key to read
  142382. * @param defaultValue The value if the key doesn't exist
  142383. * @returns The string value
  142384. */
  142385. static ReadString(key: string, defaultValue: string): string;
  142386. /**
  142387. * Writes a string to the data storage
  142388. * @param key The key to write
  142389. * @param value The value to write
  142390. */
  142391. static WriteString(key: string, value: string): void;
  142392. /**
  142393. * Reads a boolean from the data storage
  142394. * @param key The key to read
  142395. * @param defaultValue The value if the key doesn't exist
  142396. * @returns The boolean value
  142397. */
  142398. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  142399. /**
  142400. * Writes a boolean to the data storage
  142401. * @param key The key to write
  142402. * @param value The value to write
  142403. */
  142404. static WriteBoolean(key: string, value: boolean): void;
  142405. /**
  142406. * Reads a number from the data storage
  142407. * @param key The key to read
  142408. * @param defaultValue The value if the key doesn't exist
  142409. * @returns The number value
  142410. */
  142411. static ReadNumber(key: string, defaultValue: number): number;
  142412. /**
  142413. * Writes a number to the data storage
  142414. * @param key The key to write
  142415. * @param value The value to write
  142416. */
  142417. static WriteNumber(key: string, value: number): void;
  142418. }
  142419. }
  142420. declare module BABYLON {
  142421. /**
  142422. * Options used for hit testing
  142423. */
  142424. export interface IWebXRHitTestOptions {
  142425. /**
  142426. * Only test when user interacted with the scene. Default - hit test every frame
  142427. */
  142428. testOnPointerDownOnly?: boolean;
  142429. /**
  142430. * The node to use to transform the local results to world coordinates
  142431. */
  142432. worldParentNode?: TransformNode;
  142433. }
  142434. /**
  142435. * Interface defining the babylon result of raycasting/hit-test
  142436. */
  142437. export interface IWebXRHitResult {
  142438. /**
  142439. * Transformation matrix that can be applied to a node that will put it in the hit point location
  142440. */
  142441. transformationMatrix: Matrix;
  142442. /**
  142443. * The native hit test result
  142444. */
  142445. xrHitResult: XRHitResult;
  142446. }
  142447. /**
  142448. * The currently-working hit-test module.
  142449. * Hit test (or Ray-casting) is used to interact with the real world.
  142450. * For further information read here - https://github.com/immersive-web/hit-test
  142451. */
  142452. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  142453. /**
  142454. * options to use when constructing this feature
  142455. */
  142456. readonly options: IWebXRHitTestOptions;
  142457. private _direction;
  142458. private _mat;
  142459. private _onSelectEnabled;
  142460. private _origin;
  142461. /**
  142462. * The module's name
  142463. */
  142464. static readonly Name: string;
  142465. /**
  142466. * The (Babylon) version of this module.
  142467. * This is an integer representing the implementation version.
  142468. * This number does not correspond to the WebXR specs version
  142469. */
  142470. static readonly Version: number;
  142471. /**
  142472. * Populated with the last native XR Hit Results
  142473. */
  142474. lastNativeXRHitResults: XRHitResult[];
  142475. /**
  142476. * Triggered when new babylon (transformed) hit test results are available
  142477. */
  142478. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  142479. /**
  142480. * Creates a new instance of the (legacy version) hit test feature
  142481. * @param _xrSessionManager an instance of WebXRSessionManager
  142482. * @param options options to use when constructing this feature
  142483. */
  142484. constructor(_xrSessionManager: WebXRSessionManager,
  142485. /**
  142486. * options to use when constructing this feature
  142487. */
  142488. options?: IWebXRHitTestOptions);
  142489. /**
  142490. * execute a hit test with an XR Ray
  142491. *
  142492. * @param xrSession a native xrSession that will execute this hit test
  142493. * @param xrRay the ray (position and direction) to use for ray-casting
  142494. * @param referenceSpace native XR reference space to use for the hit-test
  142495. * @param filter filter function that will filter the results
  142496. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  142497. */
  142498. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  142499. /**
  142500. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  142501. * @param event the (select) event to use to select with
  142502. * @param referenceSpace the reference space to use for this hit test
  142503. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  142504. */
  142505. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  142506. /**
  142507. * attach this feature
  142508. * Will usually be called by the features manager
  142509. *
  142510. * @returns true if successful.
  142511. */
  142512. attach(): boolean;
  142513. /**
  142514. * detach this feature.
  142515. * Will usually be called by the features manager
  142516. *
  142517. * @returns true if successful.
  142518. */
  142519. detach(): boolean;
  142520. /**
  142521. * Dispose this feature and all of the resources attached
  142522. */
  142523. dispose(): void;
  142524. protected _onXRFrame(frame: XRFrame): void;
  142525. private _onHitTestResults;
  142526. private _onSelect;
  142527. }
  142528. }
  142529. declare module BABYLON {
  142530. /**
  142531. * Options used in the plane detector module
  142532. */
  142533. export interface IWebXRPlaneDetectorOptions {
  142534. /**
  142535. * The node to use to transform the local results to world coordinates
  142536. */
  142537. worldParentNode?: TransformNode;
  142538. }
  142539. /**
  142540. * A babylon interface for a WebXR plane.
  142541. * A Plane is actually a polygon, built from N points in space
  142542. *
  142543. * Supported in chrome 79, not supported in canary 81 ATM
  142544. */
  142545. export interface IWebXRPlane {
  142546. /**
  142547. * a babylon-assigned ID for this polygon
  142548. */
  142549. id: number;
  142550. /**
  142551. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  142552. */
  142553. polygonDefinition: Array<Vector3>;
  142554. /**
  142555. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  142556. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  142557. */
  142558. transformationMatrix: Matrix;
  142559. /**
  142560. * the native xr-plane object
  142561. */
  142562. xrPlane: XRPlane;
  142563. }
  142564. /**
  142565. * The plane detector is used to detect planes in the real world when in AR
  142566. * For more information see https://github.com/immersive-web/real-world-geometry/
  142567. */
  142568. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  142569. private _options;
  142570. private _detectedPlanes;
  142571. private _enabled;
  142572. private _lastFrameDetected;
  142573. /**
  142574. * The module's name
  142575. */
  142576. static readonly Name: string;
  142577. /**
  142578. * The (Babylon) version of this module.
  142579. * This is an integer representing the implementation version.
  142580. * This number does not correspond to the WebXR specs version
  142581. */
  142582. static readonly Version: number;
  142583. /**
  142584. * Observers registered here will be executed when a new plane was added to the session
  142585. */
  142586. onPlaneAddedObservable: Observable<IWebXRPlane>;
  142587. /**
  142588. * Observers registered here will be executed when a plane is no longer detected in the session
  142589. */
  142590. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  142591. /**
  142592. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  142593. * This can execute N times every frame
  142594. */
  142595. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  142596. /**
  142597. * construct a new Plane Detector
  142598. * @param _xrSessionManager an instance of xr Session manager
  142599. * @param _options configuration to use when constructing this feature
  142600. */
  142601. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  142602. /**
  142603. * Dispose this feature and all of the resources attached
  142604. */
  142605. dispose(): void;
  142606. protected _onXRFrame(frame: XRFrame): void;
  142607. private _init;
  142608. private _updatePlaneWithXRPlane;
  142609. /**
  142610. * avoiding using Array.find for global support.
  142611. * @param xrPlane the plane to find in the array
  142612. */
  142613. private findIndexInPlaneArray;
  142614. }
  142615. }
  142616. declare module BABYLON {
  142617. /**
  142618. * Configuration options of the anchor system
  142619. */
  142620. export interface IWebXRAnchorSystemOptions {
  142621. /**
  142622. * Should a new anchor be added every time a select event is triggered
  142623. */
  142624. addAnchorOnSelect?: boolean;
  142625. /**
  142626. * should the anchor system use plane detection.
  142627. * If set to true, the plane-detection feature should be set using setPlaneDetector
  142628. */
  142629. usePlaneDetection?: boolean;
  142630. /**
  142631. * a node that will be used to convert local to world coordinates
  142632. */
  142633. worldParentNode?: TransformNode;
  142634. }
  142635. /**
  142636. * A babylon container for an XR Anchor
  142637. */
  142638. export interface IWebXRAnchor {
  142639. /**
  142640. * A babylon-assigned ID for this anchor
  142641. */
  142642. id: number;
  142643. /**
  142644. * Transformation matrix to apply to an object attached to this anchor
  142645. */
  142646. transformationMatrix: Matrix;
  142647. /**
  142648. * The native anchor object
  142649. */
  142650. xrAnchor: XRAnchor;
  142651. }
  142652. /**
  142653. * An implementation of the anchor system of WebXR.
  142654. * Note that the current documented implementation is not available in any browser. Future implementations
  142655. * will use the frame to create an anchor and not the session or a detected plane
  142656. * For further information see https://github.com/immersive-web/anchors/
  142657. */
  142658. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  142659. private _options;
  142660. private _enabled;
  142661. private _hitTestModule;
  142662. private _lastFrameDetected;
  142663. private _onSelect;
  142664. private _planeDetector;
  142665. private _trackedAnchors;
  142666. /**
  142667. * The module's name
  142668. */
  142669. static readonly Name: string;
  142670. /**
  142671. * The (Babylon) version of this module.
  142672. * This is an integer representing the implementation version.
  142673. * This number does not correspond to the WebXR specs version
  142674. */
  142675. static readonly Version: number;
  142676. /**
  142677. * Observers registered here will be executed when a new anchor was added to the session
  142678. */
  142679. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  142680. /**
  142681. * Observers registered here will be executed when an anchor was removed from the session
  142682. */
  142683. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  142684. /**
  142685. * Observers registered here will be executed when an existing anchor updates
  142686. * This can execute N times every frame
  142687. */
  142688. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  142689. /**
  142690. * constructs a new anchor system
  142691. * @param _xrSessionManager an instance of WebXRSessionManager
  142692. * @param _options configuration object for this feature
  142693. */
  142694. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  142695. /**
  142696. * Add anchor at a specific XR point.
  142697. *
  142698. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  142699. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  142700. * @returns a promise the fulfills when the anchor was created
  142701. */
  142702. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  142703. /**
  142704. * attach this feature
  142705. * Will usually be called by the features manager
  142706. *
  142707. * @returns true if successful.
  142708. */
  142709. attach(): boolean;
  142710. /**
  142711. * detach this feature.
  142712. * Will usually be called by the features manager
  142713. *
  142714. * @returns true if successful.
  142715. */
  142716. detach(): boolean;
  142717. /**
  142718. * Dispose this feature and all of the resources attached
  142719. */
  142720. dispose(): void;
  142721. /**
  142722. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  142723. * @param hitTestModule the hit-test module to use.
  142724. */
  142725. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  142726. /**
  142727. * set the plane detector to use in order to create anchors from frames
  142728. * @param planeDetector the plane-detector module to use
  142729. * @param enable enable plane-anchors. default is true
  142730. */
  142731. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  142732. protected _onXRFrame(frame: XRFrame): void;
  142733. /**
  142734. * avoiding using Array.find for global support.
  142735. * @param xrAnchor the plane to find in the array
  142736. */
  142737. private _findIndexInAnchorArray;
  142738. private _updateAnchorWithXRFrame;
  142739. }
  142740. }
  142741. declare module BABYLON {
  142742. /**
  142743. * Options interface for the background remover plugin
  142744. */
  142745. export interface IWebXRBackgroundRemoverOptions {
  142746. /**
  142747. * Further background meshes to disable when entering AR
  142748. */
  142749. backgroundMeshes?: AbstractMesh[];
  142750. /**
  142751. * flags to configure the removal of the environment helper.
  142752. * If not set, the entire background will be removed. If set, flags should be set as well.
  142753. */
  142754. environmentHelperRemovalFlags?: {
  142755. /**
  142756. * Should the skybox be removed (default false)
  142757. */
  142758. skyBox?: boolean;
  142759. /**
  142760. * Should the ground be removed (default false)
  142761. */
  142762. ground?: boolean;
  142763. };
  142764. /**
  142765. * don't disable the environment helper
  142766. */
  142767. ignoreEnvironmentHelper?: boolean;
  142768. }
  142769. /**
  142770. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  142771. */
  142772. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  142773. /**
  142774. * read-only options to be used in this module
  142775. */
  142776. readonly options: IWebXRBackgroundRemoverOptions;
  142777. /**
  142778. * The module's name
  142779. */
  142780. static readonly Name: string;
  142781. /**
  142782. * The (Babylon) version of this module.
  142783. * This is an integer representing the implementation version.
  142784. * This number does not correspond to the WebXR specs version
  142785. */
  142786. static readonly Version: number;
  142787. /**
  142788. * registered observers will be triggered when the background state changes
  142789. */
  142790. onBackgroundStateChangedObservable: Observable<boolean>;
  142791. /**
  142792. * constructs a new background remover module
  142793. * @param _xrSessionManager the session manager for this module
  142794. * @param options read-only options to be used in this module
  142795. */
  142796. constructor(_xrSessionManager: WebXRSessionManager,
  142797. /**
  142798. * read-only options to be used in this module
  142799. */
  142800. options?: IWebXRBackgroundRemoverOptions);
  142801. /**
  142802. * attach this feature
  142803. * Will usually be called by the features manager
  142804. *
  142805. * @returns true if successful.
  142806. */
  142807. attach(): boolean;
  142808. /**
  142809. * detach this feature.
  142810. * Will usually be called by the features manager
  142811. *
  142812. * @returns true if successful.
  142813. */
  142814. detach(): boolean;
  142815. /**
  142816. * Dispose this feature and all of the resources attached
  142817. */
  142818. dispose(): void;
  142819. protected _onXRFrame(_xrFrame: XRFrame): void;
  142820. private _setBackgroundState;
  142821. }
  142822. }
  142823. declare module BABYLON {
  142824. /**
  142825. * Options for the controller physics feature
  142826. */
  142827. export class IWebXRControllerPhysicsOptions {
  142828. /**
  142829. * Should the headset get its own impostor
  142830. */
  142831. enableHeadsetImpostor?: boolean;
  142832. /**
  142833. * Optional parameters for the headset impostor
  142834. */
  142835. headsetImpostorParams?: {
  142836. /**
  142837. * The type of impostor to create. Default is sphere
  142838. */
  142839. impostorType: number;
  142840. /**
  142841. * the size of the impostor. Defaults to 10cm
  142842. */
  142843. impostorSize?: number | {
  142844. width: number;
  142845. height: number;
  142846. depth: number;
  142847. };
  142848. /**
  142849. * Friction definitions
  142850. */
  142851. friction?: number;
  142852. /**
  142853. * Restitution
  142854. */
  142855. restitution?: number;
  142856. };
  142857. /**
  142858. * The physics properties of the future impostors
  142859. */
  142860. physicsProperties?: {
  142861. /**
  142862. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  142863. * Note that this requires a physics engine that supports mesh impostors!
  142864. */
  142865. useControllerMesh?: boolean;
  142866. /**
  142867. * The type of impostor to create. Default is sphere
  142868. */
  142869. impostorType?: number;
  142870. /**
  142871. * the size of the impostor. Defaults to 10cm
  142872. */
  142873. impostorSize?: number | {
  142874. width: number;
  142875. height: number;
  142876. depth: number;
  142877. };
  142878. /**
  142879. * Friction definitions
  142880. */
  142881. friction?: number;
  142882. /**
  142883. * Restitution
  142884. */
  142885. restitution?: number;
  142886. };
  142887. /**
  142888. * the xr input to use with this pointer selection
  142889. */
  142890. xrInput: WebXRInput;
  142891. }
  142892. /**
  142893. * Add physics impostor to your webxr controllers,
  142894. * including naive calculation of their linear and angular velocity
  142895. */
  142896. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  142897. private readonly _options;
  142898. private _attachController;
  142899. private _controllers;
  142900. private _debugMode;
  142901. private _delta;
  142902. private _headsetImpostor?;
  142903. private _headsetMesh?;
  142904. private _lastTimestamp;
  142905. private _tmpQuaternion;
  142906. private _tmpVector;
  142907. /**
  142908. * The module's name
  142909. */
  142910. static readonly Name: string;
  142911. /**
  142912. * The (Babylon) version of this module.
  142913. * This is an integer representing the implementation version.
  142914. * This number does not correspond to the webxr specs version
  142915. */
  142916. static readonly Version: number;
  142917. /**
  142918. * Construct a new Controller Physics Feature
  142919. * @param _xrSessionManager the corresponding xr session manager
  142920. * @param _options options to create this feature with
  142921. */
  142922. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  142923. /**
  142924. * @hidden
  142925. * enable debugging - will show console outputs and the impostor mesh
  142926. */
  142927. _enablePhysicsDebug(): void;
  142928. /**
  142929. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  142930. * @param xrController the controller to add
  142931. */
  142932. addController(xrController: WebXRInputSource): void;
  142933. /**
  142934. * attach this feature
  142935. * Will usually be called by the features manager
  142936. *
  142937. * @returns true if successful.
  142938. */
  142939. attach(): boolean;
  142940. /**
  142941. * detach this feature.
  142942. * Will usually be called by the features manager
  142943. *
  142944. * @returns true if successful.
  142945. */
  142946. detach(): boolean;
  142947. /**
  142948. * Get the headset impostor, if enabled
  142949. * @returns the impostor
  142950. */
  142951. getHeadsetImpostor(): PhysicsImpostor | undefined;
  142952. /**
  142953. * Get the physics impostor of a specific controller.
  142954. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  142955. * @param controller the controller or the controller id of which to get the impostor
  142956. * @returns the impostor or null
  142957. */
  142958. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  142959. /**
  142960. * Update the physics properties provided in the constructor
  142961. * @param newProperties the new properties object
  142962. */
  142963. setPhysicsProperties(newProperties: {
  142964. impostorType?: number;
  142965. impostorSize?: number | {
  142966. width: number;
  142967. height: number;
  142968. depth: number;
  142969. };
  142970. friction?: number;
  142971. restitution?: number;
  142972. }): void;
  142973. protected _onXRFrame(_xrFrame: any): void;
  142974. private _detachController;
  142975. }
  142976. }
  142977. declare module BABYLON {
  142978. /**
  142979. * The motion controller class for all microsoft mixed reality controllers
  142980. */
  142981. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  142982. protected readonly _mapping: {
  142983. defaultButton: {
  142984. "valueNodeName": string;
  142985. "unpressedNodeName": string;
  142986. "pressedNodeName": string;
  142987. };
  142988. defaultAxis: {
  142989. "valueNodeName": string;
  142990. "minNodeName": string;
  142991. "maxNodeName": string;
  142992. };
  142993. buttons: {
  142994. "xr-standard-trigger": {
  142995. "rootNodeName": string;
  142996. "componentProperty": string;
  142997. "states": string[];
  142998. };
  142999. "xr-standard-squeeze": {
  143000. "rootNodeName": string;
  143001. "componentProperty": string;
  143002. "states": string[];
  143003. };
  143004. "xr-standard-touchpad": {
  143005. "rootNodeName": string;
  143006. "labelAnchorNodeName": string;
  143007. "touchPointNodeName": string;
  143008. };
  143009. "xr-standard-thumbstick": {
  143010. "rootNodeName": string;
  143011. "componentProperty": string;
  143012. "states": string[];
  143013. };
  143014. };
  143015. axes: {
  143016. "xr-standard-touchpad": {
  143017. "x-axis": {
  143018. "rootNodeName": string;
  143019. };
  143020. "y-axis": {
  143021. "rootNodeName": string;
  143022. };
  143023. };
  143024. "xr-standard-thumbstick": {
  143025. "x-axis": {
  143026. "rootNodeName": string;
  143027. };
  143028. "y-axis": {
  143029. "rootNodeName": string;
  143030. };
  143031. };
  143032. };
  143033. };
  143034. /**
  143035. * The base url used to load the left and right controller models
  143036. */
  143037. static MODEL_BASE_URL: string;
  143038. /**
  143039. * The name of the left controller model file
  143040. */
  143041. static MODEL_LEFT_FILENAME: string;
  143042. /**
  143043. * The name of the right controller model file
  143044. */
  143045. static MODEL_RIGHT_FILENAME: string;
  143046. profileId: string;
  143047. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  143048. protected _getFilenameAndPath(): {
  143049. filename: string;
  143050. path: string;
  143051. };
  143052. protected _getModelLoadingConstraints(): boolean;
  143053. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  143054. protected _setRootMesh(meshes: AbstractMesh[]): void;
  143055. protected _updateModel(): void;
  143056. }
  143057. }
  143058. declare module BABYLON {
  143059. /**
  143060. * The motion controller class for oculus touch (quest, rift).
  143061. * This class supports legacy mapping as well the standard xr mapping
  143062. */
  143063. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  143064. private _forceLegacyControllers;
  143065. private _modelRootNode;
  143066. /**
  143067. * The base url used to load the left and right controller models
  143068. */
  143069. static MODEL_BASE_URL: string;
  143070. /**
  143071. * The name of the left controller model file
  143072. */
  143073. static MODEL_LEFT_FILENAME: string;
  143074. /**
  143075. * The name of the right controller model file
  143076. */
  143077. static MODEL_RIGHT_FILENAME: string;
  143078. /**
  143079. * Base Url for the Quest controller model.
  143080. */
  143081. static QUEST_MODEL_BASE_URL: string;
  143082. profileId: string;
  143083. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  143084. protected _getFilenameAndPath(): {
  143085. filename: string;
  143086. path: string;
  143087. };
  143088. protected _getModelLoadingConstraints(): boolean;
  143089. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  143090. protected _setRootMesh(meshes: AbstractMesh[]): void;
  143091. protected _updateModel(): void;
  143092. /**
  143093. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  143094. * between the touch and touch 2.
  143095. */
  143096. private _isQuest;
  143097. }
  143098. }
  143099. declare module BABYLON {
  143100. /**
  143101. * The motion controller class for the standard HTC-Vive controllers
  143102. */
  143103. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  143104. private _modelRootNode;
  143105. /**
  143106. * The base url used to load the left and right controller models
  143107. */
  143108. static MODEL_BASE_URL: string;
  143109. /**
  143110. * File name for the controller model.
  143111. */
  143112. static MODEL_FILENAME: string;
  143113. profileId: string;
  143114. /**
  143115. * Create a new Vive motion controller object
  143116. * @param scene the scene to use to create this controller
  143117. * @param gamepadObject the corresponding gamepad object
  143118. * @param handness the handness of the controller
  143119. */
  143120. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  143121. protected _getFilenameAndPath(): {
  143122. filename: string;
  143123. path: string;
  143124. };
  143125. protected _getModelLoadingConstraints(): boolean;
  143126. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  143127. protected _setRootMesh(meshes: AbstractMesh[]): void;
  143128. protected _updateModel(): void;
  143129. }
  143130. }
  143131. declare module BABYLON {
  143132. /**
  143133. * A cursor which tracks a point on a path
  143134. */
  143135. export class PathCursor {
  143136. private path;
  143137. /**
  143138. * Stores path cursor callbacks for when an onchange event is triggered
  143139. */
  143140. private _onchange;
  143141. /**
  143142. * The value of the path cursor
  143143. */
  143144. value: number;
  143145. /**
  143146. * The animation array of the path cursor
  143147. */
  143148. animations: Animation[];
  143149. /**
  143150. * Initializes the path cursor
  143151. * @param path The path to track
  143152. */
  143153. constructor(path: Path2);
  143154. /**
  143155. * Gets the cursor point on the path
  143156. * @returns A point on the path cursor at the cursor location
  143157. */
  143158. getPoint(): Vector3;
  143159. /**
  143160. * Moves the cursor ahead by the step amount
  143161. * @param step The amount to move the cursor forward
  143162. * @returns This path cursor
  143163. */
  143164. moveAhead(step?: number): PathCursor;
  143165. /**
  143166. * Moves the cursor behind by the step amount
  143167. * @param step The amount to move the cursor back
  143168. * @returns This path cursor
  143169. */
  143170. moveBack(step?: number): PathCursor;
  143171. /**
  143172. * Moves the cursor by the step amount
  143173. * If the step amount is greater than one, an exception is thrown
  143174. * @param step The amount to move the cursor
  143175. * @returns This path cursor
  143176. */
  143177. move(step: number): PathCursor;
  143178. /**
  143179. * Ensures that the value is limited between zero and one
  143180. * @returns This path cursor
  143181. */
  143182. private ensureLimits;
  143183. /**
  143184. * Runs onchange callbacks on change (used by the animation engine)
  143185. * @returns This path cursor
  143186. */
  143187. private raiseOnChange;
  143188. /**
  143189. * Executes a function on change
  143190. * @param f A path cursor onchange callback
  143191. * @returns This path cursor
  143192. */
  143193. onchange(f: (cursor: PathCursor) => void): PathCursor;
  143194. }
  143195. }
  143196. declare module BABYLON {
  143197. /** @hidden */
  143198. export var blurPixelShader: {
  143199. name: string;
  143200. shader: string;
  143201. };
  143202. }
  143203. declare module BABYLON {
  143204. /** @hidden */
  143205. export var pointCloudVertexDeclaration: {
  143206. name: string;
  143207. shader: string;
  143208. };
  143209. }
  143210. // Mixins
  143211. interface Window {
  143212. mozIndexedDB: IDBFactory;
  143213. webkitIndexedDB: IDBFactory;
  143214. msIndexedDB: IDBFactory;
  143215. webkitURL: typeof URL;
  143216. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  143217. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  143218. WebGLRenderingContext: WebGLRenderingContext;
  143219. MSGesture: MSGesture;
  143220. CANNON: any;
  143221. AudioContext: AudioContext;
  143222. webkitAudioContext: AudioContext;
  143223. PointerEvent: any;
  143224. Math: Math;
  143225. Uint8Array: Uint8ArrayConstructor;
  143226. Float32Array: Float32ArrayConstructor;
  143227. mozURL: typeof URL;
  143228. msURL: typeof URL;
  143229. VRFrameData: any; // WebVR, from specs 1.1
  143230. DracoDecoderModule: any;
  143231. setImmediate(handler: (...args: any[]) => void): number;
  143232. }
  143233. interface HTMLCanvasElement {
  143234. requestPointerLock(): void;
  143235. msRequestPointerLock?(): void;
  143236. mozRequestPointerLock?(): void;
  143237. webkitRequestPointerLock?(): void;
  143238. /** Track wether a record is in progress */
  143239. isRecording: boolean;
  143240. /** Capture Stream method defined by some browsers */
  143241. captureStream(fps?: number): MediaStream;
  143242. }
  143243. interface CanvasRenderingContext2D {
  143244. msImageSmoothingEnabled: boolean;
  143245. }
  143246. interface MouseEvent {
  143247. mozMovementX: number;
  143248. mozMovementY: number;
  143249. webkitMovementX: number;
  143250. webkitMovementY: number;
  143251. msMovementX: number;
  143252. msMovementY: number;
  143253. }
  143254. interface Navigator {
  143255. mozGetVRDevices: (any: any) => any;
  143256. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  143257. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  143258. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  143259. webkitGetGamepads(): Gamepad[];
  143260. msGetGamepads(): Gamepad[];
  143261. webkitGamepads(): Gamepad[];
  143262. }
  143263. interface HTMLVideoElement {
  143264. mozSrcObject: any;
  143265. }
  143266. interface Math {
  143267. fround(x: number): number;
  143268. imul(a: number, b: number): number;
  143269. }
  143270. interface WebGLRenderingContext {
  143271. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  143272. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  143273. vertexAttribDivisor(index: number, divisor: number): void;
  143274. createVertexArray(): any;
  143275. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  143276. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  143277. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  143278. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  143279. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  143280. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  143281. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  143282. // Queries
  143283. createQuery(): WebGLQuery;
  143284. deleteQuery(query: WebGLQuery): void;
  143285. beginQuery(target: number, query: WebGLQuery): void;
  143286. endQuery(target: number): void;
  143287. getQueryParameter(query: WebGLQuery, pname: number): any;
  143288. getQuery(target: number, pname: number): any;
  143289. MAX_SAMPLES: number;
  143290. RGBA8: number;
  143291. READ_FRAMEBUFFER: number;
  143292. DRAW_FRAMEBUFFER: number;
  143293. UNIFORM_BUFFER: number;
  143294. HALF_FLOAT_OES: number;
  143295. RGBA16F: number;
  143296. RGBA32F: number;
  143297. R32F: number;
  143298. RG32F: number;
  143299. RGB32F: number;
  143300. R16F: number;
  143301. RG16F: number;
  143302. RGB16F: number;
  143303. RED: number;
  143304. RG: number;
  143305. R8: number;
  143306. RG8: number;
  143307. UNSIGNED_INT_24_8: number;
  143308. DEPTH24_STENCIL8: number;
  143309. MIN: number;
  143310. MAX: number;
  143311. /* Multiple Render Targets */
  143312. drawBuffers(buffers: number[]): void;
  143313. readBuffer(src: number): void;
  143314. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  143315. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  143316. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  143317. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  143318. // Occlusion Query
  143319. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  143320. ANY_SAMPLES_PASSED: number;
  143321. QUERY_RESULT_AVAILABLE: number;
  143322. QUERY_RESULT: number;
  143323. }
  143324. interface WebGLProgram {
  143325. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  143326. }
  143327. interface EXT_disjoint_timer_query {
  143328. QUERY_COUNTER_BITS_EXT: number;
  143329. TIME_ELAPSED_EXT: number;
  143330. TIMESTAMP_EXT: number;
  143331. GPU_DISJOINT_EXT: number;
  143332. QUERY_RESULT_EXT: number;
  143333. QUERY_RESULT_AVAILABLE_EXT: number;
  143334. queryCounterEXT(query: WebGLQuery, target: number): void;
  143335. createQueryEXT(): WebGLQuery;
  143336. beginQueryEXT(target: number, query: WebGLQuery): void;
  143337. endQueryEXT(target: number): void;
  143338. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  143339. deleteQueryEXT(query: WebGLQuery): void;
  143340. }
  143341. interface WebGLUniformLocation {
  143342. _currentState: any;
  143343. }
  143344. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  143345. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  143346. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  143347. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  143348. interface WebGLRenderingContext {
  143349. readonly RASTERIZER_DISCARD: number;
  143350. readonly DEPTH_COMPONENT24: number;
  143351. readonly TEXTURE_3D: number;
  143352. readonly TEXTURE_2D_ARRAY: number;
  143353. readonly TEXTURE_COMPARE_FUNC: number;
  143354. readonly TEXTURE_COMPARE_MODE: number;
  143355. readonly COMPARE_REF_TO_TEXTURE: number;
  143356. readonly TEXTURE_WRAP_R: number;
  143357. readonly HALF_FLOAT: number;
  143358. readonly RGB8: number;
  143359. readonly RED_INTEGER: number;
  143360. readonly RG_INTEGER: number;
  143361. readonly RGB_INTEGER: number;
  143362. readonly RGBA_INTEGER: number;
  143363. readonly R8_SNORM: number;
  143364. readonly RG8_SNORM: number;
  143365. readonly RGB8_SNORM: number;
  143366. readonly RGBA8_SNORM: number;
  143367. readonly R8I: number;
  143368. readonly RG8I: number;
  143369. readonly RGB8I: number;
  143370. readonly RGBA8I: number;
  143371. readonly R8UI: number;
  143372. readonly RG8UI: number;
  143373. readonly RGB8UI: number;
  143374. readonly RGBA8UI: number;
  143375. readonly R16I: number;
  143376. readonly RG16I: number;
  143377. readonly RGB16I: number;
  143378. readonly RGBA16I: number;
  143379. readonly R16UI: number;
  143380. readonly RG16UI: number;
  143381. readonly RGB16UI: number;
  143382. readonly RGBA16UI: number;
  143383. readonly R32I: number;
  143384. readonly RG32I: number;
  143385. readonly RGB32I: number;
  143386. readonly RGBA32I: number;
  143387. readonly R32UI: number;
  143388. readonly RG32UI: number;
  143389. readonly RGB32UI: number;
  143390. readonly RGBA32UI: number;
  143391. readonly RGB10_A2UI: number;
  143392. readonly R11F_G11F_B10F: number;
  143393. readonly RGB9_E5: number;
  143394. readonly RGB10_A2: number;
  143395. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  143396. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  143397. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  143398. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  143399. readonly DEPTH_COMPONENT32F: number;
  143400. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  143401. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  143402. 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;
  143403. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  143404. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  143405. readonly TRANSFORM_FEEDBACK: number;
  143406. readonly INTERLEAVED_ATTRIBS: number;
  143407. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  143408. createTransformFeedback(): WebGLTransformFeedback;
  143409. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  143410. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  143411. beginTransformFeedback(primitiveMode: number): void;
  143412. endTransformFeedback(): void;
  143413. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  143414. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  143415. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  143416. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  143417. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  143418. }
  143419. interface ImageBitmap {
  143420. readonly width: number;
  143421. readonly height: number;
  143422. close(): void;
  143423. }
  143424. interface WebGLQuery extends WebGLObject {
  143425. }
  143426. declare var WebGLQuery: {
  143427. prototype: WebGLQuery;
  143428. new(): WebGLQuery;
  143429. };
  143430. interface WebGLSampler extends WebGLObject {
  143431. }
  143432. declare var WebGLSampler: {
  143433. prototype: WebGLSampler;
  143434. new(): WebGLSampler;
  143435. };
  143436. interface WebGLSync extends WebGLObject {
  143437. }
  143438. declare var WebGLSync: {
  143439. prototype: WebGLSync;
  143440. new(): WebGLSync;
  143441. };
  143442. interface WebGLTransformFeedback extends WebGLObject {
  143443. }
  143444. declare var WebGLTransformFeedback: {
  143445. prototype: WebGLTransformFeedback;
  143446. new(): WebGLTransformFeedback;
  143447. };
  143448. interface WebGLVertexArrayObject extends WebGLObject {
  143449. }
  143450. declare var WebGLVertexArrayObject: {
  143451. prototype: WebGLVertexArrayObject;
  143452. new(): WebGLVertexArrayObject;
  143453. };
  143454. // Type definitions for WebVR API
  143455. // Project: https://w3c.github.io/webvr/
  143456. // Definitions by: six a <https://github.com/lostfictions>
  143457. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  143458. interface VRDisplay extends EventTarget {
  143459. /**
  143460. * Dictionary of capabilities describing the VRDisplay.
  143461. */
  143462. readonly capabilities: VRDisplayCapabilities;
  143463. /**
  143464. * z-depth defining the far plane of the eye view frustum
  143465. * enables mapping of values in the render target depth
  143466. * attachment to scene coordinates. Initially set to 10000.0.
  143467. */
  143468. depthFar: number;
  143469. /**
  143470. * z-depth defining the near plane of the eye view frustum
  143471. * enables mapping of values in the render target depth
  143472. * attachment to scene coordinates. Initially set to 0.01.
  143473. */
  143474. depthNear: number;
  143475. /**
  143476. * An identifier for this distinct VRDisplay. Used as an
  143477. * association point in the Gamepad API.
  143478. */
  143479. readonly displayId: number;
  143480. /**
  143481. * A display name, a user-readable name identifying it.
  143482. */
  143483. readonly displayName: string;
  143484. readonly isConnected: boolean;
  143485. readonly isPresenting: boolean;
  143486. /**
  143487. * If this VRDisplay supports room-scale experiences, the optional
  143488. * stage attribute contains details on the room-scale parameters.
  143489. */
  143490. readonly stageParameters: VRStageParameters | null;
  143491. /**
  143492. * Passing the value returned by `requestAnimationFrame` to
  143493. * `cancelAnimationFrame` will unregister the callback.
  143494. * @param handle Define the hanle of the request to cancel
  143495. */
  143496. cancelAnimationFrame(handle: number): void;
  143497. /**
  143498. * Stops presenting to the VRDisplay.
  143499. * @returns a promise to know when it stopped
  143500. */
  143501. exitPresent(): Promise<void>;
  143502. /**
  143503. * Return the current VREyeParameters for the given eye.
  143504. * @param whichEye Define the eye we want the parameter for
  143505. * @returns the eye parameters
  143506. */
  143507. getEyeParameters(whichEye: string): VREyeParameters;
  143508. /**
  143509. * Populates the passed VRFrameData with the information required to render
  143510. * the current frame.
  143511. * @param frameData Define the data structure to populate
  143512. * @returns true if ok otherwise false
  143513. */
  143514. getFrameData(frameData: VRFrameData): boolean;
  143515. /**
  143516. * Get the layers currently being presented.
  143517. * @returns the list of VR layers
  143518. */
  143519. getLayers(): VRLayer[];
  143520. /**
  143521. * Return a VRPose containing the future predicted pose of the VRDisplay
  143522. * when the current frame will be presented. The value returned will not
  143523. * change until JavaScript has returned control to the browser.
  143524. *
  143525. * The VRPose will contain the position, orientation, velocity,
  143526. * and acceleration of each of these properties.
  143527. * @returns the pose object
  143528. */
  143529. getPose(): VRPose;
  143530. /**
  143531. * Return the current instantaneous pose of the VRDisplay, with no
  143532. * prediction applied.
  143533. * @returns the current instantaneous pose
  143534. */
  143535. getImmediatePose(): VRPose;
  143536. /**
  143537. * The callback passed to `requestAnimationFrame` will be called
  143538. * any time a new frame should be rendered. When the VRDisplay is
  143539. * presenting the callback will be called at the native refresh
  143540. * rate of the HMD. When not presenting this function acts
  143541. * identically to how window.requestAnimationFrame acts. Content should
  143542. * make no assumptions of frame rate or vsync behavior as the HMD runs
  143543. * asynchronously from other displays and at differing refresh rates.
  143544. * @param callback Define the eaction to run next frame
  143545. * @returns the request handle it
  143546. */
  143547. requestAnimationFrame(callback: FrameRequestCallback): number;
  143548. /**
  143549. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  143550. * Repeat calls while already presenting will update the VRLayers being displayed.
  143551. * @param layers Define the list of layer to present
  143552. * @returns a promise to know when the request has been fulfilled
  143553. */
  143554. requestPresent(layers: VRLayer[]): Promise<void>;
  143555. /**
  143556. * Reset the pose for this display, treating its current position and
  143557. * orientation as the "origin/zero" values. VRPose.position,
  143558. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  143559. * updated when calling resetPose(). This should be called in only
  143560. * sitting-space experiences.
  143561. */
  143562. resetPose(): void;
  143563. /**
  143564. * The VRLayer provided to the VRDisplay will be captured and presented
  143565. * in the HMD. Calling this function has the same effect on the source
  143566. * canvas as any other operation that uses its source image, and canvases
  143567. * created without preserveDrawingBuffer set to true will be cleared.
  143568. * @param pose Define the pose to submit
  143569. */
  143570. submitFrame(pose?: VRPose): void;
  143571. }
  143572. declare var VRDisplay: {
  143573. prototype: VRDisplay;
  143574. new(): VRDisplay;
  143575. };
  143576. interface VRLayer {
  143577. leftBounds?: number[] | Float32Array | null;
  143578. rightBounds?: number[] | Float32Array | null;
  143579. source?: HTMLCanvasElement | null;
  143580. }
  143581. interface VRDisplayCapabilities {
  143582. readonly canPresent: boolean;
  143583. readonly hasExternalDisplay: boolean;
  143584. readonly hasOrientation: boolean;
  143585. readonly hasPosition: boolean;
  143586. readonly maxLayers: number;
  143587. }
  143588. interface VREyeParameters {
  143589. /** @deprecated */
  143590. readonly fieldOfView: VRFieldOfView;
  143591. readonly offset: Float32Array;
  143592. readonly renderHeight: number;
  143593. readonly renderWidth: number;
  143594. }
  143595. interface VRFieldOfView {
  143596. readonly downDegrees: number;
  143597. readonly leftDegrees: number;
  143598. readonly rightDegrees: number;
  143599. readonly upDegrees: number;
  143600. }
  143601. interface VRFrameData {
  143602. readonly leftProjectionMatrix: Float32Array;
  143603. readonly leftViewMatrix: Float32Array;
  143604. readonly pose: VRPose;
  143605. readonly rightProjectionMatrix: Float32Array;
  143606. readonly rightViewMatrix: Float32Array;
  143607. readonly timestamp: number;
  143608. }
  143609. interface VRPose {
  143610. readonly angularAcceleration: Float32Array | null;
  143611. readonly angularVelocity: Float32Array | null;
  143612. readonly linearAcceleration: Float32Array | null;
  143613. readonly linearVelocity: Float32Array | null;
  143614. readonly orientation: Float32Array | null;
  143615. readonly position: Float32Array | null;
  143616. readonly timestamp: number;
  143617. }
  143618. interface VRStageParameters {
  143619. sittingToStandingTransform?: Float32Array;
  143620. sizeX?: number;
  143621. sizeY?: number;
  143622. }
  143623. interface Navigator {
  143624. getVRDisplays(): Promise<VRDisplay[]>;
  143625. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  143626. }
  143627. interface Window {
  143628. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  143629. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  143630. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  143631. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  143632. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  143633. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  143634. }
  143635. interface Gamepad {
  143636. readonly displayId: number;
  143637. }
  143638. type XRSessionMode =
  143639. | "inline"
  143640. | "immersive-vr"
  143641. | "immersive-ar";
  143642. type XRReferenceSpaceType =
  143643. | "viewer"
  143644. | "local"
  143645. | "local-floor"
  143646. | "bounded-floor"
  143647. | "unbounded";
  143648. type XREnvironmentBlendMode =
  143649. | "opaque"
  143650. | "additive"
  143651. | "alpha-blend";
  143652. type XRVisibilityState =
  143653. | "visible"
  143654. | "visible-blurred"
  143655. | "hidden";
  143656. type XRHandedness =
  143657. | "none"
  143658. | "left"
  143659. | "right";
  143660. type XRTargetRayMode =
  143661. | "gaze"
  143662. | "tracked-pointer"
  143663. | "screen";
  143664. type XREye =
  143665. | "none"
  143666. | "left"
  143667. | "right";
  143668. interface XRSpace extends EventTarget {
  143669. }
  143670. interface XRRenderState {
  143671. depthNear?: number;
  143672. depthFar?: number;
  143673. inlineVerticalFieldOfView?: number;
  143674. baseLayer?: XRWebGLLayer;
  143675. }
  143676. interface XRInputSource {
  143677. handedness: XRHandedness;
  143678. targetRayMode: XRTargetRayMode;
  143679. targetRaySpace: XRSpace;
  143680. gripSpace: XRSpace | undefined;
  143681. gamepad: Gamepad | undefined;
  143682. profiles: Array<string>;
  143683. }
  143684. interface XRSessionInit {
  143685. optionalFeatures?: XRReferenceSpaceType[];
  143686. requiredFeatures?: XRReferenceSpaceType[];
  143687. }
  143688. interface XRSession extends XRAnchorCreator {
  143689. addEventListener: Function;
  143690. removeEventListener: Function;
  143691. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  143692. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  143693. requestAnimationFrame: Function;
  143694. end(): Promise<void>;
  143695. renderState: XRRenderState;
  143696. inputSources: Array<XRInputSource>;
  143697. // AR hit test
  143698. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  143699. updateWorldTrackingState(options: {
  143700. planeDetectionState?: { enabled: boolean; }
  143701. }): void;
  143702. }
  143703. interface XRReferenceSpace extends XRSpace {
  143704. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  143705. onreset: any;
  143706. }
  143707. type XRPlaneSet = Set<XRPlane>;
  143708. type XRAnchorSet = Set<XRAnchor>;
  143709. interface XRFrame {
  143710. session: XRSession;
  143711. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  143712. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  143713. // Anchors
  143714. trackedAnchors?: XRAnchorSet;
  143715. // Planes
  143716. worldInformation: {
  143717. detectedPlanes?: XRPlaneSet;
  143718. };
  143719. }
  143720. interface XRViewerPose extends XRPose {
  143721. views: Array<XRView>;
  143722. }
  143723. interface XRPose {
  143724. transform: XRRigidTransform;
  143725. emulatedPosition: boolean;
  143726. }
  143727. interface XRWebGLLayerOptions {
  143728. antialias?: boolean;
  143729. depth?: boolean;
  143730. stencil?: boolean;
  143731. alpha?: boolean;
  143732. multiview?: boolean;
  143733. framebufferScaleFactor?: number;
  143734. }
  143735. declare var XRWebGLLayer: {
  143736. prototype: XRWebGLLayer;
  143737. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  143738. };
  143739. interface XRWebGLLayer {
  143740. framebuffer: WebGLFramebuffer;
  143741. framebufferWidth: number;
  143742. framebufferHeight: number;
  143743. getViewport: Function;
  143744. }
  143745. declare class XRRigidTransform {
  143746. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  143747. position: DOMPointReadOnly;
  143748. orientation: DOMPointReadOnly;
  143749. matrix: Float32Array;
  143750. inverse: XRRigidTransform;
  143751. }
  143752. interface XRView {
  143753. eye: XREye;
  143754. projectionMatrix: Float32Array;
  143755. transform: XRRigidTransform;
  143756. }
  143757. interface XRInputSourceChangeEvent {
  143758. session: XRSession;
  143759. removed: Array<XRInputSource>;
  143760. added: Array<XRInputSource>;
  143761. }
  143762. interface XRInputSourceEvent extends Event {
  143763. readonly frame: XRFrame;
  143764. readonly inputSource: XRInputSource;
  143765. }
  143766. // Experimental(er) features
  143767. declare class XRRay {
  143768. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  143769. origin: DOMPointReadOnly;
  143770. direction: DOMPointReadOnly;
  143771. matrix: Float32Array;
  143772. }
  143773. interface XRHitResult {
  143774. hitMatrix: Float32Array;
  143775. }
  143776. interface XRAnchor {
  143777. // remove?
  143778. id?: string;
  143779. anchorSpace: XRSpace;
  143780. lastChangedTime: number;
  143781. detach(): void;
  143782. }
  143783. interface XRPlane extends XRAnchorCreator {
  143784. orientation: "Horizontal" | "Vertical";
  143785. planeSpace: XRSpace;
  143786. polygon: Array<DOMPointReadOnly>;
  143787. lastChangedTime: number;
  143788. }
  143789. interface XRAnchorCreator {
  143790. // AR Anchors
  143791. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  143792. }